Zabbix Documentation 2.0

3.04.04.45.0 (current)| In development:5.2 (devel)| Unsupported:1.82.02.22.43.23.44.2Guidelines

User Tools

Site Tools


manual:appendix:install:db_scripts

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

manual:appendix:install:db_scripts [2019/01/28 15:43]
manual:appendix:install:db_scripts [2017/11/03 06:03] (current)
martins-v IBM DB2 server must have DB2_COMPATIBILITY_VECTOR variable be set to 3
Line 1: Line 1:
 +==== 1 Database creation scripts ====
 +
 +=== Overview ===
 +
 +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.
 +
 +<note tip>''​schema.sql'',​ ''​images.sql''​ and ''​data.sql''​ files are located in the //​database//​ subdirectory of Zabbix sources. If Zabbix was installed from distribution packages, refer to the distribution documentation.</​note>​
 +
 +<note important>​For a Zabbix proxy database, **only** ''​schema.sql''​ should be imported (no images.sql nor data.sql)</​note>​
 +
 +<note important>​The order of database file import has been changed - **images** must be imported before ''​data.sql''​ now.</​note>​
 +
 +**Scripts**
 +
 +=== MySQL ===
 +
 +We assume that a //​username//​ user with //​password//​ password exists and has permissions to create database objects.
 +
 +  shell> mysql -u<​username>​ -p<​password>​
 +  mysql> create database zabbix character set utf8 collate utf8_bin;
 +  mysql> quit;
 +  shell> mysql -u<​username>​ -p<​password>​ zabbix < database/​mysql/​schema.sql
 +  # stop here if you are creating database for Zabbix proxy
 +  shell> mysql -u<​username>​ -p<​password>​ zabbix < database/​mysql/​images.sql
 +  shell> mysql -u<​username>​ -p<​password>​ zabbix < database/​mysql/​data.sql
 +
 +=== PostgreSQL ===
 +
 +We assume that a //​username//​ user exists and has permissions to create database objects.
 +
 +  shell> psql -U <​username>​
 +  psql> create database zabbix; ​
 +  psql> \q 
 +  shell> cd database/​postgresql
 +  shell> psql -U <​username>​ zabbix < schema.sql
 +  # stop here if you are creating database for Zabbix proxy
 +  shell> psql -U <​username>​ zabbix < images.sql
 +  shell> psql -U <​username>​ zabbix < data.sql
 +
 +=== Oracle ===
 +
 +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.
 +
 +If you are creating a database for Zabbix server you need to have images somewhere on the Oracle host, for example in the /​tmp/​zabbix_images folder. Copy all images from misc/​images/​png_modern to /​tmp/​zabbix_images directory on the Oracle host:
 +  shell> cd /​path/​to/​zabbix-sources  ​
 +  shell> scp -r misc/​images/​png_modern [email protected]:/​tmp/​zabbix_images ​
 +Edit the database/​oracle/​images.sql file and set ''​images_dir''​ variable to the /​tmp/​zabbix_images path:
 +  CREATE OR REPLACE DIRECTORY image_dir AS '/​tmp/​zabbix_images'​
 +Now prepare the database:
 +  shell> sqlplus zabbix/​[email protected]/​ORCL
 +  sqlplus> @database/​oracle/​schema.sql
 +  # stop here if you are creating database for Zabbix proxy
 +  sqlplus> @database/​oracle/​images.sql
 +  sqlplus> @database/​oracle/​data.sql
 +  ​
 +<​note>​Zabbix requires a UTF-8 database character set. If database is not UTF-8, it can be converted by running: ''​ALTER DATABASE NATIONAL CHARACTER SET UTF8;''</​note>​
 +
 +=== IBM DB2 ===
 +
 +  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 ''​OFFSET''​ and ''​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
 + 
 +=== SQLite ===
 +
 +  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
 +
 +<​note>​If using SQLite with Zabbix proxy, database will be automatically created if it does not exist.</​note>​
 +
 +Return to the [[manual:​installation:​install|installation section]].