搭建准备
官网地址:https://www.elastic.co/guide/en/elasticsearch/reference/8.0/security-basic-setup.html#encrypt-internode-communication
社区地址:https://discuss.elastic.co/t/elasticsearch-linux-startup-failed-procedure/298799
下载地址:https://www.elastic.co/kr/downloads/elasticsearch
本文安装版本为:8.13.4
下载后先解压。修改config文件 ,根据各自的情况进行修改,注意对应目录需要授权,且需要新建一个linux用户,新建用户的以及授权的命令自行百度。这一点一定要做,es的限制
# 集群名称
cluster.name: my-application
# 节点名称,三台不能一样
node.name: node-1
# 节点角色定义,Elasticsearch 8.x 推荐使用这种方式
node.roles: [ master, data ]
# 数据存储路径
path.data: /app/elasticsearch-8.13.4/data
# 日志存储路径
path.logs: /app/elasticsearch-8.13.4/logs
# 监听地址
network.host: 0.0.0.0
# HTTP端口
http.port: 9200
# 节点间通信端口在8.x版本中通常通过transport层自动配置,不需要显式设置
# transport.port: 9300 # 这一行在8.x版本中通常不再需要
# 启用传输压缩(如果支持且需要)
# transport.compress: true # 这个设置在较新版本中可能不再支持,根据需要调整
# 节点发现,填写对应节点IP地址
discovery.seed_hosts: ["192.168.14.5:9300","192.168.14.7:9300","192.168.14.8:9300"]
# 初始主节点列表
cluster.initial_master_nodes: ["node-1","node-2","node-3"]
# SSL/TLS配置
xpack.security.http.ssl:
enabled: false
# keystore相关配置根据你的证书实际情况进行调整
# keystore.path: certs/http.p12
xpack.security.transport.ssl:
enabled: true
verification_mode: certificate
# keystore和truststore相关配置根据你的证书实际情况进行调整
keystore.path: /app/elasticsearch-8.13.4/config/elastic-certificates.p12
truststore.path: /app/elasticsearch-8.13.4/config/elastic-certificates.p12
#keystore.secure_password: ${xpack.security.transport.ssl.keystore.secure_password}
#truststore.secure_password: ${xpack.security.transport.ssl.truststore.secure_password}
# 允许跨域资源共享(如果需要)
# http.cors.enabled: true
# http.cors.allow-origin: "*"
# 监听所有网络接口(注意安全风险)
http.host: 0.0.0.0
SSL/TLS配置
es提供了证书的生成配置方式 在bin目录使用这个生产证书,得到

elastic-certificates.p12和elastic-stack-ca.p12。配置文件配置elastic-certificates.p12 就行。
密钥库创建
在bin目录中使用./elasticsearch-keystore create
创建密码库
./elasticsearch-keystore add xpack.security.http.ssl.keystore.secure_password
./elasticsearch-keystore add xpack.security.http.ssl.truststore.secure_password
./elasticsearch-keystore add xpack.security.transport.ssl.keystore.secure_password
./elasticsearch-keystore add xpack.security.transport.ssl.truststore.secure_password
打开linux的限制
vi /etc/security/limits.conf
在文件最后添加
* soft nofile 65535
* hard nofile 65535
这里,* 表示对所有用户有效。soft 是警告级别的限制,而 hard 是最大限制。nofile 表示文件描述符的数量。
增加虚拟内存的限制
vi /etc/sysctl.conf
vm.max_map_count=262144
sudo sysctl -p 使改动生效
启动es
进入bin目录执行
./elasticsearch -d 可以启动成功。
如果做成了服务用下面的命令也行,自行去研究
sudo systemctl restart elasticsearch.service
1846

被折叠的 条评论
为什么被折叠?



