centos7 virtual machine installation elasticsearch5.0.x installation
- 2020-05-14 05:54:53
- OfStack
centos7 virtual machine installation elasticsearch5.0.x- installation section
Pre-installed jdk steps in detail, please refer to: / / www ofstack. com softjc / 193398. html
Create a new user (non-root user)
elasticsearch can only be started with a non-root. Here I've created a user called seven
[root@localhost ~]# useradd seven
[root@localhost ~]# passwd seven
Download elasticsearch
[root@localhost ~]# su seven
[seven@localhost root]$ cd /home/seven
[seven@localhost ~]$ mkdir download
[seven@localhost ~]$ cd download
[seven@localhost download]$ wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/5.0.0-alpha3/elasticsearch-5.0.0-alpha3.tar.gz
Unzip and run elasticsearch
Unpack the
[seven@localhost download]$ tar -zxvf elasticsearch-5.0.0-alpha3.tar.gz
Move to specified folder and rename (easy to manage)
[seven@localhost download]$ mv elasticsearch-5.0.0-alpha3 /usr/java/elasticsearch
Modify the IP and port for accessing elasticsearch
[seven@localhost config]$ vim /usr/java/elasticsearch/config/elasticsearch.yml
Find the following code snippet and uncomment the lines network.host and http.port, and modify the IP and port
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 192.168.0.155
#
# Set a custom port for HTTP:
#
http.port: 9200
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html>
Directly run the bin/elasticsearch file to start elasticsearch
[seven@localhost bin]$ cd /usr/java/elasticsearch/bin/
[seven@localhost bin]$ ./elasticsearch
Startup error found...
[seven@localhost bin]$ ./elasticsearch
[2016-06-28 13:49:27,899][INFO ][node ] [Mondo] version[5.0.0-alpha3], pid[3671], build[cad959b/2016-05-26T08:25:57.564Z], OS[Linux/3.10.0-327.el7.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1 .0_91/25.91-b14]
� 2016-06-28 13:49:27,900][INFO ][node ] [Mondo] initializing ...
[2016-06-28 13:49:28,941][INFO ][plugins ] [Mondo] modules [percolator, lang-mustache, lang-painless, ingest-grok, reindex, lang-expression, lang-groovy], plugins []
[2016-06-28 13:49:28,963][INFO ][env ] [Mondo] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [15.7gb], net total_space [17.4gb], spins? [unknown], types [rootfs]
[2016-06-28 13:49:28,963][INFO ][env ] [Mondo] heap size [1.9gb], compressed ordinary object pointers [true]
[2016-06-28 13:49:31,980][INFO ][node ] [Mondo] initialized
[2016-06-28 13:49:31,980][INFO ][node ] [Mondo] starting ...
[2016-06-28 13:49:32,115][INFO ][transport ] [Mondo] publish_address {192.168.0.155:9300}, bound_addresses {192.168.0.155:9300}
Exception in thread "main" java.lang.RuntimeException: bootstrap checks failed
initial heap size [268435456] not equal to maximum heap size [2147483648]; this can cause resize pauses and prevents mlockall from locking the entire heap
max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]
please set [discovery.zen.minimum_master_nodes] to a majority of the number of master eligible nodes in your cluster
max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
at org.elasticsearch.bootstrap.BootstrapCheck.check(BootstrapCheck.java:125)
at org.elasticsearch.bootstrap.BootstrapCheck.check(BootstrapCheck.java:85)
at org.elasticsearch.bootstrap.BootstrapCheck.check(BootstrapCheck.java:65)
at org.elasticsearch.bootstrap.Bootstrap$5.validateNodeBeforeAcceptingRequests(Bootstrap.java:183)
at org.elasticsearch.node.Node.start(Node.java:337)
at org.elasticsearch.bootstrap.Bootstrap.start(Bootstrap.java:198)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:257)
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:96)
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:91)
at org.elasticsearch.cli.SettingCommand.execute(SettingCommand.java:54)
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:91)
at org.elasticsearch.cli.Command.main(Command.java:53)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:70)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:63)
Refer to the log for complete error details.
[2016-06-28 13:49:32,144][INFO ][node ] [Mondo] stopping ...
[2016-06-28 13:49:32,198][INFO ][node ] [Mondo] stopped
[2016-06-28 13:49:32,198][INFO ][node ] [Mondo] closing ...
[2016-06-28 13:49:32,210][INFO ][node ] [Mondo] closed
So I temporarily increased the size of vm.max_map_count
* this operation requires root permissions
[root@localhost ~]# sysctl -w vm.max_map_count=262144
View modification results
[root@localhost ~]# sysctl -a|grep vm.max_map_count
vm.max_map_count = 262144
Or permanent modification
[root@localhost ~]# su seven
[seven@localhost root]$ cd /home/seven
[seven@localhost ~]$ mkdir download
[seven@localhost ~]$ cd download
[seven@localhost download]$ wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/5.0.0-alpha3/elasticsearch-5.0.0-alpha3.tar.gz
0
There is also an error above regarding the jvm memory allocation problem heap size [268435456] not equal maximum heap size [2147483648], the jvm configuration needs to be modified
[root@localhost ~]# su seven
[seven@localhost root]$ cd /home/seven
[seven@localhost ~]$ mkdir download
[seven@localhost ~]$ cd download
[seven@localhost download]$ wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/5.0.0-alpha3/elasticsearch-5.0.0-alpha3.tar.gz
1
Change -Xmx2g to -Xmx256m, which is the value of heap size [268435456] /1024/1024
There are new mistakes...
[root@localhost ~]# su seven
[seven@localhost root]$ cd /home/seven
[seven@localhost ~]$ mkdir download
[seven@localhost ~]$ cd download
[seven@localhost download]$ wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/5.0.0-alpha3/elasticsearch-5.0.0-alpha3.tar.gz
2
The problem with the 1 in the afternoon, I finally found the solution, back to the same config/elasticsearch yml file, find the following configuration, open discovery. zen. ping. unicast. hosts and discovery. zen. minimum_master_nodes
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
discovery.zen.ping.unicast.hosts: ["192.168.0.155"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of nodes / 2 + 1):
#
discovery.zen.minimum_master_nodes: 3
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-discovery.html>
Then modify max file descriptors [4096] for elasticsearch too too low, increase at least [65536] this error (switch to root operation)
[root@localhost ~]# su seven
[seven@localhost root]$ cd /home/seven
[seven@localhost ~]$ mkdir download
[seven@localhost ~]$ cd download
[seven@localhost download]$ wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/5.0.0-alpha3/elasticsearch-5.0.0-alpha3.tar.gz
4
Log back in to the seven user after the change and use the following command to see if the change was successful
[root@localhost ~]# su seven
[seven@localhost root]$ cd /home/seven
[seven@localhost ~]$ mkdir download
[seven@localhost ~]$ cd download
[seven@localhost download]$ wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/5.0.0-alpha3/elasticsearch-5.0.0-alpha3.tar.gz
5
You can start elasticsearch, start to finish using the browser to access http: / / 192.168.0.155:9200
[root@localhost ~]# su seven
[seven@localhost root]$ cd /home/seven
[seven@localhost ~]$ mkdir download
[seven@localhost ~]$ cd download
[seven@localhost download]$ wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/5.0.0-alpha3/elasticsearch-5.0.0-alpha3.tar.gz
6