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.

  1. 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
  2. Start the MariaDB service using systemctl.

    $ sudo systemctl enable mariadb.service --now
  3. 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.

  • Ranger KMS

  • Ranger Admin

  1. Create a database for the service.

    CREATE DATABASE rangerkms;
  2. Create a user for the Ranger KMS service.

    CREATE USER 'rangerkms'@'%' IDENTIFIED BY '<password>';

    where <password> is a password for the rangerkms user.

  3. Grant permissions to the database for the created user.

    GRANT ALL PRIVILEGES ON rangerkms.* TO 'rangerkms'@'%';
  1. Create a database for the service.

    CREATE DATABASE ranger;
  2. Create a user for the Ranger Admin service.

    CREATE USER 'rangeradmin'@'%' IDENTIFIED BY '<password>';

    where <password> is a password for the rangeradmin user.

  3. 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:

  1. 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
  2. Install the driver using yum.

    $ yum localinstall jdbc-mysql-connector-8.0.33-1036.el7.noarch.rpm
  3. See if the jdbc-mysql-connector.jar file has appeared in the /usr/share/java/ directory.

  4. Configure the service in ADCM.

  • Ranger KMS

  • Ranger Admin

  1. On the Clusters page, find your ADPS cluster and click its name.

  2. On the Services tab, click Ranger.

  3. 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’s com.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.

  4. In the Ranger KMS install.properties parameter group, change the DB_FLAVOR to MYSQL.

  5. Click Save.

  1. On the Clusters page, find your ADPS cluster and click its name.

  2. On the Services tab, click Ranger.

  3. 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’s com.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.

  4. In the Ranger Admin install.properties parameter group, change the DB_FLAVOR to MYSQL.

  5. Click Save.

Migration

  1. Launch the Migrate DB schema action for Ranger.

  2. Choose the components for which you want to launch the migration.

    Options for the Migrate DB schema action
    The Migrate DB schema action
  3. Confirm the action.

Found a mistake? Seleсt text and press Ctrl+Enter to report it