HDFS啓用SSD存儲
1.配置HDFS的數據節點
[DISK]/hadoop/hdfs/data,[SSD]/hadoop/hdfs/ssd
在所有的數據節點上掛載ssd盤到路徑/hadoop/hdfs/ssd下
並保證/hadoop/hdfs/ssd路徑的owner爲hdfs:hadoop
drwxr-x--- 3 hdfs hadoop 4096 Oct 17 19:10 /hadoop/hdfs/ssd
重啓數據節點
2. 創建使用ssd的hdfs路徑
hdfs dfs -mkdir /ssd
3.設置/ssd的存儲策略:ALL_SSD
hdfs storagepolicies -setStoragePolicy -path /ssd-policy ALL_SSD
HAWQ創建表空間
1. 創建文件空間配置文件,在master節點上執行
$hawq filespace -o tpc_h_config
filespace:fs_tpc_h
fsreplica:3
dfs_url::mycluster/ssd/fs_tpc_h
2. 創建HDFS目錄
$hdfs dfs -mkdir /ssd
$hdfs dfs -chown gpadmin:gpadmin /ssd
$hdfs dfs -ls /
3.創建文件空間
$hawq filespace -c tpc_h_config
4.創建表空間
psql
create tablespace ts_tpc_h filespace fs_tpc_h;
5. 查看當前所有表空間
SELECT spcname AS tblspc, fsname AS filespc,
fsedbid AS seg_dbid, fselocation AS datadir
FROM pg_tablespace pgts, pg_filespace pgfs,
pg_filespace_entry pgfse
WHERE pgts.spcfsoid=pgfse.fsefsoid
AND pgfse.fsefsoid=pgfs.oid
ORDER BY tblspc, seg_dbid;
HAWQ創建表
1. 建表
create table region(
r_regionkey integer,
r_name char(25),
r_comment varchar(152),
r_extra char(1)
)with(appendonly=true,orientation=parquet,compresstype=snappy)
tablespace ts_tpc_h
distributed by(r_regionkey) ;
2.查看錶使用的表空間
select c.relname, d.dat2tablespace tablespace_id, d.oid database_id, c.relfilenode table_id
from pg_database d, pg_class c, pg_namespace n
where c.relnamespace = n.oid
and d.datname = current_database()
and n.nspname = 'qbyps'
and c.relname = 'p';
SELECT pgfs.oid fs_id,pgts.oid ts_id, spcname AS tblspc, fsname AS filespc,
fsedbid AS seg_dbid, fselocation AS datadir
FROM pg_tablespace pgts, pg_filespace pgfs,
pg_filespace_entry pgfse
WHERE pgts.spcfsoid=pgfse.fsefsoid
AND pgfse.fsefsoid=pgfs.oid
ORDER BY tblspc, seg_dbid;
維護
HAWQ使用libhdfs3.so的API訪問HDFS,目前不支持存儲策略。因此,需要對寫入後的數據進行維護。
hdfs mover -p /ssd/fs_tpc_h
附錄:
存儲策略命令
列出所有存儲策略
hdfs storagepolicies -listPolicies
設置存儲策略
hdfs storagepolicies -setStoragePolicy -path <path> -policy <policy>
例如
hdfs storagepolicies -setStoragePolicy -path /tmp -policy ALL_SSD
取消存儲策略
hdfs storagepolicies -unsetStoragePolicy -path <path>
之後該目錄或者文件,以其上級的目錄爲準,如果是根目錄,那麼就是HOT
獲取存取策略
hdfs storagepolicies -getStoragePolicy -path <path>