chmod +x /etc/rc.d/rc.local
00 01 * * * /usr/sbin/ntpdate -u cn.pool.ntp.org
docker.cnb.cool/zhiqiangwang/elasticsearch:5.6.5 docker.cnb.cool/zhiqiangwang/elasticsearch:kibana-5.6.5
useradd elasticsearch passwd -l elasticsearch
tar -zxvf jdk-8u201-linux-x64.tar.gz
mv jdk-8u201-linux-x64 /usr/local/java1.8
# Java Environment Variables
export JAVA_HOME=/usr/local/java1.8
export JRE_HOME=$JAVA_HOME/jre
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
yum install openssl
在 /etc/sysctl.conf 中添加以下内容
vm.max_map_count=262144
在 /etc/security/limits.conf 中添加以下内容
* - nofile 65536 * - memlock unlimited
tar -zxvf elasticsearch-5.6.5.tar.gz
chown elasticsearch:elasticsearch elasticsearch-5.6.5/ -R
bin/elasticsearch-plugin install -b com.floragunn:search-guard-5:5.6.5-19.1
./gen_node_cert.sh 3 changeit capass
将 node-3*、ca/root-ca.pem 和 ca/truststore.jks 文件复制到新节点服务器目录 elasticsearch/config/。
修改 Elasticsearch 配置 elasticsearch.yml
cp elasticsearch.yml -/config/elasticsearch.yml
检查证书过期日期
[root@iZbp15b6kfepaf1vdu47unZ ca]# openssl x509 -noout -in node-1.crt.pem -dates
notBefore=Dec 3 12:24:22 2025 GMT
notAfter=Dec 3 12:24:22 2027 GMT
bin/elasticsearch
bin/elasticsearch -d
ps aux |grep elasticsearch
kill 32225
curl -XGET "http://localhost:9200/_cluster/health?pretty"
curl -XGET "http://localhost:9200/_cluster/health?pretty"
curl -XPUT http://localhost:9200/_cluster/settings -d '{
"transient" : {
"cluster.routing.allocation.enable" : "none"
}
}'
或者
curl -X PUT "localhost:9200/_cluster/settings" -H 'Content-Type: application/json' -d
'{
"persistent" : {
"cluster.routing.allocation.enable" : "none"
},
"transient" : {
"cluster.routing.allocation.enable" : "none"
}
}'
curl -XPUT http://localhost:9200/_cluster/settings -d '{
"transient" : {
"cluster.routing.allocation.enable" : "all"
}
}'
或者
curl -X PUT "localhost:9200/_cluster/settings" -H 'Content-Type: application/json' -d
'{
"persistent" : {
"cluster.routing.allocation.enable" : "none"
},
"transient" : {
"cluster.routing.allocation.enable" : "all"
}
}'
如果集群没有设置持久化的自动分片参数,不要单独使用 persistent 来禁用自动分片。它要等到整个集群重启后才会生效,而且如果关闭单个节点,可能会导致分片迁移到其他节点。