一、rocky安裝?
需要注意在設置root用戶密碼時,勾選ssh遠程連接
安裝完成后直接用root登錄
1. 網絡配置
輸入nmtui 進入網絡配置界面
選擇 Edit a connection,再選擇接口 ens3
IPV4更改為Maual 手動模式
根據實際環境配置IP地址
重啟網絡
systemctl restart NetworkManager
之后就可以通過工具遠程操作了
2. 關閉防火墻和selinux
-- 關閉防火墻systemctl stop firewalldsystemctl disable firewalld-- 關閉selinuxsetenforce 0sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
二、部署zabbix系統
Download and install Zabbix 6.0 LTS for Rocky Linux 9, MySQL, Nginx
1. 安裝zabbix軟件庫
rpm -Uvh https://repo.zabbix.com/zabbix/6.4/rhel/9/x86_64/zabbix-release-6.4-2.el9.noarch.rpm
dnf? clean? all
2.下載軟件并安裝
?安裝zabbix服務端、前端、nginx和客戶端
dnf install zabbix-server-mysql zabbix-web-mysql zabbix-nginx-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent???langpacks-zh_CN
三、安裝數據庫
1. 獲取軟件
訪問MySQL
MySQL :: MySQL Downloads
yum install https://dev.mysql.com/get/mysql84-community-release-el9-2.noarch.rpm
2. 修改下載版本
vim /etc/yum.repos.d/mysql-community.repo?
選擇80版本和tools,其他版本都不用了,保存退出
3. 安裝MySQL
yum? install? mysql-server
開啟MySQL
systemctl? start? mysqld
獲取數據庫臨時密碼
grep ?password /var/log/mysqld.log
修改數據庫密碼
mysqladmin -uroot -p'4Yr7q,q/4?d<' password 'Lyu123!@#'
4. 導入zabbix數據
-- 先登錄數據庫
mysql -u root -pcreate database zabbix character set utf8mb4 collate utf8mb4_bin;create user zabbix@'%' identified by 'Lyu123!@#';grant all privileges on zabbix.* to zabbix@'%';SET GLOBAL log_bin_trust_function_creators = 1;
導入數據,這個要等上一會
zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql -uzabbix -p zabbix
四、修改配置文件
1. zabbix配置
vim /etc/zabbix/zabbix_server.conf
ListenPort=10051
DBHost=127.0.0.1
DBUser=zabbix
DBPassword=Lyu123!@#
DBName=zabbix
SourceIP=192.168.0.110
vim /etc/zabbix/zabbix_agentd.conf
SourceIP= 192.168.0.110Server=192.168.0.110ServerActive=192.168.0.110Hostname=Zabbix-serverEnableRemoteCommands=1LogRemoteCommands=1
2. nginx配置
vim /etc/nginx/nginx.conf
server內容 全部注釋,直接復制即可
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;events {worker_connections 1024;
}http {log_format main '$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" "$http_x_forwarded_for"';access_log /var/log/nginx/access.log main;sendfile on;tcp_nopush on;tcp_nodelay on;keepalive_timeout 65;types_hash_max_size 4096;include /etc/nginx/mime.types;default_type application/octet-stream;# Load modular configuration files from the /etc/nginx/conf.d directory.# See http://nginx.org/en/docs/ngx_core_module.html#include# for more information.include /etc/nginx/conf.d/*.conf;# server {
# listen 80;
# listen [::]:80;
# server_name _;
# root /usr/share/nginx/html;
#
# # Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
#
# error_page 404 /404.html;
# location = /404.html {
# }
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# }# Settings for a TLS enabled server.
#
# server {
# listen 443 ssl http2;
# listen [::]:443 ssl http2;
# server_name _;
# root /usr/share/nginx/html;
#
# ssl_certificate "/etc/pki/nginx/server.crt";
# ssl_certificate_key "/etc/pki/nginx/private/server.key";
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 10m;
# ssl_ciphers PROFILE=SYSTEM;
# ssl_prefer_server_ciphers on;
#
# # Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
#
# error_page 404 /404.html;
# location = /40x.html {
# }
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# }}
vim /etc/nginx/conf.d/zabbix.conf
修改監聽為80
server {listen 80;server_name _;root /usr/share/zabbix;index index.php;location = /favicon.ico {log_not_found off;}location / {try_files $uri $uri/ =404;}location /assets {access_log off;expires 10d;}location ~ /\.ht {deny all;}location ~ /(api\/|conf[^\.]|include|locale) {deny all;return 404;}location /vendor {deny all;return 404;}location ~ [^/]\.php(/|$) {fastcgi_pass unix:/run/php-fpm/zabbix.sock;fastcgi_split_path_info ^(.+\.php)(/.+)$;fastcgi_index index.php;fastcgi_param DOCUMENT_ROOT /usr/share/zabbix;fastcgi_param SCRIPT_FILENAME /usr/share/zabbix$fastcgi_script_name;fastcgi_param PATH_TRANSLATED /usr/share/zabbix$fastcgi_script_name;include fastcgi_params;fastcgi_param QUERY_STRING $query_string;fastcgi_param REQUEST_METHOD $request_method;fastcgi_param CONTENT_TYPE $content_type;fastcgi_param CONTENT_LENGTH $content_length;fastcgi_intercept_errors on;fastcgi_ignore_client_abort off;fastcgi_connect_timeout 60;fastcgi_send_timeout 180;fastcgi_read_timeout 180;fastcgi_buffer_size 128k;fastcgi_buffers 4 256k;fastcgi_busy_buffers_size 256k;fastcgi_temp_file_write_size 256k;}
}
五、啟動服務
systemctl start zabbix-server zabbix-agent nginx php-fpm
systemctl enable zabbix-server zabbix-agent nginx php-fpm
開啟agent服務
systemctl start zabbix-agent
六、Web頁面配置
訪問192.168.0.110
填寫數據庫信息
使用管理員賬戶(默認用戶名為 Admin
,密碼為 zabbix
)登錄
至此zabbix6.4 就部署好啦
擴展:
因為我也是剛剛接觸zabbix的新手小白
這次安裝完之后 選不到中文。具體原因不明,解決方法如下:
確認安裝語言包
yum install langpacks-zh_CN.noarch
dnf install glibc-langpack-zh -y
檢查系統中 可用的語言環境
locale -a | grep "zh_CN"
有zh_CN.UTF-8代表系統已存在中文環境
如果沒有,則手動生成
localedef -c -f UTF-8 -i zh_CN zh_CN.UTF-8
驗證生成結果
locale -a | grep "zh_CN"
編輯
vi /etc/locale.conf
內容:
LANG=zh_CN.UTF-8
LC_ALL=zh_CN.UTF-8
生效:
source /etc/locale.conf
驗證:
locale
七、添加agent客戶端
1. 獲取anget軟件源
rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/6.4/rhel/7/x86_64/zabbix-agent-6.4.10-release1.el7.x86_64.rpm
yum clean all
yum makecache
2. 安裝&啟用
yum install zabbix-agent
systemctl restart zabbix-agent
systemctl enable zabbix-agent
3. 調整配置
編輯 /etc/sudoers
visudo
文檔內添加zabbix記錄,用于免密
root ?ALL=(ALL) ? ALL
zabbix ?ALL=(ALL) ? NOPASSWD:ALL
vim /etc/zabbix/zabbix_agentd.conf
Server=192.168.0.110ServerActive=192.168.0.110Hostname=192.168.0.16
-- 這個填agent的
ListenPort=10050LogFileSize=5
--設置單個日志文件的最大值為5M
防火墻放行
firewall-cmd --add-port=10050/tcp --permanent
firewall-cmd --reload
檢查端口監聽情況
netstat -tuln | grep 10050
檢查兩端服務狀態
systemctl status zabbix-server
systemctl status zabbix-agent
4.server端測試
Web頁面添加主機、主機群組、選擇模板
安裝調試工具
yum install zabbix-get
zabbix_get -s 192.168.0.16 -k "agent.ping"
輸出結果為1 ?為連接成功
若連接異常,可檢查一下日志
tail -f /var/log/zabbix/zabbix_agentd.log
八、回顧
現在zabbix已經安裝部署完成,回顧一下操作
1.準備工作,安裝rocky系統
2.查找并添加軟件倉庫,如果本文中的鏈接已失效,可到網址中查找
3.安裝zabbix相關的組件,server、agent、mysql、nginx、web和中文包
4.配置數據庫、導入zabbix數據、啟用zabbix服務
5.配置Web頁面、登錄、添加監控主機
希望本文能夠對我們有所幫助。