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 ...
随机推荐
- 习题-任务2初始ASP.NET MVC项目开发
一.选择题 1.在ASP.NET MVC项目的RouteConfig.cs文件中,( )方法注册了默认的路由配置. A.RegisterMap B.RegisterRoutes C. ...
- Git基础操作
配置秘钥 1.检查本机有没有秘钥 检查~/.ssh看看是否有名为d_rsa.pub和id_dsa.pub的2个文件. $ ~/.sshbash: /c/Users/lenovo/.ssh: Is a ...
- python 中分支结构(switch)
可通过字典调用:{1:case1,2:case2}.get(x,lambda *args,**key:)() # 编写一个计算器 # -*- coding=utf-8 -*- def jia(x,y) ...
- C#中文和UNICODE编码转换
C#中文和UNICODE编码转换 //中文轉為UNICODE string str = "中文"; string outStr = ""; if (!strin ...
- MYSQL 5.6中禁用INNODB引擎
并不是所有人都需要INNODB引擎,虽然它弥补了MYSQL缺乏事务支持的毛病,但是它的磁盘性能一直是让人比较担忧的.另外比较老的PHP系统,大多是采用MYISAM引擎在MYSQL建表,似乎INNODB ...
- CSS3轻松实现清新 Loading 效果
至今HTML5中国已经为大家分享过几百种基于 CSS3 的Loading加载动画,效果酷炫代码简洁,非常值得学习借鉴;今天就先给大家分享两个常用的CSS3的Loading的案例. 第一种效果: HTM ...
- redis教程
windows下安装redis: http://jingyan.baidu.com/article/49ad8bce40174f5834d8fa24.html redis教程: http://www. ...
- ASP.NET关于WebPages的一点总结
相比于早期的ASP,WebPage貌似只是多了一些Razor语法可以直接调用服务器代码,其他的内容HTML.样式CSS以及脚本JavaScript基本都是一样的处理方式 只是说内容HTML里面加入了更 ...
- mysql 中execute、executeQuery和executeUpdate之间的区别
在用纯JSP做一个页面报警功能的时候习惯性的用executeQuery来执行SQL语句,结果执行update时就遇到问题,语句能执行,但返回结果出现问题,另外还忽略了executeUpdate的返回值 ...
- PowerShell脚本:随机密码生成器
脚本名称:s随机密码生成器_v2.63.ps1脚本作用:产生随机密码.每密码字符个数,密码数量,存盘位置等可以自定义.脚本用法:脚本采用了硬编码,所以你需要打开脚本,修改如下变量:$生成密码总个数 = ...