RedHat 7.1 下安裝 Zabbix監控程序詳解(適合linux初級用戶)


RedHat 7.1 安裝 Zabbix 監控程序詳解(適合對linux初級用戶)2017-05-02

安裝步驟:

1.zabbix需要安裝LAMP架構

2.安裝zabbix服務

3.初始化zabbix系統

 

1.安裝環境:VMware虛擬

1
2
3
4
[root@localhost ~] # cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.1 (Maipo)
[root@localhost ~] # uname -a
Linux localhost.localdomain 3.10.0-229.el7.x86_64  #1 SMP Thu Jan 29 18:37:38 EST 2015 x86_64 x86_64 x86_64 GNU/Linux

=================================好吧,下面開始安裝LAMP架構============================

1.為了方便獲取安裝應用,首先配置YUM服務,RedHat 默認YUM已安裝,下面我們直接配置YUM本地源和網絡源即可。

[root@localhost ~]# mount /dev/cdrom /mnt/cdrom
 mount: /dev/sr0 is write-protected, mounting read-only 

2.查看yum是否安裝;(以下標示已安裝)

[root@localhost ~]# rpm -qa |grep yum*
yum-metadata-parser-1.1.4-10.el7.x86_64
yum-3.4.3-125.el7.noarch
yum-rhn-plugin-2.0.1-5.el7.noarch
keyutils-libs-1.5.8-3.el7.x86_64
python-pyudev-0.15-6.el7.noarch

3.配置yum本地源和網絡源;

[root@localhost yum.repos.d]# mkdir  repobak   #新建一個備份文件夾

[root@localhost yum.repos.d]#mv *  repobak    #講yum.repos.d 文件夾內文件備份到repobak內

[root@localhost yum.repos.d]#vi zabbix.repo     #新建一個zabbix.repo YUM源文件,添加如下:

=================================zabbix.repo文件===================================

[zabbix]
name=Zabbix Official Repository - $basearch                                 #可引用變量$basearh為系統平台類型(x86_64&i386)
baseurl=http://repo.zabbix.com/zabbix/3.2/rhel/7/$basearch/          #網絡源地址 (鏡像站)
enabled=1                                                                               #啟用為1 禁用為0
gpgcheck=1                                                                             #校驗為1 禁止校驗為0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591      # 這個根據系統版本自動生成,可省略。

