Elasticsearch-5.4.0叢集搭建
1、Elasticsearch-5.4.0 安裝包下載地址:https://www.elastic.co/downloads/past-releases/elasticsearch-5-4-0
2、解壓檔案:tar -zxvf /home/elasticsearch-5.4.0.tar.gz -C /usr/local/
3、設定系統引數:vi /etc/sysctl.conf
vm.max_map_count = 262144
執行 sysctl -p 後生效
4、設定系統引數:vi /etc/security/limits.conf
新增:
* soft nofile 65536
* hard nofile 65536
* soft nproc 2048
* hard nproc 4096
5、vi /etc/security/limits.d/90-nproc.conf
#修改如下內容:
* soft nproc 1024
#修改為
* soft nproc 2048
6、編寫ES Master節點配置檔案:
cluster.name: hy-es
node.name: es-1
network.host: 192.168.96.119
http.port: 9200
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: ["192.168.96.119","192.168.96.118","192.168.96.117"]
discovery.zen.minimum_master_nodes: 2
#避免出現跨域問題
http.cors.enabled: true
http.cors.allow-origin: "*"
注意:配置檔案上方需要更改兩個引數,在Memory下更改:
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
7、建立一個使用者,因為啟動es不能在root下啟動,執行以下操作:
useradd elasticsearch
#為elasticsearch使用者新增密碼:
echo 123456 | passwd --stdin elasticsearch
#將elasticsearch新增到sudoers
echo "elasticsearch ALL = (root) NOPASSWD:ALL" | tee /etc/sudoers.d/elasticsearch
chmod 0440 /etc/sudoers.d/elasticsearch
#解決sudo: sorry, you must have a tty to run sudo問題,在/etc/sudoers註釋掉 Default requiretty 一行,若未出現問題,可忽略
sudo sed -i 's/Defaults requiretty/Defaults:elasticsearch !requiretty/' /etc/sudoers
#切換使用者
su - elasticsearch
8、將檔案分發到其他機器上,注意修改 network.host 和 node.name,其他機器上也需要建立使用者
9、更改elasticsearch-5.4.0的許可權:
chown -R elasticsearch:elasticsearch /usr/local/elasticsearch-5.4.0/
10、啟動Elasticsearch:
usr/local/elasticsearch-5.4.0/bin/elasticsearch -d
11、檢視IP地址,若出現如下則啟動成功: