内容简介:Zabbix 4.0.2是一个长期支持版本(LTS),至少提供 5 年的技术支持;下面简单看一下更具时效的监控项值检查(Checking item value immediately)
一、概述
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 zabbix@localhost identified by 'zabbix2018'; grant all privileges on zabbix.* to zabbix@"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
7、安装elasticsearch-head插件
因为head是一个用于管理Elasticsearch的web前端插件,该插件在es5版本以后采用独立服务的形式进行安装使用(之前的版本可以直接在es安装目录中直接安装),因为需要安装nodejs、npm yum -y install nodejs npm git clone https://github.com/mobz/elasticsearch-head.git cd elasticsearch-head/ npm install
修改Gruntfile.js文件,修改服务监听地址(增加hostname属性,将其值设置为*)
vim Gruntfile.js
修改head/_site/app.js,修改head连接es的地址(修改localhost为本机的IP地址)
vim _site/app.js
启动插件(后台启动方式) cd /app/elasticsearch-head/node_modules/grunt/bin nohup ./grunt server & exit 启动成功后,可在浏览器访问插件与ES进行交互 http://172.16.8.76:9100/
8、Kibana安装及配置
tar -xvf kibana-6.5.1-linux-x86_64.tar.gz -C ../ mv kibana-6.5.1-linux-x86_64/ kibana6.5 chown -R zabbix.zabbix kibana6.5 grep -n ^[a-Z] /app/kibana6.5/config/kibana.yml 2:server.port: 5601 7:server.host: "0.0.0.0" 28:elasticsearch.url: "http://172.16.8.78:9200"
直接访问URLhttp://172.16.8.78:5601
四、Zabbix_server配置支持Elasticsearch
1、Zabbix_server配置文件
vim /app/zabbix4/etc/zabbix_server.conf HistoryStorageURL=http://172.16.8.76:9200 HistoryStorageTypes=uint,dbl,str,log,text /etc/init.d/zabbix_server restart
2、修改配置文件vim conf/zabbix.conf.php
- 如果不同类型使用不同的ES集群,可以按如下进行配置
$HISTORY['url'] = [
'uint' => ' http://localhost1:9200 ',
'text' => ' http://localhost2:9200 '
];
$HISTORY['types'] = ['uint', 'text']; - 所有类型使用相同ES集群
$HISTORY['url'] = ' http://172.16.8.76:9200 ';
$HISTORY['types'] = ['str', 'text', 'log', 'uint', 'dbl'];
以上所述就是小编给大家介绍的《ZABBIX4.0.2监控历史数据存放Elasticsearch及集群高可用方案》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Web Development Recipes
Brian P. Hogan、Chris Warren、Mike Weber、Chris Johnson、Aaron Godin / Pragmatic Bookshelf / 2012-1-22 / USD 35.00
You'll see a full spectrum of cutting-edge web development techniques, from UI and eye candy recipes to solutions for data analysis, testing, and web hosting. Make buttons and content stand out with s......一起来看看 《Web Development Recipes》 这本书的介绍吧!