linux系統如何安裝配置ZABBIX?

實驗環境:

操作系統:Centos 7.6

服務器ip:192.168.10.100

運行用戶:root

網絡環境:Internet

Zabbix是一個基於web界面的提供分佈式系統監控及網絡功能的企業級的開源監控工具,做爲一個企業運維人員來說,zabbix可以給企業和運維人員帶來很大的幫助,zabbix是一個功能非常強大、跨平臺、開源的企業級運維管理系統,由2部分構成:zabbix服務端和客戶端(agentd),也可以通過系統自帶的SNMP來採集數據。

 

Zabbix可以部署在Windows、Linux、unix、MAC OS等平臺上,可以監控任何網絡設備、操作系統、中間件、數據庫等,做爲一個企業的運維技術人來說,監控是非常重要的,確保線上業務能夠穩定運行,企業線上運行的和服務器網絡設備等多不少,所以,我們可以通過監控發現服務器故障,方便運維人員技術發現問題和解決問題,並且可以通過企業微信、企業QQ、企業釘釘、短信實現報警功能,有故障可以及時的通過管理員;開源的監控系統還有nagios、cacti、ganglia,我們在這裏只詳細的介紹zabbix監控,不過要想搭建zabbix監控系統還是需要有Linux技術,要有對Linux有所瞭解並且熟悉一些常見的命令及配置,如果覺得自己有Linux基礎可以參考下面的安裝步驟,通過源碼來編譯部署並配置zabbix企業運維監控系統。

 

1、install php              //通過yum源安裝php及一些與php相關的庫

# yum install php.x86_64 php-cli.x86_64 php-fpm php-gd php-json php-ldap php-mbstring php-mysqlnd php-xml php-xmlrpc php-opcache php-simplexml php-bcmath.x86_64 -y

 

2、install database         //yum源安裝MySQL(Mariadb)數據庫服務端和客戶端

# yum install mariadb.x86_64 mariadb-devel.x86_64 mariadb-server.x86_64 -y

# systemctl start mariadb.service                       //啓動數據庫

 

3、初始化數據庫

