先准备好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)
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 ]