在Linux上安装部署Elasticsearch,可以遵循以下步骤:
- 导入Elasticsearch公钥:
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
- 添加Elasticsearch到APT源列表:
echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list
- 更新APT包索引:
sudo apt-get update
- 安装Elasticsearch:
sudo apt-get install elasticsearch
- 启动Elasticsearch服务:
sudo systemctl start elasticsearch.service
- 设置Elasticsearch开机自启:
sudo systemctl enable elasticsearch.service
- 验证Elasticsearch是否正在运行:
curl -X GET "localhost:9200/"
以上步骤适用于基于Debian的系统,如Ubuntu。对于基于RPM的系统,如CentOS,步骤类似,但是使用yum
代替apt-get
。记得替换Elasticsearch的版本号以适应你的需求。