在Ubuntu 18.04.2上安裝部署ElasticSearch 6.6.0集群記錄。
操作系統(tǒng):
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環(huán)境變量,但是在命令行里敲java又有,則 在 /etc/default/elasticsearch里添加如下行 `JAVA_HOME=/usr/local/jre1.8.0_191`
2個(gè)節(jié)點(diǎn):
節(jié)點(diǎn)1的IP: 192.168.11.145
節(jié)點(diǎn)2的IP: 192.168.11.148
更改2個(gè)節(jié)點(diǎn)的配置文件 /etc/elasticsearch/elasticsearch.yml 參照這個(gè)鏈接配置 https://dzone.com/articles/elasticsearch-tutorial-creating-an-elasticsearch-c 我的2個(gè)配置
配置完成后在2個(gè)節(jié)點(diǎn)上分別重啟: systemctl restart elasticsearch.service
安裝kibana,kibana安裝在192.168.11.145節(jié)點(diǎn)上,注意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個(gè)節(jié)點(diǎn)了
在Monitoring也可以看到2個(gè)節(jié)點(diǎn)
創(chuàng)建一個(gè)index看看
PUT /index-sgd
{
“settings” : {
“index” : {
“number_of_shards” : 2,
“number_of_replicas” : 1
}
}
}
發(fā)現(xiàn)健康為yellow
查看index-sgd的stats,我是2個(gè)主分片,2個(gè)副本共4個(gè)分片,顯示有2個(gè)分片successful
Monitoring的這里也可以看到index-sgd有2個(gè)分片Unassigned
應(yīng)該是因?yàn)?92.168.11.148這個(gè)node的node.data設(shè)置為了false的原因,把這個(gè)節(jié)點(diǎn)的node.data設(shè)置為true
重啟節(jié)點(diǎn)再通過kibana查看,健康狀態(tài)就為green了
PUT /index-sgd
{
“settings” : {
“index” : {
“number_of_shards” : 2,
“number_of_replicas” : 2
}
}
}
如果把number_of_shards和number_of_replicas改成2,2,健康狀態(tài)怎么都是yellow了
{
“_shards”: {
“total”: 6,
“successful”: 4,
“failed”: 0
},
改成3,1 健康狀態(tài)為green
{
“_shards”: {
“total”: 6,
“successful”: 6,
“failed”: 0
},
改成3,2 健康狀態(tài)為yellow
{
“_shards”: {
“total”: 9,
“successful”: 6,
“failed”: 0
},
改成3,3, 健康狀態(tài)為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
},
健康狀態(tài)取決于node和number_of_replicas 滿足這個(gè)number_of_replicas<=node才能green
Elasticsearch 零基礎(chǔ)到入門新手教程 http://www.haoyitu.cn/Linux/2019-01/156356.htm