安裝es7.5.1
主機:
192.168.1.234
192.168.1.233
192.168.1.240
系統:
centos7
安裝包:
安裝前准備:
#設置內核參數
cat > /etc/sysctl.conf << EOF vm.max_map_count=655360 EOF sysctl –p
#設置文件描述符限制
cat >> /etc/security/limits.conf << EOF * soft nofile 65536 * hard nofile 131072 * soft nproc 2048 * hard nproc 4096 EOF cat >> /etc/security/limits.d/90-nproc.conf << EOF * soft nproc 4096 EOF
#解決:Centos6不支持SecComp,而ES5.2.0默認bootstrap.system_call_filter為true
vim config/elasticsearch.yml
添加:
bootstrap.system_call_filter: false
安裝es集群
1、創建普通用戶elastic
useradd elastic
2、安裝elasticsearch
將文件解壓解壓路徑為/home/elastic/
3、配置es集群
es1 cluster.name: es-itcast-cluster node.name: node02 node.master: true node.data: true network.host: 192.168.1.233 discovery.seed_hosts: ["192.168.1.234","192.168.1.233","192.168.1.240"] cluster.initial_master_nodes: ["node01","node02","node03"] path.data: /var/lib/elasticsearch path.logs: /var/log/elasticsearch http.port: 9200 transport.port: 9300 es2 cluster.name: es-itcast-cluster node.name: node02 node.master: true node.data: true network.host: 192.168.1.234 discovery.seed_hosts: ["192.168.1.234","192.168.1.233","192.168.1.240"] cluster.initial_master_nodes: ["node01","node02","node03"] path.data: /var/lib/elasticsearch path.logs: /var/log/elasticsearch http.port: 9200 transport.port: 9300 es3 cluster.name: es-itcast-cluster node.name: node02 node.master: true node.data: true network.host: 192.168.1.240 discovery.seed_hosts: ["192.168.1.234","192.168.1.233","192.168.1.240"] cluster.initial_master_nodes: ["node01","node02","node03"] path.data: /var/lib/elasticsearch path.logs: /var/log/elasticsearch http.port: 9200 transport.port: 9300
4、更改文件權限
chown -R elastic.elastic /home/elastic chown -R elastic.elastic /var/lib/elasticsearch chown -R elastic.elastic /var/log/elasticsearch
5、啟動集群
su - elastic cd elasticsearch-7.5.1/bin ./elasticsearch &
這里需要注意: 單點單節點部署Elasticsearch, 集群狀態可能為yellow, 因為單點部署Elasticsearch, 默認的分片副本數目配置為1,而相同的分片不能在一個節點上,所以就存在副本分片指定不明確的問題,所以顯示為yellow,可以通過在Elasticsearch集群上添加一個節點來解決問題,如果不想這么做,可以刪除那些指定不明確的副本分片(當然這不是一個好辦法)但是作為測試和解決辦法還是可以嘗試的,下面試一下刪除副本分片的辦法:
[root@elk-server ~]# curl -XPUT "http://localhost:9200/_settings" -d' { "number_of_replicas" : 0 } '
{"acknowledged":true}
這個時候再次查看集群的狀態狀態變成了green
[root@elk-server ~]# curl -X GET 'http://localhost:9200/_cluster/health?pretty'
{
"cluster_name" : "elasticsearch",
"status" : "green",
"timed_out" : false,
"number_of_nodes" : 1,
"number_of_data_nodes" : 1,
"active_primary_shards" : 931,
"active_shards" : 931,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 0,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0,
"task_max_waiting_in_queue_millis" : 0,
"active_shards_percent_as_number" : 100.0
}
