示例搭建
环境
系统 |
IP |
软件 |
备注 |
centos7.6 |
无所谓 |
zabbix4.2 |
清华源&清华epel |
操作步骤
- 关闭selinux和iptables
]# sed -i 's/SELINUX=enforcing/SELINUX=disabled' /etc/selinux/config
]# setenforce 0
]# service iptables stop
- 搭建LAMP
~]# yum install -y httpd mariadb-server mariadb php php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mhash
~]# rpm -qa httpd php MariaDB-server
php-5.4.16-46.el7.x86_64
httpd-2.4.6-89.el7.centos.1.x86_64
MariaDB-server-10.3.18-1.el7.centos.x86_64
~]# vim /etc/httpd/conf/httpd.conf
95 ServerName 127.0.1.1:80
164 DirectoryIndex index.html index.php
~]# vim /etc/php.ini
878 date.timezone = PRC
~]# systemctl start mariadb
~]# systemctl enable mariadb
~]# systemctl status mariadb
~]# netstat -lntup|grep mysqld
~]# mysqladmin -u root password mariadb
~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or g.
Your MariaDB connection id is 1336
Server version: 10.3.18-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
MariaDB [(none)]>create database zabbix character set utf8 collate utf8_bin;
MariaDB [(none)]>GRANT all ON zabbix.* TO 'zabbix'@'%' IDENTIFIED BY 'zabbix';
MariaDB [(none)]> flush privileges;
- 搭建zabbix4.2
~]# yum -y install net-snmp net-snmp-devel curl curl-devel libxml2 libxml2-devel libevent-devel.x86_64 javacc.noarch javacc-javadoc.noarch javacc-maven-plugin.noarch javacc*
~]# yum -y install php-bcmath php-mbstring
~]# rpm -Uvh https://repo.zabbix.com/zabbix/4.2/rhel/7/x86_64/zabbix-release-4.2-2.el7.noarch.rp
~]# yum clean all
~]# yum -y install zabbix-server-mysql zabbix-web-mysql
~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p -h 192.168.xx.xx zabbix
| 导入数据库时报错:ERROR 1118 (42000): Row size too large (> 8126). Changing some columns to TEXT or BLOB may help. In current row format, BLOB prefix of 0 bytes is stored inline.
| 解决办法:vim /etc/my.inf innodb_strict_mode = OFF 原因是Server version: 10.3.18-MariaDB MariaDB Serverinnodb_strict_mode是默认开启严格检查模式。如果采用了页数据压缩功能后,最好是开启该功能。开启此功能后,当创建表(CREATE TABLE)、更改表(ALTER TABLE)和创建索引(CREATE INDEX)语句时,如果写法有错误,不会有警告信息,而是直接抛出错误,这样就可直接将问题扼杀在摇篮里
~]# vim /etc/zabbix/zabbix_server.conf
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
~]# vim /etc/httpd/conf.d/zabbix.conf
Alias /zabbix /usr/share/zabbix
<Directory "/usr/share/zabbix">
Options FollowSymLinks
AllowOverride None
Require all granted
<IfModule mod_php5.c>
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value max_input_vars 10000
php_value always_populate_raw_post_data -1
php_value date.timezone Asia/Shanghai
</IfModule>
</Directory>
~]# systemctl enable zabbix-server
~]# systemctl start zabbix-server
~]# systemctl enable httpd
~]# systemctl start httpd
- zabbix web 汉化
1.点击右上角 用户
2.语言 Chinese(zh_CN) --> 'update'
3.windows 10 win键+R
4.Control
5.找到 字体
6.黑体 常规 命名(simhei.ttf)复制到/var/www/html/zabbix/assets/fonts
7.chown apache.apache simhei.ttf
]# vim /var/www/html/zabbix/include/defines.inc.php
define('ZBX_GRAPH_FONT_NAME', 'simhei');
define('ZBX_FONT_NAME', 'simhei');