A Zabbix database must be created during the installation of Zabbix server or proxy.
This section provides scripts for creating a Zabbix database. A separate schema script is provided for each supported database.
data.sqlfiles are located in the database subdirectory of Zabbix sources. If Zabbix was installed from distribution packages, refer to the distribution documentation.
schema.sqlshould be imported (no images.sql nor data.sql)
UTF-8 is the only encoding supported by Zabbix. It is known to work without any security flaws. Users should be aware that there are known security issues if using some of the other encodings.
shell> mysql -uroot -p<password> mysql> create database zabbix character set utf8 collate utf8_bin; mysql> grant all privileges on zabbix.* to [email protected] identified by '<password>'; mysql> quit; # stop here if you are creating database with Zabbix packages shell> cd database/mysql shell> mysql -uzabbix -p<password> zabbix < schema.sql # stop here if you are creating database for Zabbix proxy shell> mysql -uzabbix -p<password> zabbix < images.sql shell> mysql -uzabbix -p<password> zabbix < data.sql
Please refer to this section if you are installing Zabbix from packages.
You need to have database user with permissions to create database objects. The following shell command will create user
zabbix. Specify password when prompted and repeat password (note, you may first be asked for
shell> sudo -u postgres createuser --pwprompt zabbix
Now we will set up the database
zabbix (last parameter) with the previously created user as the owner (
-O zabbix) and import initial schema and data (assuming you are in the root directory of Zabbix sources):
shell> sudo -u postgres createdb -O zabbix -E Unicode -T template0 zabbix shell> cd database/postgresql shell> cat schema.sql | sudo -u zabbix psql zabbix
Stop here if you are creating database for Zabbix proxy.
shell> cat images.sql | sudo -u zabbix psql zabbix shell> cat data.sql | sudo -u zabbix psql zabbix
We assume that a zabbix database user with password password exists and has permissions to create database objects in ORCL service located on the host Oracle database server with a user shell user having write access to /tmp directory. Zabbix requires a Unicode database character set and a
UTF8 national character set. Check current settings:
sqlplus> select parameter,value from v$nls_parameters where parameter='NLS_CHARACTERSET' or parameter='NLS_NCHAR_CHARACTERSET';
If you are creating a database for Zabbix server you need to have images on a predefined location on Oracle host. Copy all images from misc/images/png_modern to /tmp/zabbix_images directory on Oracle host:
shell> cd /path/to/zabbix-sources shell> ssh [email protected] "mkdir /tmp/zabbix_images" shell> scp -r misc/images/png_modern [email protected]:/tmp/zabbix_images/
Now prepare the database:
shell> cd database/oracle shell> sqlplus zabbix/[email protected]/ORCL sqlplus> @schema.sql # stop here if you are creating database for Zabbix proxy sqlplus> @images.sql sqlplus> @data.sql
After executing the images.sql script the /tmp/zabbix_images temporary directory can be removed.
shell> db2 "create database zabbix using codeset utf-8 territory us pagesize 32768" shell> cd database/ibm_db2 shell> db2batch -d zabbix -f schema.sql # stop here if you are creating database for Zabbix proxy shell> db2batch -d zabbix -f images.sql shell> db2batch -d zabbix -f data.sql
Zabbix frontend uses
LIMIT clauses in SQL queries. For this to work, IBM DB2 server must have DB2_COMPATIBILITY_VECTOR variable be set to 3. Run the following command before starting the database server:
shell> db2set DB2_COMPATIBILITY_VECTOR=3
shell> cd database/sqlite3 shell> sqlite3 /var/lib/sqlite/zabbix.db < schema.sql # stop here if you are creating database for Zabbix proxy shell> sqlite3 /var/lib/sqlite/zabbix.db < images.sql shell> sqlite3 /var/lib/sqlite/zabbix.db < data.sql
Return to the installation section.