在CentOS 7上配置Elasticsearch开启自启动需要通过systemd服务管理器来实现。
1. 安装Elasticsearch
首先,确保你已经安装了Elasticsearch。如果还没有安装,可以按照以下步骤进行安装:
# Import the Elasticsearch PGP key
sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch# Create a new repository file
echo '[elasticsearch-7.x]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md' | sudo tee /etc/yum.repos.d/elasticsearch.repo# Install Elasticsearch
sudo yum install elasticsearch
2. 配置Elasticsearch
在编辑配置文件之前,建议备份原配置文件:
sudo cp /etc/elasticsearch/