问题复现
[root@es2 tools]# ps -ef | grep elasticsearch
9200 22693 1 1 09:31 ? 00:04:54 /usr/bin/java -Xms16g -Xmx16g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+AlwaysPreTouch -server -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -XX:-OmitStackTraceInFastThrow -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -XX:+HeapDumpOnOutOfMemoryError -Des.path.home=/usr/share/elasticsearch -Des.path.conf=/etc/elasticsearch -Des.distribution.flavor=default -Des.distribution.type=rpm -cp /usr/share/elasticsearch/lib/* org.elasticsearch.bootstrap.Elasticsearch -p /var/run/elasticsearch/elasticsearch.pid -d
9200 22718 22693 0 09:31 ? 00:00:00 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller
root 24589 22397 0 14:22 pts/0 00:00:00 grep elasticsearch
[root@es2 ~]# cd /usr/share/elasticsearch/plugins/search-guard-6/tools/
[root@es2 tools]# ./sgadmin.sh \
> -cd ../sgconfig/ \
> -icl -nhnv -cacert /etc/elasticsearch/root-ca.pem \
> -cert /etc/elasticsearch/kirk.pem \
> -key /etc/elasticsearch/kirk-key.pem \
> --accept-red-cluster
WARNING: JAVA_HOME not set, will use /usr/bin/java
Search Guard Admin v6
Will connect to localhost:9300
ERR: Seems there is no Elasticsearch running on localhost:9300 - Will exit
解决方案
带上一个参数(-1):
-h <当前节点主机名>
./sgadmin.sh \
-h 172.15.3.17 \
-cd ../sgconfig/ \
-icl -nhnv -cacert /etc/elasticsearch/root-ca.pem \
-cert /etc/elasticsearch/kirk.pem \
-key /etc/elasticsearch/kirk-key.pem \
--accept-red-cluster
[root@es2 ~]# cd /usr/share/elasticsearch/plugins/search-guard-6/tools/
[root@es1 tools]# ./sgadmin.sh \
> -h 172.15.3.17 \
> -cd ../sgconfig/ \
> -icl -nhnv -cacert /etc/elasticsearch/root-ca.pem \
> -cert /etc/elasticsearch/kirk.pem \
> -key /etc/elasticsearch/kirk-key.pem \
> --accept-red-cluster
WARNING: JAVA_HOME not set, will use /usr/bin/java
Search Guard Admin v6
Will connect to 172.15.3.17:9300 ... done
Elasticsearch Version: 6.4.1
Search Guard Version: 6.4.1-24.3
Connected as CN=kirk,OU=client,O=client,L=test,C=de
Contacting elasticsearch cluster 'elasticsearch' ...
Clustername: sdc_elastic
Clusterstate: GREEN
Number of nodes: 3
Number of data nodes: 3
searchguard index already exists, so we do not need to create one.
Populate config from /usr/share/elasticsearch/plugins/search-guard-6/sgconfig
Will update 'sg/config' with ../sgconfig/sg_config.yml
SUCC: Configuration for 'config' created or updated
Will update 'sg/roles' with ../sgconfig/sg_roles.yml
SUCC: Configuration for 'roles' created or updated
Will update 'sg/rolesmapping' with ../sgconfig/sg_roles_mapping.yml
SUCC: Configuration for 'rolesmapping' created or updated
Will update 'sg/internalusers' with ../sgconfig/sg_internal_users.yml
SUCC: Configuration for 'internalusers' created or updated
Will update 'sg/actiongroups' with ../sgconfig/sg_action_groups.yml
SUCC: Configuration for 'actiongroups' created or updated
Done with success