- 下载安装包,解压
- 进入config,修改配置文件
vim elasticsearch.yml
cluster.name: my_cluster ????????#ES集群名称
node.name: linux_node-1 ? ???? #节点名称
path.data: /usr/local/apps/elasticsearch/data ?#数据存储的目录(多个目录使用逗号分隔)
path.logs: /var/log/elasticsearch ?????#日志保存位置
network.host: 10.0.0.206 ??????????#设置本机IP地址,写内网地址无法访问
http.port: 9200 ???????????????????#端口默认9200
discovery.zen.ping.unicast.host?
s: ["10.0.0.207", "10.0.0.208","10.0.0.209"]
cluster.initial_master_nodes: ["linux_node-1"] #与节点node.name对应
#bootstrap.memory_lock: true ????????????#锁住es内存,保证内存不分配至交换分区,实验中打开启动失败 - 设置内存
cd /usr/local/apps/elasticsearch/bin
vim elasticsearch
ES_JAVA_OPTS="-Xms512m -Xmx512m"
(配置es内置jdk)
export JAVA_HOME=/usr/local/apps/elasticsearch/elasticsearch-7.9.0/jdk
export PATH=$JAVA_HOME:$PATH/bin - Linux 文件数设置
[1]:max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536] 意思是elasticsearch可以创建的文件描述的个数太少
vim /etc/security/limits.conf
elasticsearch soft nofile 65536
elasticsearch hard nofile 65535
elasticsearch soft nproc 4096
elasticsearch hard nproc 4096
* 代表针对所有用户,noproc 是代表最大进程数,nofile 是代表最大文件打开数,使用ulimit -n查看 [2]:max number of threads [3790] for user elasticsearch is too low, increase to at least [4096] ???意思是:用户线创建的线程数太少
vim /etc/sysctl.conf ?
增加配置值: vm.max_map_count=655360
执行命令 sysctl -p ? - 启动用户:
添加新用户组和用户,让非root 用户组用户启动:
groupadd elasticsearch
Useradd -g elasticsearch elasticsearch
然后把我们的es 所在文件夹的 用户指定为 elasticsearch?
chown -R elasticsearch: elasticsearch /usr/local/apps/elasticsearch 6. 启动elasticsearch su - elasticsearch
在bin 目录下
./elasticsearch -d ??????#-d后台启动
? ? ? ? 7. 查看elasticsearch节点状态?
# curl http://10.0.0.206:9200
?????????8. 设置开机自启
#!/bin/sh
#chkconfig: 2345 80 05
#description: elasticsearch
export JAVA_HOME=/usr/local/apps/java/jdk1.8
export JAVA_BIN=/usr/local/apps/java/jdk1.8/bin
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME JAVA_BIN PATH CLASSPATH
case "$1" in
start)
su elasticsearch<<!
cd /usr/local/apps/elasticsearch/elasticsearch-7.9.0
./bin/elasticsearch -d
!
echo "elasticsearch startup"
;;
stop)
es_pid=`ps aux|grep elasticsearch | grep -v 'grep elasticsearch' | awk '{print $2}'`
kill -9 $es_pid
echo "elasticsearch stopped"
;;
restart)
es_pid=`ps aux|grep elasticsearch | grep -v 'grep elasticsearch' | awk '{print $2}'`
kill -9 $es_pid
echo "elasticsearch stopped"
su elasticsearch<<!
cd /usr/lcoal/apps/elasticsearch/elasticsearch-7.9.0
./bin/elasticsearch -d
!
echo "elasticsearch startup"
;;
*)
echo "start|stop|restart"
;;
esac
exit $?
|