小白都能看懂的Linux系統下安裝配置Zabbix

實驗環境:php

操做系統:Centos 7.6html

服務器ip:192.168.10.100前端

運行用戶:rootmysql

網絡環境:Internetlinux

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

 

Zabbix能夠部署在Windows、Linux、unix、MAC OS等平臺上,能夠監控任何網絡設備、操做系統、中間件、數據庫等,作爲一個企業的運維技術人來講,監控是很是重要的,確保線上業務可以穩定運行,企業線上運行的和服務器網絡設備等多很多,因此,咱們能夠經過監控發現服務器故障,方便運維人員技術發現問題和解決問題,而且能夠經過企業微信、企業QQ、企業釘釘、短信實現報警功能,有故障能夠及時的經過管理員;開源的監控系統還有nagios、cacti、ganglia,咱們在這裏只詳細的介紹zabbix監控,不過要想搭建zabbix監控系統仍是須要有Linux技術,要有對Linux有所瞭解而且熟悉一些常見的命令及配置,如今企業運維也是必不可少的,若是想往運維方向發展的能夠去了解下《Linux就該這麼學》這邊教程,裏面的內容很是詳細,比較適合初學者,若是以爲本身有Linux基礎能夠參考下面的安裝步驟,經過源碼來編譯部署並配置zabbix企業運維監控系統。web

 

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

# 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數據庫

 

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

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

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

 

三、初始化數據庫

[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!

 

三、install apache           //yum源安裝apache

# yum install httpd.x86_64 -y

四、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

 

五、建立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

 

 

 

六、導入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

 

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

# 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         //數據庫密碼

 

八、編輯並配置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

 

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

#cd /root/zabbix-3.4.9/frontends/

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

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

 

十、訪問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 服務

 

 

十一、管理員信息

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

 

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

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

# make install

 

1三、修改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

相關文章
相關標籤/搜索