**下載ES文件** wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.3.1.zip unzip elasticsearch-6.3.1.zip cd elasticsearch-6.3.1/ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.3.1.tar.gz tar -xzf elasticsearch-6.3.1.tar.gz cd elasticsearch-6.3.1/ **安裝JAVA** #下載java到opt目錄 mkdir /usr/java tar zxvf /opt/jdk-8u172-linux-x64.tar.gz -C /usr/java #解壓到/usr/java下(重要) vim /etc/profile #編輯環境變量 #在文件末尾增長如下配置並執行 source /etc/profile 讓其生效 JAVA_HOME=/usr/java/jdk1.8.0_172 JRE_HOME=/usr/java/jdk1.8.0_172/jre PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin export JAVA_HOME JRE_HOME PATH #新建一個軟連接到/usr/bin 下 ln -s /usr/java/jdk1.8.0_172/bin/java /usr/bin/java #測試 java -version 運行./bin/elasticsearch #報錯 須要建立用戶 [2018-07-17T19:24:45,552][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:140) ~[elasticsearch-6.3.1.jar:6.3.1] at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:127) ~[elasticsearch-6.3.1.jar:6.3.1] at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.3.1.jar:6.3.1] at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.3.1.jar:6.3.1] at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.3.1.jar:6.3.1] at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) ~[elasticsearch-6.3.1.jar:6.3.1] at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:86) ~[elasticsearch-6.3.1.jar:6.3.1] Caused by: java.lang.RuntimeException: can not run elasticsearch as root at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:104) ~[elasticsearch-6.3.1.jar:6.3.1] at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:171) ~[elasticsearch-6.3.1.jar:6.3.1] at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:326) ~[elasticsearch-6.3.1.jar:6.3.1] at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136) ~[elasticsearch-6.3.1.jar:6.3.1] ... 6 more **建立elasticsearch用戶** groupadd elsearch useradd elsearch -g elsearch -p elasticsearch 運行./bin/elasticsearch #提示權限不足 Exception in thread "main" java.nio.file.AccessDeniedException: /opt/elasticsearch-6.3.1/config/jvm.options at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84) at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102) at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107) at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214) at java.nio.file.Files.newByteChannel(Files.java:361) at java.nio.file.Files.newByteChannel(Files.java:407) at java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:384) at java.nio.file.Files.newInputStream(Files.java:152) at org.elasticsearch.tools.launchers.JvmOptionsParser.main(JvmOptionsParser.java:58) **設置權限** chown -R elsearch:elsearch elasticsearch-6.3.1 運行./bin/elasticsearch curl 127.0.0.1:9200 #成功安裝可是外網沒法訪問
**設置外網訪問和按需設置iptables** vim elasticsearch-6.3.1/config/elasticsearch.yml #修改:network.host: 0.0.0.0 jps | grep Elasticsearch kill pid 運行./bin/elasticsearch #重啓後報錯虛擬機 ERROR: [2] bootstrap checks failed [1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536] 解決:切換root帳戶修改配置limits.conf 添加下面兩行而後重啓計算機 vim /etc/security/limits.conf #<domain><type><item><value> * hard nofile 65536 * soft nofile 65536 [2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144] 解決:切換root帳戶 vim /etc/sysctl.conf 增長一行 vm.max_map_count=655360 接着執行 sysctl -p 運行./bin/elasticsearch #外網訪問成功
喜歡能夠收藏或者點贊,有疑問能夠留言謝謝。html
參考連接
https://www.elastic.co/guide/...
http://immm.in/2018/05/centos...
https://www.cnblogs.com/woxpp...
https://blog.csdn.net/qq_3167...
https://blog.csdn.net/buzaiqq...java