How to relocate tablespace directory
2016-02-18 23:43
232 查看
I’ll demonstrate how to relocate a tablespace directory without the reconstruction of databases.
I have a tablespace
[1] Get Oid of the tablespace
[2] Stop postgres
[3] Relocate the tablespace directory
[4] Change the link of tablespace to new directory
[5] Start postgres
Then, the tablespace’s directory has changed.
参考:
http://www.interdb.jp/blog/tips/relocatingtablespace/
I have a tablespace
tblspclocated at
/home/postgres/tblspcand 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/
相关文章推荐
- 虚析构函数
- KBEngine 服务器端-loginapp-协议构建、解析执行
- 读书笔记 -《Python 黑帽子》 ( 三 )
- 栈stack和队列queue的常用基本函数
- sql中exists,not exists的用法
- 第一篇blog
- 台湾大学林轩田老师机器学习基石:内容简介
- 黑马程序员——网络编程
- nodejs 链接数据库的一些代码
- PHP安全相关的配置
- chrome developer tool 调试技巧
- 关于进程调度的理解很nice的一个例子
- ELK+Redis日志分析平台测试性能记录
- IOS学习 UIViewController 视图控制器的创建
- 六种常用的设计模式java实现(五)代理模式
- LINUX下硬件配置命令
- 操作系统
- 签名APK后仍然出现INSTALL_PARSE_FAILED_NO_CERTIFICATES的解决方案
- 关于mysql如何添加InnoDB
- okHttp学习(待完善)