centos7部署elastic
时间: 2023-08-06 08:09:16 浏览: 83
你可以按照以下步骤在CentOS 7上部署Elasticsearch:
1. 安装Java运行时环境(JRE):
```
sudo yum install java-1.8.0-openjdk
```
2. 导入Elasticsearch的GPG密钥:
```
sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
```
3. 添加Elasticsearch的YUM存储库:
```
sudo vi /etc/yum.repos.d/elasticsearch.repo
```
在编辑器中,添加以下内容:
```
[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
```
4. 安装Elasticsearch:
```
sudo yum install elasticsearch
```
5. 配置Elasticsearch:
打开 `/etc/elasticsearch/elasticsearch.yml` 文件进行编辑,配置以下参数:
```
cluster.name: my-cluster
node.name: my-node
network.host: 0.0.0.0
```
你可以根据需要对其他参数进行调整。
6. 启动并设置Elasticsearch服务开机自启动:
```
sudo systemctl start elasticsearch
sudo systemctl enable elasticsearch
```
7. 验证Elasticsearch是否正常运行:
```
curl -XGET http://localhost:9200
```
如果返回类似以下信息表示成功连接到Elasticsearch:
```
{
"name" : "my-node",
"cluster_name" : "my-cluster",
"cluster_uuid" : "xxxxxxxxxxxx",
"version" : {
"number" : "7.x.x",
...
},
...
}
```
现在,你已经成功在CentOS 7上部署了Elasticsearch。你可以根据需要进行进一步的配置和使用。
阅读全文