centos安装ES
- https://www.elastic.co/cn/downloads/past-releases#elasticsearch 选择elasticsearch+版本 下载
tar -zxvf elasticsearch- mv elasticsearch-8.0.0 /usr/local/elasticsearch-8.0 cd /usr/local/elasticsearch-8.0/ mkdir data mkdir log cd config/vim elasticsearch.yml path.data: /usr/local/elasticsearch-8.0/data path.logs: /usr/local/elasticsearch-8.0/log `#开启xpack` xpack.security.enabled: false xpack.security.transport.ssl.enabled: false `#允许跨域` http.cors.enabled: true http.cors.allow-origin: "*" http.cors.allow-headers: Authorization,X-Requested-With,Content-Type,Content-Length- 在 /etc/systemd/system/ 目录中创建一个名为 elasticsearch.service 的文件
vim /etc/systemd/system/elasticsearch.service将以下内容复制进 'elasticsearch.service' 文件中:
[Unit]
Description=elasticsearch
After=network.target[Service]
Type=forking
User=es
ExecStart=/home/elasticsearch/bin/elasticsearch -d
PrivateTmp=true
# 进程可以打开的最大文件数
LimitNOFILE=65535
# 进程可以打开的最大进程数
LimitNPROC=65535
# 最大虚拟内存
LimitAS=infinity
# 最大文件大小
LimitFSIZE=infinity
# 超时设置 0-永不超时
TimeoutStopSec=0
# SIGTERM是停止java进程的信号
KillSignal=SIGTERM
# 信号只发送给给JVM
KillMode=process
# java进程不会被杀掉
SendSIGKILL=no
# 正常退出状态
SuccessExitStatus=143
# 开机自启动
[Install]
WantedBy=multi-user.target
重新加载服务的配置文件
systemctl daemon-reload注册启用服务:
systemctl enable elasticsearch使用以下命令来管理Elasticsearch服务:
systemctl start elasticsearch
systemctl stop elasticsearch- 需要切换到User=es来使用启动命令
systemctl restart elasticsearch
systemctl status elasticsearch