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. json 后台传前台

    jsonObject需实例化new.jsonObject=new JSONObject();jsonObject.put("goodslist", list);jsonObject ...

  2. easyui combotree 只能选择子节点

    //区号只能选子节点 $("#quhao").combotree({ onBeforeSelect: function (node) { //返回树对象 var tree = $( ...

  3. Django1.9开发博客(13)- redis缓存

    Redis 是一个高性能的key-value数据库.redis的出现, 很大程度补偿了memcached这类keyvalue存储的不足,在部分场合可以对关系数据库起到很好的补充作用. 它提供了Pyth ...

  4. ijg库解码超大型jpeg图片

    1. ijg库解码超大型jpeg图片(>100M)的时候,如何避免内存溢出. 采用边解码边压缩的策略,每次解码一行或者若干行图片数据,然后对于这些解码的数据,进行DQT(量化处理,过滤掉高频的数 ...

  5. Search Insert Position [LeetCode]

    Given a sorted array and a target value, return the index if the target is found. If not, return the ...

  6. 第一章 企业项目开发--maven+springmvc+spring+mybatis+velocity整合

    说明:本系列文章主要是对自己在一家大型互联网公司实习的过程中对所学知识的总结!参与的是实际中使用的上线项目. 代码的github地址:https://github.com/zhaojigang/ssm ...

  7. logcat的条数设置

    在软件默认设置下,logcat的缓存为1024,即logcat显示的条数有限,给程序的调试带来很大的不便,通过设置 logcat缓存的大小,可以增加logcat显示的条数,将程序调试的输出都可以打印出 ...

  8. C#多线程 线程池

    实例1:直接看看微软提供的代码 using System; using System.Threading; public class Example { public static void Main ...

  9. JAVA OOP 基础知识提纲

    OOP: 面向对象: 认识事物的一个过程,是整体(特征/行为) 认识事物的方式.人类认识事物的自然思维习惯. 对象及类 对象是实实在在具体存在的东西,主要是从两个角度(行为,特征)去观察 类:是一组具 ...

  10. ASP.NET中的Session怎么正确使用[转]

    Session对象用于存储从一个用户开始访问某个特定的aspx的页面起,到用户离开为止,特定的用户会话所需要的信息.用户在应用程序的页面切换时,Session对象的变量不会被清除. 对于一个Web应用 ...