1. 程式人生 > >Hadoop筆記之五——java訪問hdfs的許可權設定

Hadoop筆記之五——java訪問hdfs的許可權設定

java程式碼取訪問hdfs的時候,預設不是以hdfs系統所屬使用者的身份訪問的,要想以主使用者身份訪問,有兩種方式。

        1、             配置連線hadoop的時候,加入如下程式碼。

            //客戶端使用者與檔案所屬者使用者 名稱是否一樣             System.setProperty("HADOOP_USER_NAME", "hadoop");

         2、             可以將hdfs伺服器的配置檔案中的dfs.permissions.enabled屬性配置為false,關閉許可權檢查功能

            <property>               <name>dfs.permissions.enabled</name>               <value>true</value>               <description>                 If "true", enable permission checking in HDFS.                 If "false", permission checking is turned off,                 but all other behavior is unchanged.                 Switching from one parameter value to the other does not change the mode,                 owner or group of files or directories.               </description>             </property>