当前位置:操作系统 > Unix/Linux >>

Greenplum管理表空间Tablespace

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用维护模式启动,迁移完成后重启数据库,默认的文件空间目录建议不要删除:
[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 &nbs
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,