Centos7-安裝Zabbix

FlyFlyWin發表於2020-12-02

Zabbix 安裝部署

一、初始化系統設定
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
二、安裝 LAMP 環境
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
yum clean all
yum makecache
yum -y install mariadb mariadb-server httpd php php-mysql 
systemctl enable httpd
systemctl restart httpd
systemctl enable mariadb
systemctl restart mariadb
mysql_secure_installation
#初始化mariadb
三、Zabbix 初始化
# 安裝 Zabbix 軟體包
rpm -ivh  http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
#zabbix倉庫
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
#匯入倉庫金鑰
yum -y install zabbix-server-mysql zabbix-web-mysql  zabbix-agent
#server-mysql就是zabbix-server,web-mysql就是web-GUI
# 初始化資料庫
mysql -u root -p
CREATE DATABASE zabbix DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';  

# 還原資料庫
cd /usr/share/doc/zabbix-server-mysql-3.2.1
zcat create.sql.gz | mysql -uroot -p  zabbix
#先加壓在開啟把結果交給mysql去執行

# 啟動 Zabbix 服務
vim /etc/zabbix/zabbix_server.conf
    DBHost=localhost
    DBName=zabbix
    DBUser=zabbix
    DBPassword=zabbix

systemctl start zabbix-server
systemctl enable zabbix-server

#我們要先重啟httpd服務,因為我們生成了一個zabbix.conf的介面檔案
systemctl restart httpd
#如果想訪問主頁就是zabbix,我們需要把zabbix主頁目錄連結到httpd下
vim /etc/httpd/conf/httpd.conf
修改documentroot
/usr/share/zabbix
# 編輯 zabbix 前端 php 配置
vim /etc/httpd/conf.d/zabbix.conf
    php_value max_execution_time 300
    php_value memory_limit 128M
    php_value post_max_size 16M
    php_value upload_max_filesize 2M
    php_value max_input_time 300
    php_value always_populate_raw_post_data -1
    php_value date.timezone Asia/Shanghai
    
# 調整時間同步,如果時間不同步,可能會造成監控不上的問題
ntpdate -u ntp1.aliyun.com

# 重啟 Apache 服務生效
systemctl restart httpd
四、修改中文亂碼
#如果進入zabbix出現方框
#lr 將自己windows電腦中的宋字型上傳
#上傳目錄為
/usr/share/zabbix/fonts
#注意改名為原目錄下的檔名
	
# 預設使用者密碼
    Admin
    zabbix
五、新增客戶端
vi /usr/local/zabbix/etc/zabbix_agentd.configure
    LogFile=/tmp/zabbix_agentd.log
    Server= 192.168.24.10{server端IP}
    ServerActive= 192.168.24.10{server端IP}
    Hostname=192.168.24.20{自身IP地址}
    
# Centos6 zabbix yum 源
rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/zabbix-release-3.2-1.el6.noarch.rpm