环境准备,防火墙&selinux
[root@localhost ~]#systemctl stop firewalld
[root@localhost ~]#systemctl disable firewalld
[root@localhost ~]#sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
[root@localhost ~]#setenforce 0
##修改系统环境该变量,修改完需要重启才能生效!!
[root@localhost ~]#echo 'vm.max_map_count=262144' >> /etc/sysctl.conf
##允许打开的最大文件描述
[root@localhost ~]#echo '
* soft memlock unlimited
* hard memlock unlimited
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
' >> /etc/security/limits.conf
[root@localhost ~]#ulimit -n 65535
[root@localhost ~]#sysctl -p
安装jdk
[root@localhost ~]#yum install -y java-1.8.0-openjdk
[root@localhost ~]#useradd es
[root@localhost ~]#passwd es
安装es
安装es
[root@localhost ~]#wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.6.2.tar.gz
##没外网手动下载包上传
[root@localhost ~]#tar -axf elasticsearch-6.6.2.tar.gz -C /opt/
[root@localhost ~]#chown -R es:es /opt/elasticsearch-6.6.2/
[root@localhost ~]#cd /opt/elasticsearch-6.6.2/
#修改JVM分配大小 3G这两个值要一致
[root@localhost ~]#vim ./config/jvm.options
修改配置文件,添加参数
[root@localhost ~]#echo 'cluster.name: my-es
node.name: es002
node.master: true
node.data:true
network.host: 152.215.131.172
http.port: 9200
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: ["es002", "es003",”es004”]
discovery.zen.minimum_master_nodes: 2
http.cors.enabled: true
http.cors.allow-origin: "*"
' >> /opt/elasticsearch-6.6.2/config/elasticsearch.yml
修改本地解析hosts
[root@localhost ~]# echo '152.215.131.172 my-es_es002
152.215.131.173 my-es_es003
152.215.131.174 my-es_es004'>> /ets/hosts
以es用户启动服务
[root@localhost ~]#su - es -c "sh /opt/elasticsearch-6.6.2/bin/elasticsearch &> /home/es/run.txt &"
检测集群状态
[root@localhost ~]#curl http://152.215.131.172:9200/_cluster/health?pretty
安装head插件
安装kibana
###安装kibana
[root@localhost ~]#wget https://artifacts.elastic.co/downloads/kibana/kibana-6.6.2-linux-x86_64.tar.gz
[root@localhost ~]#tar -axf kibana-6.6.2-linux-x86_64.tar.gz -C /opt
[root@localhost ~]#vim /opt/kibana-6.6.2-linux-x86_64/config/kibana.yml
修改三个字段
server.port: 5601 #服务端口
server.host: “0.0.0.0” #监听地址
elasticsearch.hosts: [“http://152.215.131.172:9200”] #es地址
##启动命令
[root@localhost ~]#nohup /opt/kibana-6.6.2-linux-x86_64/bin/kibana > /tmp/kibana.log 2>&1 &
Kibana访问地址:http://152.215.131.171:5601
检查es集群以及kibana状态是否正常