0
点赞
收藏
分享

微信扫一扫

Elasticsearch--01.ES8.1.0集群搭建


一、搭建ES集群

1.集群环境安装

本集群使用Centos7.5操作系统,2G 2C 60G(如果主机好点的节点配置可以搞高点)

分别修改三台集群服务器配置:

 1.1.修改系统配置文件/etc/security/limits.conf

* soft nofile 65536 # 设置每个进程可以打开的文件数的限制
* hard nofile 65536
* soft nproc 2048  # 设置线程数
* hard nproc 4096

1.2.修改/etc/sysctl.conf

#一个进程可以拥有的VMA数量设置为655360(默认为65536)
vm.max_map_count=655360

1.3.#sysctl -p 重新加载

集群服务器如下:

机器地址

节点名称

节点角色

节点功能

192.168.206.101

es-node-1

Master,data

主+数据节点

192.168.206.102

es-node-2

Master,data

主+数据节点

192.168.206.103

es-node-3

Master,data

主+数据节点

2.下载ES并解压

   ES-8.1.0下载地址:Elasticsearch 8.1.0 | Elastic

将es解压到指定的目录:

tar -zxvf elasticsearch-8.1.0-linux-x86_64.tar.gz -C /opt/module/

 3.新增用户es

#新增用户
useradd es
passwd es
# 创建数据文件目录
mkdir /opt/module/elasticsearch-8.1.0/data/
# 创建证书目录
mkdir /opt/module/elasticsearch-8.1.0/config/certs
# 修改文件拥有者
chown -R es:es /opt/module/elasticsearch-8.1.0

4.在第一台服务器节点上生成安全证书

#切换用户
su es
# 签发ca证书 直接敲回车 不需要输入密码
bin/elasticsearch-certutil ca
# 用ca证书签发节点证书 敲三次回车
bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12
# 将生成的证书文件移动到config/certs目录中
 mv elastic-certificates.p12 config/certs

5.在第一台服务器节点上生成http证书

# 签发Https证书
bin/elasticsearch-certutil http

关键环节如下:

Generate  a  CRS? [y/n]n  (是否发送认证证书请求)

Use  an existing CA? [y/n]y (是否使用已存在的CA证书)

CA  Path: certs/elastic-stack-ca.p12 (CA证书路径)

Password  for elastic-stack-ca.p12:  (输入CA证书密码、上面生成CA证书未设置密码、直接回车)

For  how long should  your certificate be valid: [5y] 20y (输入证书使用年限)

Generate a  certificate per node: [y/n] n(是否每个节点都 生成证书)

Enter all the hostnames that you need,one per line. (输入主机名称、回车)

when you are done,press <enter> once more to move on to the next step

linux001

linux002

linux003

Is this correct [y/n] n(输入的主机名称是否正确)

Enter all the ip address that you need,one per line. (输入节点ip地址、回车)

when you are done,press <enter> once more to move on to the next step

192.168.206.101

192.168.206.102

192.168.206.103

Is this correct [y/n] n(输入的ip地址是否正确)

DO you wish to change any of these options [y/n] n (是否修改证书配置)

Provide a password for the "http.p12" file:[<enter> for none] (输入密码、没配置密码、直接回车) 

What filename should be used for the output zip files?[/opt/module/elasticsearch-8.1.0/elasticsearch-ssl-http.zip] (是否自定义名称、直接回车)

解压并移动到config/certs目录里

unzip elasticsearch-ssl-http.zip
# 证书文件移动到指定目录下
mv elasticsearch/http.p12 kibana/elasticsearch-ca.pem config/certs

6.配置第一个服务器节点

#vim conf/elasticsearch.yml

# ES集群配置
cluster.name: cluster-es
node.name: es-node-1
#设置数据
path.data: /opt/module/elasticsearch-8.1.0/data/
path.logs: /opt/module/elasticsearch-8.1.0/logs/
# 网络访问节点名称(需要在/etc/hosts里设置解析)
network.host: linux001
# Rest访问端口9200 ES集群内部端口为9300
http.port: 9200
# 初始节点
discovery.seed_hosts: ["linux001"]
# 安全认证
xpack.security.enabled: true
xpack.security.enrollment.enabled: true
xpack.security.http.ssl:
  enabled: true
  keystore.path: /opt/module/elasticsearch-8.1.0/config/certs/http.p12
  truststore.path: /opt/module/elasticsearch-8.1.0/config/certs/http.p12
xpack.security.transport.ssl:
  enabled: true
  verification_mode: certificate
  keystore.path: /opt/module/elasticsearch-8.1.0/config/certs/elastic-certificates.p12
  truststore.path: /opt/module/elasticsearch-8.1.0/config/certs/elastic-certificates.p12
# 集群初始化的主节点
cluster.initial_master_nodes: ["es-node-1"]
http.host: [_local_, _site_]
ingest.geoip.downloader.enabled: false
xpack.security.http.ssl.client_authentication: none

7.配置其他服务器节点

其余节点的配置文件只需要修改node.name和network.host即可。

注意:

如果es是从第一台服务器节点上使用rsync/scp拷贝过去的。先删除data和logs文件、重新创建再启动es、否则会出现找不到其他服务器节点问题、如果同第一个节点一样是解压安装的忽略。

服务器节点2:

Elasticsearch--01.ES8.1.0集群搭建_大数据

服务器节点3:

Elasticsearch--01.ES8.1.0集群搭建_elastic_02

8.启动ES服务器

#bin/elasticsearch

第一次启动会显示密码、最好保存后、免得后面忘记、

忘记密码:bin/elasticsearch-reset-password -u elastic 重置登录es的密码

#bin/elasticsearch -d  (依次启动三台服务器、-d是后台启动)

这里如果不进行密码重置或者修改的话,三台机器登录的账号是共享密码的

#tail  -f   logs/cluster-es.log (查看es日志)

网页访问查看es集群信息:(带*的是主节点)

https://linux001:9200/_cat/nodes?v

Elasticsearch--01.ES8.1.0集群搭建_elastic_03

举报

相关推荐

0 条评论