Bootstrap

【centos7】rpm安装ES集群

概要

  本方案基于CentOS Linux release 7.6.1810 (Core)实践并编制,理论上兼容全部RHEL(红帽系)Red Hat Enterprise Linux (RHEL) 7系统及基于该发行版的衍生发行版。原生兼容Springboot2.7.x。方案采用rpm包三节点部署方式。

免责声明: 文档中全部IP仅为vmware虚拟机中绑定的ip。

安装步骤

准备三台机器。

操作步骤

三节点执行。

从官网下载获得

elasticsearch-7.17.20-x86_64.rpm (适配SpringBoot 2.7.3)

elasticsearch-analysis-ik-7.17.18.zip

rpm -ivh elasticsearch-7.17.20-x86_64.rpm

mkdir /usr/share/elasticsearch/plugins/ik

unzip elasticsearch-analysis-ik-7.17.18.zip -d /usr/share/elasticsearch/plugins/ik

rm -rf /var/lib/elasticsearch  默认安装后生成,未运行前为空目录

找个大的目录做一下软连接

mkdir /data/elasticsearch/

ln -s  /data/elasticsearch/  /var/lib/elasticsearch

chmod 777 -R /var/lib/elasticsearch

chmod 777 -R  /data/elasticsearch

vim /usr/share/elasticsearch/plugins/ik/plugin-descriptor.properties

修改

elasticsearch.version=7.17.20  原本7.17.18 修改20即可,兼容

主节点执行:

集群版修改方式:

vim /etc/elasticsearch/elasticsearch.yml (记得保存)

cluster.name: es-cluster

node.name: node-1

network.host: xxx.xxx.xxx.xxx   具体机器ip

discovery.seed_hosts: ["xxx.xxx.200.52", "xxx.xxx.201.52", "xxx.xxx.202.52"] 具体机器ip

xpack.security.enabled: true  开启认证

xpack.security.transport.ssl.enabled: true

xpack.security.transport.ssl.verification_mode: certificate

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

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

cluster.initial_master_nodes: ["node-1"] 集群初始化节点

systemctl start elasticsearch

开启节点间加密传输

/usr/share/elasticsearch/bin/elasticsearch-certutil ca

回车两次,集群间都在内网,可以不使用证书密码。

/usr/share/elasticsearch/bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12

回车三次

cp /usr/share/elasticsearch/elastic-certificates.p12 /etc/elasticsearch/

chmod 777 /etc/elasticsearch/elastic-certificates.p12

主节点向从节点发送数据

scp /etc/elasticsearch/elasticsearch.yml [email protected]:/etc/elasticsearch/

scp /etc/elasticsearch/elasticsearch.yml [email protected]:/etc/elasticsearch/

scp /etc/elasticsearch/elastic-certificates.p12 [email protected]:/etc/elasticsearch/

scp /etc/elasticsearch/elastic-certificates.p12 [email protected]:/etc/elasticsearch/

*******************仅主节点执行********************

创建用户

/usr/share/elasticsearch/bin/elasticsearch-setup-passwords interactive

y

重复 输入密码

systemctl enable elasticsearch.service

从节点执行

vim /etc/elasticsearch/elasticsearch.yml (记得保存)

修改node.name 为node-2和node-3

修改node.host为从节点实际的ip 如xxx.xxx.201.52

删除 cluster.initial_master_nodes

systemctl start elasticsearch

验证

浏览器访问
http://xxx.xxx.200.52:9200/_cat/nodes?v  换成具体ip

得到

同义词近义词配置

mkdir /etc/elasticsearch/analysis/

touch synonym.txt

备注: 这里xpack认证证书没有加密,如需加密,参考:

https://juejin.cn/post/7079955586330132487

其他参考文章:

Elasticesrch-7.17.7集群部署和配置 - zifuy 的个人博客

https://blog.51cto.com/u_14555/10608318

Elasticsearch 安装配置集群系统 - Song`s Blog

Elasticsearch v8.3.3使用rpm包安装集群_elasticsearch rpm包下载-CSDN博客

Elk7.17.2集群带xpack_rpm部署es7.17并配置xpack-CSDN博客

;