环境
系统平台:N/A
版本:4.3.4.7,4.7.6,5.6.5
文档用途
本文旨在介绍流复制环境(包括集群环境)下创建表空间的步骤及可能遇到的问题。
详细信息
正确步骤:
1.在所有节点系统中创建同名路径并赋权。
例如我要在主节点创建表空间,location为/datanew/tbs1。
需要确保/datanew/tbs1路径在所有节点都存在,并且运行数据库服务的操作系统用户具有其下的读写权限。
2.创建表空间。
create tablespace tbs1 location '/datanew/tbs1';
3.检查同步状态。
通过sql语句select * from pg_stat_replication ;查询同步延迟。或者psql连接备库执行\db查询表空间信息。确认无误即可。
问题点:
如果在创建前备库没有该路径,主库创建表空间成功后,备库会自动终止,在备库的日志里可见如下报错。
2020-03-02 08:54:58.778 CST [6610] FATAL: directory “/datanew/tbs1” does not exist
2020-03-02 08:54:58.778 CST [6610] HINT: Create this directory for the tablespace before restarting the server.
2020-03-02 08:54:58.778 CST [6610] CONTEXT: WAL redo at 0/18002498 for Tablespace/CREATE: 33073 “/datanew/tbs1”
2020-03-02 08:54:58.781 CST [6608] LOG: startup process (PID 6610) exited with exit code 1
2020-03-02 08:54:58.781 CST [6608] LOG: terminating any other active server processes
2020-03-02 08:54:58.793 CST [6608] LOG: database system is shut down
此时尝试启动备库也无法启动,报错相同。
此时我们需要按照日志中的提示,Create this directory for the tablespace before restarting the server.将缺失的目录创建成功后,方可启动数据库。
1403

被折叠的 条评论
为什么被折叠?



