由于安全问题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 }