Introduction
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:-
Prerequisites
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
- gcc-c++
sudo yum install gcc-c++
- pyodbc
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
sudo mysql_secure_installation
- 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'@'%';
\q
- 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;
show databases;
\q
Add Senzing Schema to MariaDB
mysql -u g2 -p G2 < /opt/senzing/g2/data/g2core-schema-mysql-create.sql
- Where:
- 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.
Website Download
- 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."
wget 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
wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
- 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 to /etc/odbc.ini, you need to edit the file with root/sudo privileges.
[G2]
Driver = MYSQL
Database = G2
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]
[MYSQL]
Driver=/usr/lib64/libmyodbc8w.so
UsageCount=1
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;
quit
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
G2Connection=mysql://g2:password4g2@127.0.01:3306/?schema=G2
- G2Module.ini - Change the CONNECTION string to
CONNECTION=mysql://g2:password4g2@127.0.01:3306/?schema=G2
Where:-
- 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 Export
Perform a test load of the supplied sample data and then perform a G2 export creation to test the new database setup.
- Source setupEnv
cd /opt/senzing/g2
. setupEnv
- Load the G2 sample data
cd python/
python G2Loader.py -P -p demo/sample/project.csv
- Create the G2 export file
python G2Export.py
Comments
0 comments
Please sign in to leave a comment.