注意:es、logstash、kibana版本必须保持一致,这里用的8.2.2
chown wsb /usr/soft/elasticsearch -R
手动启动
不能使用root账户,
进入解压位置的bin目录:
./elasticsearch &
开机自启动
1.进入init.d目录
cd /etc/init.d
2.创建服务文件
vim elasticsearch
3.编写脚本
#!/bin/bash
#chkconfig: 2345 63 37
#description: elasticsearch system service
#processname: elasticsearch-8.2.2
export ES_HOME=/usr/local/elasticsearch-8.2.2
case $1 in
start)
su - es -c "$ES_HOME/bin/elasticsearch -d -p pid"
echo "elasticsearch is started"
;;
stop)
pid=`cat $ES_HOME/pid`
kill -9 $pid
echo "elasticsearch is stopped"
;;
restart)
pid=`cat $ES_HOME/pid`
kill -9 $pid
echo "elasticsearch is stopped"
sleep 1
su - es -c "$ES_HOME/bin/elasticsearch -d -p pid"
echo "elasticsearch is started"
;;
*)
echo "start|stop|restart"
;;
esac
exit 0
4.修改文件权限:
chmod 777 elasticsearch
5.添加或删除服务
添加:
chkconfig --add elasticsearch
删除:
chkconfig --del elasticsearch
6.启动、停止或重启服务
启动:
service elasticsearch start
停止:
service elasticsearch stop
重启:
service elasticsearch restart
7.设置开启或关闭开机启动
开启:
chkconfig elasticsearch on
关闭:
chkconfig elasticsearch off
8.查看es进程,验证是否已启动
ps -ef | grep elasticsearch
http://ip:9200/
文章评论