环境:
OS:Centos 7
ES:6.8.5
目前拓扑:单节点的ES(带密码验证)
当前节点ip:
192.168.1.105
新增节点ip:
192.168.1.106
192.168.1.107
########################当前节点的配置情况##########################
1.配置参数文件
[elasticsearch@hadoop-slave1 config]$ more elasticsearch.yml
path.data: /home/middle/elasticsearch/data path.logs: /home/middle/elasticsearch/logs network.host: 192.168.1.63 http.port: 19200 path.repo: /home/elasticsearch/esbak ##安全认证 xpack.security.enabled: true xpack.security.transport.ssl.enabled: true ##第三方中间件配置参数,看情况需要 http.cors.enabled: true http.cors.allow-origin: "*" http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type
2.数据情况
[elasticsearch@localhost config]$ curl -u elastic:elastic -X GET 'http://192.168.1.105:19200/_cat/indices?v' health status index uuid pri rep docs.count docs.deleted store.size pri.store.size yellow open app_message_all E3S-HXeZTX6BuTbRlw31Pw 5 1 300000 0 222.4mb 222.4mb yellow open db_customer n3-RkwCxTK6-qjORZIs0Dg 5 1 1 0 4.5kb 4.5kb green open .security-6 Y_fF1tkBRKa2mAo2H78ozg 1 0 6 0 19.5kb 19.5kb
################当前节点上的操作#################################
在192.168.1.105上操作
1.生成ca证书(tsl方式)
参考如下连接操作
https://www.cnblogs.com/hxlasky/p/14784423.html
2.修改当前节点的配置
vi /usr/local/services/elasticsearch/config/elasticsearch.yml
##集群名称和节点名称 cluster.name: my-cluster node.name: node-1 ##安全认证部分 xpack.security.enabled: true xpack.security.transport.ssl.enabled: true xpack.security.transport.ssl.verification_mode: certificate xpack.security.transport.ssl.keystore.path: elastic-certificates.p12 xpack.security.transport.ssl.truststore.path: elastic-certificates.p12 ##集群部分 discovery.zen.ping.unicast.hosts: ["192.168.1.105", "192.168.1.106","192.168.1.107"] discovery.zen.minimum_master_nodes: 2
注意:
这个时候先不重启该节点,等另外2个节点都配置好了启动后再重启动
################新增节点1(192.168.1.106)上的操作#################################
1.节点上安装es
安装路径与现有节点保持一致
2.这里新加入基本参数,确保es能够启动
##集群名称和节点名称(注意每个节点的node.name参数不一致,其他都是一样的)
cluster.name: my-cluster node.name: node-2 path.data: /home/middle/elasticsearch/data path.logs: /home/middle/elasticsearch/logs network.host: 192.168.1.106 http.port: 19200 path.repo: /home/elasticsearch/esbak
3.确保通过上面的基本配置能够启动es
-bash-4.2$ curl http://192.168.1.106:19200/?pretty { "name" : "DnTDbU_", "cluster_name" : "elasticsearch", "cluster_uuid" : "fzzwm0OdRLGpLZYvBY2noA", "version" : { "number" : "6.8.5", "build_flavor" : "default", "build_type" : "tar", "build_hash" : "78990e9", "build_date" : "2019-11-13T20:04:24.100411Z", "build_snapshot" : false, "lucene_version" : "7.7.2", "minimum_wire_compatibility_version" : "5.6.0", "minimum_index_compatibility_version" : "5.0.0" }, "tagline" : "You Know, for Search" }
4.关闭es
-bash-4.2$ kill -9 2109
5.将上面节点生成的证书拷贝到相应的目录
192.168.1.105 上操作
[root@localhost config]# cd /usr/local/services/elasticsearch/config
scp elastic-stack-ca.p12 [email protected]:/usr/local/services/elasticsearch/config/
scp elastic-certificates.p12 [email protected]:/usr/local/services/elasticsearch/config/
另外一台机器
scp elastic-stack-ca.p12 [email protected]:/usr/local/services/elasticsearch/config/
scp elastic-certificates.p12 [email protected]:/usr/local/services/elasticsearch/config/
拷贝过去后注意要修改权限
[root@localhost home]# cd /usr/local/services
[root@localhost services]# chown -R elasticsearch:elasticsearch ./elasticsearch
6.修改配置文件,加入如下项:
su - elasticsearch
vi /usr/local/services/elasticsearch/config/elasticsearch.yml
xpack.security.enabled: true xpack.security.transport.ssl.enabled: true xpack.security.transport.ssl.verification_mode: certificate xpack.security.transport.ssl.keystore.path: elastic-certificates.p12 xpack.security.transport.ssl.truststore.path: elastic-certificates.p12 discovery.zen.ping.unicast.hosts: ["192.168.1.105", "192.168.1.106","192.168.1.107"] discovery.zen.minimum_master_nodes: 2
################新增节点1(192.168.1.107)上的操作#################################
该节点上的操作与上面的节点操作一致
################启动集群#################################
1.停掉原有节点的ES
[root@localhost config]# kill -9 1979
2.启动三个节点
每个节点都执行如下操作
[root@localhost config]# su - elasticsearch
[elasticsearch@localhost bin]$ cd /usr/local/services/elasticsearch/bin
[elasticsearch@localhost bin]$ ./elasticsearch -d
3.集群验证
[elasticsearch@localhost bin]$ curl -u elastic:elastic 'http://192.168.1.105:19200/_cat/nodes?pretty' 192.168.1.106 3 95 68 1.87 0.63 0.26 mdi - node-2 192.168.1.107 3 93 84 1.66 0.53 0.26 mdi - node-3 192.168.1.105 3 97 39 1.16 0.47 0.21 mdi * node-1 [elasticsearch@localhost bin]$ curl -u elastic:elastic 'http://192.168.1.105:19200/_cat/health?v' epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent 1691482056 08:07:36 my-cluster green 3 3 32 16 0 0 0 0 - 100.0%
4.验证数据情况
节点1: [elasticsearch@localhost bin]$ curl -u elastic:elastic -X GET 'http://192.168.1.105:19200/_cat/indices?v' health status index uuid pri rep docs.count docs.deleted store.size pri.store.size green open .security-6 U8MPlehwRFWYSQY2cgh8mw 1 1 6 0 39.1kb 19.5kb green open db_customer n3-RkwCxTK6-qjORZIs0Dg 5 1 1 0 9kb 4.5kb green open app_message_all E3S-HXeZTX6BuTbRlw31Pw 5 1 300000 0 444.9mb 222.4mb green open db_customer01 MZ54EHsBQY-teVmJTKf1kA 5 1 1 0 9kb 4.5kb 节点2: [elasticsearch@localhost bin]$ curl -u elastic:elastic -X GET 'http://192.168.1.106:19200/_cat/indices?v' health status index uuid pri rep docs.count docs.deleted store.size pri.store.size green open .security-6 U8MPlehwRFWYSQY2cgh8mw 1 1 6 0 39.1kb 19.5kb green open db_customer n3-RkwCxTK6-qjORZIs0Dg 5 1 1 0 9kb 4.5kb green open app_message_all E3S-HXeZTX6BuTbRlw31Pw 5 1 300000 0 444.9mb 222.4mb green open db_customer01 MZ54EHsBQY-teVmJTKf1kA 5 1 1 0 9kb 4.5kb 节点3: [elasticsearch@localhost bin]$ curl -u elastic:elastic -X GET 'http://192.168.1.107:19200/_cat/indices?v' health status index uuid pri rep docs.count docs.deleted store.size pri.store.size green open .security-6 U8MPlehwRFWYSQY2cgh8mw 1 1 6 0 39.1kb 19.5kb green open db_customer n3-RkwCxTK6-qjORZIs0Dg 5 1 1 0 9kb 4.5kb green open app_message_all E3S-HXeZTX6BuTbRlw31Pw 5 1 300000 0 444.9mb 222.4mb green open db_customer01 MZ54EHsBQY-teVmJTKf1kA 5 1 1 0 9kb 4.5kb
可以看到之前单节点的数据都自动同步到其他另外的2个节点了.
说明:
集群模式的备份目录必须是每个节点都能访问的公共目录,实现的方式有:
1.通过将一个节点的的备份目录通过nfs挂载到另外的2台机器;
2.若是采用云服务的话,可以购买一个nas服务,分别挂载到每个节点;
标签:kb,由单,elastic,192.168,elasticsearch,security,节点 From: https://www.cnblogs.com/hxlasky/p/17614762.html