centos7下RPM安装elasticSearch7.0.1

基于centos7 x64安装elasticSearch7.0.1
相关环境:

centos7 x64
jdk1.8,elastic依赖于jdk,官方解说最低版本1.8
elastic RPM安装包

step1:卸载centos7自带的jdk,默认是1.8版本,但是这里保险起见我选择卸载并重新安装

rpm -qa | grep java     #命令来查询出系统自带的jdk
rpm -e --nodeps xxx   #(xxx是具体的java相关的文件名,使用该命令删除所有java相关内容)
java -version               #确认是否已经全部移除系统自带的jdk

step2:安装jdk
1、官网下载1.8版本64位jdk,如图


64位jdk8

2、将下载的jdk文件上传到系统目录,我的目录是:/opt/java8
3、解压安装

tar -zxvf jdk-8u131-linux-x64.tar.gz
cd jdk1.8.0_131/
解压成功,配置java环境变量
vim /etc/profile
在末尾增加如下内容
export JAVA_HOME=/opt/java8/jdk1.8.0_131   #这里是jdk解压目录,根据自己的环境修改
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
保存配置,并刷新
source /etc/profile
java -version #查看环境变量
![jdk环境变量配置成功](https://upload-images.jianshu.io/upload_images/11383238-9568711c8818e114.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

step3、安装elasticSearch7
1、在elastic官网下载新版本RPM安装包


elastic RPM安装包

2、将RPM安装包上传到 /opt/elastic7
3、执行安装

sudo rpm --install elasticsearch-7.1.0-x86_64.rpm
配置elastic随系统启动:sudo chkconfig --add elasticsearch
启动命令:sudo -i service elasticsearch start
停止命令:sudo -i service elasticsearch stop
查看运行状态:sudo -i service elasticsearch status
--------------------------------或者如下命令--------------------------------
配置elastic随系统启动:
sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable elasticsearch.service
启动命令:sudo systemctl start elasticsearch.service
停止命令:sudo systemctl stopelasticsearch.service
查看运行状态:sudo systemctl status elasticsearch.service
--------------------------------检测是否安装成功--------------------------------
curl -X GET "localhost:9200/"
返回如下信息标识安装成功
{
  "name" : "Cp8oag6",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "AT69_T_DTp-1qgIJlatQqA",
  "version" : {
    "number" : "7.1.0",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "f27399d",
    "build_date" : "2016-03-30T09:51:41.449Z",
    "build_snapshot" : false,
    "lucene_version" : "8.0.0",
    "minimum_wire_compatibility_version" : "1.2.3",
    "minimum_index_compatibility_version" : "1.2.3"
  },
  "tagline" : "You Know, for Search"
}

安装后elastic启动配置文件在:/etc/elasticsearch/elasticsearch.yml
安装后elastic日志输出在:/var/log/elasticsearch/elasticsearch.log
官网在指导安装后有这一步提示,没太明白,但是我操作了,如下
vim /etc/elasticsearch/elasticsearch.yml 
#增加如下内容
action.auto_create_index: .monitoring*,.watches,.triggered_watches,.watcher-history*,.ml*

step4:修改配置,开通外网访问
1、修改配置文件elasticsearch.yml

node.name: node-1   #取消该注释
network.host: 192.168.136.110  #192.168.0.1改为自己elastic服务器地址
cluster.initial_master_nodes: ["node-1"]   #这里一定要这样设置

#在最后加上这两句,这样浏览器就可以访问了
http.cors.enabled: true
http.cors.allow-origin: "*"

2、修改系统配置

vim etc/sysctl.conf 
#增加如下配置
vm.max_map_count=655360
sysctl -p
#重启elastic
sudo systemctl restart elasticsearch.service

3、测试配置否是成功
浏览器访问:http://ip:port

配置成功

PS:
1、参考自elastic官网,https://www.elastic.co/guide/en/elasticsearch/reference/current/rpm.html#install-rpm
2、安装后修改配置文件浏览器访问不到,参考博客解决,https://blog.csdn.net/lidew521/article/details/88091539