I’ll demonstrate how to relocate a tablespace directory without the reconstruction of databases.

I have a tablespace tblspc located at /home/postgres/tblspc and want to relocate to /home/postgres/new_tblspc.

[1] Get Oid of the tablespace

testdb=# SELECT oid,spcname FROM pg_tablespace WHERE spcname = 'tblspc'; 
oid | spcname -------+---------- 24580 | tblspc
(1 row)

[2] Stop postgres

[postgres]$ pg_ctl -D $PGDATA stop

[3] Relocate the tablespace directory

[postgres]$ cp -r /home/postgres/tblspc /home/postgres/new_tblspc 
[postgres]$ rm -rf /home/postgres/tblspc

[4] Change the link of tablespace to new directory

[postgres]$ cd $PGDATA/pg_tblspc 
[postgres]$ rm 24580
[postgres]$ ln -s /home/postgres/new_tblspc 24580

[5] Start postgres

[postgres]$ pg_ctl -D $PGDATA start

Then, the tablespace’s directory has changed.

testdb=# SELECT pg_tablespace_location(24580);
pg_tablespace_location -------------------------- /home/postgres/new_tblspc
(1 row)

参考:

http://www.interdb.jp/blog/tips/relocatingtablespace/

How to relocate tablespace directory的更多相关文章

  1. mysql Inoodb 内核

    MySQL从5.5版本开始将InnoDB作为默认存储引擎,该存储引擎是第一个完整支持事务ACID特性的存储引擎,且支持数据行锁,多版本并发控制(MVCC),外键,以及一致性非锁定读. 作为默认存储引擎 ...

  2. PostgreSQL中流复制pg_basebackup做了什么

    解压PostgreSQL源代码包后可以到如下路径:postgresql-9.2.4\src\backend\replication下可以看到,basebackup.c,另外还可以看到walreceiv ...

  3. InnoDB On-Disk Structures(三)--Tablespaces (转载)

    转载.节选于 https://dev.mysql.com/doc/refman/8.0/en/innodb-tablespace.html This section covers topics rel ...

  4. 14.5.5 Creating a File-Per-Table Tablespace Outside the Data Directory

    14.5.5 Creating a File-Per-Table Tablespace Outside the Data Directory 创建一个File-Per-Table Tablespace ...

  5. 1118ALTER TABLE tabname DISCARD TABLESPACE快速导入数据利用表空间

    -- 快速导入数据如果你有.ibd文件的一个干净的备份,你可以按如下操作从被起源的地方恢复它到MySQL安装中:相当快速 1. 发出这个ALTER TABLE语句: 2. ALTER TABLE tb ...

  6. REORG TABLESPACE on z/os

    这个困扰了我两天的问题终于解决了,在运行这个job时:总是提示 A REQUIRED DD CARD OR TEMPLATE IS MISSING NAME=SYSDISC A REQUIRED DD ...

  7. PostgreSQL: Query for location of global tablespace?

    Q: I have been trying to make our database clients pro-active about not filling up the partition on ...

  8. svn switch relocate用法

    svn info svn info 得到 Path: . Working Copy Root Path: /Users/chunhuizhao/phpworkspace/buptef_wxpay/tr ...

  9. Oracle Tablespace Transportation

    前提:进行表空间传输需要用户有SYSDBA的系统权限,被移动的表空间是自包含的表空间,不应有依赖于表空间外部对象的对象存在.确定是否自包含可使用系统包DBMS_TTS中的TRANSPORT_SET_C ...

随机推荐

  1. 在centos7上作用mongodb

    安装服务端 yum install mongodb-server 安装客户端 yum install mongodb 版本 mongo --version 是否安装了mongodbwhich mong ...

  2. Creating Materials at runtime And Issue of Shader.Find()

    Creating Materials at runtimehttp://forum.unity3d.com/threads/create-materials-at-runtime.72952/ //通 ...

  3. python的类和对象——番外篇(类的静态字段)

    什么是静态字段 在开始之前,先上图,解释一下什么是类的静态字段(我有的时候会叫它类的静态变量,总之说的都是它.后面大多数情况可能会简称为类变量.): 我们看上面的例子,这里的money就是静态字段,首 ...

  4. php WIN下编译注意问题

    下载VC2012,安装打开CMD 须运行 vcvars32.bat (初始化VC编译环境) 下载PHP WIN编译包:http://windows.php.net/downloads/php-sdk/ ...

  5. WCF服务在类库中的引用

    在类库中引用了WCF服务,悲剧降临了,追踪日志看到下边一串: --------------------------------------------------------------------- ...

  6. [最近公共祖先] POJ 3728 The merchant

    The merchant Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 4556   Accepted: 1576 Desc ...

  7. 微信、QQ浏览器X5内核问题汇总

    一. 资料汇总 1.前端H5调起QQ浏览器的总结:http://km.oa.com/group/22486/articles/show/210189?kmref=search 2.Android We ...

  8. 转: 什么是REST?

    REST (REpresentation State Transfer) 描述了一个架构样式的网络系统,比如 web 应用程序.它首次出现在 2000 年 Roy Fielding 的博士论文中,他是 ...

  9. iptables基本规则

    注意:iptables只能被拥有超级权限的用户设置.   重启 清空 iptables 规则:在终端输入:   iptables -F iptables -X iptables -t nat -F i ...

  10. Jmeter教程索引

    一.基础部分: 使用Jmeter进行http接口测试 Jmeter之Http Cookie Manager Jmeter之HTTP Request Defaults Jmeter之逻辑控制器(Logi ...