Cent OS 7.x 安裝Zabbix 3.x

系統環境:php

     VMware Workstation 12 Pro 12.5.0java

Cent OS 7.3_1611mysql

Zabbix 3.2linux

---如下操做均以root身份操做---web

1:設置網卡爲開機啓動sql

Shell>ifconfig

1.   [root@localhost ~]# ifconfig  數據庫

2.   ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  vim

3.           inet 172.20.13.172  netmask 255.255.252.0  broadcast 172.20.15.255  centos

4.           inet6 fe80::7ba8:6f74:fd63:7ca4  prefixlen 64  scopeid 0x20<link>  瀏覽器

5.           inet6 fe80::3f6e:c838:e848:dc58  prefixlen 64  scopeid 0x20<link>  

6.           inet6 fe80::bc3d:6b85:c582:cb27  prefixlen 64  scopeid 0x20<link>  

7.           ether 00:0c:29:3b:62:7e  txqueuelen 1000  (Ethernet)  

8.           RX packets 1211  bytes 106305 (103.8 KiB)  

9.           RX errors 0  dropped 0  overruns 0  frame 0  

10.         TX packets 327  bytes 47347 (46.2 KiB)  

11.         TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0  

其中ens33爲須要修改的網卡名稱

   Shell>vi /etc/sysconfig/network-scripts/ifcfg-ens33

   按 i 鍵進入輸入模式,上下左右移動光標至ONBOOT項

   修改ONBOOT項爲 yes,而後Shift+:進入命令模式輸入 wq 回車

2:關閉系統IPv6

方法1(永久有效)

Shell>vi /etc/sysctl.conf

添加下面的行:

net.ipv6.conf.all.disable_ipv6 =1   //禁用全部網卡的IPv6

net.ipv6.conf.default.disable_ipv6 =1

若是你想要爲特定的網卡禁止IPv6,好比,對於ens33,添加下面的行。

net.ipv6.conf.ens33.disable_ipv6 =1

保存並退出文件。

執行下面的命令來使設置生效。

Shell>sysctl -p

方法 2(重啓失效)

要在運行的系統中禁止IPv6,依次輸入下面的命令:

Shell>echo 1>/proc/sys/net/ipv6/conf/all/disable_ipv6
Shell>echo 1>/proc/sys/net/ipv6/conf/default/disable_ipv6

或者

Shell>sysctl -w net.ipv6.conf.all.disable_ipv6=1
Shell>sysctl -w net.ipv6.conf.default.disable_ipv6=1

3:安裝YUM源

安裝epel源

Shell>rpm -Uvh         //命令大小寫敏感

(若提示傳輸錯誤能夠使用WinSCP等FTP軟件將rpm包上傳至服務器中,而後使用rpm –Uvh 本地磁盤路徑 方式安裝)

Shell>yum -y install epel-release
Shell>yum repolist

配置MariaDB的yum源:

Shell>cd /etc/yum.repos.d
Shell>vi mariaDB.repo

添加如下內容:

[mariadb]

name=MariaDB

baseurl=http://mirrors.ustc.edu.cn/mariadb/yum/10.1/rhel7-amd64

gpgkey=https://mirrors.ustc.edu.cn/RPM-GPG-KEY-MariaDB

gpgcheck=0

[mariadb]

name=MariaDB

baseurl=http://yum.mariadb.org/10.1.22/centos7-amd64

gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB

gpgcheck=0

保存退出

4:安裝Zabbix源文件

Shell>cd /etc/yum.repos.d
Shell>rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
Shell>yum clean all
Shell>yum update

關閉Selinux

Shell>cd /etc/selinux
Shell>vi config

SELINUX=enforcing改成disabled

安裝網絡校時服務:

Shell> yum install -y ntp
Shell> ntpdate cn.ntp.org.cn

CentOS初始配置完成,重啓系統,準備安裝Zabbix

5:安裝Zabbix

依次執行如下命令:

1.   Shell> yum install -y php php-gd php-mysql php-bcmath php-mbstring php-xml curl  

2.   Shell>yum install -y curl-devel net-snmp gcc net-snmp-devel perl-DBI   

3.   Shell>yum install -y OpenIPMI-devel openssl-devel libcurl-devel httpd fping  

4.   Shell>yum install -y ntp ntpdate iksemel  

5.   Shell>yum install -y zabbix-server zabbix-server-mysql zabbix-web-mysql  

