HFile and Write ahead log (WAL) in HBase are not encrypted by default. To encrypt them, perform the following operations.
sh ${BIGDATA_HOME}/FusionInsight_HD_8.1.0.1/install/FusionInsight-HBase-2.2.3/hbase/bin/hbase-encrypt.sh <path>/hbase.jks <type> <length> <alias>
For example, to generate an SMS4 encryption key, run the following command:
sh ${BIGDATA_HOME}/FusionInsight_HD_8.1.0.1/install/FusionInsight-HBase-2.2.3/hbase/bin/hbase-encrypt.sh /home/hbase/conf/hbase.jks SMS4 16 omm
To generate an AES encryption key, run the following command:
sh ${BIGDATA_HOME}/FusionInsight_HD_8.1.0.1/install/FusionInsight-HBase-2.2.3/hbase/bin/hbase-encrypt.sh /home/hbase/conf/hbase.jks AES 128 omm
<key_Path_Name> indicates the path of the key file. For example, if the path of the key file is /home/hbase/conf/hbase.jks, set this parameter to jceks:///home/hbase/conf/hbase.jks.
<encrypted_password> indicates the encrypted password generated during the key file creation. The parameter value is displayed in ciphertext. Run the following command as user omm to obtain the related encrypted password on the nodes where HBase service is installed:
sh ${BIGDATA_HOME}/FusionInsight_HD_8.1.0.1/install/FusionInsight-HBase-2.2.3/hbase/bin/hbase-encrypt.sh
After running the command, you need to enter <password>. The password is the same as that entered in 1.
create '<table name>', {NAME => 'd', ENCRYPTION => '<type>'}
public void testCreateTable() { String tableName = "user"; Configuration conf = getConfiguration(); HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(tableName)); HColumnDescriptor hcd = new HColumnDescriptor("d"); //Set the encryption mode to SMS4 or AES. hcd.setEncryptionType("<type>"); htd.addFamily(hcd); HBaseAdmin admin = null; try { admin = new HBaseAdmin(conf); if(!admin.tableExists(tableName)) { admin.createTable(htd); } } catch (IOException e) { e.printStackTrace(); } finally { if(admin != null) { try { admin.close(); } catch (IOException e) { e.printStackTrace(); } } } }
In this case, you can perform the following steps to encrypt the inserted data:
flush'<table_name>'
alter'<table_name>',NAME=>'<column_name>',ENCRYPTION => '<type>'
enable'<table_name>'
A new data record must be inserted so that the HFile will generate a new HFile and the unencrypted data inserted previously will be rewritten and encrypted.
put'<table_name>','id2','f1:c1','value222222222222222222222222222222222'
flush'<table_name>'
Modifying a key file has a great impact on the system and will cause data loss in case of any misoperation. Therefore, this operation is not recommended.
During the HFile and WAL Encryption operation, the related key file must be generated and its password must be set to ensure system security. After a period of running, you can replace the key file with a new one to encrypt HFile and WAL.
sh ${BIGDATA_HOME}/FusionInsight_HD_8.1.0.1/install/FusionInsight-HBase-2.2.3/hbase/bin/hbase-encrypt.sh <path>/hbase.jks <type> <length> <alias-new>
For example, to generate an SMS4 encryption key, run the following command:
sh ${BIGDATA_HOME}/FusionInsight_HD_8.1.0.1/install/FusionInsight-HBase-2.2.3/hbase/bin/hbase-encrypt.sh /home/hbase/conf/hbase.jks SMS4 16 omm_new
To generate an AES encryption key, run the following command:
sh ${BIGDATA_HOME}/FusionInsight_HD_8.1.0.1/install/FusionInsight-HBase-2.2.3/hbase/bin/hbase-encrypt.sh /home/hbase/conf/hbase.jks AES 128 omm_new
Administrators need to select a safe procedure to distribute keys based on the enterprise security requirements.
major_compact '<table_name>'
sh ${BIGDATA_HOME}/FusionInsight_HD_8.1.0.1/install/FusionInsight-HBase-2.2.3/hbase/bin/hbase-encrypt.sh <path>/hbase.jks <alias-old>
For example:
sh ${BIGDATA_HOME}/FusionInsight_HD_8.1.0.1/install/FusionInsight-HBase-2.2.3/hbase/bin/hbase-encrypt.sh /home/hbase/conf/hbase.jks omm
To ensure operations can be successfully performed, the <path>/hbase.jks directory needs to be created in advance, and the cluster operation user must have the rw permission of this directory.