elasticsearch7.5.0 集群搭建
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                elasticsearch7.5.0 集群搭建
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.                        
                                elasticsearch7.5.0 集群搭建
服務器???服務?? ?系統?? ?ES版本
 192.168.8.218?? ?node.master? ? centos7.3?? ?es7.5
 192.168.8.219?? ?node.data?? ?centos7.3?? ?es7.5
 192.168.8.220?? ?node.data?? ?centos7.3?? ?es7.5
 ?
1、添加用戶及zu:
#elk用戶添加 groupadd -g 100 elk useradd -u 100 -g elk elk參數修改
echo "fs.file-max = 1000000" >> /etc/sysctl.conf echo "vm.max_map_count=262144" >> /etc/sysctl.conf echo "vm.swappiness = 0" >> /etc/sysctl.conf sysctl -p sed -i 's/* soft nofile 65535/* soft nofile 655350/g' /etc/security/limits.conf sed -i 's/* hard nofile 65535/* hard nofile 655350/g' /etc/security/limits.conf sed -i 's#* soft nproc 4096##' /etc/security/limits.d/20-nproc.conf#修改/etc/security/limits.d/20-nproc.conf * soft memlock unlimited * hard memlock unlimited2、JDK安裝:1.8
export JAVA_HOME=、opt/soft/jdk export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar3、集群搭建:
3.1、master節點:
cd /home/elk wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.5.0-linux-x86_64.tar.gz #解壓 tar -xvf elasticsearch-7.5.0-linux-x86_64.tar.gz新建日志、存儲、備份目錄: mkdir -p /home/elk/data && mkdir -p /home/elk/logs && mkdir /home/elk/esback chown -Rf elk.elk /home/elk[elk@localhost elasticsearch-7.5.0]$ su -elk [elk@localhost elasticsearch-7.5.0]$ cd /home/elk/elasticsearch-7.5.0/ [elk@localhost elasticsearch-7.5.0]$ cat config/elasticsearch.yml # ======================== Elasticsearch Configuration ========================= cluster.name: fengyu node.name: fengyu218 path.data: /home/elk/data path.logs: /home/elk/logs path.repo: ["/home/elk/esback"] bootstrap.memory_lock: true network.host: 192.168.8.218 http.port: 9200 transport.tcp.port: 9300 node.master: true node.data: true discovery.seed_hosts: ["192.168.8.218:9300", "192.168.8.219:9300", "192.168.8.220:9300"] cluster.initial_master_nodes: ["192.168.8.218"] gateway.recover_after_nodes: 2 transport.tcp.compress: true # 以下配置可以減少當es節點短時間宕機或重啟時shards重新分布帶來的磁盤io讀寫浪費 discovery.zen.fd.ping_timeout: 300s discovery.zen.fd.ping_retries: 8 discovery.zen.fd.ping_interval: 30s discovery.zen.ping_timeout: 180s #啟動 ./bin/elasticsearch #PS:如果用root啟動過一次,需要重新將elk目錄重新賦權給elk。要不elk無法正常啟動 #能看到端口起來就正常 [2020-04-13T19:46:41,471][INFO ][o.e.x.s.a.s.FileRolesStore] [fengyu218] parsed [0] roles from file [/home/elk/elasticsearch-7.5.0/config/roles.yml] [2020-04-13T19:46:42,379][INFO ][o.e.x.m.p.l.CppLogMessageHandler] [fengyu218] [controller/7071] [Main.cc@110] controller (64 bit): Version 7.5.0 (Build 17d1c724ca38a1) Copyright (c) 2019 Elasticsearch BV [2020-04-13T19:46:42,977][DEBUG][o.e.a.ActionModule ] [fengyu218] Using REST wrapper from plugin org.elasticsearch.xpack.security.Security [2020-04-13T19:46:43,100][INFO ][o.e.d.DiscoveryModule ] [fengyu218] using discovery type [zen] and seed hosts providers [settings] [2020-04-13T19:46:43,995][INFO ][o.e.n.Node ] [fengyu218] initialized [2020-04-13T19:46:43,996][INFO ][o.e.n.Node ] [fengyu218] starting ... [2020-04-13T19:46:44,108][INFO ][o.e.t.TransportService ] [fengyu218] publish_address {192.168.8.218:9300}, bound_addresses {192.168.8.218:9300} [2020-04-13T19:46:44,270][INFO ][o.e.b.BootstrapChecks ] [fengyu218] bound or publishing to a non-loopback address, enforcing bootstrap checks [2020-04-13T19:46:44,273][INFO ][o.e.c.c.Coordinator ] [fengyu218] cluster UUID [upnpaUuXTDmqYoQGzXWGlw] [2020-04-13T19:46:44,584][INFO ][o.e.c.s.MasterService ] [fengyu218] elected-as-master ([1] nodes joined)[{fengyu218}{GKJ2npj9Rc-wQUvCm8W_Ow}{b-sp6dmTR0apAdmpBtjrOg}{192.168.8.218}{192.168.8.218:9300}{dilm}{ml.machine_memory=3975491584, xpack.installed=true, ml.max_open_jobs=20} elect leader, _BECOME_MASTER_TAS _, _FINISH_ELECTION_], term: 2, version: 22, delta: master node changed {previous [], current [{fengyu218}{GKJ2npj9Rc-wQUvCm8W_Ow}{b-sp6dmTR0apAdmpBtjrOg}{192.168.8.218}{192.168.8.218:9300}{dilm}{ml.machine_memory=3975491584, xpack.installed=true, ml.max_open_jobs=20}]}測試訪問: 網頁訪問:http://192.168.8.218:9200/3.2、node1節:
cd /home/elk wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.5.0-linux-x86_64.tar.gz #解壓 tar -xvf elasticsearch-7.5.0-linux-x86_64.tar.gz#新建日志、存儲、備份目錄: mkdir -p /home/elk/data && mkdir -p /home/elk/logs && mkdir /home/elk/esback chown -Rf elk.elk /home/elk#更改elasticsearch.yml[elk@localhost elasticsearch-7.5.0]$ cd /home/elk/elasticsearch-7.5.0 [elk@localhost elasticsearch-7.5.0]$ cat config/elasticsearch.yml cluster.name: fengyu node.name: fengyu219 path.data: /home/elk/data path.logs: /home/elk/logs path.repo: ["/home/elk/esback"] bootstrap.memory_lock: true network.host: 192.168.8.219 http.port: 9200 transport.tcp.port: 9300 node.master: false node.data: true discovery.seed_hosts: ["192.168.8.218:9300", "192.168.8.219:9300", "192.168.8.220:9300"] cluster.initial_master_nodes: ["192.168.8.218"] gateway.recover_after_nodes: 2 transport.tcp.compress: true # 以下配置可以減少當es節點短時間宕機或重啟時shards重新分布帶來的磁盤io讀寫浪費 discovery.zen.fd.ping_timeout: 300s discovery.zen.fd.ping_retries: 8 discovery.zen.fd.ping_interval: 30s discovery.zen.ping_timeout: 180s啟動:./bin/elasticsearch -d3.3、node2節點配置:
[elk@localhost elasticsearch-7.5.0]$ cat config/elasticsearch.yml cluster.name: fengyu node.name: fengyu220 path.data: /home/elk/data path.logs: /home/elk/logs path.repo: ["/home/elk/esback"] bootstrap.memory_lock: true network.host: 192.168.8.220 http.port: 9200 transport.tcp.port: 9300 node.master: false node.data: true discovery.seed_hosts: ["192.168.8.218:9300", "192.168.8.219:9300", "192.168.8.220:9300"] cluster.initial_master_nodes: ["192.168.8.218"] gateway.recover_after_nodes: 2 transport.tcp.compress: true # 以下配置可以減少當es節點短時間宕機或重啟時shards重新分布帶來的磁盤io讀寫浪費 discovery.zen.fd.ping_timeout: 300s discovery.zen.fd.ping_retries: 8 discovery.zen.fd.ping_interval: 30s discovery.zen.ping_timeout: 180s集群狀態驗證,當status 為green時候,集群狀態正常:
[elk@localhost elasticsearch-7.5.0]$ curl -u elastic:jumeng123! http://192.168.8.218:9200/_cluster/health?pretty {"cluster_name" : "fengyu","status" : "green","timed_out" : false,"number_of_nodes" : 3,"number_of_data_nodes" : 3,"active_primary_shards" : 1,"active_shards" : 2,"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 }增加密碼校驗
 在各個節點的elasticsearch.yml 最后增加
