最近有需求,所以决定把之前运行的elasticsearch 71.10替换为8的版本。
准备工作:
一、下载:
1、elasticsearch 8
我选的8.13.3,据说比较稳定,且被elasticpress支持
地址:
https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.13.3-windows-x86_64.zip
https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.13.3-linux-x86_64.tar.gz
如果需要其他版本,可以直接修改链接中的版本号
2、Analysis-ik*中文分词插件
因为内容主要是中文,所以使用中文分词插件:
地址:https://get.infini.cloud/elasticsearch/analysis-ik/8.13.3
该插件版本需要与elasticsearch的版本一致。
二、主节点
1、添加用户,因为ES不能使用root运行,使用命令:
adduser espasswd es
2、YML文件配置
直接贴elasticsearch.yml吧先
主节点配置示例
xpack.security.enabled: truehttp.port: 12001cluster.name: elasticsearchnode.name: master-1 #节点名字network.host: 0.0.0.0或指定具体的 IP 地址transport.port: 9400 # 集群通信端口node.roles: ["master", "data"]
xpack.security.http.ssl.enabled: false #我是http访问;如果需要https访问,改为truexpack.security.http.ssl.keystore.path: "elastic-certificates.p12"xpack.security.transport.ssl.enabled: truexpack.security.transport.ssl.verification_mode: certificatexpack.security.transport.ssl.client_authentication: requiredxpack.security.transport.ssl.keystore.path: "elastic-certificates.p12"
xpack.security.transport.ssl.truststore.path: "elastic-certificates.p12"
cluster.initial_master_nodes: ["master-1"] #从节点无需配置该处discovery.seed_hosts: - 1.1.1.1 # 其他节点的 IP 地址
3、证书生成及密钥设置 :
elasticsearch-certutil ca
然后会提示输入密码,输入即可:

elasticsearch-certutil cert --ca elastic-stack-ca.p12
然后会提示输入密码,输入即可:

以上命令生成的文件直接在 /elasticsearch根目录,即便你是在/bin下执行的。

需要拷贝至config/目录下

写入elasticsearch-keystore (很关键)
elasticsearch-keystore add xpack.security.transport.ssl.keystore.secure_password
elasticsearch-keystore add xpack.security.transport.ssl.truststore.secure_password

elasticsearch-keystore add xpack.security.http.ssl.keystore.secure_password

4、设置elasticsearch密码

需要先运行es
./elasticsearch
等运行OK后,然后
./elasticsearch-setup-passwords interactive

三、从节点
1、从节点Yml文件配置:
cluster.name: elasticsearchnode.name: node-1← 改成你从节点的实际名字network.host: 0.0.0.0http.port: 120022可以和主节点一样,也可以改成其他端口(如 51291)transport.port: 9400node.roles: ["data"] # 纯数据节点(推荐)# 集群发现配置(必须指向主节点)discovery.seed_hosts: - 1.1.1.1:9400 # 主节点的 IP:transport端口
# 安全配置(和主节点保持一致)xpack.security.enabled: true
# Transport SSL(节点间通信,必须和主节点配置完全一致)xpack.security.transport.ssl.enabled: truexpack.security.transport.ssl.verification_mode: certificatexpack.security.transport.ssl.client_authentication: requiredxpack.security.transport.ssl.keystore.path: "elastic-certificates.p12"xpack.security.transport.ssl.truststore.path: "elastic-certificates.p12"
# HTTP SSL(客户端访问)xpack.security.http.ssl.enabled: false # 当前保持关闭,和主节点一致
2、证书:
需要拷贝主节点的证书文件elastic-certificates.p12;
并执行:
elasticsearch-keystore add xpack.security.transport.ssl.keystore.secure_passwordelasticsearch-keystore add xpack.security.transport.ssl.truststore.secure_passwordelasticsearch-keystore add xpack.security.http.ssl.keystore.secure_password
3、从节点无须再设置密码
四、插件安装
./bin/elasticsearch-plugin install https://get.infini.cloud/elasticsearch/analysis-ik/8.13.3

五、问题处理
(1)设置密码(证书缺失):

解决:
elasticsearch-keystore add xpack.security.transport.ssl.keystore.secure_passwordelasticsearch-keystore add xpack.security.transport.ssl.truststore.secure_passwordelasticsearch-keystore add xpack.security.http.ssl.keystore.secure_password
(2)设置密码

解决:先运行./elasticsearch
(3)权限:

elasticsearch.keystore文件的权限需要是es的系统用户的权限,且为660:

(4)文件清理:
如果要清理节点数据,一定要使用rm -rf * 来处理/data/目录下的文件,因为有隐藏文件/文件夹 ,只使用rm *.*不行;
六、wordpress+elasticpress
为了配合elastic8 ,安装elasticpress5.3.2.2;配置Elasticsearch主机 URL:

如:http://elastic:密码@127.0.0.1:12001/即可
然后可以愉快地sync了:


当然为了验证集群是否正常,可以使用浏览器插件Elasticvue:

视图化:


七、测试效果
运行:

八、其他杂项可参考
https://vulsee.com/archives/vulsee_2024/0825_17541.html
https://vulsee.com/archives/vulsee_2024/0815_17507.html
https://vulsee.com/archives/vulsee_2023/0517_16870.html
https://vulsee.com/archives/vulsee_2023/0516_16859.html
https://vulsee.com/archives/vulsee_2025/0915_17812.html



![[java]Error: Invalid or corrupt jarfile问题-微慑信息网-VulSee.com](http://vulsee.com/wp-content/uploads/2020/08/997.png)












![[八卦] 王婷婷—揭秘一个大三女生的性爱录像-微慑信息网-VulSee.com](http://free.86hy.com/crack/pic/1.jpg)
![[随笔]今天国际警察节-微慑信息网-VulSee.com](http://photo.sohu.com/20041017/Img222528326.jpg)

青云网
