在ubuntu18.04.2上搭建elasticsearch6.6.0集羣

操作系統:
在ubuntu18.04.2上搭建elasticsearch6.6.0集羣
在ubuntu18.04.2上搭建elasticsearch6.6.0集羣

es的安裝:https://www.elastic.co/guide/en/elasticsearch/reference/current/deb.html
要緊的就這2步:
   wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.6.0.deb
     sudo dpkg -i elasticsearch-6.6.0.deb
     sudo /bin/systemctl daemon-reload
     sudo /bin/systemctl enable elasticsearch.service
     sudo /bin/systemctl start elasticsearch.service
     如果啓動失敗說找不到JAVA_HOME環境變量,但是在命令行裏敲java又有,則
     在 /etc/default/elasticsearch裏添加如下行
         `JAVA_HOME=/usr/local/jre1.8.0_191`

2個節點:
節點1的IP: 192.168.11.145
節點2的IP: 192.168.11.148

更改2個節點的配置文件  /etc/elasticsearch/elasticsearch.yml
參照這個鏈接配置 https://dzone.com/articles/elasticsearch-tutorial-creating-an-elasticsearch-c

我的2個配置

在ubuntu18.04.2上搭建elasticsearch6.6.0集羣

在ubuntu18.04.2上搭建elasticsearch6.6.0集羣
配置完成後在2個節點上分別重啓: systemctl restart elasticsearch.service
安裝kibana,kibana安裝在192.168.11.145節點上,注意kibana的版本要與es的版本匹配
注意/etc/kibana/kibana.yml裏的elasticsearch.hosts要與es的node.master: true的
network.host:network.port相匹配

打開 192.168.11.145:5601查看
在DevTool裏輸入GET /_cluster/state?pretty查看,可以看到有2個節點了
在ubuntu18.04.2上搭建elasticsearch6.6.0集羣

在Monitoring也可以看到2個節點
在ubuntu18.04.2上搭建elasticsearch6.6.0集羣

創建一個index看看
PUT /index-sgd
{
"settings" : {
"index" : {
"number_of_shards" : 2,
"number_of_replicas" : 1
}
}
}

發現健康爲yellow
在ubuntu18.04.2上搭建elasticsearch6.6.0集羣

查看index-sgd的stats,我是2個主分片,2個副本共4個分片,顯示有2個分片successful
在ubuntu18.04.2上搭建elasticsearch6.6.0集羣
Monitoring的這裏也可以看到index-sgd有2個分片Unassigned
在ubuntu18.04.2上搭建elasticsearch6.6.0集羣

應該是因爲192.168.11.148這個node的node.data設置爲了false的原因,把這個節點的node.data設置爲true
重啓節點再通過kibana查看,健康狀態就爲green了
在ubuntu18.04.2上搭建elasticsearch6.6.0集羣

PUT /index-sgd
{
"settings" : {
"index" : {
"number_of_shards" : 2,
"number_of_replicas" : 2
}
}
}

如果把number_of_shards和number_of_replicas改成2,2,健康狀態怎麼都是yellow了
{
"_shards": {
"total": 6,
"successful": 4,
"failed": 0
},
改成3,1 健康狀態爲green
{
"_shards": {
"total": 6,
"successful": 6,
"failed": 0
},
改成3,2 健康狀態爲yellow
{
"_shards": {
"total": 9,
"successful": 6,
"failed": 0
},

改成3,3, 健康狀態爲yellow
{

"_shards": {
"total": 12,
"successful": 6,
"failed": 0
},
改成4,1,green
{
"_shards": {
"total": 8,
"successful": 8,
"failed": 0
},
改成4,2,yellow
{
"_shards": {
"total": 12,
"successful": 8,
"failed": 0
},
改成100,1,green
{
"_shards": {
"total": 200,
"successful": 200,
"failed": 0
},

改成1,2,yellow
{

"_shards": {
"total": 3,
"successful": 2,
"failed": 0
},

健康狀態取決於node和number_of_replicas
滿足這個number_of_replicas<=node才能green
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章