弹性搜索引擎Elasticsearch:本地部署与远程访问指南
# 安装Elasticsearch
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
sudo apt-get install apt-transport-https
echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list
sudo apt-get update && sudo apt-get install elasticsearch
# 启动Elasticsearch服务
sudo systemctl start elasticsearch.service
# 设置Elasticsearch开机自启
sudo systemctl enable elasticsearch.service
# 配置Elasticsearch以允许远程访问
sed -i 's/#network.host: 192.168.0.1/network.host: 0.0.0.0/' /etc/elasticsearch/elasticsearch.yml
# 重启Elasticsearch服务以应用配置更改
sudo systemctl restart elasticsearch.service
这段代码展示了如何在Ubuntu系统上安装Elasticsearch,并配置其服务以允许远程访问。首先,我们下载Elasticsearch的GPG密钥,并添加到apt-key中。然后,我们添加Elasticsearch的APT仓库,并更新本地包列表。接下来,我们安装Elasticsearch。最后,我们修改配置文件以设置network.host
为0.0.0.0
,这允许Elasticsearch监听所有接口上的请求,从而允许远程访问。最后,我们重启Elasticsearch服务以应用这些更改。
评论已关闭