greenplum create tablespace

简介: gp表空间依赖于filespace,filespace需要自己首先设置文件路径 首先为其创建文件路径 master,slave1,slave2.
gp表空间依赖于filespace,filespace需要自己首先设置文件路径


首先为其创建文件路径
master,slave1,slave2...

第二授权用户gpadmin 访问修改文件的权限

第三按照文档执行


表空间创建语句

tutorial=> \h create tablespace
Command:     CREATE TABLESPACE
Description: define a new tablespace
Syntax:
CREATE TABLESPACE tablespace_name [OWNER username] FILESPACE filespace_name



[gpadmin@master ~]$ psql -U gpadmin template1
psql (8.2.15)
Type "help" for help.

template1=# select oid,* from pg_filespace;
oid  |  fsname   | fsowner
------+-----------+---------
3052 | pg_system |      10
(1 row)

template1=# select * from pg_tablespace;
  spcname   | spcowner | spclocation | spcacl | spcprilocations | spcmirlocations | spcfsoid
------------+----------+-------------+--------+-----------------+-----------------+----------
pg_default |       10 |             |        |                 |                 |     3052
pg_global  |       10 |             |        |                 |                 |     3052
(2 rows)




tutorial=>  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     
------------+-----------+---------+----------------------
pg_default | pg_system |       1 | /data/master/gpseg-1
pg_default | pg_system |       2 | /data/primary/gpseg0
pg_default | pg_system |       3 | /data/primary/gpseg1
pg_global  | pg_system |       1 | /data/master/gpseg-1
pg_global  | pg_system |       2 | /data/primary/gpseg0
pg_global  | pg_system |       3 | /data/primary/gpseg1
(6 rows)


--将文件路径创建并授权


[root@slave2 ~]# cd /
[root@slave2 /]# mkdir newdata
[root@slave2 /]# chown -R gpadmin /newdata

[root@slave1 ~]# cd /
[root@slave1 /]# mkdir newdata
[root@slave1 /]# chown -R gpadmin /newdata



[root@master /]# mkdir gpmaster
[root@master /]# cd gpmaster/
[root@master gpmaster]# ls
[root@master gpmaster]# mkdir gpfilespace_config_1
[root@master gpmaster]# chown -R gpadmin /gpmaster/gpfilespace_config_1/


[gpadmin@master ~]$ export PGDATABASE=tutorial;


[gpadmin@master ~]$ gpfilespace -o /gpmaster/gpfilespace_config_1
20161108:07:37:02:014040 gpfilespace:master: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.


20161108:07:37:02:014040 gpfilespace:master:gpadmin-[INFO]:-getting config
Enter a name for this filespace
> tbtest   

Checking your configuration:
Your system has 2 hosts with 1 primary and 0 mirror segments per host.
Your system has 1 hosts with 0 primary and 0 mirror segments per host.

Configuring hosts: [slave1, slave2]

Please specify 1 locations for the primary segments, one per line:
primary location 1> /newdata
[Error] slave1: /newdata : No write permissions

primary location 1> /newdata

Configuring hosts: [master]

Enter a file system location for the master
master location> /newgpmaster
20161108:07:39:18:014040 gpfilespace:master:gpadmin-[INFO]:-Creating configuration file...
20161108:07:39:18:014040 gpfilespace:master:gpadmin-[INFO]:-[created]
20161108:07:39:18:014040 gpfilespace:master:gpadmin-[INFO]:-
To add this filespace to the database please run the command:
   gpfilespace --config /gpmaster/gpfilespace_config_1/gpfilespace_config_20161108_073703



[gpadmin@master ~]$ gpfilespace --config  /gpmaster/gpfilespace_config_1/gpfilespace_config_20161
108_073703 20161108:07:43:49:014288 gpfilespace:master: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.


20161108:07:43:49:014288 gpfilespace:master:gpadmin-[INFO]:-getting config
Reading Configuration file: '/gpmaster/gpfilespace_config_1/gpfilespace_config_20161108_073703'
20161108:07:43:49:014288 gpfilespace:master:gpadmin-[INFO]:-Performing validation on paths
..............................................................................

20161108:07:43:49:014288 gpfilespace:master:gpadmin-[INFO]:-Connecting to database
20161108:07:43:49:014288 gpfilespace:master:gpadmin-[INFO]:-Filespace "tbtest" successfully creat ed




[gpadmin@master ~]$ psql -U user1 tutorial
Password for user user1:
psql (8.2.15)
Type "help" for help.

tutorial=> select * from pg_filespace;
  fsname   | fsowner
-----------+---------
pg_system |      10
tbtest    |      10
(2 rows)

tutorial=>

[gpadmin@master ~]$ psql -U gpadmin tutorial;
psql (8.2.15)
Type "help" for help.

tutorial=# create tablespace ts_gh filespace tbtest;
CREATE TABLESPACE
tutorial=# \q


[gpadmin@master ~]$ psql -U gpadmin tutorial
psql (8.2.15)
Type "help" for help.

