分享CentOS 6.6下搭建Zabbix 3.0.3 的過程,但願都你們有所幫助。php
環境安裝html
系統環境:mysql
# cat /etc/RedHat-release
CentOS release 6.6 (Final)linux
服務器IP地址:web
10.20.0.101sql
Apache安裝數據庫
#yum install httpd libxml2-devel net-snmp-devel libcurl-develapache
配置webvim
更改ServerNamecentos
# vim /etc/httpd/conf/httpd.conf
ServerName 10.20.0.101
安裝MySQL
建議安裝MySQL5.6 centos6 默認安裝mysql是5.1 不是很穩定 性能也沒有MySQL5.6好
下載rpm源及安裝
#rpm -ivh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
# yum install -y mysql-server mysql-devel
更改配置文件 添加內容以下:
#vim /etc/my.cnf
default-storage-engine = innodb
innodb_file_per_table
collation-server = utf8_general_ci
init-connect = 'SET NAMES utf8'
character-set-server = utf8
啓動數據庫
# service mysqld start
MySQL安全設置:
# mysql_secure_installation
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 MySQL
root user without the proper authorisation.
Set root password? [Y/n] y #設置root密碼 選擇Y 或者回車
New password: #設置root密碼
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
Remove anonymous users? [Y/n] y 是否刪除匿名用戶 選擇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] y 是否禁止用戶登錄root 遠程 選擇Y 爲了安全考慮
... Success!
Remove test database and access to it? [Y/n] y 刪除test數據庫 選擇y
- Dropping test database...
Reload privilege tables now? [Y/n] y 是否從新加載刷新表空間 選擇Y 是
... Success!
All done! If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
Cleaning up...
建立zabbix數據庫
# mysql -uroot -p
mysql> CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;
mysql> show create database zabbix;
+----------+----------------------------------------------------------------------------------+
| Database | Create Database |
+----------+----------------------------------------------------------------------------------+
| zabbix | CREATE DATABASE `zabbix` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_bin */ |
+----------+----------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY 'zabbix';
Query OK, 0 rows affected (0.04 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| zabbix |
+--------------------+
4 rows in set (0.00 sec)
安裝PHP
zabbix3.0版本 對於PHP要求是5.4版本以上 默認CentOS6.幾 默認是5.3 好像
rpm下載及yum安裝php5.6
# rpm -ivh http://repo.webtatic.com/yum/el6/latest.rpm
# yum install php56w php56w-gd php56w-mysql php56w-bcmath php56w-mbstring php56w-xml php56w-ldap
更改配置文件
vim /etc/php.ini
date.timezone = Asia/Shanghai
post_max_size = 32M
max_execution_time = 300
max_input_time = 300
always_populate_raw_post_data = -1
安裝zabbix
建立zabbix用戶與組
# groupadd -g 201 zabbix
# useradd -g zabbix -u 201 -m zabbi
下載zabbix軟件包而且安裝
#wget http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/3.0.3/zabbix-3.0.3.tar.gz
#tar zxvf zabbix-3.0.3.tar.gz
# cd zabbix-3.0.3
# /usr/bin/mysql -uzabbix -pzabbix zabbix < database/mysql/schema.sql
# /usr/bin/mysql -uzabbix -pzabbix zabbix < database/mysql/images.sql
# /usr/bin/mysql -uzabbix -pzabbix zabbix < database/mysql/data.sql
#./configure --prefix=/usr/local/zabbix --sysconfdir=/etc/zabbix/ --enable-server --enable-agent --with-net-snmp --with-libcurl --with-mysql --with-libxml2
# make && make install
(編譯 zabbix 若是報下面錯誤,就作如下操做
configure: error: Not found mysqlclient library
#find / -name libmysqlclient*
ln -s /usr/lib64/mysql/libmysqlclient.so.18.1.0 /usr/lib64/mysql/libmysqlclient.so
ln -s /usr/lib64/mysql/libmysqlclient_r.so.18.1.0 /usr/lib64/mysql/libmysqlclient_r.so)
配置zabbix
# vim /etc/zabbix/zabbix_server.conf
DBHost=localhost 數據庫ip地址
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
ListenIP=10.20.0.101
#ln -s /usr/local/zabbix/sbin/* /usr/sbin/
#cd
#cp zabbix-3.0.3/misc/init.d/Fedora/core/zabbix_* /etc/init.d/
#chmod +x /etc/init.d/zabbix_*
#sed -i "s@BASEDIR=/usr/local@BASEDIR=/usr/local/zabbix@g" #/etc/init.d/zabbix_server
#mkdir -p /var/www/html/zabbix
#cp -r zabbix-3.0.3/frontends/php/* /var/www/html/zabbix/
#chown -R apache.apache /var/www/html/zabbix/
#chkconfig zabbix_server on
啓動Apache和zabbix server
# /etc/init.d/zabbix_server restart
# /etc/init.d/httpd restart
打開瀏覽器 進行安裝
http://172.16.10.106/zabbix/setup.php
安裝成功 登錄默認用戶是Admin 密碼 zabbix
漢化中文
上傳字體到/var/www/html/zabbix/fonts 下面 我上傳的是微軟黑體msyh.ttf下載見 http://www.linuxidc.com/Linux/2009-11/22691.htm
修改配置文件
vim /var/www/html/zabbix/include/locales.inc.php
'zh_CN' => ['name' => _('Chinese (zh_CN)'), 'display' => true], 默認是true 不用改 若是是false 就改爲true
更換語言後,圖形會出現亂碼,咱們作以下修改便可。
修改你的defines.inc.php 這個文件
define('ZBX_FONT_NAME', 'msyh'); #第93行 define('ZBX_GRAPH_FONT_NAME', 'msyh'); // font file name #第45行
一些Zabbix相關教程集合:
Ubuntu 14.04下Zabbix2.4.5 源碼編譯安裝 http://www.linuxidc.com/Linux/2015-05/117657.htm
CentOS 7 LNMP環境搭建Zabbix3.0 http://www.linuxidc.com/Linux/2017-02/140134.htm
Ubuntu 16.04安裝部署監控系統Zabbix2.4 http://www.linuxidc.com/Linux/2017-03/141436.htm
Zabbix監控安裝部署及警報配置 http://www.linuxidc.com/Linux/2017-03/141611.htm
Ubuntu 16.04下安裝部署Zabbix3.0 http://www.linuxidc.com/Linux/2017-02/140395.htm
CentOS 6.3下Zabbix監控apache server-status http://www.linuxidc.com/Linux/2013-05/84740.htm
CentOS 7 下 Zabbix 3.0安裝詳解 http://www.linuxidc.com/Linux/2017-03/141716.htm
64位CentOS 6.2下安裝Zabbix 2.0.6 http://www.linuxidc.com/Linux/2014-11/109541.htm
CentOS 7.2下搭建Zabbix 3.2 實踐圖解教程 http://www.linuxidc.com/Linux/2017-03/142077.htm