環境 系統:Ubuntu 20.04 虛擬平臺:Vmware Workstation 16 PRO 軟體版本:Zabbix 6.0 LTS 資料庫:PostgreSQL Web服務:Apache 新建虛擬機(物理機跳過) Ubuntu安裝優化 安裝Zabbix倉庫 wget https://repo ...
環境
- 系統:Ubuntu 20.04
- 虛擬平臺:Vmware Workstation 16 PRO
- 軟體版本:Zabbix 6.0 LTS
- 資料庫:PostgreSQL
- Web服務:Apache
新建虛擬機(物理機跳過)
安裝Zabbix倉庫
wget https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-4%2Bubuntu20.04_all.deb
sudo dpkg -i zabbix-release_6.0-4+ubuntu20.04_all.deb
sudo apt update
安裝Zabbix server,Web前端,agent
sudo apt install zabbix-server-pgsql zabbix-frontend-php php7.4-pgsql zabbix-apache-conf zabbix-sql-scripts zabbix-agent
創建初始資料庫
安裝PostgreSQL資料庫
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install postgresql
確保資料庫服務啟動並正常運行。
在資料庫主機運行以下代碼
sudo -u postgres createuser --pwprompt zabbix
sudo -u postgres createdb -O zabbix zabbix
導入初始架構和數據。
zcat /usr/share/zabbix-sql-scripts/postgresql/server.sql.gz | sudo -u zabbix psql zabbix
為Zabbix server配置資料庫
將password改為你設置的資料庫密碼。
sudo vim /etc/zabbix/zabbix_server.conf
DBPassword=password
啟動Zabbix server和agent進程
啟動Zabbix server和agent進程,併為它們設置開機自啟。
sudo systemctl restart zabbix-server zabbix-agent apache2
sudo systemctl enable zabbix-server zabbix-agent apache2
打開Zabbix前端頁面配置
虛擬機運行的可以通過ifconfig查看IP地址,並通過http://host/zabbix訪問。
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.31.193 netmask 255.255.255.0 broadcast 192.168.31.255
inet6 fe80::1ce1:20af:7447:faf5 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:cd:ef:83 txqueuelen 1000 (Ethernet)
RX packets 55216 bytes 76688088 (76.6 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 25210 bytes 2166096 (2.1 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 10820 bytes 14683581 (14.6 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 10820 bytes 14683581 (14.6 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
選擇好語言,點下一步。
檢測沒問題,點下一步。
輸入資料庫密碼,點下一步。
設置Zabbix主機名稱,點下一步。
點下一步,完成安裝。
預設賬號:Admin
預設密碼:zabbix
登錄
輸入訪問地址,賬號密碼,就可以正常使用Zabbix了。
使用Mariadb資料庫
安裝mariadb資料庫(要求版本10.5以上)
Download MariaDB Server - MariaDB.org
根據文檔命令進行安裝
mariadb:create test file /usr/local/mysql/data/ubuntu20.lower-test
錯誤提示:
Jul 14 10:14:00 ubuntu20 mariadbd[2813]: 2022-07-14 10:14:00 0 [Note] /usr/sbin/mariadbd (mysqld 10.5.16-MariaDB-1:10.5.16+maria~focal-log) starting as process 2813 ...
Jul 14 10:14:00 ubuntu20 mariadbd[2813]: 2022-07-14 10:14:00 0 [Warning] Can't create test file /usr/local/mysql/data/ubuntu20.lower-test
Jul 14 10:14:00 ubuntu20 mariadbd[2813]: 2022-07-14 10:14:00 0 [ERROR] mariadbd: File './mysql-bin.index' not found (Errcode: 30 "Read-only file system")
解決辦法:
MariaDB cannot start after update: [Warning] Can't create test file /home/mysql/beta.lower-test
mariadb fails to start on raw drive filesystem
亂碼
zabbix6 中文亂碼處理_dbfedbf的博客-CSDN博客
錯誤
zabbix-server 停止服務
查看日誌cat /var/log/zabbix/zabbix_server.log
11531:20220714:110546.762 [file:dbconfig.c,line:89] __zbx_mem_malloc(): out of memory (requested 256 bytes)
11531:20220714:110546.762 [file:dbconfig.c,line:89] __zbx_mem_malloc(): please increase CacheSize configuration parameter
11531:20220714:110546.762 === memory statistics for configuration cache ===
11531:20220714:110546.762 free chunks of size 24 bytes: 68
11531:20220714:110546.762 free chunks of size 32 bytes: 4
11531:20220714:110546.762 free chunks of size 40 bytes: 1
11531:20220714:110546.762 min chunk size: 24 bytes
11531:20220714:110546.762 max chunk size: 40 bytes
11531:20220714:110546.762 memory of total size 29254736 bytes fragmented into 268708 chunks
11531:20220714:110546.762 of those, 1800 bytes are in 73 free chunks
11531:20220714:110546.762 of those, 29252936 bytes are in 268635 used chunks
11531:20220714:110546.762 of those, 4299312 bytes are used by allocation overhead
日誌顯示需要增加CacheSize的容量。
修改配置文件,增加緩存大小。
vim /etc/zabbix/zabbix_server.conf
# 根據機器配置修改容量
CacheSize=8G```
本文來自博客園,作者:Solita1y,轉載請註明原文鏈接:https://www.cnblogs.com/solita1y/p/17153976.html