tutorial=# create table testtb(id int) tablespace ts_gh;
NOTICE:  Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'id' as the Greenplum D
atabase data distribution key for this table.HINT:  The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chose
n are the optimal data distribution key to minimize skew.CREATE TABLE
tutorial=# set default_tablespace = ts_gh;
SET
tutorial=# alter database tutorial set default_tablespace = ts_gh;
ALTER DATABASE
tutorial=# \q


将表空间权限移动给user1

[gpadmin@master ~]$ psql -U gpadmin tutorial
psql (8.2.15)
Type "help" for help.

tutorial=# alter tablespace ts_gh owner to user1;
ALTER TABLESPACE
tutorial=# select * from pg_tablespace;
  spcname   | spcowner | spclocation | spcacl | spcprilocations | spcmirlocations | spcfsoid
------------+----------+-------------+--------+-----------------+-----------------+----------
pg_default |       10 |             |        |                 |                 |     3052
pg_global  |       10 |             |        |                 |                 |     3052
ts_gh      |    24576 |             |        |                 |                 |    61178
(3 rows)

tutorial=# \q
[gpadmin@master ~]$ psql -U user1 tutorial
Password for user user1:
psql (8.2.15)
Type "help" for help.

tutorial=> create table test01_ts(id int) tablespace ts_gh;
NOTICE:  Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'id' as the Greenplum D
atabase data distribution key for this table.HINT:  The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chose
n are the optimal data distribution key to minimize skew.CREATE TABLE
tutorial=>


目录
相关文章
|
16天前
|
Linux Go 开发工具
手机上跑 DeepSeek 智能体:开源安卓客户端 DSH Go 安装与使用指南
DSH Go 是一款开源安卓客户端,将 DeepSeek Harness 智能体引擎装进手机:免 Root、免 Termux,一键安装即用;支持本机运行(内置 Ubuntu+Node.js)或远程接管电脑会话;具备插话打断、过程折叠、屏幕操控、端到端加密分享等特色功能,真正实现智能体“口袋化”。
15952 59
|
6天前
|
域名解析 人工智能 Linux
|
14天前
|
人工智能
Google 提示「所在地区不可用」?进不去 Antigravity 或 Gemini,先查账号这个设置
进不去 Antigravity 或 Gemini,提示所在地区不可用?三步查清 Google 账号关联地区、官方更正表单理由选法与改区注意事项。
Google 提示「所在地区不可用」?进不去 Antigravity 或 Gemini,先查账号这个设置
|
11天前
|
人工智能 开发工具 开发者
2026最新codex下载安装保姆级使用教程(下载+安装+登录+使用,含所有历史版本)
Codex 是 OpenAI 推出的开源 AI 编程智能体,跑在本地终端和桌面客户端里,能读懂整个代码仓库,一句自然语言就能让它改代码、执行命令、跑测试、修 Bug,支持 Windows、macOS、Linux 三大平台。本文把 Codex下载、安装、登录、汉化、基础使用一次讲全,并整理了国内用户最常踩的坑,跟着做 10 分钟就能跑起来。
1969 5
|
16天前
|
弹性计算 人工智能 API
Codex超详细入门指南(下载·安装·登录·上手,全版本覆盖,2026最新版)
建议收藏本教程,2026 全年各版本更新随时回来查阅。如果你在搭建过程中遇到任何问题,欢迎结合 阿里云工单系统 提交技术支持请求,或在 阿里云开发者社区 搜索 Codex 相关话题交流。 祝你编码愉快,效率翻倍!
3585 22
|
5天前
|
Linux API iOS开发
【DSH】DeepSeek Harness新手保姆教程(下载+安装+配置+使用,2026最新实测)
DeepSeek Harness(dsh)是 DeepSeek AI 开源的智能体框架,秉持“一切皆插件”理念,支持读文件、改代码、执行命令、处理表格等自动化任务;免费开源,兼容 Win/macOS,需配 API 密钥使用。(239字)
1020 1
|
18天前
|
Linux API iOS开发
【DSH】DeepSeek Harness新手保姆教程(下载+安装+配置+使用,2026最新实测)
DeepSeek Harness(dsh)是DeepSeek AI开源的智能体框架,秉持“一切皆插件”理念,支持读文件、改代码、跑命令、处理表格、联网搜索等操作。免费开源,兼容Windows/macOS/Linux,提供桌面端与网页端,可灵活安装插件扩展能力。
|
14天前
|
传感器 安全 区块链
Windows 电脑运行安卓应用教程:开源工具 ApkStart 双击 APK 即装、独立窗口运行
ApkStart 是一款开源Windows工具,让安卓APP像原生软件一样运行:双击APK即安装、生成真实图标、独立窗口启动、开始菜单可搜索。无需传统模拟器,内置QEMU运行时,支持数据互通、ARM兼容与命令行操作。(239字)
|
9天前
|
JSON 数据格式 iOS开发
DeepSeek 宿主插件 dsh-purge 社区版实战:安装、自检与备份回滚
dsh-purge Community 是 DeepSeek Harness(DSH)高人气开源插件(GitHub Star 过万,v1.7.20),提供宿主兼容、25层自检、提示词管理、自动快照与一键回滚等工程化能力,全程本机运行、可见可溯、安全可控。
1242 0

热门文章

最新文章