概述
目录
基本操作
修改配置文件
拷贝配置文件到其他服务器
分别修改不同服务器elasticsearch.yml配置文件中节点的名字
设置开机自启
知识点扩展:
查找jdk默认安装路径
防火墙命令
修改用户密码
基本操作
#前提:配置java环境变量
#下载
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.3.0.tar.gz
#解压
tar -zxvf elasticsearch-6.3.0.tar.gz
#修改名称
mv elasticsearch-6.3.0 es630
#添加组
groupadd es_admin
#添加用户
useradd es_admin -g es_admin
#修改用户密码
echo 'es_admin' | passwd --stdin es_admin
#给用户提权限
chown -Rf es_admin:es_admin /usr/local/elk/es630
创建数据和日志目录
mkdir -pv /usr/local/elk/es630/data/{data1,data2,data3,logs}
#修改max_map_count
[root@localhost es630]# echo 'vm.max_map_count=655360' >> /etc/sysctl.conf
[root@localhost es630]# sysctl -p
vm.max_map_count = 655360
#内存问题
[root@localhost es630]# echo '* soft memlock unlimited' >> /etc/security/limits.conf
[root@localhost es630]# echo '* hard memlock unlimited' >> /etc/security/limits.conf
[root@localhost es630]# tail -2 /etc/security/limits.conf
* soft memlock unlimited
* hard memlock unlimited
修改文件描述符
echo '* soft nofile 65536' >> /etc/security/limits.conf
echo '* hard nofile 65536' >> /etc/security/limits.conf
然后重新登录终端
ulimit -n
65536
修改配置文件
cluster.name: elasticsearch
node.name: es_node1
node.master: true
node.data: true
path.data: /usr/local/elk/es630/data/data1,/usr/local/elk/es630/data/data2,/usr/local/elk/es630/data/data3
path.logs: /usr/local/elk/es630/data/logs
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: 10.211.55.7
network.tcp.no_delay: true
network.tcp.keep_alive: true
network.tcp.reuse_address: true
network.tcp.send_buffer_size: 64mb
network.tcp.receive_buffer_size: 64mb
transport.tcp.port: 9301
transport.tcp.compress: true
http.max_content_length: 100mb
http.enabled: true
#解决跨域问题
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-methods: OPTIONS, HEAD, GET, POST, PUT, DELETE
http.cors.allow-headers: "X-Requested-With, Content-Type, Content-Length, X-User"
http.port: 9201
discovery.zen.minimum_master_nodes: 2
discovery.zen.fd.ping_timeout: 150s
discovery.zen.fd.ping_retries: 6
discovery.zen.fd.ping_interval: 15s
cluster.routing.allocation.cluster_concurrent_rebalance: 16
cluster.routing.allocation.node_concurrent_recoveries: 16
cluster.routing.allocation.node_initial_primaries_recoveries: 16
拷贝配置文件到其他服务器
scp -r /usr/local/elk/es630/config/elasticsearch.yml root@192.168.22.167:/usr/local/elk/es630/config/
scp -r /usr/local/elk/es630/config/elasticsearch.yml root@192.168.22.166:/usr/local/elk/es630/config/
分别修改不同服务器elasticsearch.yml配置文件中节点的名字
node.name: es_node2
node.name: es_node3
设置开机自启
执行vi /etc/init.d/elasticsearch 命令 ,根据自己电脑进行配置,注意用户,jdk路径,以及es安装路径
#!/bin/sh
#chkconfig: 2345 80 05
#description: elasticsearch
#author: jason
export JAVA_HOME=/usr/java/jdk1.8.0_191-amd64/
export JAVA_BIN=/usr/java/jdk1.8.0_191-amd64/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 es_admin<<!
cd /usr/local/elk/es630
./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 es_admin<<!
cd /usr/local/elk/es630
./bin/elasticsearch -d
!
echo "elasticsearch startup"
;;
*)
echo "start|stop|restart"
;;
esac
exit $?
#修改文件权限
sudo chmod +x /etc/init.d/elasticsearch
#添加开机自启
sudo chkconfig --add /etc/init.d/elasticsearch
#切换到es_admin用户,定位es安装路径的bin目录,后台启动
./elasticsearch -d
#查看是否启动成功
ps aux|grep elasticsearch
#查看节点
curl -XGET 'http://192.168.22.165:9201/_cat/nodes?v'
知识点扩展:
查找jdk默认安装路径
[root@localhost ~]# java -version
java version "1.7.0_51"
OpenJDK Runtime Environment (rhel-2.4.5.5.el7-x86_64 u51-b31)
OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)
[root@localhost ~]# which java
/usr/bin/java
[root@localhost ~]# ls -lrt /usr/bin/java
lrwxrwxrwx. 1 root root 22 9月 6 22:51 /usr/bin/java -> /etc/alternatives/java
[root@localhost ~]# ls -lrt /etc/alternatives/java
lrwxrwxrwx. 1 root root 72 9月 6 22:51 /etc/alternatives/java -> /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.51-2.4.5.5.el7.x86_64/jre/bin/java
防火墙命令
查看防火墙状态: systemctl status firewalld.service
执行关闭命令: systemctl stop firewalld.service
启动防火墙:systemctl start firewalld.service
执行开机禁用防火墙自启命令 : systemctl disable firewalld.service
修改用户密码
sudo passwd user_name
然后连续两次输入新的用户密码即可;
最后
以上就是端庄可乐为你收集整理的Centos7 搭建elasticsearch6.3.0集群的全部内容,希望文章能够帮你解决Centos7 搭建elasticsearch6.3.0集群所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复