ELK日志分析系统部署

=======================================================================================


分别部署在不同的服务器上。
   创建多台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

原文地址:https://www.cnblogs.com/CMX_Shmily/p/11827023.html