Change default permission of hive database
Category : Hive
When you create a database or internal tables in hive cli then by default it creates with 777 permission.Even though if you have umask in hdfs then also it will be same permission. But now you can change it with the help of following steps.
1.From the command line in the Ambari server node, edit the file
vi /var/lib/ambari–server/resources/common–services/HIVE/0.12.0.2.0/package/scripts/hive.py
Search for hive_apps_whs_dir which should go to this block:
params.HdfsResource(params.hive_apps_whs_dir,
type=“directory”,
action=“create_on_execute”,
owner=params.hive_user,
group=params.user_group,
mode=0755
)
2. Modify the value for mode from 0777 to the desired permission, for example 0750.Save and close the file.
3. Restart the Ambari server to propagate the change to all nodes in the cluster:
ambari–server restart
4. From the Ambari UI, restart HiveServer2 to apply the new permission to the warehouse directory. If multiple HiveServer2 instances are configured, any one instance can be restarted.
hive> create database test2;
OK
Time taken: 0.156 seconds
hive> dfs -ls /apps/hive/warehouse;
Found 9 items
drwxrwxrwx – hdpuser hdfs 0 2016-09-08 01:54 /apps/hive/warehouse/test.db
drwxr-xr-x -hdpuser hdfs 0 2016-09-08 02:04 /apps/hive/warehouse/test1.db
drwxr-x— -hdpuser hdfs 0 2016-09-08 02:09 /apps/hive/warehouse/test2.db
I hope this will help you to serve your purpose.
1 Comment
john
March 5, 2019 at 3:56 amI used the above method to modify the directory, but it did not take effect. May I ask what may be the reason?
1.vi /var/lib/ambari–server/resources/common–services/HIVE/0.12.0.2.0/package/scripts/hive.py
mode=0750
2.Save and close the file
3.ambari-server restart
4.hiveserver2 restart