一、概述
Zabbix 4.0.2是一个长期支持版本(LTS),至少提供 5 年的技术支持;
下面简单看一下Zabbix 4.0.2 新特征
更具时效的监控项值检查(Checking item value immediately)
新的 HTTP 监控项类型(New HTTP item type)
监控项原型可以依赖于常规的监控项(Item prototypes can depend on regular items)
更灵活的主动式 Agent 自动注册(More flexible active agent auto-registration)
支持 MySQL 8.0(MySQL 8.0 supported)
Elasticsearch 配置基于日期的索引(Date-based indices setup for Elasticsearch)
1、环境准备
172.16.8.76 qas-zabbix-node01
172.16.8.77 vip地址
172.16.8.78 qas-zabbix-node02
2、OS及软件版本
CentOS Linux release 7.5.1804 (Core)
zabbix-4.0.2.tar.gz
mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
jdk-8u181-linux-x64.tar.gz
elasticsearch-6.5.1.tar.gz
kibana-6.5.1-linux-x86_64.tar.gz
3、架构图
二、mysql数据安装(分别在node1、node2安装)
mysql安装请参考相关链接:
Centos7.5安装mysql5.7.24二进制包方式部署
三、Zabbix安装及配置(分别在node1、node2安装)
1、下载源码包
相关链接
zabbix官网:https://www.zabbix.com/
zabbix下载:https://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/4.0.2/zabbix-4.0.2.tar.gz/download
2、 YUM安装PHP环境及所需要依赖包
yum -y install gcc* make php php-gd php-mysql php-bcmath php-mbstring php-xml curl curl-devel net-snmp net-snmp-devel perl-DBI httpd mysql-devel libxml2-devel curl-devel unixODBC-devel net-snmp-devel OpenIPMI-devel openldap openldap-devel php-ldap libevent-devel
3、创建zabbix用户及安装目录
groupadd zabbix
useradd -g zabbix zabbix
mkdir -pv /app/zabbix4
4、zabbix软件解压及安装
tar -xvf zabbix-4.0.2.tar.gz
cd zabbix-4.0.2
./configure --prefix=/app/zabbix4 --enable-server --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --with-openipmi --with-unixodbc
make && make install
5、Mysql数据库创建及导入基础数据
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to [email protected] identified by ‘zabbix2018‘;
grant all privileges on zabbix.* to [email protected]"172.16.8.%" identified by ‘zabbix2018‘;
FLUSH PRIVILEGES;
导入数据库
cd /app/tools/zabbix-4.0.2/database/mysql/
mysql -uzabbix -pzabbix2018 zabbix < schema.sql
mysql -uzabbix -pzabbix2018 zabbix < images.sql
mysql -uzabbix -pzabbix2018 zabbix < data.sql
6、修改PHP的配置参数
vim /etc/php.ini
date.timezone= Asia/Shanghai
max_execution_time = 300
post_max_size = 32M
memory_limit = 128M
mbstring.func_overload = 1
max_input_time = 300
7、拷贝zabbix数据到httpd目录并授权
cd /app/tools/zabbix-4.0.2/
cp -r frontends/php/ /var/www/html/zabbix
ll /var/www/html/
chown -R apache.apache /var/www/html/zabbix/
8、修改配置文件zabbix_server.conf
创建相关目录
mkdir /app/zabbix4/{tmp,logs,alertscripts,externalscripts} -p
chown -R zabbix.zabbix /app/zabbix4
修配置文件如下:
# grep -n ^[a-Z] /app/zabbix4/etc/zabbix_server.conf
38:LogFile=/app/zabbix4/logs/zabbix_server.log
68:PidFile=/app/zabbix4/tmp/zabbix_server.pid
94:DBName=zabbix
110:DBUser=zabbix
118:DBPassword=zabbix2018
125:DBSocket=/tmp/mysql.sock
465:Timeout=4
506:AlertScriptsPath=/app/zabbix4/alertscripts
515:ExternalScripts=/app/zabbix4/externalscripts
551:LogSlowQueries=3000
9、拷贝zabbix服务启动脚本
cd /app/tools/zabbix-4.0.2/
cp misc/init.d/fedora/core/zabbix_server /etc/init.d/
vim /etc/init.d/zabbix_server
BASEDIR=/app/zabbix4
10、启动服务及设置开机启动
chkconfig --add zabbix_server
chkconfig zabbix_server on
systemctl enable httpd.service
systemctl start httpd.service
/etc/init.d/zabbix_server restart
11、web服务初始化
登陆默认用户名:Admin,密码:zabbix
三、Elasticsearch集群安装及配置
1、安装java
tar -xvf jdk-8u181-linux-x64.tar.gz -C ../
cd /app/
mv jdk1.8.0_181/ jdk
chown -R root.root jdk
编辑profile文件,添加jdk环境变量
vim /etc/profile
JAVA_HOME=//app/jdk/jdk1.8.0_181
CLASSPATH=$JAVA_HOME/lib/
PATH=$PATH:$JAVA_HOME/bin
export PATH JAVA_HOME CLASSPATH
2、elasticsearch解压及安装
tar -xvf elasticsearch-6.5.1.tar.gz -C ../
cd /app/
mv elasticsearch-6.5.1 elasticsearch6.5
chown -R zabbix.zabbix elasticsearch6.5
su - zabbix
mkdir -p /app/elasticsearch6.5/data
3、修改elasticsearch集群配置文件
su - zabbix
node01
mkdir -p /app/elasticsearch6.5/data
grep -n ^[a-Z] /app/elasticsearch6.5/config/elasticsearch.yml
17:cluster.name: app-zabbix
23:node.name: 172.16.8.76
33:path.data: /app/elasticsearch6.5/data
37:path.logs: /app/elasticsearch6.5/logs
43:bootstrap.memory_lock: true
55:network.host: 0.0.0.0
59:http.port: 9200
60:transport.tcp.port: 9300
69:discovery.zen.ping.unicast.hosts: ["172.16.8.76:9300", "172.16.8.78:9300"]
73:discovery.zen.minimum_master_nodes: 1
90:bootstrap.system_call_filter: false
91:http.cors.enabled: true
92:http.cors.allow-origin: "*"
node02
grep -n ^[a-Z] /app/elasticsearch6.5/config/elasticsearch.yml
17:cluster.name: app-zabbix
23:node.name: 172.16.8.78
33:path.data: /app/elasticsearch6.5/data
37:path.logs: /app/elasticsearch6.5/logs
43:bootstrap.memory_lock: true
55:network.host: 0.0.0.0
59:http.port: 9200
60:transport.tcp.port: 9300
69:discovery.zen.ping.unicast.hosts: ["172.16.8.76:9300", "172.16.8.78:9300"]
73:discovery.zen.minimum_master_nodes: 1
90:bootstrap.system_call_filter: false
91:http.cors.enabled: true
92:http.cors.allow-origin: "*"
4、编辑limits.conf配置文件
vim /etc/security/limits.conf
* soft nofile 65536
* hard nofile 131072
zabbix soft memlock unlimited
zabbix hard memlock unlimited
zabbix hard nproc 4096
zabbix soft nproc 4096
5、内核参数优化
vim /etc/sysctl.conf
vm.max_map_count=262144
vm.swappiness=1
用命令sysctl -p 生效
sysctl vm.max_map_count 查看值是否修改, 也可以通过sysctl -w vm.max_map_count=262144 临时设置值
6、启动elasticsearch 服务
```.
./elasticsearch -d
http://172.16.8.76:9200/
![](http://i2.51cto.com/images/blog/201812/01/e9a4db690ef8cb4e11acf4b170f0cfe9.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
http://172.16.8.78:9200/
![](http://i2.51cto.com/images/blog/201812/01/4de59091becd683df9724d610250e3cb.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
原文地址:http://blog.51cto.com/10880347/2324788
时间: 2024-10-07 09:54:52