初始环境
centos7 postgresql9.4
psql升级
根据官网:https://www.postgresql.org/download/linux/redhat/
- Install the repository RPM:
yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm
- Install the client packages
yum install postgresql96
- Optionally install the server packages:
yum install postgresql96-server
pg_pathman安装
- 获取源代码
git clone https://github.com/postgrespro/pg_pathman
- root下编译
make USE_PGXS=1
make USE_PGXS
如果报错pg_config不存在,则安装pg_cofig
yum install postgresql96-devel
- make成功后修改postgresql.conf
打开postgresql.conf:将shared_preload_libraries配置改为如下
shared_preload_libraries = 'pg_pathman'
- 重启psql
附:
- 增加用户
create user xxx
- 修改用户密码
alter user xxx with password 'xxx';
- 执行分表
CREATE EXTENSION pg_pathman;
SELECT create_hash_partitions('bbs_reply', 'thread_id', 128); #bbs_reply表名,thread_id字段名,128分表数量