6.   Shell>yum install -y zabbix-web zabbix-get zabbix-java-gateway zabbix-sender zabbix-agent  

7.   Shell>yum -y install MariaDB-client MariaDB-server MariaDB-devel  

安裝完成後,進行配置

Shell>chkconfig mariadb on       //初始化MariaDB數據庫等同於systemctl enable mariadb.service  開機啓動MariaDB
Shell>systemctl start mariadb   //啓動MariaDB

配置MariaDB數據庫

 

Shell>mysqladmin -uroot password passw0rd //設置數據庫root用戶密碼爲passw0rd
Shell>mysql -uroot -ppassw0rd
MariaDB [(none)]> create database zabbix character set utf8;
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> show databases;


+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

| test               |

| zabbix             |

+--------------------+

MariaDB [(none)]>exit;
Shell>cd /usr/share/doc/zabbix-server-mysql-3.2.7  //此處示例爲3.2.7版本數據庫
Shell>zcat create.sql.gz | mysql -uzabbix -pzabbix zabbix
Shell>vi /etc/zabbix/zabbix_server.conf

修改如下幾處並保存,或者直接刪除DBHost和DBPassword去掉前面的#號保存也可

DBHost=localhost

DBName=zabbix

DBUser=zabbix

DBPassword=zabbix

編輯時區配置

Shell>vim /etc/httpd/conf.d/zabbix.conf

    <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 Europe/Riga

        php_value date.timezone Asia/Shanghai

保存並退出

接着啓動各項服務

Shell>chkconfig mariadb on  //初始化MariaDB數據庫
Shell>systemctl start mariadb  //啓動MariaDB
Shell>systemctl enable httpd.service   //HTTP服務開機啓動
Shell>systemctl start httpd.service     //啓動HTTP
Shell>systemctl start zabbix-server    //啓動Zabbix-Server
Shell>systemctl enable zabbix-server.service    //開機啓動Zabbix-Server
Shell>firewall-cmd --zone=public --add-service=http –permanent //添加HTTP服務至防火牆白名單
Shell>systemctl restart firewalld                    //重啓防火牆生效

6:WEB配置:

打開瀏覽器,輸入http://ip/zabbix

blob.png

點擊 下一步

blob.png

數據庫檢查經過,點擊 下一步

blob.png

紅色標記處是修改的 zabbix-server.conf的內容,填入數據庫密碼zabbix,點擊下一步

blob.png

Name爲自定義Zabbix服務器名稱,可不填。點擊下一步

blob.png

信息再次彙總顯示經過,點擊 下一步

blob.png

完成頁面配置

blob.png

自動跳轉至登陸界面,用戶名:Admin,初始密碼:zabbix

blob.png

配置完成,Web登陸界面

--------------------------------------------------------------------------------------

附加配置:

中文字符異常

Win+R打開運行,輸入fonts,回車進入Windows字體目錄,找到想替換的字體如:微軟雅黑-常規字體,而後上傳到/usr/share/zabbix/fonts

上傳成功後,編輯

Shell>vi /usr/share/zabbix/include/defines.inc.php


blob.png

修改graphfont爲msyh

修改完成後,網頁點擊刷新,便可正常顯示中文。

Zabbix-agent配置

接下來在zabbix-server服務器配置一個zabbix-agent監控服務器

安裝 zabbix-agent客戶端

Shell>yum install –y zabbix-agent

進入目錄/etc/zabbix/編輯zabbix-agent

Shell>vi /etc/zabbix/zabbix_agentd.conf

找到如下內容,並編輯

Server=172.17.100.193   //如有多個zabbix服務器,後面用逗號分隔服務器IP,若是是本機就用默認的127.0.0.1

ListenPort=10050   //監聽端口號

ListenIP=172.17.232.32   //監聽的IP地址,這裏填寫爲客戶端的IP,若是是本機就用默認的127.0.0.1

Hostname=自定義主機名   // Agent客戶端的主機名,若是是本機,默認的便可

而後修改 /etc/service

Shell>vi /etc/services

在最後的位置添加:

zabbix-agent 10050/tcp # zabbix agent

zabbix-agent 10050/udp # zabbix agent

zabbix-trapper 10051/tcp # zabbix trapper

zabbix-trapper 10051/udp # zabbix trapper

手動啓動zabbix-agent,並設置開機啓動

Shell> systemctl start zabbix-agent
Shell>systemctl enable zabbix-agent
相關文章
相關標籤/搜索