How to relocate tablespace directory
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的更多相关文章
- mysql Inoodb 内核
MySQL从5.5版本开始将InnoDB作为默认存储引擎,该存储引擎是第一个完整支持事务ACID特性的存储引擎,且支持数据行锁,多版本并发控制(MVCC),外键,以及一致性非锁定读. 作为默认存储引擎 ...
- PostgreSQL中流复制pg_basebackup做了什么
解压PostgreSQL源代码包后可以到如下路径:postgresql-9.2.4\src\backend\replication下可以看到,basebackup.c,另外还可以看到walreceiv ...
- InnoDB On-Disk Structures(三)--Tablespaces (转载)
转载.节选于 https://dev.mysql.com/doc/refman/8.0/en/innodb-tablespace.html This section covers topics rel ...
- 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 ...
- 1118ALTER TABLE tabname DISCARD TABLESPACE快速导入数据利用表空间
-- 快速导入数据如果你有.ibd文件的一个干净的备份,你可以按如下操作从被起源的地方恢复它到MySQL安装中:相当快速 1. 发出这个ALTER TABLE语句: 2. ALTER TABLE tb ...
- REORG TABLESPACE on z/os
这个困扰了我两天的问题终于解决了,在运行这个job时:总是提示 A REQUIRED DD CARD OR TEMPLATE IS MISSING NAME=SYSDISC A REQUIRED DD ...
- 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 ...
- svn switch relocate用法
svn info svn info 得到 Path: . Working Copy Root Path: /Users/chunhuizhao/phpworkspace/buptef_wxpay/tr ...
- Oracle Tablespace Transportation
前提:进行表空间传输需要用户有SYSDBA的系统权限,被移动的表空间是自包含的表空间,不应有依赖于表空间外部对象的对象存在.确定是否自包含可使用系统包DBMS_TTS中的TRANSPORT_SET_C ...
随机推荐
- GitHub下载的 Git Shell中出现的字符支持警告,将字体修改为新宋体即可
——解决办法: 将命令行字体修改为新宋体就可以了. 文章引用:http://www.cnblogs.com/veryinf/archive/2012/10/26/2740899.html
- LinkedList源码分析
LinkedList也和ArrayList一样实现了List接口,但是它执行插入和删除操作时比ArrayList更加高效,因为它是基于链表的.基于链表也决定了它在随机访问方面要比ArrayList逊色 ...
- unittest框架介绍
1.test fixture(测试框架) 测试准备前要做的工作和测试执行完成后要做的工作,例如测试前需要把数据初始化,测试完成后需要把测试环境中需要关的东西都关掉.主要包括setUp()和tearDo ...
- 经典SQL语句大全以及50个常用的sql语句
经典SQL语句大全 一.基础 1.说明:创建数据库CREATE DATABASE database-name 2.说明:删除数据库drop database dbname3.说明:备份sql serv ...
- LCT专题练习
[bzoj2049]洞穴勘测 http://www.cnblogs.com/Sdchr/p/6188628.html 小结 (1)LCT可以方便维护树的连通性,但是图的连通性的维护貌似很麻烦. [bz ...
- 7 -- Spring的基本用法 -- 7...
7.7 创建Bean的3种方式 ① 调用构造器创建Bean. ② 调用静态工厂方法创建Bean. ③ 调用实例工厂方法创建Bean. 7.7.1 使用构造器创建Bean实例. 使用构造器来创建Bean ...
- 使用C语言将IE收藏夹生成HTML
IE收藏夹里收藏的链接很多,查找也不方便,使用C编写一个小工具,可以将收藏夹里的链接文件生成到一个HTML文件上. 源码还有许多地方需要优化,后续我会优化,先分享出来.目的主要是为了练习C语言,这个代 ...
- js中的cookie操作
一.js cookie 使用时把此段代码引入页面 (function (factory) { if (typeof define === 'function' && define. ...
- iOS开发UI篇—在UIImageView中添加按钮以及Tag的参数说明
ios开发UI篇—在ImageView中添加按钮以及Tag的参数说明 一.tag参数 一个视图通常都只有一个父视图,多个子视图,在开发中可以通过使用子视图的tag来取出对应的子视图.方法为Viewwi ...
- 使用PYTHON实现docx文档的读写
经常写文章的小白们会遇到这样的问题,知道想表达的意思,想出了大概描述的词汇,但就是缺乏完整漂亮的句子,也许曾经在某个地方看到过,但是找不到了.另外一种情况,阅读了大量的报告,用的时候想到了其中的某个结 ...