新版已经支持免java方式安装, 参考文档 传送门
依赖安装:java
Elasticsearch基于java开发,先要安装java环境,推荐yum命令安装
查看java可下载列表(官网推荐使用jdk 1.8.0安装)
yum -y list java*
Elasticsearch requires at least Java 8. Specifically as of this writing, it is recommended that you use the Oracle JDK version 1.8.0_131
我们安装-devel版本,时间不同,版本号有区别
yum install -y java-1.8.0-openjdk-devel.x86_64
输入
java -version
查看是否安装成功默认安装在/usr/lib/jvm目录,通过
echo $JAVA_HOME
可以查看将java添加到环境变量
vi /etc/profile
,在尾部添加如下配置:export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181-3.b13.el6_10.x86_64 export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=$PATH:$JAVA_HOME/bin
按Esc按键,然后输入
:wq
命令保存文件,输入以下命令使配置生效source /etc/profile
安装Elasticsearch
下载Elasticsearch的rpm安装包(一包解万坑),可以在https://www.elastic.co/cn/downloads/elasticsearch 查看,下载最新的rmp包
wget -c https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.2.0-x86_64.rpm
执行安装
rpm -ivh elasticsearch-7.2.0-x86_64.rpm
运行,这里不需要切换用户运行,因为elasticsearch的服务命令会完成这一切
sudo systemctl daemon-reload sudo systemctl start elasticsearch.service
查看是否成功
curl -XGET 'http://localhost:9200/'
{
"name" : "localhost.localdomain",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "izX7KuQATc2ghCjDbEYwYg",
"version" : {
"number" : "7.2.0",
"build_flavor" : "default",
"build_type" : "rpm",
"build_hash" : "508c38a",
"build_date" : "2019-06-20T15:54:18.811730Z",
"build_snapshot" : false,
"lucene_version" : "8.0.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
- 设置开机启动
sudo systemctl daemon-reload
sudo systemctl enable elasticsearch.service
- 停止开机启动
sudo systemctl disable elasticsearch.service