Zabbix Documentation 5.2

3.04.05.0 (current)| In development:5.2 (devel)| Unsupported:1.82.02.22.43.23.44.24.4Guidelines

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

Both sides previous revision Previous revision
Next revision
Previous revision
manual:appendix:install:db_scripts [2019/01/28 13:44]
martins-v on -> enabled
manual:appendix:install:db_scripts [2020/03/24 15:05]
marinagen timescale DB instructions removed
Line 6: Line 6:
  
 This section provides instructions for creating a Zabbix database. A separate set of instructions is available for each supported database. This section provides instructions for creating a Zabbix database. A separate set of instructions is available 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>​ 
  
 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. 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.
 +
 === MySQL === === MySQL ===
 +
 +Character set utf8 and utf8_bin collation is required for Zabbix server/​proxy to work properly with MySQL database.
  
   shell> mysql -uroot -p<​password>​   shell> mysql -uroot -p<​password>​
   mysql> create database zabbix character set utf8 collate utf8_bin;   mysql> create database zabbix character set utf8 collate utf8_bin;
-  mysql> grant all privileges on zabbix.* to [email protected]localhost identified by '<​password>​';+  ​mysql> create user '​zabbix'​@'​localhost'​ identified by '<​password>';​ 
 +  ​mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost';
   mysql> quit;   mysql> quit;
  
-If you use Zabbix packages continue with instructions for [[manual:installation:​install_from_packages:​debian_ubuntu#​importing_data|Debian/Ubuntu]] or [[manual:installation:​install_from_packages:​rhel_centos#​importing_data|RHEL/CentOS]] to import the data into the database.+<note warning>If you are installing from Zabbix ​**packages**, stop here and continue with instructions for [[https://​www.zabbix.com/​download?​zabbix=5.0&​os_distribution=red_hat_enterprise_linux&​os_version=8&​db=mysql|RHEL/CentOS]] or [[https://​www.zabbix.com/​download?​zabbix=5.0&​os_distribution=debian&​os_version=10_buster&​db=mysql|Debian/Ubuntu]] to import the data into the database.</​note>​ 
 + 
 +If you are installing Zabbix from sources, proceed to import the data into the database. For a Zabbix proxy database, only ''​schema.sql''​ should be imported (no images.sql nor data.sql):
  
   shell> cd database/​mysql   shell> cd database/​mysql
Line 33: Line 35:
   shell> sudo -u postgres createuser --pwprompt zabbix   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):+Now we will set up the database ''​zabbix''​ (last parameter) with the previously created user as the owner (''​-O zabbix''​).
  
   shell> sudo -u postgres createdb -O zabbix -E Unicode -T template0 zabbix   shell> sudo -u postgres createdb -O zabbix -E Unicode -T template0 zabbix
  
-If you use Zabbix packages continue with instructions for [[manual:installation:​install_from_packages:​debian_ubuntu#​importing_data|Debian/Ubuntu]] or [[manual:installation:​install_from_packages:​rhel_centos#​importing_data|RHEL/CentOS]] to import the data into the database.+<note warning>If you are installing from Zabbix ​**packages**, stop here and continue with instructions for [[https://​www.zabbix.com/​download?​zabbix=5.0&​os_distribution=red_hat_enterprise_linux&​os_version=8&​db=postgresql|RHEL/CentOS]] or [[https://​www.zabbix.com/​download?​zabbix=5.0&​os_distribution=debian&​os_version=10_buster&​db=postgresql|Debian/Ubuntu]] to import the initial schema and data into the database.</​note>​ 
 + 
 +If you are installing Zabbix from sources, proceed to import the initial schema and data (assuming you are in the root directory of Zabbix sources). For a Zabbix proxy database, only ''​schema.sql''​ should be imported (no images.sql nor data.sql).
  
   shell> cd database/​postgresql   shell> cd database/​postgresql
Line 50: Line 54:
 === TimescaleDB === === TimescaleDB ===
  
-Support of TimescaleDB ​has been added on **experimental** basis in Zabbix 4.2.0.+Instructions for creating and configuring ​TimescaleDB ​are provided ​in a separate [[:​manual/​appendix/​install/​timescaledb|section]]
  
-<note warning>​TimescaleDB is supported with Zabbix server only.</​note>​ 
- 
-We assume that TimescaleDB extension has been already installed in the database (see [[https://​docs.timescale.com/​v1.1/​getting-started/​installation|installation instructions]]). 
- 
-TimescaleDB extension must also be enabled for the specific DB by executing: 
- 
-  echo "​CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;"​ | sudo -u postgres psql zabbix 
- 
-Running this command requires database administrator privileges. ​ 
- 
-The ''​timescaledb.sql''​ script is located in database/​postgresql. The script must be run after the regular PostgreSQL database has been created with initial schema/data (see section above): 
- 
-  cat timescaledb.sql | sudo -u zabbix psql zabbix 
- 
-//Note// that the ''​timescaledb.sql''​ script sets the following housekeeping parameters (from //​Administration//​ -> //General// -> //​Housekeeping//​):​ 
- 
-  * Override item history period 
-  * Override item trend period 
- 
-In order to use partitioned housekeeping for history and trends both these options must be enabled. It's possible to use TimescaleDB partitioning only for trends (by setting //Override item trend period//) or only for history (//Override item history period//). 
 === Oracle === === Oracle ===
  
Line 92: Line 76:
   sqlplus> @images.sql   sqlplus> @images.sql
   sqlplus> @data.sql   sqlplus> @data.sql
-  ​+ 
 +<note tip>​Please set the initialization parameter CURSOR_SHARING=FORCE for best performance.</​note>​ 
 Now the temporary directory can be removed: Now the temporary directory can be removed:
  
   shell> ssh [email protected]_host "rm -rf /​tmp/​zabbix_images"​   shell> ssh [email protected]_host "rm -rf /​tmp/​zabbix_images"​
- 
-=== 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 ​ 
- 
-<​note>​It is important to set UTF-8 locale for Zabbix server, Zabbix proxy and the web server running Zabbix frontend. Otherwise text information from Zabbix will be interpreted by IBM DB2 server as non-UTF-8 and will be additionally converted on the way from Zabbix to the database and back. The database will store corrupted non-ASCII characters.</​note>​ 
- 
-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 === === SQLite ===