[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=http://repo.zabbix.com/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX                   # 這個根據系統版本自動生成,可省略。
gpgcheck=1
[waiwang]
name=waiwang
baseurl=http://mirrors.163.com/centos/7/os/x86_64/
enabled=1
gpgcheck=0
[extras]
name=extras
baseurl=http://mirrors.163.com/centos/7/extras/x86_64/
enabled=1
gpgcheck=0

======================================END====================================

4.清除YUM緩存文件

[root@localhost ~]# yum clean all                                           #清除yum緩存


Loaded plugins: product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cleaning repos: extras waiwang zabbix zabbix-non-supported
Cleaning up everything 

5.創建YUM緩存文件

 

[root@localhost ~]# yum makecache                                    #生成yum緩存


Loaded plugins: product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
extras | 3.4 kB 00:00 
waiwang | 3.6 kB 00:00 
zabbix | 951 B 00:00 
zabbix-non-supported | 951 B 00:00 
(1/8): extras/prestodelta | 99 kB 00:00 
(2/8): extras/primary_db | 151 kB 00:00 
(3/8): waiwang/group_gz | 155 kB 00:00 
(4/8): extras/other_db | 640 kB 00:01 
(5/8): extras/filelists_db | 770 kB 00:02 
(6/8): waiwang/filelists_db | 6.6 MB 00:02 
(7/8): waiwang/other_db | 2.4 MB 00:00 
(8/8): waiwang/primary_db | 5.6 MB 00:03 
(1/6): zabbix/x86_64/primary | 13 kB 00:00 
(2/6): zabbix/x86_64/filelists | 43 kB 00:00 
(3/6): zabbix/x86_64/other | 7.7 kB 00:00 
(4/6): zabbix-non-supported/x86_64/filelists | 660 B 00:00 
(5/6): zabbix-non-supported/x86_64/primary | 1.6 kB 00:00 
(6/6): zabbix-non-supported/x86_64/other | 1.5 kB 00:00 
zabbix 92/92
zabbix 92/92
zabbix 92/92
zabbix-non-supported 4/4
zabbix-non-supported 4/4
zabbix-non-supported 4/4
Metadata Cache Created 

6.[root@localhost ~]# yum  list  可以查看YUM獲取到的文件列表

7.關閉firewall:(vi/etc/selinux/)

[root@localhost ~]#systemctl stop firewalld.service                       #停止firewall

[root@localhost ~]#systemctl disable firewalld.service                   #禁止firewall開機啟動

[root@localhost ~]# vi /etc/selinux/config                                     #將selinux=enforcing  改為 selinux=disabled 即可。

[root@localhost ~]# sestatus                                                       #查看selinux狀態

 

=======================================截止YUM環境已經准備完畢=======================

一.開始安裝LAMP架構

1.安裝Apache

[root@localhost ~]#yum install httpd                                           #根據提示,輸入Y安裝即可成功安裝

[root@localhost ~]#systemctl start httpd.service                          #啟動apache

[root@localhost ~]#systemctl stop httpd.service                           #停止apache

[root@localhost ~]#systemctl restart httpd.service                       #重啟apache

[root@localhost ~]#systemctl enable httpd.service                       #設置apache開機啟動

 

2.安裝MariaDB

RHEL 7.0中,已經使用MariaDB替代了MySQL數據庫

2.1安裝MariaDB

[root@localhost ~]#yum install mariadb mariadb-server                #詢問是否要安裝,輸入Y即可自動安裝,直到安裝完成

[root@localhost ~]#systemctl start mariadb.service                      #啟動MariaDB

[root@localhost ~]#systemctl stop mariadb.service                      #停止MariaDB

[root@localhost ~]#systemctl restart mariadb.service                  #重啟MariaDB

[root@localhost ~]#systemctl enable mariadb.service                  #設置開機啟動

3.安裝PHP

[root@localhost ~]#yum install php                                          #根據提示輸入Y直到安裝完成 

4.安裝PHP組件,使PHP支持 MariaDB

[root@localhost ~]#yum install php-mysql php-gd libjpeg*  php-ldap php-odbc php-pear php-xml php-xmlrpc php-mhash  

                                                                                                                  #這里選擇以上安裝包進行安裝,根據提示輸入Y回車

[root@localhost ~]#systemctl restart mariadb.service                                        #重啟MariaDB

[root@localhost ~]#systemctl restart httpd.service                                            #重啟apache

 

5.重新啟動服務

[root@localhost ~]#systemctl restart mariadb.service                                       #重啟MariaDB

[root@localhost ~]#systemctl restart httpd.service                                           #重啟apache

 

6.登錄http://localhost  測試httpd服務是否正常。

=========================LAMP架構已經搭建完畢==========================================

二.zabbix服務的安裝和配置

1安裝存儲庫配置文件
[root@localhost ~]#rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
2.安裝zabbix程序
[root@localhost ~]#yum install zabbix-server-mysql zabbix-web-mysql zabbix-get zabbix-agent 安裝zabbix,提示點"y"即可完成安裝。
[root@localhost ~]#rpm -ql zabbix-server-mysql  驗證安裝文件

/etc/logrotate.d/zabbix-server
/etc/zabbix/zabbix_server.conf
/usr/lib/systemd/system/zabbix-server.service
/usr/lib/tmpfiles.d/zabbix-server.conf
/usr/lib/zabbix/alertscripts
/usr/lib/zabbix/externalscripts
/usr/sbin/zabbix_server_mysql
/usr/share/doc/zabbix-server-mysql-3.2.5
/usr/share/doc/zabbix-server-mysql-3.2.5/AUTHORS
/usr/share/doc/zabbix-server-mysql-3.2.5/COPYING
/usr/share/doc/zabbix-server-mysql-3.2.5/ChangeLog
/usr/share/doc/zabbix-server-mysql-3.2.5/NEWS
/usr/share/doc/zabbix-server-mysql-3.2.5/README
/usr/share/doc/zabbix-server-mysql-3.2.5/create.sql.gz
/usr/share/man/man8/zabbix_server.8.gz
/var/log/zabbix
/var/run/zabbix

3.初始化mariadb數據庫
[root@localhost ~]#mysql -u root 

 

4..導入zabbix初始模式和數據

[root@localhost ~]#zcat /usr/share/doc/zabbix-server-mysql-3.2.1/create.sql.gz | mysql -uroot zabbix 
[root@localhost ~]#mysql -u root  驗證數據是否導入成功

MariaDB [zabbix]>use zabbix;

Database changed
MariaDB [zabbix]> show tables;
+----------------------------+
| Tables_in_zabbix |
+----------------------------+
| acknowledges |
| actions |
| alerts |
| application_discovery |
| application_prototype |
| application_template |
| applications |
| auditlog |

5.配置zabbix配置文件,修改數據庫密碼為zabbix

[root@localhost ~]#vi /etc/zabbix/zabbix_server.conf
DBPassword=zabbix
 
6.配置Http配置文件,修改時區為亞洲上海
# vi /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai
 
7.啟動zabbix-server,並設置開機自啟
#systemctl start zabbix-server
#systemctl enable zabbix-server
注意:
①如果zabbixserver無法啟動,則需要安裝trousers支持包。
#yum install trousers
②如果報pid錯誤
需要做軟連接/var/run > /run
#ln -s /var/run /run
 
8.啟動http,並設置開機自啟
#systemctl start httpd
#systemctl enable httpd
 
9.啟動zabbix-agent,並設置開機自啟
#systemctl start zabbix-agent
#systemctl enable zabbix-agent
 
10使用IE登陸zabbix圖形界面進行設置。
地址:http://192.168.1.*/zabbix/(zabbix服務器IP)
賬戶:admin   密碼:zabbix
 
11. zabbix圖形界面的配置。圖形界面配置網上有很多,可以自行查詢,此處省略。。。。。。。。。。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM