赞
踩
elasticsearch-7.8.1
为例。
cd /root/install
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.8.1-linux-x86_64.tar.gz
tar -zxvf elasticsearch-7.8.1-linux-x86_64.tar.gz
使用root用户登录,新建elasticsearch用户。
useradd elasticsearch
passwd elasticsearch
chown -R elasticsearch:elasticsearch /root/install/elasticsearch-7.8.1
vi /opt/elasticsearch-7.8.1/config/elasticsearch.yml
###############################################################
cluster.name: elasticsearch #集群名
node.name: node-1 #节点名称
path.data: /opt/data/es/data #数据存储路径
path.logs: /opt/data/es/logs #日志存储路径
network.host: 0.0.0.0 #本机IP,可以写0.0.0.0
http.port: 9200 #访问端口
discovery.seed_hosts: ["127.0.0.1"] #通信地址
cluster.initial_master_nodes: ["node-1"] #master节点名称
http.cors.enabled: true #是否支持跨域,默认为false
http.cors.allow-origin: "*" #当设置允许跨域,默认为*,表示支持所有域名
###############################################################
# 切换用户
su - elasticsearch
# 启动ES
sh /root/install/elasticsearch-7.8.1/bin/elasticsearch
vi /etc/init.d/elasticsearch
#!/bin/bash
#
#chkconfig: 345 63 37
#description: elasticsearch
#processname: elasticsearch-7.8.1
ES_HOME=/root/install/elasticsearch-7.8.1
case $1 in
start)
su - elasticsearch -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
chmod 777 /etc/init.d/elasticsearch
chkconfig --add elasticsearch #设置开机启动
chkconfig --del elasticsearch #删除开机启动
chkconfig elasticsearch on #打开开机启动
chkconfig elasticsearch off #关闭开机启动
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。