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_hfsreplica:3dfs_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_hdistributed 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>
Apache HAWQ 创建使用SSD磁盘的表
原文地址:http://blog.51cto.com/1196740/2160862