Zabbix Documentation 3.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

Both sides previous revision Previous revision
Next revision
Previous revision
manual:appendix:install:db_scripts [2016/02/22 09:53]
glebs.ivanovskis [IBM DB2] fixed typo
manual:appendix:install:db_scripts [2020/02/20 13:53]
martins-v removing duplicated instructions
Line 11: Line 11:
 <note important>​For a Zabbix proxy database, **only** ''​schema.sql''​ should be imported (no images.sql nor data.sql)</​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.
  
 **Scripts** **Scripts**
  
 === MySQL === === MySQL ===
 +
 +Character set utf8 and utf8_bin collation is required for Zabbix server 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;
 +
 +<note warning>​If you are installing from Zabbix packages, stop here and continue with instructions for [[manual:​installation:​install_from_packages|package installation]] to import the data into the database.</​note>​
 +
 +<note warning> Zabbix server prior to 4.4 cannot work correctly with newer MariaDB versions out of the box. See [[:​manual/​installation/​known_issues#​MariaDB_row_size_error|Known issues]] for required database modifications. </​note>​
 +
 +If you are installing Zabbix from sources, proceed to import the data into the database:
 +
   shell> cd database/​mysql   shell> cd database/​mysql
   shell> mysql -uzabbix -p<​password>​ zabbix < schema.sql   shell> mysql -uzabbix -p<​password>​ zabbix < schema.sql
Line 25: Line 36:
   shell> mysql -uzabbix -p<​password>​ zabbix < images.sql   shell> mysql -uzabbix -p<​password>​ zabbix < images.sql
   shell> mysql -uzabbix -p<​password>​ zabbix < data.sql   shell> mysql -uzabbix -p<​password>​ zabbix < data.sql
 +
  
 === PostgreSQL === === PostgreSQL ===
-We assume that a //​username//​ user exists and has permissions to create database objects. 
  
-  ​shell> psql -U <​username>​ +Please refer to [[manual:​installation:​install_from_packages|this section]] if you are installing Zabbix from packages. 
-  ​psqlcreate ​database zabbix + 
-  ​psql\q +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 ''​sudo''​ password):​ 
 + 
 +  ​shellsudo -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): 
 + 
 +  ​shellsudo -u postgres createdb -O zabbix -E Unicode -T template0 zabbix
   shell> cd database/​postgresql   shell> cd database/​postgresql
-  shell> ​psql -U <​username>​ zabbix < schema.sql +  shell> ​cat schema.sql ​| sudo -u zabbix psql zabbix 
-  # stop here if you are creating database for Zabbix proxy + 
-  shell> ​psql -U <​username>​ zabbix < images.sql +Stop here if you are creating database for Zabbix proxy
-  shell> psql -U <​username> ​zabbix < data.sql+ 
 +  shell> ​cat images.sql ​| sudo -u zabbix psql zabbix 
 +  shell> ​cat data.sql | sudo -u zabbix psql zabbix 
 + 
 +<note important>​The above commands are provided as an example that will work in most of GNU/Linux installations. You can use different commands, e. g. "psql -U <​username>​" depending on how your system/​database are configuredIf you have troubles setting up the database please consult your Database administrator. 
 +</​note>​
  
 === Oracle === === 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.+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: 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> cd /​path/​to/​zabbix-sources 
-  shell> scp -r misc/​images/​png_modern [email protected]:/​tmp/​zabbix_images ​ +  shell> ssh [email protected] "mkdir /​tmp/​zabbix_images"​ 
 +  shell> scp -r misc/​images/​png_modern [email protected]:/​tmp/​zabbix_images/
 Now prepare the database: Now prepare the database:
   shell> cd database/​oracle   shell> cd database/​oracle
Line 51: Line 75:
   sqlplus> @images.sql   sqlplus> @images.sql
   sqlplus> @data.sql   sqlplus> @data.sql
-  ​ 
-After executing the images.sql script the /​tmp/​zabbix_images temporary directory can be removed. 
-  ​ 
-<​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>​ 
  
 +<note tip>​Please set the initialization parameter CURSOR_SHARING=FORCE for best performance.</​note>​
 +
 +After executing the images.sql script the /​tmp/​zabbix_images temporary directory can be removed.
 === IBM DB2 === === IBM DB2 ===
  
Line 66: Line 89:
  
 <​note>​It is important to set UTF-8 locale for Zabbix server, Zabbix proxy and 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>​ <​note>​It is important to set UTF-8 locale for Zabbix server, Zabbix proxy and 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 ===