By default Senzing is set to use an embedded SQLite database. This article describes the steps to configure Senzing to use MariaDB as the entity repository and how to create the Senzing schema within a MariaDB database.
CentOS 7 was used in testing the steps outlined herein and the latest version of MariaDB available at the time; which was 10.3. This article assumes you are already a MariaDB user or familiar with MariaDB, it only briefly covers the installation steps of MariaDB. If you require additional MariaDB information the following links will be useful:-
In addition to the dependencies outlined in the Introduction: Quickstart article the following operating system prerequisites and packages are required. You must ensure the dependencies in the quickstart article are met before proceeding.
- sudo or root privileges to install MariaDB and issue system commands
- unixODBC and unixODBC-devel
sudo yum install unixODBC unixODBC-devel
sudo yum install gcc-c++
sudo yum install pyodbc
Install and Basic MariaDB Setup
The following is a brief overview of the steps required to install MariaDB. For full details on installing MariaDB on Linux please see Getting, Installing, and Upgrading MariaDB.
- Generate the MariaDB repository information
- Setting up MariaDB Repositories
- CentOS -> CentOS 7 (x86_64) -> 10.3 Stable (or latest version)
- Record the MariaDB repository information
- Create a new repository file by pasting in the information generated from the previous step and save the file
sudo vi /etc/yum.repos.d/MariaDB.repo
- Install MariaDB
sudo yum install MariaDB-server MariaDB-client
- Start MariaDB and check the status
sudo systemctl start mariadb
sudo systemctl status mariadb
- If started successfully you will see output similar to the following
- To start MariaDB at system boot
sudo systemctl enable mariadb
- It is recommended to harden security settings
- Set the password for root access
- Answer 'Y' to all questions (unless your organizations policies differ)
- Test connection and setup G2 user. Check the following permissions meet your organisations policies. The user name 'g2' is used in the following example, change as appropriate to the user id your G2 installation is run under
mysql -u root -p
- You will be prompted for your new root password
create user 'g2'@'%' identified by '<g2_user_password>';
- Change <your_password> to your desired password to access MariaDB
grant all privileges on G2.* to 'g2'@'%';
grant all privileges on G2_REPORT.* to 'g2'@'%';
- Test the new g2 user and create the G2 databases
mysql -u g2 -p
- You will be prompted for the password you used for <g2_user_password>
create database G2 character set=utf8 collate=utf8_bin;
create database G2_REPORT character set=utf8 collate=utf8_bin;
Add Senzing Schemas to MariaDB
- Core Schema
mysql -u g2 -p G2 < /opt/senzing/g2/data/g2core-schema-mysql-create.sql
- Report Schema
mysql -u g2 -p G2_REPORT < /opt/senzing/g2/data/report_schema_mysql-create.sql
- g2 = User id previously used in above commands, substitute your user id if different
- -p = Will prompt for the password you used for <g2_user_password>
- /opt/senzing/g2/... = Default Senzing deployment directory
Configure and Test ODBC
At this time Senzing uses the MySQL ODBC connector, not the MariaDB connector.
Download the MySQL repository installation package directly from the yum repository website or with the wget command.
- MySQL Yum Repository
- Locate the Red Hat Enterprise Linux 7 / Oracle Linux 7 package
- Select Download
- If you don't have a MySQL account choose "No thanks, just start my download."
- On the MySQL Yum Repository website locate the Red Hat Enterprise Linux 7 / Oracle Linux 7 package and then the package name in brackets under the title
- Use wget with this name string to directly download the package
- Once downloaded add the repository information by installing the package, and then install the MySQL ODBC connector.
sudo yum localinstall mysql80-community-release-el7-1.noarch.rpm
sudo yum install mysql-connector-odbc mysql-community-libs
Once installed, add the following entries to /etc/odbc.ini, you need to edit the file with root/sudo privileges.
Driver = MYSQL
Database = G2
Server = 127.0.0.1
Port = 3306
Driver = MYSQL
Database = G2_REPORT
Server = 127.0.0.1
Port = 3306
Modify /etc/odbcinst.ini (also with root/sudo) and comment out the stanza header for [MySQL ODBC 8.0 Unicode Driver] and add the [MYSQL] header. If you already have a [MYSQL] stanza section are not using it (from an old driver) you can comment out the entire old [MYSQL] section.
#[MySQL ODBC 8.0 Unicode Driver]
Test ODBC is working with MySQL against the G2 database, you should see a result set of count =0 from the SQL select statement.
isql -v G2 g2 <user_password>
select count(*) from OBS_ENT;
Configure G2Project.ini and G2Module.ini
Modify the following ini files to reference the new MariaDB databases and schemas. These files are located in /opt/senzing/g2/python (if you've not altered the default location). You can comment out the current lines by prefixing them with # and adding the modified ones below.
- G2Project.ini - Change the G2Connection and ODSConnection strings to
- G2Module.ini - Change the CONNECTION string to
- g2 = G2 userid
- password4g2 = Password for the G2 userid
- 127.0.0.1 = G2 server address
- 3306 = MySQL port number
Run a Test G2 Load and G2 Report
Perform a test load of the supplied sample data and then perform a G2 report creation to test the new database setup.
- Source setupEnv
- Load the G2 sample data
python G2Loader.py -P -p demo/sample/project.csv
- Create the g2report file