二 Elasticsearch 基础之安装( 七 )


[root@VM-0-12-centos ~]# lselasticsearch-8.6.1elasticsearch-8.6.1-linux-x86_64.tar.gzlnmp1.9lnmp1.9.tar.gzlnmp-install.logmysqlreset_mysql_root_password.sh[root@VM-0-12-centos ~]# cd /usr/local/elasticsearch-8.6.1/[root@VM-0-12-centos elasticsearch-8.6.1]# cp -rf /root/elasticsearch-8.6.1 ./node2/[root@VM-0-12-centos elasticsearch-8.6.1]# cp -rf /root/elasticsearch-8.6.1 ./node3/[root@VM-0-12-centos elasticsearch-8.6.1]# lsdatalogsnode1node2node3[root@VM-0-12-centos elasticsearch-8.6.1]# chown -R elastic:elastic ./node2/[root@VM-0-12-centos elasticsearch-8.6.1]# chown -R elastic:elastic ./node3/[root@VM-0-12-centos elasticsearch-8.6.1]# su elastic[elastic@VM-0-12-centos elasticsearch-8.6.1]$ ./node1/bin/elasticsearch -d...
如果开启集群了,则必须开启,否则启动失败 。
⑵、生成注册令牌,并试node2、node3加入集群
生成注册令牌并保存,用于后续节点接入 。
[elastic@VM-0-12-centos elasticsearch-8.6.1]$ ./node1/bin/elasticsearch-create-enrollment-token -s nodewarning: ignoring JAVA_HOME=/usr/local/java; using bundled JDKeyJ2ZXIiOiI4LjYuMSIsImFkciI6WyIxNzIuMTcuMC4xMjo5MjAwIl0sImZnciI6ImYxMjRhMDkzOGQxMDM1OGIyZjU4ODZhYTdkYzExZjMxMzQwMGE1YjM0YTg3ZGQxYmRlOWNlNTgzNTE5OWVmNzYiLCJrZXkiOiJxTE1nWG9ZQmgwQ1VranhDTWNpbjpuS1dVZHRmclQ2aWtCMmRnNnZhUzVRIn0=[elastic@VM-0-12-centos elasticsearch-8.6.1]$[elastic@VM-0-12-centos elasticsearch-8.6.1]$ ./node2/bin/elasticsearch -d --enrollment-token eyJ2ZXIiOiI4LjYuMSIsImFkciI6WyIxNzIuMTcuMC4xMjo5MjAwIl0sImZnciI6ImYxMjRhMDkzOGQxMDM1OGIyZjU4ODZhYTdkYzExZjMxMzQwMGE1YjM0YTg3ZGQxYmRlOWNlNTgzNTE5OWVmNzYiLCJrZXkiOiJxTE1nWG9ZQmgwQ1VranhDTWNpbjpuS1dVZHRmclQ2aWtCMmRnNnZhUzVRIn0=...[elastic@VM-0-12-centos elasticsearch-8.6.1]$ ./node3/bin/elasticsearch -d --enrollment-token eyJ2ZXIiOiI4LjYuMSIsImFkciI6WyIxNzIuMTcuMC4xMjo5MjAwIl0sImZnciI6ImYxMjRhMDkzOGQxMDM1OGIyZjU4ODZhYTdkYzExZjMxMzQwMGE1YjM0YTg3ZGQxYmRlOWNlNTgzNTE5OWVmNzYiLCJrZXkiOiJxTE1nWG9ZQmgwQ1VranhDTWNpbjpuS1dVZHRmclQ2aWtCMmRnNnZhUzVRIn0=...###### 第三个节点因为服务器内存不够没有启动成功,不过应该是没问题的
通过路由 _cat/nodes?v 访问节点信息搭建成功 。
2、搭建集群时遇到的问题
注意:新节点加入集群,不要直接从老节点复制,重新从下载的压缩包中解压出来作为新节点,否则加入集群报错 。
以下是我遇到的错误,我的解决办法就是解压新节点加入集群,不过对于配置文件的修改和 ES重启我还在不了解,后面熟悉后再补充 。
⑴、从 node1 复制 node2 加入集群,报错
【二Elasticsearch 基础之安装】[elastic@VM-0-12-centos elasticsearch-8.6.1]$ ./node2/bin/elasticsearch -d --enrollment-token eyJ2ZXIiOiI4LjYuMSIsImFkciI6WyIxNzIuMTcuMC4xMjo5MjAwIl0sImZnciI6ImYxMjRhMDkzOGQxMDM1OGIyZjU4ODZhYTdkYzExZjMxMzQwMGE1YjM0YTg3ZGQxYmRlOWNlNTgzNTE5OWVmNzYiLCJrZXkiOiJjT1k1WG9ZQnh4RS1fTGNxX05ISzpoSHVSbTZla1Q1MmRtTDFKS2lHc21RIn0=warning: ignoring JAVA_HOME=/usr/local/java; using bundled JDKERROR: Skipping security auto configuration because it appears that the node is not starting up for the first time. The node might already be part of a cluster and this auto setup utility is designed to configure Security for new clusters only.[elastic@VM-0-12-centos elasticsearch-8.6.1]$
后面我又重新生成证书,修改配置文件还是不行:read[](as a ) ,node1节点都没有启动成功 。
[elastic@VM-0-12-centos elasticsearch-8.6.1]$./elasticsearch-certutil ca[elastic@VM-0-12-centos elasticsearch-8.6.1]$./elasticsearch-certutil cert --ca elastic-stack-ca.p12然后把证书放到所有节点的 config/cert 目录下,并授权777(有的博客说是权限问题,还是不行)[elastic@VM-0-12-centos elasticsearch-8.6.1]$ vim ./node1/config/elasticsearch.yml修改配置文件:Enable encryption and mutual authentication between cluster nodesxpack.security.transport.ssl:enabled: trueverification_mode: certificatekeystore.path: /usr/local/elasticsearch-8.6.1/node1/config/elastic-certificates.p12truststore.path: /usr/local/elasticsearch-8.6.1/node1/config/certs/elastic-certificates.p12# node1 节点启动就报错[elastic@VM-0-12-centos elasticsearch-8.6.1]$ ./node1/bin/elasticsearch -d...[2023-02-17T15:52:10,522][ERROR][o.e.b.Elasticsearch] [VM-0-12-centos] fatal exception while booting Elasticsearchorg.elasticsearch.ElasticsearchSecurityException: failed to load SSL configuration [xpack.security.transport.ssl] - cannot read configured [PKCS12] keystore (as a truststore) [/usr/local/elasticsearch-8.6.1/node1/config/certs/elastic-certificates.p12] - this is usually caused by an incorrect password; (a keystore password was provided)at org.elasticsearch.xcore@8.6.1/org.elasticsearch.xpack.core.ssl.SSLService.lambda$loadSslConfigurations$11(SSLService.java:605)at java.base/java.util.HashMap.forEach(HashMap.java:1429)at java.base/java.util.Collections$UnmodifiableMap.forEach(Collections.java:1553)at org.elasticsearch.xcore@8.6.1/org.elasticsearch.xpack.core.ssl.SSLService.loadSslConfigurations(SSLService.java:601)at org.elasticsearch.xcore@8.6.1/org.elasticsearch.xpack.core.ssl.SSLService.