[root@localhost ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB

      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current

password for the root user.  If you've just installed MariaDB, and

you haven't set the root password yet, the password will be blank,

so you should just press enter here.

 

Enter current password for root (enter for none):

OK, successfully used password, moving on...

 

Setting the root password ensures that nobody can log into the MariaDB

root user without the proper authorisation.

 

Set root password? [Y/n] y

New password:

Re-enter new password:

Password updated successfully!

Reloading privilege tables..

 ... Success!

 

By default, a MariaDB installation has an anonymous user, allowing anyone

to log into MariaDB without having to have a user account created for

them.  This is intended only for testing, and to make the installation

go a bit smoother.  You should remove them before moving into a

production environment.

 

Remove anonymous users? [Y/n] y

 ... Success!

 

Normally, root should only be allowed to connect from 'localhost'.  This

ensures that someone cannot guess at the root password from the network.

 

Disallow root login remotely? [Y/n] n

 ... skipping.

 

By default, MariaDB comes with a database named 'test' that anyone can

access.  This is also intended only for testing, and should be removed

before moving into a production environment.

 

Remove test database and access to it? [Y/n] n

 ... skipping.

 

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

 

Reload privilege tables now? [Y/n] y

 ... Success!

 

Cleaning up...

 

All done!  If you've completed all of the above steps, your MariaDB

installation should now be secure.

 

Thanks for using MariaDB!

 

3、install apache           //yum源安裝apache

# yum install httpd.x86_64 -y

4、install zabbix_server             //源碼安裝zabbix服務端和客戶端

# tar -zxvf zabbix-3.4.9.tar.gz && cd zabbix-3.4.9

# groupadd zabbix && useradd -g zabbix Zabbix            //創建zabbix用戶及組

#./configure --prefix=/usr/local/zabbix user=zabbix group=zabbix --enable-server --enable-agent --enable-proxy --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2                  //配置編譯

# make install                       //編譯通過後安裝zabbix server

 

5、創建zabbix數據庫及zabbix數據庫用戶並授權

[root@zabbix ~]# mysql -u root -p Enter password:  Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 10 Server version: 5.5.47-MariaDB MariaDB Server Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;

Query OK, 1 row affected (0.00 sec) 

MariaDB [(none)]> GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY "password";

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> FLUSH PRIVILEGES;Q

uery OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit Bye

 

 

 

6、導入zabbix默認數據庫:

#cd /root/zabbix-3.4.9/database/mysql

# mysql -uroot -p zabbix < schema.sql && mysql -uroot -p zabbix < images.sql && mysql -uroot -p zabbix < data.sql

 

7、編輯默認安裝配置文件

# vim /usr/local/etc/zabbix_server.conf  

# vim /usr/local/zabbix/etc/zabbix_server.conf

ListenPort=10051                     //監聽端口

DBHost=localhost                     //數據庫服務器

DBName=Zabbix                        //數據庫名

DBUser=Zabbix                        //數據庫用戶名

DBPassword=password         //數據庫密碼

 

8、編輯並配置zabbix啓動腳本,並設置開機自動啓動

#cd /root/zabbix-3.4.9/misc/init.d/tru64

# cp -r /root/zabbix-3.4.9/misc/init.d/tru64/zabbix_* /etc/init.d/

# chmod +x /etc/init.d/zabbix* 

#chown -R zabbix:zabbix /usr/local/zabbix

# cp -r /usr/local/zabbix/sbin/zabbix_* /usr/local/sbin/

#/etc/init.d/zabbix_server restart

#/etc/init.d/zabbix_agentd restart

 

9、拷貝zabbix web端文件到apache根目錄下面

#cd /root/zabbix-3.4.9/frontends/

# mkdir -p /var/www/html/zabbix/

#cp -ra php/* /var/www/html/zabbix/

 

10、訪問web端

http://ip/zabbix

 

錯誤如下:

l   Minimum required size of PHP post is 16M (configuration option "post_max_size").

l   Minimum required limit on execution time of PHP scripts is 300 (configuration option "max_execution_time").

l   Minimum required limit on input parse time for PHP scripts is 300 (configuration option "max_input_time").

l   Time zone for PHP is not set (configuration parameter "date.timezone").

l   At least one of MySQL, PostgreSQL, Oracle or IBM DB2 should be supported.

l   PHP bcmath extension missing (PHP configuration parameter --enable-bcmath).

l   PHP mbstring extension missing (PHP configuration parameter --enable-mbstring).

l   PHP gd extension missing (PHP configuration parameter --with-gd).

l   PHP gd PNG image support missing.

l   PHP gd JPEG image support missing.

l   PHP gd FreeType support missing.

l   PHP xmlwriter extension missing.

l   PHP xmlreader extension missing.

 

 

 

 

 解決步驟:

#vim /etc/php.ini

post_max_size8M16M

max_execution_time30300

max_input_time60300

date.timezone = Asia/Shanghai

 

#systemctl restart httpd.service

 

 

 

 

 

 

 

 

 

 

先下載zabbix.conf.php配置文件,再把下載的zabbix.conf.php配置的配置文件上傳到/var/www/html/zabbix/conf/目錄下。

 

#systemctl restart httpd.service                     //重啓apache 服務

 

 

11、管理員信息

user/password:Admin/Zabbix           //Zabbix 前端默認用戶名和密碼,如果是企業使用搭建成功後一定要修改密碼,也可以把用戶名修改這樣安全些。

 

12、client install zabbix_agentd                        //源碼編譯安裝zabbix_agentd客戶端

#./configure --prefix=/usr/local/zabbix --enable-agent

# make install

 

13、修改agentd配置文件

# vim /usr/local/zabbix/etc/zabbix_agentd.conf

LogFile=/usr/local/zabbix/log/zabbix_agentd.log

EnableRemoteCommands=0

Server=192.168.10.100

ServerActive=192.168.10.100

Hostname=192.168.10.100

Timeout=30

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章