在CentOS 7上安装和配置Elasticsearch的方法
#!/bin/bash
# 更新系统包
sudo yum update -y
# 导入Elasticsearch公钥
sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
# 添加Elasticsearch到yum仓库
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
# 安装Elasticsearch
sudo yum install -y elasticsearch
# 启动Elasticsearch服务并设置开机自启
sudo systemctl start elasticsearch
sudo systemctl enable elasticsearch
# 验证Elasticsearch是否正在运行
curl -X GET "localhost:9200/"
这段脚本首先更新了系统的包信息,然后导入了Elasticsearch的公钥,并将其添加到yum仓库。接着,它安装了Elasticsearch,启动了服务,并设置了开机自启。最后,使用curl命令验证Elasticsearch是否正常运行。
评论已关闭