1.關(guān)閉防火墻并關(guān)閉開(kāi)機(jī)啟動(dòng):
systemctl stop firewalld.service
systemctl disable firewalld.service
2.關(guān)閉SELinux安全機(jī)制(為避免出現(xiàn)不必要麻煩):
1.臨時(shí)關(guān)閉:
setenforce 0 ##(設(shè)置SELinux 成為permissive模式)
##(setenforce 1 設(shè)置SELinux 成為enforcing模式)
2.永久關(guān)閉(修改配置文件需要重啟機(jī)器):
修改/etc/selinux/config
文件將SELINUX=enforcing改為SELINUX=disabled
重啟機(jī)器即可
3.搭建zabbix所需要的lamp環(huán)境。
首先將YUM源更新到最新,我這邊更換到阿里云:
1.備份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2.下載新的CentOS-Base.repo 到/etc/yum.repos.d/
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
3.運(yùn)行yum makecache生成緩存
在開(kāi)始安裝之前,還需要說(shuō)明下centos7自帶的mysql是mariadb锐秦,我們可以通過(guò)如下命令查看:
yum search mysql|tac
LAMP環(huán)境的安裝:
yum -y install mariadb mariadb-server php php-mysql httpd
4.配置數(shù)據(jù)庫(kù)
將mariadb加入開(kāi)機(jī)啟動(dòng)惊奇,并啟動(dòng)郊酒。
systemctl enable mariadb
systemctl start mariadb
初始化mysql數(shù)據(jù)庫(kù)尝胆,并配置root用戶密碼。
mysql_secure_installation
數(shù)據(jù)庫(kù)初始化
mysql初始化完畢后掉蔬,創(chuàng)建zabbix數(shù)據(jù)庫(kù)及其用戶,使用如下命令:
mysql -uroot -proot -e "create database zabbix default character set utf8 collate utf8_bin;"
mysql -uroot -proot -e "grant all on zabbix.* to 'zabbix'@'%' identified by 'zabbix';"
現(xiàn)在來(lái)測(cè)試剛剛創(chuàng)建的zabbix用戶矾瘾,是否可以連接mysql數(shù)據(jù)庫(kù)女轿,如下:
mysql -uzabbix -pzabbix
show databases;
5.將apache加入開(kāi)機(jī)啟動(dòng),并啟動(dòng)霜威,以及開(kāi)放80端口:
systemctl enable httpd
systemctl start httpd
6.安裝zabbix server
導(dǎo)入YUM源
rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
安裝zabbix:
yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent
安裝完成后導(dǎo)入zabbix數(shù)據(jù)結(jié)構(gòu):
cd /usr/share/doc/zabbix-server-mysql-3.2.2
zcat create.sql.gz | mysql -uroot -proot zabbix
數(shù)據(jù)庫(kù)導(dǎo)入完成以后谈喳,修改zabbix server配置文件:
vi /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
然后修改PHP的zabbix配置文件:
修改時(shí)區(qū)參數(shù)即可
vi /etc/httpd/conf.d/zabbix.conf
#
# Zabbix monitoring system php web frontend
#
Alias /zabbix /usr/share/zabbix
<Directory "/usr/share/zabbix">
Options FollowSymLinks
AllowOverride None
Require all granted
<IfModule mod_php5.c>
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
</IfModule>
</Directory>
<Directory "/usr/share/zabbix/conf">
Require all denied
</Directory>
<Directory "/usr/share/zabbix/app">
Require all denied
</Directory>
<Directory "/usr/share/zabbix/include">
Require all denied
</Directory>
<Directory "/usr/share/zabbix/local">
Require all denied
</Directory>
將zabbix server加入開(kāi)機(jī)啟動(dòng),并啟動(dòng):
systemctl enable zabbix-server
systemctl start zabbix-server
7.重啟apache:
systemctl restart httpd
8.打開(kāi)瀏覽器訪問(wèn)zabbix戈泼,地址:
訪問(wèn)地址如果需要修改的話婿禽,可以在zabbix.conf文件中修改 Alias 參數(shù):
vi /etc/httpd/conf.d/zabbix.conf
出現(xiàn)以上頁(yè)面即可正常登陸,默認(rèn)超級(jí)管理員登陸賬戶:Admin 密碼:zabbix
9.客戶端zabbix-agent安裝(centos7):
導(dǎo)入YUM源
rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
YUM安裝zabbix-agent
yum -y install zabbix-agent
修改zabbix-agent配置文件;
zabbix agent的配置很簡(jiǎn)單大猛,只需要修改zabbix agent配置文件中的Server扭倾、ServerActive和Hostname這三項(xiàng)即可。
其中Server挽绩、ServerActive是zabbix server服務(wù)器的IP地址膛壹,Hostname是被監(jiān)控端的IP地址,如下:
[root@zabbix163 ~]# cat /etc/zabbix/zabbix_agentd.conf |grep -v '^#'|grep -v '^$'
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=192.168.1.162
ServerActive=192.168.1.162
Hostname=192.168.1.163
Include=/etc/zabbix/zabbix_agentd.d/*.conf
將zabbix-agent設(shè)置開(kāi)機(jī)啟動(dòng)唉堪,并啟動(dòng)模聋。
systemctl enable zabbix-agent
systemctl start zabbix-agent
在zabbix web中添加主機(jī),注意主機(jī)名稱要和配置文件中的hostname一樣唠亚。
如圖即為正常链方。
參考地址:
http://blog.csdn.net/reblue520/article/details/52136850
https://www.zabbix.com/documentation/3.2/manual/installation