一.環境準備
jdk1.8(自己找教程安裝這邊就不贅述了)
elasticsearch-5.6.6.tar(https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.6.tar.gz)
二.解壓壓縮包
tar -zxvf elasticsearch-5.6.6.tar
三.修改配置文件
進入ES根目錄,然後輸入命令
vim config/elasticsearch.yml
主機配置:
cluster.name: escluster
node.name: node-01
node.master: true
node.data: true
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: 192.168.1.171
http.port: 9200
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: ["192.168.1.172:9300", "192.168.1.173:9300"]
discovery.zen.minimum_master_nodes: 3
http.cors.enabled: true
http.cors.allow-origin: "*"
從機1配置:
cluster.name: escluster
node.name: node-01
node.master: true
node.data: true
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: 192.168.1.172
http.port: 9200
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: ["192.168.1.171:9300", "192.168.1.173:9300"]
discovery.zen.minimum_master_nodes: 3
http.cors.enabled: true
http.cors.allow-origin: "*"
從機2配置:
cluster.name: escluster
node.name: node-01
node.master: true
node.data: true
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: 192.168.1.173
http.port: 9200
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: ["192.168.1.172:9300", "192.168.1.171:9300"]
discovery.zen.minimum_master_nodes: 3
http.cors.enabled: true
http.cors.allow-origin: "*"
四.設置ES堆內存
修改文件config/jvm.options,添加如下配置:
-Xms4g
-Xmx4g
五.指定JDK版本
修改bin/elasticsearch
export JAVA_HOME=/usr/java/jdk1.8
export PATH=$JAVA_HOME/bin:$PATH
六.新增用戶(ES不能用root用戶啓動)
輸入命令新增elasticsearch用戶
useradd elasticsearch
爲elasticsearch用戶賦予對elasticsearch-5.6編輯修改權限
chown elasticsearch:elasticsearch /elasticsearch-5.6.6
七.啓動ES(三臺分別起)
- 切換用戶
-
su - elasticsearch
啓動進入.bin目錄下,輸入命令:
-
./elasticsearch -d
可能會遇到bootstrap checks failed問題,解決方案https://blog.csdn.net/TynMhxx/article/details/83012481所示,添加完配置文件重新登錄用戶重啓ES即可。
-
啓動結束,看日誌信息,如無報錯就是成功
-
或者,輸入命令
-
curl 192.168.1.171:9200
八.安裝ElasticSearch-head
ElasticSearch-head(後續簡稱es-head)是ElasticSearch的一個插件,提供了es 的可視化操作界面。在es 2.X版本後,該插件不在支持es的插件安裝方式安裝及啓動,而是使用grunt方式啓動。
ElasticSearch-head 地址:https://github.com/mobz/elasticsearch-head
- 首頁安裝node
yum install gcc gcc-c++ wget https://npm.taobao.org/mirrors/node/v10.14.1/node-v10.14.1-linux-x64.tar.gz tar -xvf node-v8.0.0-linux-x64.tar.xz mv node-v8.1.4-linux-x64 node
配置環境變量
-
vim /etc/profile #set for nodejs export NODE_HOME=/usr/local/node export PATH=$NODE_HOME/bin:$PATH
出現如下圖片即爲安裝成功
- 下載es-head並安裝
使用git 下載es-head資源,這裏如果沒有安裝git,需要先安裝git,然後切換到es-head的跟目錄下安裝node_modules目錄,具體命令如下:
git clone https://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head/
npm install
九.修改es-head配置文件(主機配置即可)
編輯es-head/Gruntfile.js,修改服務器監聽地址,增加hostname屬性,如下
十.啓動ES-head
./node_modules/grunt/bin/grunt server
即爲安裝成功!