At present, the application development based on an ES is nearing completion, and the App needs to be deployed online for testing. Since Docker is used for local development, switching online also requires installing some necessary applications in Linux(ubuntu16LTS). For future convenience, there is this note.

Preparatory work

For well-known reasons, it is slow to download the application directly from the original source, so select a faster domestic image in advance to ease the waiting process.

Use the image of Ubuntu 16.04LTS on Alicloud, edit /etc/apt/sources.list, and replace with the following:

deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted  universe multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverseCopy the code

After saving, update cache sudo apt Update

If the ES is installed on an existing system, it is better to back up the original system disk now. Later in the installation process, some system parameters will need to be modified, and in case they fail, you can restore them. (The backup process is omitted)

Its installation

java -version
Copy the code

If you already have a Java environment, skip this step.

sudo apt-get update
sudo apt-get install openjdk-8-jdk
java -version
Copy the code

Download ElasticSearch and Kibana

Take the latest version as an example:

Wget wget HTTP: / / https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.6.0.tar.gz https://artifacts.elastic.co/downloads/kibana/kibana-6.6.0-linux-x86_64.tar.gz # extract tar - VXSF elasticsearch - 6.6.0. Tar. Gz The tar - VXSF kibana 6.6.0 - Linux - x86_64. Tar. GzCopy the code

Configure/start ES and KB

Both applications have yML configuration files with the same name in the config directory. You can configure information such as database, log path, service binding address, and port number.

If the binding address of the Es service is native internal (127.0.0.1), it is ready to start directly. If it is an externally accessible address (0.0.0.0), you need to modify the virtual memory. Otherwise, the virtual memory is reported to be too small and the program is terminated.

ERROR: [1] bootstrap checks failed
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
Copy the code

Solution: Modify the /etc/sysctl.conf file and add it to the /etc/sysctl.

vm.max_map_count=262144

Run without restarting:

sysctl -w vm.max_map_count=262144

ES is not allowed to run as root, so if a security hole is created due to configuration queries, the entire server will be at risk. So, if you are currently the root account, you need to create another account to start

Useradd elsearch -g elsearch -p elsticsearch # ES Remember to also modify the database and log directory chown -r elSearch :elsearch./ElasticSearchCopy the code

The executable file of the same name in the bin directory is the application startup file. Run directly from the back.

Finally, add the es and KB start commands to rc.local to automatically start the service every time the server restarts.

Safety recommendations

In addition to configuring firewalls to allow both default ports 9200 and 5601, it is important to note that the ES API can be tailored to the project environment. The search of the current project is carried out through the business logic in the program, calling the SEARCH API of ES, and it does not need to be directly external. Therefore, the bound port 9200 does not need to be exposed to the public network.

The Kb service is not needed all the time, only when you are just getting started or when you run into problems. In this case, you can configure KB to bind to the external IP address, but you can not start the service. Alternatively, the firewall can set the request IP address of port 5601 to the IP address of the company network.