(这个属于工作中的联系,搭建着看看)
可以参考zabbix 官网文档(最好按照官网配置来)
https://www.zabbix.com/documentation/current/manual/installation/install
一,编译安装zabbix
#解压目录
[root@iZ2ze1o data]# tar xvf zabbix-5.0.0.tar.gz
[root@iZ2ze1o data]# cd zabbix-5.0.0
# 安装依赖
[root@iZ2ze1o zabbix-5.0.0]# yum install mysql-devel net-snmp net-snmp-devel libevent-devel curl-devel -y
[root@iZ2ze1o zabbix-5.0.0]# ./configure --prefix=/apps/zabbix5.0 --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
[root@iZ2ze1o zabbix-5.0.0]# make && make install
二,配置数据库
- 创建阿里云RDS数据库(注意不能这样创建数据库会报错 zabbix默认字符集不支持)在下面有
- 创建账号
- 设置连接白名单
- 登录测试
[root@iZ2ze1o0n0b42zks2le9byZ mysql]#mysql -uzabbix -p密码 -h链接地址 Welcome to the MariaDB monitor. Commands end with ; or \g. Your MySQL connection id is 191 Server version: 8.0.16 Source distribution Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MySQL [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | zabbix | +--------------------+ 3 rows in set (0.001 sec) MySQL [(none)]>
- 导入数据库(注意如果导入数据失败就需要看下数据库类型了) 下面有正确的
# 进入tar解压目录 [root@iZ2ze1o mysql]#cd /data/zabbix-5.0.0/database/mysql [root@iZ2ze1o mysql]#mysql -uzabbix -pLiu123 -hrm-2z.mysql.rds.aliyuncs.com zabbix < schema.sql ERROR 1142 (42000) at line 1965: REFERENCES command denied to user 'zabbix'@'172.27.78.237' for table 'zabbix.hosts' [root@iZ2ze1o mysql]#mysql -uzabbix -pLiu123 -hrm-2ze.mysql.rds.aliyuncs.com zabbix < images.sql [root@iZ2ze1o mysql]#mysql -uzabbix -pLiu123 -hrm-2ze.mysql.rds.aliyuncs.com zabbix < data.sql
三,配置web页面,修改配置文件
-
让web服务能显示zabbx
# 修改server配置文件 [root@iZ2ze1o etc]#grep "^[a-Z]" zabbix_server.conf LogFile=/tmp/zabbix_server.log DBHost=rm-2zec.mysql.rds.aliyuncs.com DBName=zabbix DBUser=zabbix DBPassword=Liu123 Timeout=4 LogSlowQueries=3000 StatsAllowedIP=127.0.0.1 [root@iZ2ze1o etc]#pwd /apps/zabbix5.0/etc # 拷贝web文件到 nginx目录 [root@iZ2ze1o zabbix]#cd /data/zabbix-5.0.0/ [root@iZ2ze1o zabbix-5.0.0]# cp -a ui/ /apps/nginx/html/zabbix/ # 修改目录权限 [root@iZ2ze1o zabbix5.0]#cd /apps/nginx/html/ [root@iZ2ze1o html]#chown nginx.nginx zabbix/ -R # 启动服务测试访问 [root@iZ2ze1o zabbix-5.0.0]#cd /apps/zabbix5.0/ [root@iZ2ze1o zabbix5.0]#./sbin/zabbix_server -c ./etc/zabbix_server.conf
-
如果显示503 则是因为nginx 默认文件 没有写index.php 添加上即可
[root@iZ2ze1o0n0b42zks2le9byZ zabbix]#vi /apps/nginx/conf/nginx.conf location / { root html; index index.html index.htm index.php; }
-
配置zabbix
点击下一步则会报出很多错误依赖
Minimum required size of PHP post is 16M (configuration option “post_max_size”).
Minimum required limit on execution time of PHP scripts is 300 (configuration option “max_execution_time”).
Time zone for PHP is not set (configuration parameter “date.timezone”).
上面是更改 php.ini 配置文件
下面是安装包
PHP bcmath extension missing (PHP configuration parameter --enable-bcmath).
PHP gd extension missing (PHP configuration parameter --with-gd).
PHP gd PNG image support missing.
PHP gd JPEG image support missing.
PHP gd FreeType support missing. -
麻烦得事情来了,因为我是编译安装得php 所以我要重新加上参数 --withi-gd , --enable-bcmath 重新编译
一定要把之前得编译参数保存起来,方便以后添加功能 。 依赖包: libwebp-devel libjpeg-devel libpng-devel freetype-devel[root@iZ2ze1o php-7.3.18]#./configure --help | grep bcmath --enable-bcmath Enable bc style precision math functions [root@iZ2ze1o php-7.3.18]#./configure --help | grep gd --with-gdbm=DIR DBA: GDBM support --with-gd=DIR Include GD support. DIR is the GD library base --enable-gd-jis-conv GD: Enable JIS-mapped Japanese font support [root@iZ2ze1o php-7.3.18]# ./configure --prefix=/apps/php7.3.18 --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --enable-mbstring --enable-xml --enable-sockets --enable-fpm --enable-maintainer-zts --disable-fileinfo --with-gd --enable-bcmath checking for FreeType 2... yes checking whether to enable JIS-mapped Japanese font support in GD... no If configure fails try --with-webp-dir=<DIR> 所需依赖包 : libwebp-devel configure: error: jpeglib.h not found. 所需依赖包 : libjpeg-devel configure: error: png.h not found. 所需依赖包 :libpng-devel If configure fails try --with-xpm-dir=<DIR> configure: error: freetype-config not found. 所需依赖包: freetype-devel [root@iZ2ze1o php-7.3.18]#make && make install [root@iZ2ze1o php-7.3.18]#systemctl restart php-fpm.service
直接重启服务即可,配置不用再配置了,之前得配置是保留得。刷新页面,效果显著剩下php.ini 修改下配置文件就行了
[root@iZ2ze1o] ~]#vi /apps/php7.3.18/etc/php.ini date.timezone = Asia/Shanghai max_execution_time = 300 post_max_size = 16M max_input_time = 300
我修改php.ini 没有生效,然后打开phpinfo 发现我得编译参数是让他去etc 去找,为我的年轻付出了代价,把php.ini 文件拷贝到了/etc/php.ini 检测通过
-
配置数据库
数据库报错
Undefined index: table_name [setup.php:99 → CSetupWizard->__construct() → CSetupWizard->eventHandler() → CSetupWizard->checkConnection() → MysqlDbBackend->checkEncoding() → MysqlDbBackend-
# 查看日志发现使用web页面创建的数据库字符集是不支持的。 cat /tmp/zabbix_server.log 32110:20200526:095622.958 Zabbix supports only "utf8_bin" collation. Database "zabbix" has default collation "utf8_general_ci" 32110:20200526:095622.968 character set name or collation name that is not supported by Zabbix found in 421 column(s) of database "zabbix" 32110:20200526:095622.968 only character set "utf8" and collation "utf8_bin" should be used in database # 重新使用高权限用户,然后创建数据库,然后给zabbix账号分配权限 MySQL [(none)]> grant all privileges on zabbix_server.* to zabbix@"%"; MySQL [(none)]> create database zabbix_server character set utf8 collate utf8_bin; # 重新导入数据库 [root@iZ2ze1o0n0b42zks2le9byZ mysql]#mysql -uzabbix -hrm-2zec2q33ldwx26924125010.mysql.rds.aliyuncs.com -p zabbix_server < schema.sql Enter password: [root@iZ2ze1o0n0b42zks2le9byZ mysql]#mysql -uzabbix -hrm-2zec2q33ldwx26924125010.mysql.rds.aliyuncs.com -p zabbix_server < images.sql Enter password: [root@iZ2ze1o0n0b42zks2le9byZ mysql]#mysql -uzabbix -hrm-2zec2q33ldwx26924125010.mysql.rds.aliyuncs.com -p zabbix_server < data.sql [root@iZ2ze1o0n0b42zks2le9byZ mysql]# # 我这里是换数据库的名称了,需要在zabbix_server.conf里修改数据库名称,如果做得话,直接删库重新创建即可
搞定
注意生成的配置文件,如果没有权限,则需要自己拷贝到网站的相应目录,我这个是正常生成好的
四、结束,默认账户Admin,密码zabbix
注意修改密码,5.0好像和之前的不太一样,我先准备准备看看能不能改成中文