安装依赖包
yum install gcc libxml2-devel net-snmp net-snmp-devel curl curl-devel php php-bcmath php-mbstring mariadb mariadb-devel mariadb-server libevent-devel java* -y
准备数据库
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@"192.168.37.%" identified by '123456';
编译安装
useradd zabbix -s /sbin/nologin
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --enable-java
make && make install
导入数据库
mysql -uzabbix -p123456 -h192.168.37.101 zabbix < database/mysql/schema.sql
mysql -uzabbix -p123456 -h192.168.37.101 zabbix < database/mysql/images.sql
mysql -uzabbix -p123456 -h192.168.37.101 zabbix < database/mysql/data.sql
复制启动脚本
cp ./misc/init.d/fedora/core/zabbix_server /etc/init.d/
cp ./misc/init.d/fedora/core/zabbix_agentd /etc/init.d/
分别修改两个启动脚本
vim /etc/init.d/zabbix_server
vim /etc/init.d/zabbix_agentd
21 # Zabbix-Directory
22 BASEDIR=/usr/local/zabbix
修改配置文件
mkdir /var/log/zabbix && chown zabbix.zabbix /var/log/zabbix -R
LogFile=/var/log/zabbix/zabbix_server.log
DBHost=192.168.10.103
DBName=zabbix
DBUser=zabbix
DBPassword=123456
DBPort=3306
Timeout=30
LogSlowQueries=3000
启动
/usr/local/zabbix/sbin/zabbix_server -c /usr/local/zabbix/etc/zabbix_server.conf
Zabbix Server systemd启动脚本
cat /usr/lib/systemd/system/zabbix-server.service
[Unit]
Description=Zabbix Server
After=syslog.target
After=network.target
[Service]
Environment="CONFFILE=/usr/local/zabbix/etc/zabbix_server.conf" EnvironmentFile=-/etc/sysconfig/zabbix-server
Type=forking
Restart=on-failure
PIDFile=/usr/local/zabbix/zabbix_server.pid
KillMode=control-group
ExecStart=/usr/local/zabbix/sbin/zabbix_server -c $CONFFILE
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s
TimeoutSec=0
[Install]
WantedBy=multi-user.target
# systemctl daemon-reload && systemctl start zabbix-server && systemctl enable zabbix-server
Zabbix Agent systemd启动脚本
[Unit]
Description=Zabbix Agent
After=syslog.target
After=network.target
[Service]
Environment="CONFFILE=/usr/local/zabbix/etc/zabbix_agentd.conf" EnvironmentFile=-/etc/sysconfig/zabbix-agent
Type=forking
Restart=on-failure
PIDFile=/usr/local/zabbix/zabbix_agentd.pid
KillMode=control-group
ExecStart=/usr/local/zabbix/sbin/zabbix_agentd -c $CONFFILE
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s
[Install]
WantedBy=multi-user.target
# systemctl daemon-reload && systemctl start zabbix-agent && systemctl enable zabbix-agent
配置web界面
yum install httpd -y
mkdir /var/www/html/zabbix
cp -a ./frontends/php/* /var/www/html/zabbix
systemctl restart httpd
安装系统所需依赖
yum install php-gettext php-session php-ctype php-xmlreader php-xmlwriter php-xml php-net-socket php-gd php-mysql php-ldap
如下更改vim /etc/php.ini
post_max_size = 8M 改为 post_max_size = 16M
max_execution_time = 30 改为 max_execution_time = 300
max_input_time = 60 改为 max_input_time = 300
;date.timezone = 改为 date.timezone = Asia/Shanghai
systemctl restart httpd
访问http://ip/zabbix 按提示操作
配置完成后用户名是Admin,密码是zabbix
可以在程序中设置中文/zabbix/profile.php
中文乱码是因为字体不正确
将字体*.ttf上传到
/var/www/html/zabbix/assets/fonts
修改php程序代码
vim /var/www/html/zabbix/include/defines.inc.php
define('ZBX_GRAPH_FONT_NAME', 'msyh'); // 文件名称
被监控端
yum -y install pcre* gcc
编译安装zabbix-agent
./configure --prefix=/apps/zabbix-agent --enable-agent make && make install
修改配置文件
vim /apps/zabbix-agent/etc/zabbix_agentd.conf
Server=192.168.37.101
Hostname=192.168.37.102
AllowRoot=1
User=root
启动服务
/apps/zabbix-agent/sbin/zabbix_agentd
配置tomcat,nginx,memcached,redis监控模板及主机监控项过程省略
管理-配置-报警媒介类型
用户-报警媒介,
配置-动作-创建动作和操作
系统会根据监控主机的监控项配置的触发器发送邮件