Configure an external MySQL database for Ranger metadata
Overview
The Ranger’s Migrate DB schema action allows you to migrate a database schema and service users from an internal to an external database. The migration is available for the Ranger KMS and Ranger Admin service components.
Follow the steps below to configure the database server and cluster hosts for the migration.
NOTE
Before migrating to an external database, make sure that it’s set up and running.
|
MySQL server configuration
The example below demonstrates how to set up a MySQL server on a CentOS 7 host.
-
Install the necessary version of the MySQL (MariaDB) server. The CentOS 7 distribution includes a MariaDB 5.5 server by default. To install a different version, refer to the MariaDB documentation.
$ sudo yum install mariadb-server
-
Start the MariaDB service using
systemctl
.$ sudo systemctl enable mariadb.service --now
-
See if you can access the mysql console.
$ mysql -u root
From this point, refer to the relevant tab below. The commands should be launched in the mysql console.
-
Create a database for the service.
CREATE DATABASE rangerkms;
-
Create a user for the Ranger KMS service.
CREATE USER 'rangerkms'@'%' IDENTIFIED BY '<password>';
where
<password>
is a password for therangerkms
user. -
Grant permissions to the database for the created user.
GRANT ALL PRIVILEGES ON rangerkms.* TO 'rangerkms'@'%';
-
Create a database for the service.
CREATE DATABASE ranger;
-
Create a user for the Ranger Admin service.
CREATE USER 'rangeradmin'@'%' IDENTIFIED BY '<password>';
where
<password>
is a password for therangeradmin
user. -
Grant permissions to the database for the created user.
GRANT ALL PRIVILEGES ON ranger.* TO 'rangeradmin'@'%';
Once everything is done, restart the MariaDB service:
$ sudo systemctl restart mariadb
Host setup
If you haven’t previously, you need to install a MySQL JDBC driver on the Ranger KMS and/or Ranger Admin hosts. To do that, follow the steps below:
-
Download the driver.
$ wget https://downloads.adsw.io/ADH/3.2.4_arenadata2/centos/7/community/x86_64/jdbc-mysql-connector-8.0.33-1036.el7.noarch.rpm
-
Install the driver using yum.
$ yum localinstall jdbc-mysql-connector-8.0.33-1036.el7.noarch.rpm
-
See if the jdbc-mysql-connector.jar file has appeared in the /usr/share/java/ directory.
-
Configure the service in ADCM.
-
On the Clusters page, find your ADPS cluster and click its name.
-
On the Services tab, click Ranger.
-
On the opened configuration page, expand the dbks-site.xml parameter group and fill in the following parameters:
-
ranger.ks.jpa.jdbc.password
— password for a user in an external database. -
ranger.ks.jpa.jdbc.url
— a JDBC connection URL, e.g.jdbc:mysql://<database_host>:3306/rangerkms
. -
ranger.ks.jpa.jdbc.driver
— a classname for a JDBC driver. For MySQL, it’scom.mysql.jdbc.Driver
. -
ranger.ks.jdbc.sqlconnectorjar
— a path to an SQL connector jar, e.g./usr/share/java/jdbc-mysql-connector.jar
. -
ranger.ks.jpa.jdbc.user
— name of a user in an external database, e.g.rangerkms
.
-
-
In the Ranger KMS install.properties parameter group, change the
DB_FLAVOR
toMYSQL
. -
Click Save.
-
On the Clusters page, find your ADPS cluster and click its name.
-
On the Services tab, click Ranger.
-
On the opened configuration page, expand the ranger-admin-site.xml parameter group and fill in the following parameters:
-
ranger.jpa.jdbc.password
— password for a user in an external database. -
ranger.jpa.jdbc.url
— a JDBC connection URL, e.g.jdbc:mysql://<database_host>:3306/ranger
. -
ranger.jpa.jdbc.driver
— a classname for a JDBC driver. For MySQL, it’scom.mysql.jdbc.Driver
. -
ranger.jdbc.sqlconnectorjar
— a path to an SQL connector jar, e.g./usr/share/java/jdbc-mysql-connector.jar
. -
ranger.jpa.jdbc.user
— name of a user in an external database, e.g.rangeradmin
.
-
-
In the Ranger Admin install.properties parameter group, change the
DB_FLAVOR
toMYSQL
. -
Click Save.