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用维护模式启动,迁移完成后重启数据库,默认的文件空间目录建议不要删除:
[gpadmin@o564gtser1 ~]$ gpstop -a
20130418:16:34:28:007658 gpstop:o564gtser1:gpadmin-[INFO]:-Starting gpstop with args: -a
20130418:16:34:28:007658 gpstop:o564gtser1:gpadmin-[INFO]:-Gathering information and validating the environment...
20130418:16:34:28:007658 gpstop:o564gtser1:gpadmin-[INFO]:-Obtaining Greenplum Master catalog information
20130418:16:34:28:007658 gpstop:o564gtser1:gpadmin-[INFO]:-Obtaining Segment details from master...
20130418:16:34:28:007658 gpstop:o564gtser1:gpadmin-[INFO]:-Greenplum Version: 'postgres (Greenplum Database) 4.2.4.0 build 1'
20130418:16:34:28:007658 gpstop:o564gtser1:gpadmin-[INFO]:-There are 0 connections to the database
20130418:16:34:28:007658 gpstop:o564gtser1:gpadmin-[INFO]:-Commencing Master instance shutdown with mode='smart'
20130418:16:34:28:007658 gpstop:o564gtser1:gpadmin-[INFO]:-Master host=o564gtser1
20130418:16:34:28:007658 gpstop:o564gtser1:gpadmin-[INFO]:-Commencing Master instance shutdown with mode=smart
20130418:16:34:28:007658 gpstop:o564gtser1:gpadmin-[INFO]:-Master segment instance directory=/data/master/gtgpseg-1
20130418:16:34:29:007658 gpstop:o564gtser1:gpadmin-[INFO]:-No standby master host configured
20130418:16:34:29:007658 gpstop:o564gtser1:gpadmin-[INFO]:-Commencing parallel segment instance shutdown, please wait...
...
20130418:16:34:32:007658 gpstop:o564gtser1:gpadmin-[INFO]:-----------------------------------------------------
20130418:16:34:32:007658 gpstop:o564gtser1:gpadmin-[INFO]:- Segments stopped successfully = 2
20130418:16:34:32:007658 gpstop:o564gtser1:gpadmin-[INFO]:- Segments with errors during stop = 0
20130418:16:34:32:007658 gpstop:o564gtser1:gpadmin-[INFO]:-----------------------------------------------------
20130418:16:34:32:007658 gpstop:o564gtser1:gpadmin-[INFO]:-Successfully shutdown 2 of 2 segment instances
20130418:16:34:32:007658 gpstop:o564gtser1:gpadmin-[INFO]:-Database successfully shutdown with no errors reported
gpadmin@o564gtser1 ~]$ gpstart -R
20130418:16:35:52:007724 gpstart:o564gtser1:gpadmin-[INFO]:-Starting gpstart with args: -R
20130418:16:35:52:007724 gpstart:o564gtser1:gpadmin-[INFO]:-Gathering information and validating the environment...
20130418:16:35:52:007724 gpstart:o564gtser1:gpadmin-[INFO]:-Greenplum Binary Version: 'postgres (Greenplum Database) 4.2.4.0 build 1'
20130418:16:35:52:007724 gpstart:o564gtser1:gpadmin-[INFO]:-Greenplum Catalog Version: '201109210'
20130418:16:35:52:007724 gpstart:o564gtser1:gpadmin-[INFO]:-Starting Master instance in admin mode
20130418:16:35:53:007724 gpstart:o564gtser1:gpadmin-[INFO]:-Obtaining Greenplum Master catalog information
20130418:16:35:53:007724 gpstart:o564gtser1:gpadmin-[INFO]:-Obtaining Segment details from master...
20130418:16:35:53:007724 gpstart:o564gtser1:gpadmin-[INFO]:-Setting new master era
20130418:16:35:53:007724 gpstart:o564gtser1:gpadmin-[INFO]:-Master Started...
20130418:16:35:53:007724 gpstart:o564gtser1:gpadmin-[INFO]:-Shutting down master
20130418:16:35:55:007724 gpstart:o564gtser1:gpadmin-[INFO]:---------------------------
20130418:16:35:55:007724 gpstart:o564gtser1:gpadmin-[INFO]:-Master instance parameters
20130418:16:35:55:007724 gpstart:o564gtser1:gpadmin-[INFO]:---------------------------
20130418:16:35:55:007724 gpstart:o564gtser1:gpadmin-[INFO]:-Database = template1
20130418:16:35:55:007724 gpstart:o564gtser1:gpadmin-[INFO]:-Master Port = 5432
20130418:16:35:55:007724 gpstart:o564gtser1:gpadmin-[INFO]:-Master directory = /data/master/gtgpseg-1
20130418:16:35:55:007724 gpstart:o564gtser1:gpadmin-[INFO]:-Timeout = 600 seconds
20130418:16:35:55:007724 gpstart:o564gtser1:gpadmin-[INFO]:-Master standby = Off
20130418:16:35:55:007724 gpstart:o564gtser1:gpadmin-[INFO]:---------------------------------------
20130418:16:35:55:007724 gpstart:o564gtser1:gpadmin-[INFO]:-Segment instances that will be started
20130418:16:35:55:007724 gpstart:o564gtser1:gpadmin-[INFO]:---------------------------------------
20130418:16:35:55:007724 gpstart:o564gtser1:gpadmin-[INFO]:- Host Datadir Port
20130418:16:35:55:007724 gpstart:o564gtser1:gpadmin-[INFO]:- o564gtser1 /data/primary/gtgpseg0 40000
20130418:16:35:55:007724 gpstart:o564gtser1:gpadmin-[INFO]:- o564gtser1 /data/primary/gtgpseg1 40001
Continue with Greenplum instance startup Yy|Nn (default=N):
> y
20130418:16:35:57:007724 gpstart:o564gtser1:gpadmin-[INFO]:-No standby master configured. skipping...
20130418:16:35:57:007724 gpstart:o564gtser1:gpadmin-[INFO]:-Commencing parallel segment instance startup, please wait...
..
20130418:16:35:59:007724 gpstart:o564gtser1:gpadmin-[INFO]:-Process results...
20130418:16:35:59:007724 gpstart:o564gtser1:gpadmin-[INFO]:-----------------------------------------------------
20130418:16:35:59:007724 gpstart:o564gtser1:gpadmin-[INFO]:- Successful segment starts = 2
20130418:16:35:59:007724 gpstart:o564gtser1:gpadmin-[INFO]:- Failed segment starts = 0
20130418:16:35:59:007724 gpstart:o564gtser1:gpadmin-[INFO]:- Skipped segment starts (segments are marked down in configuration) = 0
20130418:16:35:59:007724 gpstart:o564gtser1:gpadmin-[INFO]:-----------------------------------------------------
20130418:16:35:59:007724 gpstart:o564gtser1:gpadmin-[INFO]:-
20130418:16:35:59:007724 gpstart:o564gtser1:gpadmin-[INFO]:-Successfully started 2 of 2 segment instances
20130418:16:35:59:007724 gpstart:o564gtser1:gpadmin-[INFO]:-----------------------------------------------------
20130418:16:35:59:007724 gpstart:o564gtser1:gpadmin-[INFO]:-Starting Master instance o564gtser1 directory /data/master/gtgpseg-1 in RESTRICTED mode
20130418:16:36:00:007724 gpstart:o564gtser1:gpadmin-[INFO]:-Command pg_ctl reports Master o564gtser1 instance active
20130418:16:36:00:007724 gpstart:o564gtser1:gpadmin-[INFO]:-Database successfully started
[gpadmin@o564gtser1 ~]$ gpfilespace --showtransfilespace
20130418:16:36:34:007937 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:36:34:007937 gpfilespace:o564gtser1:gpadmin-[INFO]:-Getting filespace information for TRANSACTION_FILES
20130418:16:36:34:007937 gpfilespace:o564gtser1:gpadmin-[INFO]:-Checking for filespace consistency
20130418:16:36:34:007937 gpfilespace:o564gtser1:gpadmin-[INFO]:-Obtaining current filespace entries used by TRANSACTION_FILES
20130418:16:36:35:007937 gpfilespace:o564gtser1:gpadmin-[INFO]:-TRANSACTION_FILES OIDs are consistent for pg_system filespace
20130418:16:36:36:007937 gpfilespace:o564gtser1:gpadmin-[INFO]:-TRANSACTION_FILES entries are consistent for pg_system filespace
20130418:16:36:36:007937 gpfilespace:o564gtser1:gpadmin-[INFO]:-Obtaining current filespace entries used by TRANSACTION_FILES
20130418:16:36:36:007937 gpfilespace:o564gtser1:gpadmin-[INFO]:-Current Filespace for TRANSACTION_FILES is pg_system
20130418:16:36:36:007937 gpfilespace:o564gtser1:gpadmin-[INFO]:-1 /data/master/gtgpseg-1
20130418:16:36:36:007937 gpfilespace:o564gtser1:gpadmin-[INFO]:-2 /data/primary/gtgpseg0
20130418:16:36:36:007937 gpfilespace:o564gtser1:gpadmin-[INFO]:-3 /data/primary/gtgpseg1
[gpadmin@o564gtser1 ~]$ gpfilespace --showtempfilespace
20130418:16:36:41:008196 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:36:41:008196 gpfilespace:o564gtser1:gpadmin-[INFO]:-Getting filespace information for TEMPORARY_FILES
20130418:16:36:41:008196 gpfilespace:o564gtser1:gpadmin-[INFO]:-Checking for filespace consistency
20130418:16:36:41:008196 gpfilespace:o564gtser1:gpadmin-[INFO]:-Obtaining current filespace entries used by TEMPORARY_FILES
20130418:16:36:42:008196 gpfilespace:o564gtser1:gpadmin-[INFO]:-TEMPORARY_FILES OIDs are consistent for pg_system filespace
20130418:16:36:43:008196 gpfilespace:o564gtser1:gpadmin-[INFO]:-TEMPORARY_FILES entries are consistent for pg_system filespace
20130418:16:36:43:008196 gpfilespace:o564gtser1:gpadmin-[INFO]:-Obtaining current filespace entries used by TEMPORARY_FILES
20130418:16:36:43:008196 gpfilespace:o564gtser1:gpadmin-[INFO]:-Current Filespace for TEMPORARY_FILES is pg_system
20130418:16:36:43:008196 gpfilespace:o564gtser1:gpadmin-[INFO]:-1 /data/master/gtgpseg-1
20130418:16:36:43:008196 gpfilespace:o564gtser1:gpadmin-[INFO]:-2 /data/primary/gtgpseg0
20130418:16:36:43:008196 gpfilespace:o564gtser1:gpadmin-[INFO]:-3 /data/primary/gtgpseg1
[gpadmin@o564gtser1 ~]$ gpfilespace --movetransfilespace gtlionsfilespace
20130418:16:37:37:008477 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:37:37:008477 gpfilespace:o564gtser1:gpadmin-[INFO]:-Database was started in RESTRICTED mode
20130418:16:37:37:008477 gpfilespace:o564gtser1:gpadmin-[INFO]:-Stopping Greenplum Database
20130418:16:37:42:008477 gpfilespace:o564gtser1:gpadmin-[INFO]:-Starting Greenplum Database
20130418:16:37:48:008477 gpfilespace:o564gtser1:gpadmin-[INFO]:-Stopping Greenplum Database
20130418:16:37:52:008477 gpfilespace:o564gtser1:gpadmin-[INFO]:-Starting Greenplum Database in master only mode
20130418:16:37:54:008477 gpfilespace:o564gtser1:gpadmin-[INFO]:-Checking if filespace gtlionsfilespace exists
20130418:16:37:54:008477 gpfilespace:o564gtser1:gpadmin-[INFO]:-Checking if filespace is same as current filespace
20130418:16:37:54:008477 gpfilespace:o564gtser1:gpadmin-[INFO]:-Stopping Greenplum Database in master only mode
20130418:16:37:55:008477 gpfilespace:o564gtser1:gpadmin-[INFO]:-Checking for connectivity
20130418:16:37:55:008477 gpfilespace:o564gtser1:gpadmin-[INFO]:-Obtaining current filespace information
20130418:16:37:55:008477 gpfilespace:o564gtser1:gpadmin-[INFO]:-Obtaining current filespace entries used by TRANSACTION_FILES
20130418:16:37:55:008477 gpfilespace:o564gtser1:gpadmin-[INFO]:-Obtaining segment information ...
20130418:16:37:55:008477 gpfilespace:o564gtser1:gpadmin-[INFO]:-Creating RemoteOperations list
20130418:16:37:55:008477 gpfilespace:o564gtser1:gpadmin-[INFO]:-Moving TRANSACTION_FILES filespace from pg_system to gtlionsfilespace ...
20130418:16:38:59:008477 gpfilespace:o564gtser1:gpadmin-[INFO]:-Starting Greenplum Database
[gpadmin@o564gtser1 ~]$ gpfilespace --movetempfilespace gtlionsfilespace
20130418:16:39:29:009662 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:39:29:009662 gpfilespace:o564gtser1:gpadmin-[INFO]:-Database was started in NORMAL mode
20130418:16:39:29:009662 gpfilespace:o564gtser1:gpadmin-[INFO]:-Stopping Greenplum Database
20130418:16:39:34:009662 gpfilespace:o564gtser1:gpadmin-[INFO]:-Starting Greenplum Database
20130418:16:39:43:009662 gpfilespace:o564gtser1:gpadmin-[INFO]:-Stopping Greenplum Database
20130418:16:39:48:009662 gpfilespace:o564gtser1:gpadmin-[INFO]:-Starting Greenplum Database in master only mode
20130418:16:39:49:009662 gpfilespace:o564gtser1:gpadmin-[INFO]:-Checking if filespace gtlionsfilespace exists
20130418:16:39:49:009662 gpfilespace:o564gtser1:gpadmin-[INFO]:-Checking if filespace is same as current filespace
20130418:16:39:49:009662 gpfilespace:o564gtser1:gpadmin-[INFO]:-Stopping Greenplum Database in master only mode
20130418:16:39:51:009662 gpfilespace:o564gtser1:gpadmin-[INFO]:-Checking for connectivity
20130418:16:39:51:009662 gpfilespace:o564gtser1:gpadmin-[INFO]:-Obtaining current filespace information
20130418:16:39:51:009662 gpfilespace:o564gtser1:gpadmin-[INFO]:-Obtaining current filespace entries used by TEMPORARY_FILES
20130418:16:39:51:009662 gpfilespace:o564gtser1:gpadmin-[INFO]:-Obtaining segment information ...
20130418:16:39:51:009662 gpfilespace:o564gtser1:gpadmin-[INFO]:-Creating RemoteOperations list
20130418:16:39:51:009662 gpfilespace:o564gtser1:gpadmin-[INFO]:-Moving TEMPORARY_FILES filespace from pg_system to gtlionsfilespace ...
20130418:16:39:52:009662 gpfilespace:o564gtser1:gpadmin-[INFO]:-Starting Greenplum Database
[gpadmin@o564gtser1 ~]$ gpstop -r
20130418:16:40:17:011276 gpstop:o564gtser1:gpadmin-[INFO]:-Starting gpstop with args: -r
20130418:16:40:17:011276 gpstop:o564gtser1:gpadmin-[INFO]:-Gathering information and validating the environment...
20130418:16:40:17:011276 gpstop:o564gtser1:gpadmin-[INFO]:-Obtaining Greenplum Master catalog information
20130418:16:40:17:011276 gpstop:o564gtser1:gpadmin-[INFO]:-Obtaining Segment details from master...
20130418:16:40:17:011276 gpstop:o564gtser1:gpadmin-[INFO]:-Greenplum Version: 'postgres (Greenplum Database) 4.2.4.0 build 1'
20130418:16:40:17:011276 gpstop:o564gtser1:gpadmin-[INFO]:---------------------------------------------
20130418:16:40:17:011276 gpstop:o564gtser1:gpadmin-[INFO]:-Master instance parameters
20130418:16:40:17:011276 gpstop:o564gtser1:gpadmin-[INFO]:---------------------------------------------
20130418:16:40:17:011276 gpstop:o564gtser1:gpadmin-[INFO]:- Master Greenplum instance process active PID = 11200
20130418:16:40:17:011276 gpstop:o564gtser1:gpadmin-[INFO]:- Database = template1
20130418:16:40:17:011276 gpstop:o564gtser1:gpadmin-[INFO]:- Master port = 5432
20130418:16:40:17:011276 gpstop:o564gtser1:gpadmin-[INFO]:- Master directory = /data/master/gtgpseg-1
20130418:16:40:17:011276 gpstop:o564gtser1:gpadmin-[INFO]:- Shutdown mode = smart
20130418:16:40:17:011276 gpstop:o564gtser1:gpadmin-[INFO]:- Timeout = 600
20130418:16:40:17:011276 gpstop:o564gtser1:gpadmin-[INFO]:- Shutdown Master standby host = Off
20130418:16:40:17:011276 gpstop:o564gtser1:gpadmin-[INFO]:---------------------------------------------
20130418:16:40:17:011276 gpstop:o564gtser1:gpadmin-[INFO]:-Segment instances that will be shutdown:
20130418:16:40:17:011276 gpstop:o564gtser1:gpadmin-[INFO]:---------------------------------------------
20130418:16:40:17:011276 gpstop:o564gtser1:gpadmin-[INFO]:- Host Datadir Port Status
20130418:16:40:17:011276 gpstop:o564gtser1:gpadmin-[INFO]:- o564gtser1 /data/primary/gtgpseg0 40000 u
20130418:16:40:17:011276 gpstop:o564gtser1:gpadmin-[INFO]:- o564gtser1 /data/primary/gtgpseg1 40001 u
Continue with Greenplum instance shutdown Yy|Nn (default=N):
> y
20130418:16:40:18:011276 gpstop:o564gtser1:gpadmin-[INFO]:-There are 0 connections to the database
20130418:16:40:18:011276 gpstop:o564gtser1:gpadmin-[INFO]:-Commencing Master instance shutdown with mode='smart'
20130418:16:40:18:011276 gpstop:o564gtser1:gpadmin-[INFO]:-Master host=o564gtser1
20130418:16:40:18:011276 gpstop:o564gtser1:gpadmin-[INFO]:-Commencing Master instance shutdown with mode=smart
20130418:16:40:18:011276 gpstop:o564gtser1:gpadmin-[INFO]:-Master segment instance directory=/data/master/gtgpseg-1
20130418:16:40:19:011276 gpstop:o564gtser1:gpadmin-[INFO]:-No standby master host configured
20130418:16:40:19:011276 gpstop:o564gtser1:gpadmin-[INFO]:-Commencing parallel segment instance shutdown, please wait...
...
20130418:16:40:22:011276 gpstop:o564gtser1:gpadmin-[INFO]:-----------------------------------------------------
20130418:16:40:22:011276 gpstop:o564gtser1:gpadmin-[INFO]:- Segments stopped successfully = 2
20130418:16:40:22:011276 gpstop:o564gtser1:gpadmin-[INFO]:- Segments with errors during stop = 0
20130418:16:40:22:011276 gpstop:o564gtser1:gpadmin-[INFO]:-----------------------------------------------------
20130418:16:40:22:011276 gpstop:o564gtser1:gpadmin-[INFO]:-Successfully shutdown 2 of 2 segment instances
20130418:16:40:22:011276 gpstop:o564gtser1:gpadmin-[INFO]:-Database successfully shutdown with no errors reported
20130418:16:40:22:011276 gpstop:o564gtser1:gpadmin-[INFO]:-Restarting System...
[gpadmin@o564gtser1 ~]$ gpfilespace --showtransfilespace
20130418:16:40:49:011997 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:40:49:011997 gpfilespace:o564gtser1:gpadmin-[INFO]:-Getting filespace information for TRANSACTION_FILES
20130418:16:40:49:011997 gpfilespace:o564gtser1:gpadmin-[INFO]:-Checking for filespace consistency
20130418:16:40:49:011997 gpfilespace:o564gtser1:gpadmin-[INFO]:-Obtaining current filespace entries used by TRANSACTION_FILES
20130418:16:40:50:011997 gpfilespace:o564gtser1:gpadmin-[INFO]:-TRANSACTION_FILES OIDs are consistent for gtlionsfilespace filespace
20130418:16:40:51:011997 gpfilespace:o564gtser1:gpadmin-[INFO]:-TRANSACTION_FILES entries are consistent for gtlionsfilespace filespace
20130418:16:40:51:011997 gpfilespace:o564gtser1:gpadmin-[INFO]:-Obtaining current filespace entries used by TRANSACTION_FILES
20130418:16:40:51:011997 gpfilespace:o564gtser1:gpadmin-[INFO]:-Current Filespace for TRANSACTION_FILES is gtlionsfilespace
20130418:16:40:51:011997 gpfilespace:o564gtser1:gpadmin-[INFO]:-1 /data1/gtgpseg-1
20130418:16:40:51:011997 gpfilespace:o564gtser1:gpadmin-[INFO]:-2 /data1/gtgpseg0
20130418:16:40:51:011997 gpfilespace:o564gtser1:gpadmin-[INFO]:-3 /data1/gtgpseg1
[gpadmin@o564gtser1 ~]$ gpfilespace --showtempfilespace
20130418:16:40:57:012256 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:40:57:012256 gpfilespace:o564gtser1:gpadmin-[INFO]:-Getting filespace information for TEMPORARY_FILES
20130418:16:40:57:012256 gpfilespace:o564gtser1:gpadmin-[INFO]:-Checking for filespace consistency
20130418:16:40:57:012256 gpfilespace:o564gtser1:gpadmin-[INFO]:-Obtaining current filespace entries used by TEMPORARY_FILES
20130418:16:40:58:012256 gpfilespace:o564gtser1:gpadmin-[INFO]:-TEMPORARY_FILES OIDs are consistent for gtlionsfilespace filespace
20130418:16:40:59:012256 gpfilespace:o564gtser1:gpadmin-[INFO]:-TEMPORARY_FILES entries are consistent for gtlionsfilespace filespace
20130418:16:40:59:012256 gpfilespace:o564gtser1:gpadmin-[INFO]:-Obtaining current filespace entries used by TEMPORARY_FILES
20130418:16:40:59:012256 gpfilespace:o564gtser1:gpadmin-[INFO]:-Current Filespace for TEMPORARY_FILES is gtlionsfilespace
20130418:16:40:59:012256 gpfilespace:o564gtser1:gpadmin-[INFO]:-1 /data1/gtgpseg-1
20130418:16:40:59:012256 gpfilespace:o564gtser1:gpadmin-[INFO]:-2 /data1/gtgpseg0
20130418:16:40:59:012256 gpfilespace:o564gtser1:gpadmin-[INFO]:-3 /data1/gtgpseg1
至此,已经成功的将系统的默认文件空间pg_system迁移到gtlionsfilespace。
创建一个表空间
gtlions=# create tablespace gtlions_ts1 filespace gtlionsfilespace;
CREATE TABLESPACE
gtlions=# select * from pg_tablespace;
spcname | spcowner | spclocation | spcacl | spcprilocations | spcmirlocations | spcfsoid
-------------+----------+-------------+--------+-----------------+-----------------+----------
pg_default | 10 | | | | | 3052
pg_global | 10 | | | | | 3052
gtlions_ts1 | 98690 | | | | | 98691
(3 rows)
gtlions=# select * from pg_filespace;
fsname | fsowner
------------------+---------
pg_system | 10
gtlionsfilespace | 10
(2 rows)
gtlions=# select * from pg_filespace_entry;
fsefsoid | fsedbid | fselocation
----------+---------+------------------------
3052 | 1 | /data/master/gtgpseg-1
3052 | 2 | /data/primary/gtgpseg0
3052 | 3 | /data/primary/gtgpseg1
98691 | 1 | /data1/gtgpseg-1
98691 | 2 | /data1/gtgpseg0
98691 | 3 | /data1/gtgpseg1
(6 rows)
gtlions=# SELECT spcname, fsname,fsedbid,fselocation FROM pg_tablespace pgts, pg_filespace pgfs,pg_filespace_entry pgfse WHERE pgts.spcfsoid=pgfse.fsefsoid AND pgfse.fsefsoid=pgfs.oid ORDER BY 1,3;
spcname | fsname | fsedbid | fselocation
-------------+------------------+---------+------------------------
gtlions_ts1 | gtlionsfilespace | 1 | /data1/gtgpseg-1
gtlions_ts1 | gtlionsfilespace | 2 | /data1/gtgpseg0
gtlions_ts1 | gtlionsfilespace | 3 | /data1/gtgpseg1
pg_default | pg_system | 1 | /data/master/gtgpseg-1
pg_default | pg_system | 2 | /data/primary/gtgpseg0
pg_default | pg_system | 3 | /data/primary/gtgpseg1
pg_global | pg_system | 1 | /data/master/gtgpseg-1
pg_global | pg_system | 2 | /data/primary/gtgpseg0
pg_global | pg_system | 3 | /data/primary/gtgpseg1
(9 rows)
在指定表空间上创建对象:
gtlions=# create table t2(id int) tablespace gtlions_ts1;
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'id' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
CREATE TABLE
gtlions=# select * from pg_tables where tableowner='gtlions';
schemaname | tablename | tableowner | tablespace | hasindexes | hasrules | hastriggers
------------+-----------+------------+-------------+------------+----------+-------------
gtlions | t1 | gtlions | | f | f | f
gtlions | t2 | gtlions | gtlions_ts1 | f | f | f
(2 rows)
我们也可以在会话级别设置默认表空间:
gtlions=# set default_tablespace=gtlions_ts1;
SET
也可以直接在数据库级别修改要使用的默认表空间:
gtlions=# alter database gtlions set default_tablespace=gtlions_ts1;
ALTER DATABASE
-EOF-