添加完以后不重啟,制作證書
#必須用elk用戶制作證書 [elk@localhost elasticsearch-7.5.0]$ ./bin/elasticsearch-certutil ca Please enter the desired output file [elastic-stack-ca.p12]: #回車 Enter password for elastic-stack-ca.p12 : #回車 [elk@localhost elasticsearch-7.5.0]$ bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12 #直接回車就好 [elk@localhost elasticsearch-7.5.0]$ cp elastic-certificates.p12 config/ #重啟elasticsearch [elk@localhost elasticsearch-7.5.0]$ pkill -9 -f elk [elk@localhost elasticsearch-7.5.0]$ ./bin/elasticsearch #如果此時無法啟動,是證書制作有問題 #將證書一次傳到其他的節點 [elk@localhost elasticsearch-7.5.0]$ for i in 192.168.8.219 192.168.8.220; do scp /home/elk/elasticsearch-7.5.0/config/elastic-certificates.p12 $i:/home/elk/elasticsearch-7.5.0/config; done #依次重啟其他節點 #獲取集裝狀態 [elk@localhost elasticsearch-7.5.0]$ curl -u elastic:jumeng123! http://192.168.8.218:9200/_cluster/health?pretty {"cluster_name" : "fengyu","status" : "green","timed_out" : false,"number_of_nodes" : 3,"number_of_data_nodes" : 3,"active_primary_shards" : 1,"active_shards" : 2,"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 } #密碼初始化 輸入你的密碼 [elk@localhost elasticsearch-7.5.0]$ bin/elasticsearch-setup-passwords interactive Initiating the setup of passwords for reserved users elastic,apm_system,kibana,logstash_system,beats_system,remote_monitoring_user. You will be prompted to enter passwords as the process progresses. Please confirm that you would like to continue [y/N]y Enter password for [elastic]: Reenter password for [elastic]: Enter password for [apm_system]: Reenter password for [apm_system]: Enter password for [kibana]: Reenter password for [kibana]: Enter password for [logstash_system]: Reenter password for [logstash_system]: Enter password for [beats_system]: Reenter password for [beats_system]: Enter password for [remote_monitoring_user]: Reenter password for [remote_monitoring_user]: Changed password for user [apm_system] Changed password for user [kibana] Changed password for user [logstash_system] Changed password for user [beats_system] Changed password for user [remote_monitoring_user] Changed password for user [elastic]配置后,后續訪問elastaicsearch需要輸入密碼:
總結
以上是生活随笔為你收集整理的elasticsearch7.5.0 集群搭建的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: ES:java.nio.file.Acc
- 下一篇: matlab r2021b校园正版软件安
