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.
Scripts
MySQL (we assume that user username 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 user username 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 user zabbix with password password exists and has permissions to create database objects in service ORCL):
If you are creating database for Zabbix server you need to have images somewhere on Oracle host:
# copy directory create/images/old_images somewhere on Oracle server (e.g. /home/oracle): shell> scp -r create/images/old_images user@host:/home/oracle # edit file database/oracle/images.sql and set images_dir variable to where you have copied them (e. g. "/home/oracle/old_images"): CREATE OR REPLACE DIRECTORY image_dir AS '/home/oracle/old_images'
Now prepare the database:
shell> sqlplus zabbix/password@host/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
ALTER DATABASE NATIONAL CHARACTER SET UTF8;
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
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
Return to installation section.
Data source: Zabbix