天天看點

大資料元件部署——ES叢集部署

作者:麻辣小楊排
  • 下載下傳16.3版本的es

[root@master opt]# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.16.3-linux-x86_64.tar.gz

  • 解壓到/usr/local目錄下

[root@master opt]# tar -zxvf elasticsearch-7.16.3-linux-x86_64.tar.gz -C /usr/local/

  • 修改es配置檔案

[root@master elasticsearch-7.16.3]# cd config/

[root@master config]# vim elasticsearch.yml

cluster.name: my-application

node.name: node-1

path.data: /usr/local/elasticsearch-7.16.3/data

path.logs: /usr/local/elasticsearch-7.16.3/logs

network.host: 10.255.33.58

http.port: 9200

discovery.seed_hosts: ["10.255.33.58","10.255.33.58","10.255.33.62"]

cluster.initial_master_nodes: ["node-1"] (需要注意的是,該配置隻需配置在主節點即可)

  • 建立資料目錄

[root@master config]# mkdir /usr/local/elasticsearch-7.16.3/data

  • 建立es普通使用者,并授權,因為ES不能用root使用者啟動

[root@master local]# useradd es

[root@master local]# echo "Szzt@2022" | passwd --stdin es

  • 賦予權限

[root@master local]#chown -R es:es /usr/local/elasticsearch-7.16.3/

  • 修改es的jdk(在37行添加)

[root@master elasticsearch-7.16.3]# vim bin/elasticsearch-env

# use elasticesar idk

ES_JAVA_HOME="/usr/local/elasticsearch-7.16.3/jdk"

大資料元件部署——ES叢集部署
  • 修改核心參數

[root@master ~]# vim /etc/sysctl.conf

vm.max_map_count=655360

[root@master ~]# sysctl -p

[root@master ~]#vim /etc/security/limits.conf

* soft nofile 65536

* hard nofile 65536

* soft nproc 65536

* hard nproc 65536

* soft nproc memlock unlimited

* hard nproc memlock unlimited

  • 切換到es使用者,啟動es

[root@master elasticsearch-7.16.3]# su – es

[es@master ~]$ cd /usr/local/elasticsearch-7.16.3/bin/

  • 網頁測試

http://10.255.33.58:9200

  • 配置使用者名和密碼

生成CA憑證

[root@bigdata1 bin]# ./elasticsearch-certutil ca

生成p12密鑰

[root@bigdata1 bin]# ./elasticsearch-certutil cert --ca elastic-stack-ca.p12

拷貝P12密鑰檔案

[root@bigdata1 config]# cd /usr/local/elasticsearch-7.15.2/config/

[root@bigdata1 config]# mkdir certs

[root@bigdata1 config]# cp /usr/local/elasticsearch-7.15.2/elastic-certificates.p12 certs/

在其他的節點建立certs目錄,然後将p12檔案拷貝過去

[root@bigdata1 config]# cd /usr/local/elasticsearch-7.15.2/config/

[root@bigdata1 config]# mkdir certs

[root@bigdata1 config]#scp /usr/local/elasticsearch-7.15.2/elastic-certificates.p12 bigdata2:/usr/local/elasticsearch-7.15.2/config/certs/elastic-certificates.p12

[root@bigdata1 config]#scp /usr/local/elasticsearch-7.15.2/elastic-certificates.p12 bigdata3:/usr/local/elasticsearch-7.15.2/config/certs/elastic-certificates.p12

停止es服務

[es@3 bin]$ jps

6373 Elasticsearch

[es@3 bin]$kill -9 6373

修改配置檔案./config/elasticsearch.yml

将以下内容添加進去

xpack.security.enabled: true

xpack.security.transport.ssl.enabled: true

xpack.security.transport.ssl.verification_mode: certificate

xpack.security.transport.ssl.keystore.path: certs/elastic-certificates.p12

xpack.security.transport.ssl.truststore.path: certs/elastic-certificates.p12

切換到es使用者,并且啟動es

[es@3 bin]$ ./elasticsearch &

執行設定使用者名和密碼

[es@3 bin]$ ./elasticsearch-setup-passwords interactive

Initiating the setup of passwords for reserved users elastic,apm_system,kibana,kibana_system,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_system]:

Reenter password for [kibana_system]:

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]:

[2022-08-22T14:03:55,105][INFO ][o.e.x.s.s.SecurityIndexManager] [node-1] security index does not exist, creating [.security-7] with alias [.security]

[2022-08-22T14:03:55,200][INFO ][o.e.c.m.MetadataCreateIndexService] [node-1] [.security-7] creating index, cause [api], templates [], shards [1]/[0]

[2022-08-22T14:03:55,374][INFO ][o.e.c.r.a.AllocationService] [node-1] Cluster health status changed from [YELLOW] to [GREEN] (reason: [shards started [[.security-7][0]]]).

Changed password for user [apm_system]

Changed password for user [kibana_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]

網頁驗證

賬号:elastic

密碼:Szzt#2022

繼續閱讀