一、安装jdk 1.7和jdk 1.8
cd /usr/local/software
sftp上传两个版本的jdk到目录下。
#解压jdk7
tar -zxvf jdk-7u80-linux-x64.tar.gz
#解压jdk8
tar -zxvf jdk-8u151-linux-x64.tar.gz
#修改jdk文件夹名称
mv jdk1.7.0_80 jdk7
=====1、为了满足Elasticsearch对于jdk1.8的要求,我们需要在centos中安装两个版本的jdk========================================================================
#修改jdk8文件夹名称
mv jdk1.8.0_151 jdk8
cd /usr/local
mkdir jvm
将jdk7和jdk8移动到jvm目录下
mv /usr/local/software/jdk7 jvm/
mv /usr/local/software/jdk8 jvm/
#在jvm目录下执行
vi /usr/local/jvm/jdk_toggle.sh
#!/bin/bash
#声明jdk7和jdk路径变量
JAVA_7_HOME=/usr/local/jvm/jdk7
JAVA_8_HOME=/usr/local/jvm/jdk8
#执行脚本传入的值进行判断。默认是jdk8
case $1 in
jdk7)
export JAVA_HOME=$JAVA_7_HOME
;;
jdk8)
export JAVA_HOME=$JAVA_8_HOME
;;
*)
export JAVA_HOME=$JAVA_8_HOME
;;
esac
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
#在jvm目录下
cd /usr/local/jvm
#切换到jdk7
source jdk_toggle.sh jdk7
#切换到jdk8
source /usr/local/jvm/jdk_toggle.sh jdk8
测试结果
java -version
====2、开始安装====================================================================================
# 假设我们已经将es6拷贝上传到这里了
cd /usr/local/software
yum install unzip -y
unzip elasticsearch-6.1.1.zip
cd elasticsearch-6.1.1/
#添加用户
adduser elasticsearch
#给用户赋值
echo elasticsearch | passwd --stdin elasticsearch
# 给权限
chown -R elasticsearch /usr/local/software/elasticsearch-6.1.1
# 以elasticsearch用户身份运行程序,而且是后台运行
su elasticsearch -l -c "source /usr/local/jvm/jdk_toggle.sh jdk8 && /usr/local/software/elasticsearch-6.1.1/bin/elasticsearch -d"
# 停止的办法
ps -ef | grep elasticsearch |awk ‘{print $2}‘|xargs kill -9
=====================================================================================================
3、安装中文分词插件
cd /usr/local/software
/usr/local/software/elasticsearch-6.1.1/bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.1.1/elasticsearch-analysis-ik-6.1.1.zip
然后需要重启一下elasticsearch-6.1.1
# 新增记录
curl -X PUT ‘localhost:9200/accounts/person/1‘ -H ‘Content-Type: application/json‘ -d ‘
# 简易使用
http://www.ruanyifeng.com/blog/2017/08/elasticsearch.html
文中提到的文件下载地址:链接:https://pan.baidu.com/s/1nw2lXhv 密码:9nez
4、为了让其它机器也能访问的到此服务,需要:
vi /usr/local/software/elasticsearch-6.1.1/config/elasticsearch.yml
配置:
network.host: 0.0.0.0
保存,重启服务!