Linux Centos7下安装Elasticsearch
- 如果没有安装Java环境, 需要先安装。
通过
yum list java*
查看需要安装的java版本。
这里安装 java-1.8.0-openjdk。yum -y install java-1.8.0-openjdk
查看java版本是否安装成功。java -version
- 下载并安装GPG公共签名秘钥
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
- 添加 Elasticsearch 的 yum 仓库。
vim /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
- yum安装Elasticsearch.
yum install elasticsearch
- 配置Elasticsearch, 配置外网访问, 端口。
vim /etc/elasticsearch/elasticsearch.yml
如果这里不设置 cluster.initial_master_nodes
节点,会报错如下:
bootstrap check failure [1] of [1]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_host...be configured
Sep 16 15:52:03 VM_0_8_centos systemd-entrypoint[19004]: ERROR: Elasticsearch did not exit normally - check the logs at /var/log/elasticsearch/elasticsearch.log
- 配置完成后,启动Elasticsearch.
systemctl restart elasticsearch.service
- 查看Elasticsearch的状态。绿色代表已启动了。
systemctl status elasticsearch.service
- 测试ES能否请求。
curl localhost:9200
, 或者用 postman用外网ip请求试试。
{
"name": "node-1",
"cluster_name": "elasticsearch",
"cluster_uuid": "_na_",
"version": {
"number": "7.14.1",
"build_flavor": "default",
"build_type": "rpm",
"build_hash": "66b55ebfa59c92c15db3f69a335d500018b3331e",
"build_date": "2021-08-26T09:01:05.390870785Z",
"build_snapshot": false,
"lucene_version": "8.9.0",
"minimum_wire_compatibility_version": "6.8.0",
"minimum_index_compatibility_version": "6.0.0-beta1"
},
"tagline": "You Know, for Search"
}