This section contains instructions for creating Oracle database and configuring connections between the database and Zabbix server, proxy, and frontend.
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. 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';
Now prepare the database:
shell> cd /path/to/zabbix-sources/database/oracle
shell> sqlplus zabbix/password@oracle_host/ORCL
sqlplus> @schema.sql
# stop here if you are creating database for Zabbix proxy
sqlplus> @images.sql
sqlplus> @data.sql
Please set the initialization parameter CURSOR_SHARING=FORCE for best performance.
Zabbix supports two types of connect identifiers (connection methods):
Connection configuration parameters for Zabbix server and Zabbix proxy can be set in the configuration files. Important parameters for the server and proxy are DBHost, DBUser, DBName and DBPassword. The same parameters are important for the frontend: $DB["SERVER"], $DB["PORT"], $DB["DATABASE"], $DB["USER"], $DB["PASSWORD"].
Zabbix uses the following connection string syntax:
<connect_identifier> can be specified either in the form of "Net Service Name" or "Easy Connect".
Easy Connect uses the following parameters to connect to the database:
Example:
Database parameters set in the server or proxy configuration file (zabbix_server.conf and zabbix_proxy.conf):
Connection string used by Zabbix to establish connection:
During Zabbix frontend installation, set the corresponding parameters in the Configure DB connection step of the setup wizard:
Alternatively, these parameters can be set in the frontend configuration file (zabbix.conf.php):
$DB["TYPE"] = 'ORACLE';
$DB["SERVER"] = 'localhost';
$DB["PORT"] = '1521';
$DB["DATABASE"] = 'ORCL';
$DB["USER"] = 'myusername';
$DB["PASSWORD"] = 'mypassword';
Since Zabbix 5.4.0 it is possible to connect to Oracle by using net service name.
<net_service_name> is a simple name for a service that resolves to a connect descriptor.
In order to use the service name for creating a connection, this service name has to be defined in the tnsnames.ora file located on both the database server and the client systems. The easiest way to make sure that the connection will succeed is to define the location of tnsnames.ora file in the TNS_ADMIN environment variable. The default location of the tnsnames.ora file is:
A simple tnsnames.ora file example:
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ORCL)
)
)
To set configuration parameters for the "Net Service Name" connection method, use one of the following options:
In the second case, the TWO_TAKS environment variable has to be set. It specifies the default remote Oracle service (service name). When this variable is defined, the connector connects to the specified database by using an Oracle listener that accepts connection requests. This variable is for use on Linux and UNIX only. Use the LOCAL environment variable for Microsoft Windows.
Example:
Connect to a database using Net Service Name set as ORCL and the default port. Database parameters set in the server or proxy configuration file (zabbix_server.conf and zabbix_proxy.conf):
During Zabbix frontend installation, set the corresponding parameters in the Configure DB connection step of the setup wizard:
Alternatively, these parameters can be set in the frontend configuration file (zabbix.conf.php):
$DB["TYPE"] = 'ORACLE';
$DB["SERVER"] = '';
$DB["PORT"] = '0';
$DB["DATABASE"] = 'ORCL';
$DB["USER"] = 'myusername';
$DB["PASSWORD"] = 'mypassword';
Connection string used by Zabbix to establish connection: