(這個屬於工作中的聯繫,搭建着看看)
可以參考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好像和之前的不太一樣,我先準備準備看看能不能改成中文