Migrating the Master Key from HSM to Ranger KMS DB
How to migrate the master key from Luna HSM to Ranger KMS DB.
-
Go to the Ranger KMS directory.
Example:
cd /opt/cloudera/parcels/CDH/lib/ranger-kms
-
Export the below variables
export JAVA_HOME=/usr/java/jdk1.8.0_232-cloudera
export RANGER_KMS_HOME=/opt/cloudera/parcels/CDH/lib/ranger-kms
-
Get the active directiory for rangerkms process and copy the conf
directory
ps -ef | grep rangerkms
From the output of the above command, get the value of the rangerkms conf directory.
export RANGER_KMS_CONF=/var/run/cloudera-scm-agent/process/xxxx-ranger_kms-RANGER_KMS_SERVER/conf export SQL_CONNECTOR_JAR=/opt/cloudera/cm/lib/postgresql-42.1.4.jre7.jar
-
Get the active directory for rangerkms process and copy the active directory path.
ps -ef | grep rangerkms
-
Open proc.json and get the value for HADOOP_CREDSTORE_PASSWORD
vim /var/run/cloudera-scm-agent/process/xxxx-ranger_kms-RANGER_KMS_SERVER/proc.json export HADOOP_CREDSTORE_PASSWORD=hadoop_credstore_pwd
-
Run the following command:
[root@os-mv-711-1 ranger-kms]# ${JAVA_HOME}/bin/java -cp "${RANGER_KMS_HOME}/cred/lib/*:${RANGER_KMS_CONF}:${RANGER_KMS_HOME}/ews/webapp/WEB-INF/classes/lib/*:${SQL_CONNECTOR_JAR}:${RANGER_KMS_HOME}/ews/webapp/config:${RANGER_KMS_HOME}/ews/lib/*:${RANGER_KMS_HOME}/ews/webapp/lib/*:${RANGER_KMS_HOME}/ews/webapp/META-INF:${RANGER_KMS_CONF}/*" org.apache.hadoop.crypto.key.HSM2DBMKUtil LunaProvider <partition-name>
-
Run the following command:
./HSMMK2DB.sh <provider> <HSM_PARTITION_NAME>
Example :./HSMMK2DB.sh LunaProvider
- Enter the partition password when requested.
-
Login to the database that Ranger KMS is using, and validate whether master key is successfully migrated.
Example : If the Ranger KMS database is Postgres, then
su - postgres psql Password : cloudera \l Find rangerkms db \c rangerkms select * from ranger_masterkey;
-
Login to CM and disable the HSM
ranger.ks.hsm.enabled = false
- Restart Ranger KMS.
-
Delete the master key from the partition.
/usr/safenet/lunaclient/bin/ ./lunacm lunacm:>role login -n co enter password: ********** lunacm:>par con lunacm:>par clear proceed