先準備好mysql,創建zabbix數據庫,並且把字符集改爲utf8
MariaDB [(none)]> create database zabbix character set utf8; Query OK, 1 row affected (0.09 sec)
授權一個遠程用戶,如果mysql與zabbix不在同一主機下,需要此步:
MariaDB [(none)]> grant all on zabbix.* to 'zbxuser'@'192.168.%.%' identified by 'zbxpass'; Query OK, 0 rows affected (0.07 sec)
再授權本機:
MariaDB [(none)]> grant all on zabbix.* to 'zbxuser'@'localhost' identified by 'zbxpass'; Query OK, 0 rows affected (0.00 sec)
ok,mysql配置完成:接下來配置zabbix
下載安裝zabbix:
本機直接下載官方yum源來進行安裝。
http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm
2,單獨安裝需要的軟件包:
yum install zabbix-server-2.4.0-1.el6.x86_64.rpm zabbix-server-mysql-2.4.0-1.el6.x86_64.rpm zabbix-get-2.4.0-1.el6.x86_64.rpm zabbix-2.4.0-1.el6.x86_64.rpm zabbix-web-2.4.0-1.el6.noarch.rpm zabbix-web-mysql-2.4.0-1.el6.noarch.rpm zabbix-agent-2.4.0-1.el6.x86_64.rpm zabbix-sender-2.4.0-1.el6.x86_64.rpm
zabbix-server-2.4.0-1.el6.x86_64.rpm #zabbix-server端主程序包
zabbix-server-mysql-2.4.0-1.el6.x86_64.rpm #zabbix-server與mysql相關的程序包
3.導入文件到zabbix數據庫:
文件路徑在:/usr/share/doc/zabbix-server-mysql-2.4.0/create
第一步:
[root@localhost create]# mysql zabbix < schema.sql
第二步:
[root@localhost create]# mysql zabbix < images.sql
第三步:
[root@localhost create]# mysql zabbix < data.sql
4.修改zabbix主配置文件:
[root@localhost zabbix]# vim /etc/zabbix/zabbix_server.conf
### Option: DBHost # Database host name. # If set to localhost, socket is used for MySQL. # If set to empty string, socket is used for PostgreSQL. # # Mandatory: no # Default: DBHost=localhost #開啓數據庫,並且修改地址。比如DBHost=192.168.1.146
修改用戶名,密碼:
### Option: DBUser # Database user. Ignored for SQLite. # # Mandatory: no # Default: # DBUser= DBUser=zbxuser ### Option: DBPassword # Database password. Ignored for SQLite. # Comment this line if no password is used. # # Mandatory: no # Default: # DBPassword= DBPassword=zbxpass
修改數據庫sock:
### Option: DBSocket # Path to MySQL socket. # # Mandatory: no # Default: # DBSocket=/tmp/mysql.sock DBSocket=/tmp/mysql.sock
啓動服務:
[root@localhost zabbix]# service zabbix-server start Starting Zabbix server: [ OK ]