注:由于是测试服务器给的配置只能保证服务能启而已,与生产环境不符

主机信息

主机配置:centos 7 4c 100g

es1 10.0.0.60 root 123456*
es2 10.0.0.61 root 123456*
es3 10.0.0.71 root 123456*

实施

1.上传包

elasticsearch-5.6.9.tar.gz

scp elasticsearch-5.6.9.tar.gz 10.0.0.60:/data
scp elasticsearch-5.6.9.tar.gz 10.0.0.61:/data
scp elasticsearch-5.6.9.tar.gz 10.0.0.71:/data

2.解压:

cd /data
tar xf elasticsearch-5.6.9.tar.gz 
mv elasticsearch-5.6.9 elasticsearch

3.编写启动脚本

cat /op_sh 
#!/bin/sh
#chkconfig: 2345 80 05
#description: elasticsearch
cd /data/elasticsearch/bin/ 
case "$1" in
start)
su elastic << !
  ./elasticsearch -d &
!
echo “elasticsearch startup”
;;
stop)
es_pid=`ps aux | grep elasticsearch | grep -v 'grep' | grep -v 'controller' | awk -F " " '{print $2}'`
kill -9 ${es_pid}
echo “elasticsearch stopped”
;;
restart)
es_pid=`ps aux | grep elasticsearch | grep -v 'grep' | grep -v 'controller' | awk -F " " '{print $2}'`
kill -9 ${es_pid}
echo "elasticsearch stopped"
su elastic << !
 ./elasticsearch -d &
!
echo “elasticsearch startup”
;;
*)
echo "start|stop|restart"
;;
esac
exit $?

4.创建启动es用户

groupadd elastic
useradd -g elastic elastic

5.目录授权

chown elastic. /data/elasticsearch -R

6.修改系统配置文件

vim /etc/sysctl.conf 
vm.max_map_count=655360
vm.swappiness=0

vim /etc/security/limits.conf #这个修改完之后最好重启一下系统
elastic soft nofile 65536
elastic hard nofile 65536
* soft memlock unlimited
* hard memlock unlimited

7.es配置文件

node.name和network.hos根据实际情况填写,配置文件也只是参考参考^_^

grep -Ev "^$|^[;#]" config/elasticsearch.yml
cluster.name: es01
node.name: master 
path.data: /data/elasticsearch/data 
path.logs: /data/elasticsearch/logs
bootstrap.memory_lock: true
node.master: true
network.host: 10.0.0.60
http.port: 9200
discovery.zen.ping.unicast.hosts: ["10.0.0.60", "10.0.0.61" , "10.0.0.71"]
discovery.zen.minimum_master_nodes: 2
http.max_initial_line_length: 1024k
http.max_header_size: 512kb
http.max_content_length: 500mb
thread_pool.search.queue_size: 5000
thread_pool.search.size: 512
indices.memory.index_buffer_size: 50%
indices.memory.min_index_buffer_size: 2048mb
indices.fielddata.cache.size: 30%
discovery.zen.fd.ping_timeout: 120s
discovery.zen.fd.ping_retries: 6
discovery.zen.fd.ping_interval: 30s

8.配置java环境

# tar zvxf jdk1.8.tar.gz -C /data
# mv /data/jdk1.8.0_171/ /data/jdk1.8

# vim /etc/profile.d/java.sh
export JAVA_HOME=/data/jdk1.8
export JRE_HOME=/data/jdk1.8/jre
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export CLASSPATH=./:$JAVA_HOME/lib:$JRE_HOME/lib

# source /etc/profile.d/java.sh
# java -version
# javac -version

启动:

/data/elasticsearch/op_sh start

查看日志:

tailf /data/elasticsearch/logs/es01.log

head插件

https://github.com/mobz/elasticsearch-head
cd elasticsearch-head
npm install
npm run start

而我用的是Cerebro插件^_^
页面展示效果图

Last modification:July 6, 2020
如果觉得我的文章对你有用,请随意赞赏