cento下安装elasticsearch6.1.1小记

1.首先需要安装好java,并配置好环境变量

本人网上查询资料,自己安装部署后整理的资料,第四部的是根据公司服务器配置的。
下载jdk
如果在官网下载比较慢,那么可以到我的云盘分享上,下载jdk 1.8.0的版本:
链接:https://pan.baidu.com/s/1H74LMI1OsmsWV0aiVhRQaQ
提取码:t9ir
https://www.elastic.co/downloads/elasticsearch
解压缩jdk安装包
#解压缩安装文件
tar -zxvf jdk-8-linux-x64.tar.gz

#把文件目录拷贝到/usr下
mv jdk1.8.0 /usr/java/jdk1.8.0
引入PATH以及JAVA_HOME环境变量
#编辑/etc/profile文件
vi /etc/profile

#在末尾添加下面两行
export JAVA_HOME=/usr/java/jdk1.8.0
export PATH= P A T H : PATH: PATH:JAVA_HOME/bin

#当前配置手动触发生效
source /etc/profile
编辑完后,你就可以看到JAVA_HOME的变量了
echo $JAVA_HOME
不过,还没有完哦!!
替换OpenJDK
上面的步骤完成,如果你执行java -version,就会发现版本还是不对。(如果没有问题,可以忽略这个步骤)
因为/usr/bin下的java其实是默认链接到openjdk的。因此:
#以root身份,进入/usr/bin目录
cd /usr/bin

#备份原有的链接
mv java java.bak
#创建新的链接
ln -s /usr/java/jdk1.8.0/bin/java java
#此时执行java -version就可以看到效果了
[root@localhost bin]# ll java
lrwxrwxrwx. 1 root root 27 Aug 16 10:15 java -> /usr/java/jdk1.8.0/bin/java
[root@localhost bin]# java -version
java version “1.8.0”
Java™ SE Runtime Environment (build 1.8.0-b132)
Java HotSpot™ 64-Bit Server VM (build 25.0-b70, mixed mode)

2.安装elastics

1.首先需要安装好java,并配置好环境变量
2.下载elasticsearch的zip包,地址:https://pan.baidu.com/s/1NfP_lmYLTb5GtGUcxjo-PQ
假设我们已经将es6拷贝上传到这里了
cd /usr/local

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/elasticsearch-6.1.1

#以elasticsearch用户身份运行程序,而且是后台运行
/usr/local/elasticsearch-6.1.1/bin/elasticsearch -d
查看安装情况
curl ‘http://localhost:9200/?pretty’
停止的办法
ps -ef | grep elasticsearch |awk ‘{print $2}‘|xargs kill -9

3、安装中文分词插件 ,

【es@node1 elasticsearch-6.1.1]$ cd /usr/local/elasticsearch-6.1.1
【es@node1 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
-> Downloading https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.1.1/elasticsearch-analysis-ik-6.1.1.zip
【es@node1 elasticsearch-6.1.1]$ bin/elasticsearch-plugin install https://github.com/NLPchina/elasticsearch-sql/releases/download/6.1.1.0/elasticsearch-sql-6.1.1.0.zip
查看安装的插件 curl http://localhost:9200/_cat/plugins

开启外网访问问题
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决方案
vi /etc/security/limits.conf
elasticsearch soft nofile 819200
elasticsearch hard nofile 819200
vi /etc/sysctl.conf
vm.max_map_count=655360
sysctl -p

4.内存分配设置,设置开机自启动

修改./bin/elasticsearch添加export ES_HEAP_SIZE=10g(一般是服务器内存一半)
用root账号在/etc/rc.d/init.d/
cd /etc/init.d/
vi es

#!/bin/sh
#chkconfig: 2345 80 05
#description: es

case $1 in
start)
#下面的“<<!”是切换用户后,待执行的命令,执行完后使用“!”来进行结束
su elasticsearch<<!
cd /usr/local/elasticsearch-6.1.1
./bin/elasticsearch -d
exit
!
#上面的“!”是以上面的对应起来,并且顶格放置,这是语法
echo “elasticsearch startup”
;;
stop)
#注意这个号“” es_pid=ps aux|grep elasticsearch | grep -v ‘grep elasticsearch’ | awk '{print $2}'kill -9 $es_pid echo "es stopup" #将该行替换成你自己的服务启动命令 ;; restart) #“grep -v”过滤掉本身的执行命令,获取准确的pid es_pid=ps aux|grep elasticsearch | grep -v ‘grep elasticsearch’ | awk ‘{print $2}’`
kill -9 $es_pid
echo “es stopup”
#将该行替换成你自己的服务启动命令
su elasticsearch<<!
cd /usr/local/elasticsearch-6.1.1
./bin/elasticsearch -d
!
#将该行替换成你自己的服务启动命令
echo “es startup”
;;
*)
#将该行替换成你自己的服务启动命令
echo “start|stop|restart”
;;
esac

授权执行 chmod +x es
chkconfig --add es
相关bug解决文档:
https://www.jianshu.com/p/fa31f38d241e

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值