es单机版安装:
因为安全问题elasticsearch 不让用root用户直接运行,所以要创建新用户
添加用户:
useradd es
passwd es
echo "es ALL = (root) NOPASSWD:ALL" | tee /etc/sudoers.d/es
创建目录并解压
cd /usr/local/devtools
mkdir es
cd es
tar -zxvf elasticsearch-5.4.3.tar.gz
添加权限
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: 9200
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 4096
vi /etc/security/limits.d/90-nproc.conf
修改如下内容:
* soft nproc 1024
#修改为
* soft nproc 2048
vi /etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360
并执行命令:
sysctl -p
检测:
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 }