Greenplum管理表空间Tablespace(一)

2014-11-24 15:23:28 · 作者: · 浏览: 7
Greenplum管理表空间Tablespace
create tablespace gtlions_ts1 [owner gtlions] filespace gtlionsfilespace;
alter tablespace gtlions_ts1 rename to gtlions_ts2;
alter tablespace gtlions_ts1 owner to gtlions;
表空间是基于文件空间filespace的,实际上指定的是一个文件目录,gp并不关心底层数据是如何分布的,因此你只要指定一个文件目录即可,然后gp使用这个目录来创建表空间,一个filespace可以创建多个表空间,因此并没有必要在一个逻辑磁盘位置上创建多个filespace,你也无法控制数据文件在逻辑文件系统上的具体分布。。出于性能的考虑,可能会创建多个表空间,让表空间落到不同类型的磁盘上(如果有的话)以获得性能的差异化;否则就没有必要创建和使用多个表空间。
创建filespace
使用gpfilespace工具创建,必须是superuser权限才能执行该操作。
[gpadmin@o564gtser1 ~]$ ll /data1/;ll /data1 -d
总计 0
drwxr-xr-x 2 gpadmin gpadmin 4096 04-18 16:29 /data1
[gpadmin@o564gtser1 ~]$ gpfilespace -o .
20130418:16:30:51:007324 gpfilespace:o564gtser1:gpadmin-[INFO]:-
A tablespace requires a file system location to store its database
files. A filespace is a collection of file system locations for all components
in a Greenplum system (primary segment, mirror segment and master instances).
Once a filespace is created, it can be used by one or more tablespaces.
20130418:16:30:51:007324 gpfilespace:o564gtser1:gpadmin-[INFO]:-getting config
Enter a name for this filespace
> gtlionsfilespace
Checking your configuration:
Your system has 1 hosts with 2 primary and 0 mirror segments per host.
Configuring hosts: [o564gtser1]
Please specify 2 locations for the primary segments, one per line:
primary location 1> /data1
primary location 2> /data1
Enter a file system location for the master
master location> /data1
20130418:16:31:17:007324 gpfilespace:o564gtser1:gpadmin-[INFO]:-Creating configuration file...
20130418:16:31:17:007324 gpfilespace:o564gtser1:gpadmin-[INFO]:-[created]
20130418:16:31:17:007324 gpfilespace:o564gtser1:gpadmin-[INFO]:-
To add this filespace to the database please run the command:
gpfilespace --config ./gpfilespace_config_20130418_163051
[gpadmin@o564gtser1 ~]$ cat ./gpfilespace_config_20130418_163051
filespace:gtlionsfilespace
o564gtser1:1:/data1/gtgpseg-1
o564gtser1:2:/data1/gtgpseg0
o564gtser1:3:/data1/gtgpseg1
[gpadmin@o564gtser1 ~]$ gpfilespace --config ./gpfilespace_config_20130418_163051
20130418:16:31:49:007492 gpfilespace:o564gtser1:gpadmin-[INFO]:-
A tablespace requires a file system location to store its database
files. A filespace is a collection of file system locations for all components
in a Greenplum system (primary segment, mirror segment and master instances).
Once a filespace is created, it can be used by one or more tablespaces.
20130418:16:31:49:007492 gpfilespace:o564gtser1:gpadmin-[INFO]:-getting config
Reading Configuration file: './gpfilespace_config_20130418_163051'
20130418:16:31:49:007492 gpfilespace:o564gtser1:gpadmin-[INFO]:-Performing validation on paths
..............................................................................
20130418:16:31:49:007492 gpfilespace:o564gtser1:gpadmin-[INFO]:-Connecting to database
20130418:16:31:50:007492 gpfilespace:o564gtser1:gpadmin-[INFO]:-Filespace "gtlionsfilespace" successfully created
在新的文件空间创建表空间
gtlions=# create tablespace gtlions_ts filespace gtlionsfilespace;
CREATE TABLESPACE
迁移系统默认的表空间至新创建的文件空间,必须将gp用维护