=======================================================================================
分別部署在不同的服務器上。 創建多台Elasticearch節點的目的是存放數據的多個副本,在實際生產環境中,節點的數量可能更多,及Logstash.Elasticsearch和kibana集中部署在node1節點上,也可以采用分布式部署,即logstash/Elasticserach
============================================================================================
操作系統IP 地址主機名 角色
CentSO7.5x86_64 192.168.200.113 linux-node1.example.com
CentSO7.5x86_64 192.168.200.114 linux-node2.example.com
添加新磁盤用於存放日志,兩台都操作
[root@linux-node2 ~]# systemctl stop firewalld
[root@linux-node2 ~]# iptables -F
[root@linux-node2 ~]# setenforce 0
[root@linux-node1 ~]# hostname
linux-node1.example.com
[root@linux-node1 ~]# cat /etc/hosts
192.168.200.111 linux-node1 linux-node1.example.com
192.168.200.112 linux-node2 linux-node2.example.com
格式化磁盤,不分區都可以兩台都操作
[root@linux-node1 ~]# mkfs.xfs /dev/sdb
[root@linux-node1 ~]# blkid
/dev/sdb: UUID="51e03a92-6b53-4427-829a-800d00dfa7a2" TYPE="xfs"
[root@linux-node1 ~]# mkdir /elk
[root@linux-node1 ~]# cat /etc/fstab
/dev/mapper/centos-root / xfs defaults 0 0 UUID=d6156ca9-c851-4e32-9ad3-1bf57130a7f7 /boot xfs defaults 0 0 /dev/mapper/centos-swap swap swap defaults 0 0 UUID="51e03a92-6b53-4427-829a-800d00dfa7a2" /elk xfs defaults 0 0
[root@linux-node1 ~]# mount -a
[root@linux-node1 ~]# ls
elasticsearch-5.5.0.rpm jdk-8u221-linux-x64.rpm
[root@linux-node1 ~]# yum install *.rpm -y #最好是單個解壓
node2主機配置文件操作:
[root@linux-node2 ~]# vim /etc/elasticsearch/elasticsearch.yml
17:cluster.name: elk-cluster1 #集群名----》用於elasticsearch架設間通信,node1和node2必須一致
23:node.name: elk-node2 #節點名(主機名)
33 :path.data: /elk/data #數據存放位置
37 :path.logs: /elk/logs #日志存放位置
55: network.host: 192.168.200.112 #綁定ip,0.0.0.0代表所有地址,此處寫node2ip是為了只讓內網訪問,自己寫可以改0.0.0.0
59: http.port: 9200 #監聽的9200端口
68 :discovery.zen.ping.unicast.hosts: ["192.168.200.111", "192.168.200.112"] #組播地址改ip安全
[root@linux-node2 ~]# systemctl start elasticsearch #這里報錯因為elk沒有權限,導致/elk下沒有數據生成
[root@linux-node2 ~]# ps -ef | grep java
root 10384 7815 0 17:27 pts/0 00:00:00 grep --color=auto java
[root@linux-node2 ~]# ll /elk/
總用量 0
[root@linux-node2 ~]# ll -d /elk/
drwxr-xr-x. 2 root root 6 3月 22 16:19 /elk/
[root@linux-node2 ~]# chown elasticsearch.elasticsearch /elk/ #設置權限
[root@linux-node2 ~]# ll /elk/logs/
總用量 4
-rw-r--r--. 1 elasticsearch elasticsearch 0 3月 22 17:46 elk-cluster1_deprecation.log
-rw-r--r--. 1 elasticsearch elasticsearch 0 3月 22 17:46 elk-cluster1_index_indexing_slowlog.log
-rw-r--r--. 1 elasticsearch elasticsearch 0 3月 22 17:46 elk-cluster1_index_search_slowlog.log
-rw-r--r--. 1 elasticsearch elasticsearch 1448 3月 22 17:46 elk-cluster1.log
查看端口:
[root@linux-node2 ~]# ss -tnl
LISTEN 0 128 ::ffff:192.168.200.112:9200 :::*
LISTEN 0 128 ::ffff:192.168.200.112:9300 :::*
查看節點輸出情況
[root@linux-node2 ~]# scp /etc/elasticsearch/elasticsearch.yml root@192.168.200.111:/etc/elasticsearch/elasticsearch.yml
node1主機配置文件操作
[root@linux-node1 ~]# vim /etc/elasticsearch/elasticsearch.yml
cluster.name: elk-cluster1 node.name: elk-node1 path.data: /elk/data path.logs: /elk/logs network.host: 192.168.200.111 http.port: 9200 discovery.zen.ping.unicast.hosts: ["192.168.200.111", "192.168.200.112"]
[root@linux-node1 ~]# chown elasticsearch.elasticsearch /elk/ #給/elk目錄elasticsearch權限
[root@linux-node1 ~]# systemctl start elasticsearch
[root@linux-node1 ~]# cd /usr/local/src/
[root@linux-node1 src]# rz
z waiting to receive.**B0100000023be50
[root@linux-node1 src]# ls
elasticsearch-head.tar.gz
[root@linux-node1 src]# tar xf elasticsearch-head.tar.gz
[root@linux-node1 src]# ls
elasticsearch-head elasticsearch-head.tar.gz
[root@linux-node1 src]# cd elasticsearch-head/
[root@linux-node1 elasticsearch-head]# ll node_modules/grunt #啟動文件目錄
總用量 24
drwxr-xr-x. 2 500 root 19 4月 6 2016 bin
-rw-r--r--. 1 500 root 7111 4月 6 2016 CHANGELOG
drwxr-xr-x. 4 500 root 47 7月 27 2017 lib
-rw-r--r--. 1 500 root 1592 3月 23 2016 LICENSE
drwxr-xr-x. 19 500 root 4096 7月 27 2017 node_modules
-rw-r--r--. 1 root root 3102 7月 27 2017 package.json
-rw-r--r--. 1 500 root 878 2月 12 2016 README.md
[root@linux-node1 elasticsearch-head]# yum install nmp -y