在Ubuntu 18.04.2上安装部署ElasticSearch 6.6.0集群记录。
操作系统:
代码语言:javascript复制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
代码语言:javascript复制更改2个节点的配置文件 /etc/elasticsearch/elasticsearch.yml
参照这个链接配置 https://dzone.com/articles/elasticsearch-tutorial-creating-an-elasticsearch-c
我的2个配置
配置完成后在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个节点了
在Monitoring也可以看到2个节点
创建一个index看看 PUT /index-sgd { "settings" : { "index" : { "number_of_shards" : 2, "number_of_replicas" : 1 } } }
发现健康为yellow
查看index-sgd的stats,我是2个主分片,2个副本共4个分片,显示有2个分片successful
Monitoring的这里也可以看到index-sgd有2个分片Unassigned
应该是因为192.168.11.148这个node的node.data设置为了false的原因,把这个节点的node.data设置为true 重启节点再通过kibana查看,健康状态就为green了
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 },
代码语言:javascript复制改成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 },
代码语言:javascript复制改成1,2,yellow
{
"_shards": { "total": 3, "successful": 2, "failed": 0 },
代码语言:javascript复制健康状态取决于node和number_of_replicas
满足这个number_of_replicas<=node才能green
Elasticsearch 零基础到入门新手教程 https://www.linuxidc.com/Linux/2019-01/156356.htm