架构图
- 考虑到日志系统的可扩展性以及目前的资源(部分功能复用),整个ELK架构如下:
架构解读 : (整个架构从左到右,总共分为5层)
第一层、数据采集层
最左边的是业务服务器集群,上面安装了filebeat做日志采集,同时把采集的日志分别发送给两个logstash服务(2.187、2.189)
第二层、数据处理层,数据缓存层
logstash服务把接受到的日志经过格式处理,转存到本地的kafka broker+zookeeper 集群中。
第三层、数据转发层
这个单独的Logstash(2.184)节点会实时去kafka broker集群拉数据,转发至ES DataNode。
第四层、数据持久化存储
ES DataNode 会把收到的数据,写磁盘,建索引库。
第五层、数据检索,数据展示
ES Master + Kibana 主要 协调 ES集群,处理数据检索请求,数据展示。
服务器资源以及软件版本
- 操作系统:centos7.2、虚拟机
- 服务器角色(研究环境)
192.168.2.184 | elastic、kafka、 logstash-out-from-kafka zookeeper | |
192.168.2.187 | elastic、kafka、logstash-in-to-kafka、zookeeper | |
192.168.2.189 | elastic、kafka、logstash-in-to-kafka、zookeeper、kibana | |
主机ip |
部署服务 |
服务器配置 |
---|
- 群星日志系统服务器角色(测试环境)
主机ip |
部署服务 |
服务器配置 |
---|---|---|
192.168.2.130 | ExceptionLess | |
192.168.2.131 | kafka、 logstash-out-from-kafka zookeeper | opskafka.manjinba.cn |
192.168.2.132 | kafka、logstash-in-to-kafka、zookeeper | opskafka.manjinba.cn |
192.168.2.133 | kafka、logstash-in-to-kafka、zookeeper | opskafka.manjinba.cn |
192.168.2.135 | elastic | opselastic.manjinba.cn |
192.168.2.136 | elastic | opselastic.manjinba.cn |
192.168.2.138 | kibana | kibana.manjinba.cn |
软件版本:
jdk-8u151-linux-x64
elasticsearch-5.2.2 wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.2.2.tar.gz
kafka_2.10-0.10.2.0 wget http://mirror.bit.edu.cn/apache/kafka/0.10.2.0/kafka_2.10-0.10.2.0.tgz
kafka-manager wget https://github.com/yahoo/kafka-manager/archive/master.zip
kibana-5.2.2-linux-x86_64 wget https://artifacts.elastic.co/downloads/kibana/kibana-5.2.2-linux-x86_64.tar.gz
logstash-5.2.2 wget https://artifacts.elastic.co/downloads/logstash/logstash-5.2.2.tar.gz
zookeeper-3.4.9 wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.9/zookeeper-3.4.9.tar.gz
filebeat-5.2.2 wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-5.2.2-linux-x86_64.tar.gz
安装部署
- 系统优化
cat /etc/sysctl.conf
net.ipv4.tcp_max_syn_backlog = 4096
net.core.netdev_max_backlog = 2048
net.ipv4.tcp_fin_timeout = 15
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_syncookies = 1
vm.max_map_count= 262144 #后期配置ES很关键
vm.swappiness = 1
cat /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
- 配置java环境
cd /apps/svr
tar zxvf jdk-8u151-linux-x64.tar.gz
ln -s jdk1.8.0_151 jdk
cat >> /etc/profile <<EOF
export JAVA_HOME=/apps/svr/jdk
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib/tools.jar
EOF
source /etc/profile
- 用户问题
为了方便这里所有的应用全部都在apps帐号下
useradd apps && echo "Qwer1234" | passwd --stdin apps - python升级以及安装supervisor
cat update_python.sh
#!/bin/bash
#creat by xiaojs
if
[ whoami !=
‘root‘
]
then
exit 1
fi
if
[[ python -c
"import platform ;print platform.python_version()"
= 2.7.* ]]
then
echo
‘you need not do everything‘
exit 0
else
echo
‘============================‘
echo
‘=======start update========‘
fi
# get the tar
cd /usr/local/src
wget http:
//ops.bubugao-inc.com/python/Python-2.7.8.tgz
wget http:
//ops.bubugao-inc.com/python/pyinotify.tar.gz
wget http:
//ops.bubugao-inc.com/python/MySQL-python-1.2.4.zip
##
yum -y install git gcc mysql mysql-devel
#install
tar zxvf Python-2.7.8.tgz
cd Python-2.7.8
./configure --prefix=/usr/local/python2.7.8
make && make install
mv /usr/bin/python /usr/bin/python_old
ln -s /usr/local/python2.7.8/bin/python /usr/bin/
sed -i
‘s/python/python_old/1‘
/usr/bin/yum
#intall the plugin
cd ..
tar zxvf pyinotify.tar.gz
cd pyinotify
python setup.py install
cd ..
unzip MySQL-python-1.2.4.zip
cd MySQL-python-1.2.4
python setup.py install
####install supervisor
cd /usr/local/src
wget --no-check-certificate https:
//bootstrap.pypa.io/ez_setup.py -O - | sudo python
wget http:
//pypi.python.org/packages/source/d/distribute/distribute-0.6.10.tar.gz
tar xf distribute-0.6.10.tar.gz
cd distribute-0.6.10
python setup.py install
easy_install supervisor
cd /usr/local/python2.7.8/bin/
cp supervisord supervisorctl echo_supervisord_conf /usr/bin/
mkdir /etc/supervisor && cd /etc/supervisor
wget http:
//ops.bubugao-inc.com/python/supervisord.conf
- 安装elasticsearch
cd /apps/svr/
tar zxvf elasticsearch-5.2.2.tar.gz
ln -s elasticsearch-5.2.2 elasticsearch
[[email protected] elasticsearch]# sed -n /^[^#]/p config/elasticsearch.yml
cluster.name: SuperApp
node.name: manjinba01
network.host: 0.0.0.0
http.port: 9200
discovery.zen.ping.unicast.hosts: [
"192.168.2.184:9300"
,
"192.168.2.187:9300"
,
"192.168.2.189:9300"
]
discovery.zen.minimum_master_nodes: 1
bootstrap.system_call_filter:
false
bootstrap.memory_lock:
false
http.cors.enabled:
true
http.cors.allow-origin:
"*"
启动elasticsearch
chown -R apps.apps /apps
su - apps
cd /apps/svr/elasticsearch
bin/elasticsearch -d
- 另外两台类似,后续会安装x-pack,所以以前的head和bigdesk不用安装
- zookeeper+kafka集群部署
#zookeeper
cd /apps/svr
tar zxvf zookeeper-3.4.9.tar.gz
ln -s zookeeper-3.4.9 zookeeper
mkdir -p /apps/dbdat/zookeeper
[[email protected] zookeeper]# sed -n ‘/^[^#]/p’ conf/zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/apps/dbdat/zookeeper
clientPort=2181
server.1=192.168.2.184:12888:13888
server.2=192.168.2.187:12888:13888
server.3=192.168.2.189:12888:13888
#三台服务器分别赋值
echo 1 > /apps/dbdat/zookeeper/myid
echo 2 > /apps/dbdat/zookeeper/myid
echo 3 > /apps/dbdat/zookeeper/myid
#启动并查看状态
/apps/svr/zookeeper/bin/zkServer.sh start
/apps/svr/zookeeper/bin/zkServer.sh status
[[email protected] zookeeper]# /apps/svr/zookeeper/bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /apps/svr/zookeeper/bin/../conf/zoo.cfg
Mode: follower
#以上信息就是没问题
#kafka集群
|
#不同的节点,注意broker.id和linsten的ip
|
logstash的部署和配置
cd /apps/svr
tar zxvf logstash-5.2.2.tar.gz
ln -s logstash-5.2.2/ logstash
#安装都一样,重点是两端配置文件不一样,一个是负责写入kafka,一个是负责从kafka提取出来写入elasticsearch,配置分别如下:
[[email protected] ~]# cat /apps/conf/logstash/logstash-in-kafka.conf
|
|
启动logstash
192.168.2.184
nohup /apps/svr/logstash/bin/logstash
-f /apps/conf/logstash/logstash-kafka.conf &
192.168.2.187/192.168.2.189
nohup /apps/svr/logstash/bin/logstash
-f /apps/conf/logstash/logstash-in-kafka.conf &
应用服务器的filebeat的配置
|
kibana页面配置
|
启动kibana
nohup bin/kibana &
#对应的nginx的配置如下
|
}
#至此,整个框架已经完成,可以先建立kafka的topic测试,然后观察elasticsearch的索引是否建立成功,或简单的从页面观察即可
- 插件和其他相关
1、由于上述大部分应用都是跑在后台,有时候进程是否挂掉,不得而知,监控如果对于每个进程监控略显麻烦,而且不方便启动,所以这里用supervisor进行统一管理,上述已经有安装记录,具体的配置就不做展示了
2、 x-pack的安装
/apps/svr/kibana/bin/kibana-plugin install x-pack
原文地址:https://www.cnblogs.com/larry-luo/p/11133395.html