單節點的es添加另外一個節點組成主從集群


環境:
OS:Centos 7
DB:6.5.0

192.168.1.135:19200 現有的單節點
192.168.1.134:19200 准備新添加的節點

--------新節點(192.168.1.134)安裝es---------------
1.安裝跟現有版本一致的es
我這里的版本是6.5.0
[root@localhost hxlmiao]# tar -xvf elasticsearch-6.5.0.tar.gz
[root@localhost hxlmiao]# mv elasticsearch-6.5.0 single_elasticsearch
[root@localhost hxlmiao]# chown -R hxlmiao:hxlmiao ./single_elasticsearch

2.創建相應目錄
su - hxlmiao
[hxlmiao@localhost single_elasticsearch]$ cd /home/hxlmiao/single_elasticsearch
[hxlmiao@localhost single_elasticsearch]$ mkdir data

3.修改配置文件
vi /home/hxlmiao/single_elasticsearch/config/elasticsearch.yml
注意修改如下項目:
cluster.name: escluster ##主從節點一致
node.name: node-slave ##與主節點區別
path.data: /home/hxlmiao/single_elasticsearch/data
path.logs: /home/hxlmiao/single_elasticsearch/logs
network.host: 192.168.1.134
http.port: 19200
discovery.zen.ping.unicast.hosts: ["192.168.1.134:9300", "192.168.1.135:9300"] ##這里必須填寫9300端口內部通信端口
discovery.zen.minimum_master_nodes: 1
http.cors.enabled: true
http.cors.allow-credentials: true
http.cors.allow-origin: "/.*/"
http.cors.allow-headers: WWW-Authenticate,X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization
xpack.security.enabled: false
transport.tcp.port:9300 ##節點之間內部通信端口

4.啟動
[root@localhost opt]# su - hxlmiao
[hxlmiao@localhost bin]$ cd /home/hxlmiao/single_elasticsearch/bin
[hxlmiao@localhost bin]$./elasticsearch -d

5.這個時候主庫配置沒有修改,也沒有重啟動,看下數據是否有同步過來
[hxlmiao@localhost logs]$ curl -X GET 'http://192.168.1.134:19200/_cat/indices?v'
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size

看到數據是沒有同步過來的


---------------------原來的節點(192.168.1.135)配置修改-----------------
1.查看原來節點數據情況
[hxlmiao@localhost config]$ curl -X GET 'http://192.168.1.135:19200/_cat/indices?v'
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open inoculate_new tWt0-g8wQreRCu-dp0Iuow 5 1 18280 0 4mb 2mb
green open reservation_new Shg_bn80TFucvknXxikmZw 5 1 5607 0 1.4mb 734.8kb


2.修改配置文件
vi /home/hxlmiao/single_elasticsearch/config/elasticsearch.yml
注意修改如下項目:
cluster.name: escluster ##主從節點一致
node.name: node-slave ##與主節點區別
path.data: /home/hxlmiao/single_elasticsearch/data
path.logs: /home/hxlmiao/single_elasticsearch/logs
network.host: 192.168.1.135
http.port: 19200
discovery.zen.ping.unicast.hosts: ["192.168.1.134:9300", "192.168.1.135:9300"] ##這里必須填寫9300端口內部通信端口
discovery.zen.minimum_master_nodes: 1
http.cors.enabled: true
http.cors.allow-credentials: true
http.cors.allow-origin: "/.*/"
http.cors.allow-headers: WWW-Authenticate,X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization
xpack.security.enabled: false
transport.tcp.port:9300 ##節點之間內部通信端口

2.重新啟動
[root@localhost opt]# su - hxlmiao
[hxlmiao@localhost bin]$ cd /home/hxlmiao/single_elasticsearch/bin
[hxlmiao@localhost bin]$./elasticsearch -d

3.在新的節點驗證數據是否同步過來
[hxlmiao@localhost logs]$ curl -X GET 'http://192.168.1.134:19200/_cat/indices?v'
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open inoculate_new tWt0-g8wQreRCu-dp0Iuow 5 1 18280 0 4mb 2mb
green open reservation_new Shg_bn80TFucvknXxikmZw 5 1 5607 0 1.4mb 734.8kb

可以看到數據已經同步過來.


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM