微慑信息网

linux ubuntu下elasticsearch集群详细配置+wordpres+elasticPress使用配置

最近有需求,所以决定把之前运行的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

然后会提示输入密码,输入即可:

linux ubuntu下elasticsearch集群详细配置+wordpres+elasticPress使用配置
elasticsearch-certutil cert --ca elastic-stack-ca.p12

然后会提示输入密码,输入即可:

linux ubuntu下elasticsearch集群详细配置+wordpres+elasticPress使用配置

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

linux ubuntu下elasticsearch集群详细配置+wordpres+elasticPress使用配置

需要拷贝至config/目录下

linux ubuntu下elasticsearch集群详细配置+wordpres+elasticPress使用配置

写入elasticsearch-keystore (很关键)

elasticsearch-keystore add xpack.security.transport.ssl.keystore.secure_password
elasticsearch-keystore add xpack.security.transport.ssl.truststore.secure_password
linux ubuntu下elasticsearch集群详细配置+wordpres+elasticPress使用配置
elasticsearch-keystore add xpack.security.http.ssl.keystore.secure_password
linux ubuntu下elasticsearch集群详细配置+wordpres+elasticPress使用配置

4、设置elasticsearch密码

linux ubuntu下elasticsearch集群详细配置+wordpres+elasticPress使用配置

需要先运行es

./elasticsearch

等运行OK后,然后

./elasticsearch-setup-passwords interactive
linux ubuntu下elasticsearch集群详细配置+wordpres+elasticPress使用配置

三、从节点

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
linux ubuntu下elasticsearch集群详细配置+wordpres+elasticPress使用配置

五、问题处理

(1)设置密码(证书缺失):

linux ubuntu下elasticsearch集群详细配置+wordpres+elasticPress使用配置

解决:

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)设置密码

linux ubuntu下elasticsearch集群详细配置+wordpres+elasticPress使用配置

解决:先运行./elasticsearch

(3)权限:

linux ubuntu下elasticsearch集群详细配置+wordpres+elasticPress使用配置

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

linux ubuntu下elasticsearch集群详细配置+wordpres+elasticPress使用配置

(4)文件清理:

如果要清理节点数据,一定要使用rm -rf * 来处理/data/目录下的文件,因为有隐藏文件/文件夹 ,只使用rm *.*不行;

六、wordpress+elasticpress

为了配合elastic8 ,安装elasticpress5.3.2.2;配置Elasticsearch主机 URL:

linux ubuntu下elasticsearch集群详细配置+wordpres+elasticPress使用配置

如:http://elastic:密码@127.0.0.1:12001/即可

然后可以愉快地sync了:

linux ubuntu下elasticsearch集群详细配置+wordpres+elasticPress使用配置
linux ubuntu下elasticsearch集群详细配置+wordpres+elasticPress使用配置

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

linux ubuntu下elasticsearch集群详细配置+wordpres+elasticPress使用配置

视图化:

linux ubuntu下elasticsearch集群详细配置+wordpres+elasticPress使用配置
linux ubuntu下elasticsearch集群详细配置+wordpres+elasticPress使用配置

七、测试效果

运行:

linux ubuntu下elasticsearch集群详细配置+wordpres+elasticPress使用配置

八、其他杂项可参考

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

赞(0) 打赏
转载请附本站链接,未经允许不得转载,,谢谢:微慑信息网-VulSee.com » linux ubuntu下elasticsearch集群详细配置+wordpres+elasticPress使用配置

微慑信息网 专注工匠精神

微慑信息网-VulSee.com-关注前沿安全态势,聚合网络安全漏洞信息,分享安全文档案例

访问我们联系我们

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续提供更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫

微信扫一扫

登录

找回密码

注册