CentOS7下Elasticsearch集群部署记录
生活随笔
收集整理的這篇文章主要介紹了
CentOS7下Elasticsearch集群部署记录
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Elasticsearch是一個分布式搜索服務,提供Restful API,底層基于Lucene,采用多shard的方式保證數據安全,并且提供自動resharding的功能,github等大型的站點也都采用Elasticsearch作為其搜索服務。廢話在此就不多贅述了,下面記錄下CentOS7下Elasticsearch集群部署過程:
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | 之前在三臺服務器部署Elasticsearch集群: qd-vpc-op-es01??? 101.119.92.247 qd-vpc-op-es02??? 101.119.92.249 qd-vpc-op-es03??? 101.119.92.254 下面再追加一臺es04機器到集群中,操作如下: qd-vpc-op-es04??? 101.119.92.16 1)安裝jdk和elasticsearch jdk-8u5-linux-x64.rpm下載地址: https://pan.baidu.com/s/1bpxtX5X??????(提取密碼:df6s) elasticsearch-5.5.0.rpm下載地址: https://pan.baidu.com/s/1mibwWeG?????(提取密碼:vtm2) [root@qd-vpc-op-es04 ~]# cd tools/ [root@qd-vpc-op-es04 tools]# ls elasticsearch-5.5.0.rpm? jdk-8u5-linux-x64.rpm [root@qd-vpc-op-es04 tools]# rpm -ivh elasticsearch-5.5.0.rpm [root@qd-vpc-op-es04 tools]# rpm -ivh jdk-8u5-linux-x64.rpm [root@qd-vpc-op-es04 tools]# java -version java version?"1.8.0_05" Java(TM) SE Runtime Environment (build 1.8.0_05-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode) 2)配置elasticsearch [root@qd-vpc-op-es04 ~]# cd /etc/elasticsearch/ [root@qd-vpc-op-es04 elasticsearch]# ls elasticsearch.yml? elasticsearch.yml.bak? jvm.options? log4j2.properties??nohup.out? scripts [root@qd-vpc-op-es04 elasticsearch]# cat elasticsearch.yml|grep -v "#"?????????? //集群中每個節點的配置內容都基本一致 cluster.name: image_search???????????????????????????????????????????????????????//集群名稱 node.name: image_search_node_4???????????????????????????????????????????????????//集群中本節點的節點名稱,這里定義即可 path.data:?/data/es/data?????????????????????????????????????????????????????????//服務目錄路徑 path.logs:?/data/es/logs?????????????????????????????????????????????????????????//服務日志路徑 discovery.zen.ping.unicast.hosts: ["101.119.92.247","101.119.92.249","101.119.92.254","10.111.233.16"]?????//這里是各節點的ip地址 network.host: 0.0.0.0????????????????????????????????????????????????????????????//服務綁定的網絡地址 默認elasticsearch服務端口時9200 [root@qd-vpc-op-es04 elasticsearch]# cat elasticsearch.yml|grep 9200 #http.port: 9200 [root@qd-vpc-op-es04 elasticsearch]# systemctl start elasticsearch.service [root@qd-vpc-op-es04 elasticsearch]# systemctl restart elasticsearch.service [root@qd-vpc-op-es04 elasticsearch]# systemctl status elasticsearch.service [root@qd-vpc-op-es04 elasticsearch]# ps -ef|grep elasticsearch [root@qd-vpc-op-es04 elasticsearch]# lsof -i:9200 COMMAND?? PID????????? USER?? FD?? TYPE DEVICE SIZE/OFF?NODE NAME java??? 10998 elasticsearch? 320u? IPv4? 39255????? 0t0? TCP *:wap-wsp (LISTEN) 檢查elasticsearch的健康狀態 [root@qd-vpc-op-es04 elasticsearch]# curl 'localhost:9200/_cat/indices?v' health status index?????????????????? uuid?????????????????? pri rep docs.count docs.deleted store.size pri.store.size green??open???video_filter??????????? Bx7He6ZtTEWuRBqXYC6gRw?? 5?? 1???? 458013??????????? 0????? 4.1gb??????????? 2gb green??open???recommend_history_image svYo_Do4SM6wUiv6taUWug?? 5?? 1??? 2865902??????????? 0???? 24.9gb???????? 12.4gb green??open???recommend_history_gif?? rhN3MDN2TbuYILqEDksQSg?? 5?? 1???? 265731??????????? 0????? 2.4gb????????? 1.2gb green??open???post_images???????????? TMsMsMEoR5Sdb7UEQJsR5Q?? 5?? 1?? 48724932??????????? 0??? 407.3gb??????? 203.9gb green??open???review_images_v2??????? qzqnknpgTniU4rCsvXzs0w?? 5?? 1?? 50375955??????????? 0???? 61.6gb???????? 30.9gb green??open???review_images?????????? rWC4WlfMS8aGe-GOkTauZg?? 5?? 1?? 51810877??????????? 0??? 439.3gb??????? 219.7gb green??open???sensitive_images??????? KxSrjvXdSz-y8YcqwBMsZA?? 5?? 1????? 13393??????????? 0??? 128.1mb?????????? 64mb green??open???post_images_v2????????? FDphBV4-QuKVoD4_G3vRtA?? 5?? 1?? 49340491??????????? 0???? 55.8gb???????? 27.8gb 從上面的命令結果中可以看出,本節點已經成功加入到名為image_search的elasticsearch集群中了,green表示節點狀態很健康,數據也已經在同步中了。 3)在代碼中更新elasticsearch的配置 通知開發同事,在代碼中增加新增elasticsearch節點的配置,上線更新后,到新節點上查看elasticsearch日志是否有信息寫入: [root@qd-vpc-op-es04 ~]# cd /data/es/logs/ [root@qd-vpc-op-es04 ~]# chown -R elasticsearch.elasticsearch /data/es [root@qd-vpc-op-es04 logs]# ls image_search_deprecation.log? image_search_index_indexing_slowlog.log? image_search_index_search_slowlog.log? image_search.log ---------------------------------------------------------------------------------------------------------------- 注意: 如果往elasticsearch集群中新增一個節點,做法如下: 1)在新節點上安裝jdk和elasticsearch服務,配置elasticsearch.yml文件了,啟動elasticsearch服務 2)在集群中其他節點上配置elasticsearch.yml文件,不需要啟動elasticsearch服務 3)在新節點上執行curl?'localhost:9200/_cat/indices?v'命令,查看健康狀態以及數據同步情況 4)在代碼中增加新增elasticsearch節點的配置,上線更新后,查看新增節點的elasticsearch日志是否有信息寫入 ---------------------------------------------------------------------------------------------------------------- 最后順便貼一下其他三個節點的elasticsearch.yml文件配置: [root@qd-vpc-op-es01 ~]# cat /etc/elasticsearch/elasticsearch.yml |grep -v "#" cluster.name: image_search node.name: image_search_node_1 path.data:?/data/es/data path.logs:?/data/es/logs discovery.zen.ping.unicast.hosts: ["10.111.233.16","101.119.92.247","101.119.92.249","101.119.92.254"] network.host: 0.0.0.0 [root@qd-vpc-op-es02 ~]# cat /etc/elasticsearch/elasticsearch.yml |grep -v "#" cluster.name: image_search node.name: image_search_node_2 path.data:?/data/es/data path.logs:?/data/es/logs discovery.zen.ping.unicast.hosts: ["10.111.233.16","101.119.92.247","101.119.92.249","101.119.92.254"] network.host: 0.0.0.0 [root@qd-vpc-op-es03 ~]# cat /etc/elasticsearch/elasticsearch.yml|grep -v "#" cluster.name: image_search node.name: image_search_node_3 path.data:?/data/es/data path.logs:?/data/es/logs discovery.zen.ping.unicast.hosts: ["101.119.92.247","101.119.92.249","101.119.92.254","10.111.233.16"] network.host: 0.0.0.0 ---------------------------------------------------------------------------------------------------------------- 如果關閉某個節點或將其從集群中提出來,需要提前通知該節點停止同步數據(遷移的時候會用到): # curl -XPUT 'localhost:9200/_cluster/settings' -d '{"transient" : {"cluster.routing.allocation.enable" : "none”}}’ |
本文轉自散盡浮華博客園博客,原文鏈接:http://www.cnblogs.com/kevingrace/p/7693422.html,如需轉載請自行聯系原作者
總結
以上是生活随笔為你收集整理的CentOS7下Elasticsearch集群部署记录的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: LSI系列芯片Raid卡配置方法、管理手
- 下一篇: QQ开发技术资料集锦