由於安全問題elasticsearch 不讓用root用戶直接運行,因此要建立新用戶node
添加用戶:
useradd es
passwd es
echo "es ALL = (root) NOPASSWD:ALL" | tee /etc/sudoers.d/esbootstrap
建立目錄並解壓
cd /usr/local/devtools
mkdir es
cd es
tar -zxvf elasticsearch-5.4.3.tar.gzvim
添加權限
chown -R es:es /usr/local/devtools/es
解決:sudo:sorry,you must have a try to run sudo問題
sudo sed -i 's/Defaults requiretty/Defaults:es !requiretty/' /etc/sudoers安全
修改配置文件
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: xupan003
http.port: 9200elasticsearch
error:
ERROR: bootstrap checks failed
max file descriptors [10240] for elasticsearch process likely too low, increase to at least [65536]
max number of threads [1024] for user [elsearch] likely too low, increase to at least [2048]
max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
[2016-11-14T10:22:17,569][INFO ][o.e.n.Node ] [mysteel-node1] stopping ...
[2016-11-14T10:22:17,615][INFO ][o.e.n.Node ] [mysteel-node1] stopped
[2016-11-14T10:22:17,615][INFO ][o.e.n.Node ] [mysteel-node1] closing ...
[2016-11-14T10:22:17,638][INFO ][o.e.n.Node ] [mysteel-node1] closed測試
切換到root用戶
vi /etc/security/limits.conf
添加以下內容:
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096fetch
vi /etc/security/limits.d/90-nproc.conf
修改以下內容:
* soft nproc 1024
#修改成
* soft nproc 2048ui
vi /etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360spa
並執行命令:
sysctl -pip
檢測:
http://xupan002:9200/?pretty
修改vim config/elasticsearch.yml
cluster.name: my-es
node.name: xupan003-es
network.host: xupan003
discovery.zen.ping.unicast.hosts: ["xupan001", "xupan002", "xupan003"]
說明:
cluster.name每一個節點必須相同
node.name每一個節點有本身的名字必須不一樣
network.host每一個節點的主機名,每一個節點必須不一樣
discovery.zen.ping.unicast.hosts:參與leader選舉的節點,每一個必須相同
http://xupan001:9200/_cluster/health?pretty
{ "cluster_name" : "my-es", "status" : "green", "timed_out" : false, "number_of_nodes" : 3, "number_of_data_nodes" : 3, "active_primary_shards" : 0, "active_shards" : 0, "relocating_shards" : 0, "initializing_shards" : 0, "unassigned_shards" : 0, "delayed_unassigned_shards" : 0, "number_of_pending_tasks" : 0, "number_of_in_flight_fetch" : 0, "task_max_waiting_in_queue_millis" : 0, "active_shards_percent_as_number" : 100.0 }