CentOS上安装 ElasticSearch 详解

CentOS上安装 ElasticSearch参考官方文档:Install Elasticsearch with RPM

ElasticSearch依赖Java,所以需要先安装Java:

到Oracle官网找到下载链接

http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

wget http://download.oracle.com/otn-pub/java/jdk/8u112-b15/jdk-8u112-linux-x64.rpm?AuthParam=1480402865_ac614d1fc3f20dfc6e7d8a525f7f4190

下载完成后:

rpm -ivh jdk-8u112-linux-x64.rpm\?AuthParam\=1480402865_ac614d1fc3f20dfc6e7d8a525f7f4190

开始安装ES,先下载公钥:

rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch

添加源:

cd yum.repos.d/
vi elasticsearch.repo

编辑elasticsearch.repo:

[elasticsearch-5.x]
name=Elasticsearch repository for 5.x packages
baseurl=https://artifacts.elastic.co/packages/5.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md

安装:

yum install elasticsearch

也可以手动下载安装:

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.0.2.rpm
sha1sum elasticsearch-5.0.2.rpm 
sudo rpm --install elasticsearch-5.0.2.rpm

不过这里会报错,官网坑我,直接用浏览器打开地址:

CentOS上安装 ElasticSearch 详解

后来改上面的安装方法发现官网提供是是5.0.1的包,所以把这里的5.0.2改成5.0.1即可。

安装完后启动服务:

systemctl start elasticsearch.service

查看运行状态:

curl http://localhost:9200

CentOS上安装 ElasticSearch 详解

安装成功。接下来要开放端口:

firewall-cmd --zone=public --add-port=9200/tcp --permanent
firewall-cmd --reload

可以开始测试了,如果需要在Windows上测试,还需要改下配置,ES默认绑定了本地地址

cd /etc/elasticsearch/
vi elasticsearch.yml

修改network.host节点:

network.host: 192.168.1.10

这里可以使用IP,也可以使用:

_[networkInterface]_

Addresses of a network interface, for example _en0_.

_local_

Any loopback addresses on the system, for example 127.0.0.1.

_site_

Any site-local addresses on the system, for example 192.168.0.1.

_global_

Any globally-scoped addresses on the system, for example 8.8.8.8.

这里我使用网卡,使用ip addr 可以查看:

CentOS上安装 ElasticSearch 详解

这里使用无线网卡:wlp3s0

也就是:

network.host: _wlp3s0_

保存后重启,在Windows打开http://10.255.20.44:9200/即可访问:

CentOS上安装 ElasticSearch 详解 

ElasticSearch 的详细介绍:请点这里
ElasticSearch 的下载地址:请点这里 

相关推荐