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. STM32学习笔记(六) SysTick系统时钟滴答实验(stm32中断入门)

    系统时钟滴答实验很不难,我就在面简单说下,但其中涉及到了STM32最复杂也是以后用途最广的外设-NVIC,如果说RCC是实时性所必须考虑的部分,那么NVIC就是stm32功能性实现的基础,NVIC的难 ...

  2. Deep Learning 17:DBN的学习_读论文“A fast learning algorithm for deep belief nets”的总结

    1.论文“A fast learning algorithm for deep belief nets”的“explaining away”现象的解释: 见:Explaining Away的简单理解 ...

  3. spring4+mybatis3+maven

    简介 在上一篇博文中,我们搭建了maven环境,现在我们就用maven搭个ssm框架,废话不多说,直接开始吧 代码下载地址 链接:http://pan.baidu.com/s/1nvg42EH 密码: ...

  4. Python学习笔记只列表和元组

    一.成员资格 1.检查某个字符是否在某个字符串中:'a' in 'absent' 2.获取数组的长度.最大.最小值: numbers=[100,54,345] len(numbers) //长度 ma ...

  5. sphinx索引文件进一步说明——最好是结合lucene一起看,直觉告诉我二者本质无异

    摘自:http://blog.csdn.net/cangyingzhijia/article/details/8592441 Sphinx使用的文件包括 "sph", " ...

  6. 分布式系统开发的一些相关理论基础——CAP、ACID、BASE

    本文主要讲述分布式系统开发的一些相关理论基础. 一.ACID 事务的四个特征: 1.Atomic原子性 事务必须是一个原子的操作序列单元,事务中包含的各项操作在一次执行过程中,要么全部执行成功,要么全 ...

  7. Linux字符设备

    一.linux系统将设备分为3类:字符设备.块设备.网络设备. 字符设备:是指只能一个字节一个字节读写的设备,不能随机读取设备内存中的某一数据,读取数据需要按照先后数据.字符设备是面向流的设备,常见的 ...

  8. MATLAB 物体识别算法说明:vision.ForegroundDetector, vision.BlobAnalysis

    在官方示例中,Motion-Based Multiple Object Tracking和Using Kalman Filter for Object Tracking都使用了下面两个算法进行物体的识 ...

  9. 《TCP/IP详解卷1:协议》第2章 链路层-读书笔记

    章节回顾: <TCP/IP详解卷1:协议>第1章 概述-读书笔记 <TCP/IP详解卷1:协议>第2章 链路层-读书笔记 <TCP/IP详解卷1:协议>第3章 IP ...

  10. 安卓手机上的python运行环境-qpython

    qpython是一个能让安卓手机运行和编写python的APP,到网上下载APK安装或者在GOOGLE PLAY搜索安装即可. 安装之后你可以你手机跑自己的python程序. qpython有两个大版 ...