1: elasticsearch-5.4.0.tar.gzhtml
1:jdk-8u111-linux-x64.tar.gzjava
一些開發版的centos會自帶jdk,咱們通常用本身的jdk,把自帶的刪除。先看看有沒有安裝java -versionnode
一、查找他們的安裝位置python
[root@localhost ~]# rpm -qa | grep javalinux
java-1.8.0-openjdk-headless-1.8.0.101-3.b13.el7_2.x86_64bootstrap
tzdata-java-2016f-1.el7.noarchvim
java-1.8.0-openjdk-1.8.0.101-3.b13.el7_2.x86_64centos
javapackages-tools-3.4.1-11.el7.noarchbash
java-1.7.0-openjdk-headless-1.7.0.111-2.6.7.2.el7_2.x86_64網絡
java-1.7.0-openjdk-1.7.0.111-2.6.7.2.el7_2.x86_64
python-javapackages-3.4.1-11.el7.noarch
二、刪除所有,noarch文件能夠不用刪除
[root@localhost ~]# rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.101-3.b13.el7_2.x86_64
[root@localhost ~]# rpm -e --nodeps java-1.8.0-openjdk-1.8.0.101-3.b13.el7_2.x86_64
[root@localhost ~]# rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.111-2.6.7.2.el7_2.x86_64
[root@localhost ~]# rpm -e --nodeps java-1.7.0-openjdk-1.7.0.111-2.6.7.2.el7_2.x86_64
三、檢查有沒有刪除 [root@localhost ~]# java -version
-bash: /usr/bin/java: 沒有那個文件或目錄
一、解壓 tar xvzf jdk-8u111-linux-x64.tar.gz
二、配置環境變量
輸入 vi /etc/profile,進入profile文件,而後按 I 鍵進入編輯模式,輸入如下內容:
export JAVA_HOME=/evchar/java/jdk1.8.0_111
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
鍵盤 按 : i
shift + :
wq 保存
三、source /etc/profile ← 使配置生效
第一種方式: wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.4.0.tar.gz
第二種方式:
網絡很差,能夠直接去官網下載
https://www.elastic.co/downloads/past-releases/elasticsearch-5-4-1
官網參考:
https://www.elastic.co/guide/en/elasticsearch/reference/current/zip-targz.html
官方文檔上說Elasticsearch不適合在root管理員賬號下運行,因此要先創建一個帳號專門運行Elasticsearch.
建立一個elasticsearch用戶
adduser elasticsearch
passwd elasticsearch 123456
按照提示輸入密碼和確認密碼就成功建立elasticsearch帳戶了。
修改用戶權限,這一步很是重要
使用vim 編輯器打開文件打開/etc 目錄下面的文件sudoers
vim /etc/sudoers
i 編輯
shift+:
wq! 強制保存
改變 權限 爲elasticsearch 用戶
chown -R elasticsearch:elasticsearch elasticsearch-5.4.1
配置 elasticsearch.yaml 文件
cluster.name: evchar-cluster
node.name: node-1
path.data: /evchar/elk/es/data
path.logs: /evchar/elk/es/logs
bootstrap.memory_lock: true
network.host: 127.0.0.1 本機IP
http.port: 9200
增長新的參數,這樣head插件能夠訪問es
http.cors.enabled: true
http.cors.allow-origin: "*"
保存elasticsearch.yaml文件
[elasticsearch@localhost bin]$ ./elasticsearch
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: memory locking requested for elasticsearch process but memory is not locked
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[4]: max number of threads [1024] for user [elasticsearch] is too low, increase to at least [2048]
參考文檔:https://www.elastic.co/guide/en/elasticsearch/reference/current/file-descriptors.html
參考文檔:https://www.elastic.co/guide/en/elasticsearch/reference/current/vm-max-map-count.html
參考文檔:https://www.elastic.co/guide/en/elasticsearch/reference/current/max-number-of-threads.html
根據提示 修改 limits.conf文件
elasticsearch soft memlock unlimited elasticsearch hard memlock unlimited * hard nofile 65536 * soft nofile 65536
[root@localhost bin]# sysctl -p
fs.file-max = 65536 vm.max_map_count = 262144
4 、錯誤緣由:啓動檢查未經過 elasticsearch用戶的最大線程數過低
su root
修改limits.d目錄下的配置文件:
vi /etc/security/limits.d/90-nproc.conf
啓動命令:bin/elasticsearch &
檢查ES服務是否啓動
ps -ef |grep elasticsearch
檢查防火牆是否關閉
systemctl disable firewalld 永久關閉防火牆命令。重啓後,防火牆不會自動啓動。
systemctl stop firewalld 臨時關閉防火牆命令。重啓電腦後,防火牆自動起來
systemctl status firewalld 查看防火牆狀態
systemctl enable firewalld 打開防火牆命令
關閉防火牆。
訪問 頁面,檢查es 是否啓動完畢