Enabling Hadoop encryption
You must enable encryption in Hadoop.
Procedure
- Create a service user. For example, useradd kms.
- Copy the Hadoop-KMS package to the home directory. For example, enter the following command:
cp /usr/iop/current/hadoop-client/mapreduce.tar.gz /home/kms/mapreduce.tar.gz - Extract the archive. For example, enter the following command:
export KMS_ROOT=/home/kms/ cd $KMS_ROOT tar -xvf mapreduce.tar.gz - Start the KMS server.
- If you do not have the JAVA_HOME variable set, run the following
command:
export JAVA_HOME=/usr/jdk64/java-1.8.0-openjdk-1.8.0.77-0.b03.el7_2.x86_64/jreEnsure that you use the appropriate path for your environment.
- Go to the $KMS_ROOT/hadoop/sbin/ directory.
- Enter the following command: ./kms.sh run
Wait until you see that the server started.
- If you do not have the JAVA_HOME variable set, run the following
command:
- From the Ambari console, update the KMS server.
- In the Ambari console, click the HDFS service.
- Click Configs > Advanced.
- Add the following values:
Configuration section Key Value1 Advanced core-site hadoop.security.key.provider.path kms://http@<KMS Server IP>:16000/kms Advanced hdfs-site dfs.encryption.key.provider.uri kms://http@<KMS Server IP>:16000/kms
- Generate a key as a regular user.
- Log on as a regular user, such as ambari-qa.
- Create the key by entering the following command: hadoop key create ambariqa-key
- Create an encryption zone for the /user/sifsuser
directory.
- Log in as the hdfs user.
- Run the following commands:
hdfs crypto -createZone -keyName ambariqa-key -path /user/sifsuser hdfs dfs -chown sifsuser:hadoop /user/sifsuserTip: If you encounter any errors, you can check the following log directories:- /var/log/hadoop/hdfs
- /var/log/ambari-server
- /var/log/ambari-agent
- /var/lib/ambari-agent/data
- Verify that the contents are encrypted.
- Log in as the sifsuser.
- Copy a test data file to the /user/sifsuser directory.
- Run the following commands:
hdfs dfs –put testdata.txt /user/sifsuser/ hdfs dfs -cat /user/sifsuser/testdata.txt hdfs dfs -cat /.reserved/raw/user/sifsuser/testdata.txtThis should show decrypted, clear text data.
Run the following command:
hdfs dfs -cat /.reserved/raw/user/sifsuser/testdata.txtThis should show encrypted data.
Note: If the Kerberos session has expired, you can run the kinit command.