Postgresql 的表空间的创建命令比较简单。
Command: CREATE TABLESPACE
Description: define a new tablespace
Syntax:
CREATE TABLESPACE tablespace_name [ OWNER user_name ] LOCATION 'directory'
Command: CREATE DATABASE
Description: create a new database
Syntax:
CREATE DATABASE name
[ [ WITH ] [ OWNER [=] user_name ]
[ TEMPLATE [=] template ]
[ ENCODING [=] encoding ]
[ LC_COLLATE [=] lc_collate ]
[ LC_CTYPE [=] lc_ctype ]
[ TABLESPACE [=] tablespace_name ]
[ CONNECTION LIMIT [=] connlimit ] ]
可能的错误
create tablespace testspaceeee location '/mnt/data1222';
ERROR: directory "/mnt/data1222" does not exist
表空间目录必须提前创建好。
postgresql 的归档模式设置
wal_level = archive
checkpoint_segments = 3 # in logfile segments,min 1,16MB each
checkpoint_timeout = 10min # 强制生成 checkpoint 的周期
checkpoint_completion_target = 0.5 # checkpoint target duration,0.0 - 1.0
checkpoint_warning = 30s # 0 disables
archive_mode = on # 启动归档模式
#
archive_command ='cp %p /home/postgres/data1/%f'
#
#
# 归档路径
archive_timeout = 120 #
#