1. Prepare relevant installation file packages
Download Elasticsearch address: https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.2.2.tar.gz
Download Kibana:
https://artifacts.elastic.co/downloads/kibana/kibana-5.2.2-linux-x86_64.tar.gz
2. Install Elasticsearch
1. Unzip the Elasticsearch installation package tar -zxvf elasticsearch-5.2.2.tar.gz
2. Execute ./elasticsearch in the decompressed folder. The error is as follows
[2017-01-14T18:35:29,164][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:125) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:112) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.cli.SettingCommand.execute(SettingCommand.java:54) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:122) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.cli.Command.main(Command.java:88) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:89) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:82) ~[elasticsearch-5.1.2.jar:5.1.2]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:100) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:176) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:306) ~[elasticsearch-5.1.2.jar:5.1.2]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:121) ~[elasticsearch-5.1.2.jar:5.1.2]
... 6 more
Reason: Elasticsearch must be started using a non-root account
Solution: Create a dedicated account for Elasticsearch
1. Create a user group
groupadd elsearch
2Create user
useradd elsearch -g elsearch -p elasticsearch
3. Change
elasticsearch-5.2.2
the user and group belonging to the folder and internal files to elsearch:elsearch
chown -R elsearch:elsearch /data/www/search/es/elasticsearch-5.2.2
Switch to the elsearch user to execute and start
elasticsearch
stop elasticsearch
Modify the configuration file elasticsearch.yml
cluster.name: es522
node.name: node
network.host: 192.168.1.1
http.port: 9200
After multiple startups, elasticsearch cannot be started due to the limit on the number of files occupied by each thread after startup. The error is reported as follows.
ERROR: bootstrap checks failed
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2017-01-14T18:50:27,955][INFO ][o.e.n.Node ] [node-3] stopping ...
[2017-01-14T18:50:27,965][INFO ][o.e.n.Node ] [node-3] stopped
[2017-01-14T18:50:27,965][INFO ][o.e.n.Node ] [node-3] closing ...
[2017-01-14T18:50:27,977][INFO ][o.e.n.Node ] [node-3] closed
Solution:
Modify the number of files
vi /etc/sysctl.conf
vm.max_map_count=655360
fs.file-max = 6815744
and execute the command:
sysctl -p
Modify file limits and process limits
vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
vi /etc/security/limits.d/90-nproc.conf
Modify the following content:
* soft nproc 1024
#change into
* soft nproc 2048
3. Start again after modifying the above configuration information.
Access to the console without error message output
The following message appears, indicating that the ES installation is successful;
{ "name" : "node1", "cluster_name" : "es522", "cluster_uuid" : "MnQRBEqvQN-Qz6k84bj3Eg", "version" : { "number" : "5.2.2", "build_hash" : "f9d9b74", "build_date" : "2017-02-24T17:26:45.835Z", "build_snapshot" : false, "lucene_version" : "6.4.1" }, "tagline" : "You Know, for Search" }
3. Install Kibana
1. Unzip the Elasticsearch installation package tar -zxvf kibana-5.2.2-linux-x86_64.tar.gz
2. Modify the configuration file and add the following three configuration information
server.port: 5601
server.name: "es522"
elasticsearch.url: "http://192.168.1.1:9200"
3. Start Kibana (add & code at the end of the command to start in the background. If not added, the current window will start, the window will close, and the service will stop)
/bin/child &
After successful startup, visit http://192.168.1.1:5601
Kibana is installed successfully!