㈠ hadoop hdfs的默認目錄問題
frostfish425說的是對的!/user/hadoop是安裝目錄,就是說你hadoop相關的配置和代碼都是放在這個位置,這個你自己定就可以了,但是要注意你配置文件和環境變數中的相關配置都要相應的發生改變。而/tmp/hadoop-hadoop/dfs/name是你配置的hdfs目錄,也就是數據存放目錄,在hdfs-site.xml中配置的,當然你也可以改變這個目錄!這個目錄掛載的磁碟要足夠大,不然數據存放不下,你初始化的時候報的這個Storage directory /tmp/hadoop-hadoop/dfs/name has been successfully formatted其實就是在/tmp/hadoop-hadoop/dfs這個目錄下創建了name目錄,意思就是告訴你,數據存放目錄已經創建成功了!
㈡ 怎麼查看hdfs linux 路徑
可以fdisk -l 看到 但是它本身是自己的文件系統 就是hdfs 你從linux本地是看不到的 想看裡面的文件可以使用如下命令 hadoop fs -ls
㈢ hadoop程序怎麼訪問hdfs路徑
先用hdfsGetPathInfo 得到一個hdfsFileInfo類型的結構體, get_real_path(dsh, s, real_path); hdfsFileInfo * pt_hdfs_file_info = hdfsGetPathInfo(hdfs,real_path);// 這個結構體中有個kind屬性,就是來區分是文件還是目錄 typedef struct
~如果你認可我的回答,請及時點擊【採納為滿意回答】按鈕
~~手機提問的朋友在客戶端右上角評價點【滿意】即可。
~你的採納是我前進的動力
~~O(∩_∩)O,記得好評和採納,互相幫助,謝謝。
㈣ hdfs怎麼查看目錄路徑
用ls命令, 如果返回一行說明是文件,如果多行則表示目錄
hadoop fs -ls $path | grep $path | wc -l
㈤ 如何獲取文件在hdfs中的路徑
如何獲取文件在hdfs中的路徑
hadoop有提供相應的腳本去驗證文件目錄是否存在的:
-bash-3.2$ hadoop fs -help
...
-test -[defsz] <path>: Answer various questions about <path>, with result via exit status.
-d return 0 if <path> is a directory.
-e return 0 if <path> exists.
-f return 0 if <path> is a file.
-s return 0 if file <path> is greater than zero bytes in size.
-z return 0 if file <path> is zero bytes in size.
else, return 1.
測試的hdfs目錄中:
-bash-3.2$ hadoop fs -ls /user/hive/warehouse/yhd_gmv_month
Found 3 items
drwxr-xr-x - deploy supergroup 0 2014-08-25 11:15 /user/hive/warehouse/yhd_gmv_month/ds=2014-08-24
drwxr-xr-x - deploy supergroup 0 2014-08-26 13:02 /user/hive/warehouse/yhd_gmv_month/ds=2014-08-25
drwxr-xr-x - deploy supergroup 0 2014-08-27 08:09 /user/hive/warehouse/yhd_gmv_month/ds=2014-08-26
檢驗昨天產生的目錄是否產生的shell腳本:
yesterday=$(date -d '-1 day' '+%Y-%m-%d')
hadoop fs -test -e /user/hive/warehouse/yhd_gmv_month/ds=$yesterday
if [ $? -eq 0 ] ;then
echo 'exist'
else
echo 'Error! Directory is not exist'
fi
驗證存在的輸出結果如下:
-bash-3.2$ hadoop fs -test -e /user/hive/warehouse/yhd_gmv_month/ds=$yesterday
if [ $? -eq 0 ] ;then
echo 'exist'
else
echo 'Error! Directory is not exist Or Zero bytes in size'
fi
-bash-3.2$ if [ $? -eq 0 ] ;then
> echo 'exist'
> else
> echo 'Error! Directory is not exist Or Zero bytes in size'
> fi
exist
㈥ hadoop怎麼訪問hdfs路徑
先用hdfsGetPathInfo 得到一個hdfsFileInfo類型的結構體,
get_real_path(dsh, s, real_path);
hdfsFileInfo * pt_hdfs_file_info = hdfsGetPathInfo(hdfs,real_path);//
這個結構體中有個kind屬性,就是來區分是文件還是目錄
typedef struct {
tObjectKind mKind; /* file or directory */
char *mName; /* the name of the file */
tTime mLastMod; /* the last modification time for the file in seconds */
tOffset mSize; /* the size of the file in bytes */
short mReplication; /* the count of replicas */
tOffset mBlockSize; /* the block size for the file */
char *mOwner; /* the owner of the file */
char *mGroup; /* the group associated with the file */
short mPermissions; /* the permissions associated with the file */
tTime mLastAccess; /* the last access time for the file in seconds */
} hdfsFileInfo;
㈦ 關於hdfs的物理存儲路徑問題
我沒用過Hive,但HDFS的存儲機制都是一樣的。
你所謂的物理位置指的是在操作系統中的磁碟路徑?
這個路徑是在Hadoop配置的時候寫在hdfs-site.xml文件的dfs.datanode.data.dir欄位里的,在每個datanode的這個文件夾里存著該節點上存儲的所有數據塊block,以blk_打頭。
dfs.namenode.data.dir指定的文件夾在namenode中則存在元數據。
所以即便你知道這個所謂的物理路徑也沒什麼用,數據都是以block形式存在的,大的數據還由好多個block組成,而且每個block還有副本。
㈧ 查看Hadoop安裝路徑
查看hadoop二進制文件路徑
查看hadoop二進制文件鏈接路徑
由此可知,hadoop安裝目錄為 /usr/local/Cellar/hadoop/3.1.1
而 core-site.xml 、 hdfs-site.xml 等配置文件的存放目錄為
/usr/local/Cellar/hadoop/3.1.1/libexec/etc/hadoop
㈨ hdfs命令查找文件所在路徑
指令
hadoop fsck /user/hadoop/filename -files -blocks -locations -racks
-files 文件分塊信息,
-blocks 在帶-files參數後才顯示block信息
-locations 在帶-blocks參數後才顯示block塊所在datanode的具體IP位置,
-racks 在帶-files參數後顯示機架位置
注意:此命令只能在namenode里輸入,在datanode里輸入會報錯的