ubuntu 22.04.1 install zabbix 6.4_ngnix
設定固定IP
1.sudo nano /etc/netplan/00-installer-config.yaml
設定固定IP
network:
version: 2
ethernets:
ens32:
dhcp4: false
addresses: [192.168.0.50/24]
routes:
- to: default
via: 192.168.0.1
nameservers:
addresses: [1.1.1.1,8.8.8.8]
重啟網路設定
sudo netplan apply
更新系統及軟體
sudo apt-get update && sudo apt-get upgrade -y
更改系統的時區
看目前時區
timedatectl
修改時區
sudo timedatectl set-timezone Asia/Taipei
安裝NTP同步時間
sudo apt install -y ntp
sudo systemctl start ntp
sudo systemctl enable ntp
------------------------------------------------------
下載Zabbix-Nginx安裝包
sudo wget https://repo.zabbix.com/zabbix/6.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.4-1+ubuntu22.04_all.deb
sudo dpkg -i zabbix-release_6.4-1+ubuntu22.04_all.deb
sudo apt update
sudo apt install -y zabbix-server-mysql zabbix-frontend-php zabbix-nginx-conf zabbix-sql-scripts zabbix-agent mysql-server
# mysql --version
# sudo systemctl start mysql.service
# sudo systemctl enable mysql.service
sudo mysql -uroot
# ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by '1qaz2wsx';
exit;
sudo mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root:
VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?
Press y|Y for Yes, any other key for No: n
Using existing password for root.
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n
... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!
mysql -uroot -p
# mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
# mysql> create user zabbix@localhost identified by '1qaz2wsx';
# mysql> grant all privileges on zabbix.* to zabbix@localhost;
# mysql> set global log_bin_trust_function_creators = 1;
# mysql> SHOW VARIABLES LIKE 'char%';
# mysql> SHOW VARIABLES LIKE 'collation%';
# mysql> quit;
sudo zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix
mysql -uroot -p
mysql> set global log_bin_trust_function_creators = 0;
mysql> quit;
sudo nano /etc/zabbix/zabbix_server.conf
修改
DBPassword=1qaz2wsx
sudo nano /etc/zabbix/nginx.conf
listen 80;
server_name 192.168.137.243;--zabbix server ip
sudo systemctl restart zabbix-server zabbix-agent nginx php8.1-fpm
sudo systemctl enable zabbix-server zabbix-agent nginx php8.1-fpm
http://IP --設定一些規則
http://IP Admin--zabbix --登入
---------------------------------------------------------
sudo nano /usr/share/zabbix/include/locales.inc.php #打開此文件確認中文已經打開顯示(true)
'zh_TW' => ['name' => _('Chinese (zh_TW)'), 'display' => true],
sudo apt install -y language-pack-zh-hant language-pack-zh-hans #安裝中文
sudo nano /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"
添加以下2行
LANG="zh_TW.UTF-8"
LANGUAGE="zh_TW:zh:en_US:en"
sudo dpkg-reconfigure locales
sudo systemctl restart zabbix-server zabbix-agent nginx php8.1-fpm
---------------------------------------------------------
find / -name fonts
cd /usr/share/zabbix/assets/fonts
ls
graphfont.ttf
sudo wget https://alist.yyzq.cf/d/%20%E6%9C%AC%E5%9C%B0%E7%BD%91%E7%9B%98/software%20/fonts/simkai.ttf #下載新字體
sudo mv graphfont.ttf graphfont.ttfbak #備份原字體
sudo mv simkai.ttf graphfont.ttf #使用新字體
sudo systemctl restart zabbix-server zabbix-agent nginx php8.1-fpm
---------------------------------------------------------
資料庫出現
mysql -uroot -p
Enter password:
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
解決辦法
sudo mysql -u root # I had to use "sudo" since it was a new installation
mysql> USE mysql;
mysql> SELECT User, Host, plugin FROM mysql.user;
+------------------+-----------+-----------------------+
| User | Host | plugin |
+------------------+-----------+-----------------------+
| debian-sys-maint | localhost | caching_sha2_password |
| mysql.infoschema | localhost | caching_sha2_password |
| mysql.session | localhost | caching_sha2_password |
| mysql.sys | localhost | caching_sha2_password |
| root | localhost | auth_socket |
| zabbix | localhost | caching_sha2_password |
+------------------+-----------+-----------------------+
As you can see in the query, the "root" user is using the "auth_socket" plugin.
sudo mysql -u root # I had to use "sudo" since it was a new installation
mysql> USE mysql;
mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root';
mysql> FLUSH PRIVILEGES;
mysql> exit;
sudo systemctl restart mysql.service
-----------------------------------------------------
sudo apt update出現
Failed to fetch http://tw.archive.ubuntu.com/dists/jammy/InRelease
1.先ping tw.archive.ubuntu.com 是否又問題
2.如果無法ping到,修改source.list
3.cd /etc/apt
4.cp sources.list sources.list.bak
5.sudo nano sources.list
將全部http://tw.archive.ubuntu.com 改成http://archive.ubuntu.com/ubuntu/ 存檔
6.再執行一次sudo apt update
----------------------------------------------------------
linux agent 安裝
安裝ubuntu22.04.1後
到https://www.zabbix.com/download?zabbix=6.4&os_distribution=ubuntu&os_version=22.04&components=agent_2&db=&ws=
看如何安裝,注意執行動作前要記得核對版本喔!!
wget https://repo.zabbix.com/zabbix/6.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.4-1+ubuntu22.04_all.deb
sudo dpkg -i zabbix-release_6.4-1+ubuntu22.04_all.deb
sudo apt update
安裝 Zabbix Agent2
sudo apt install zabbix-agent2 zabbix-agent2-plugin-*
修改參數
sudo nano /etc/zabbix/zabbix_agent2.conf
Server、ServerActive 2選1
Server=192.168.137.243 ---被動提供資料給zabbix server
ServerActive=127.0.0.1 ---主動提供資料給zabbix server
Hostname=192.168.137.33 ---被監控主機IP或名稱
因為剛有調整參數,所以必須重啟服務
sudo systemctl restart zabbix-agent2
設定開機啟動
sudo systemctl enable zabbix-agent2