部署postgres数据库(Docker)

使用sameersbn/postgresql

工作目录:/home/postgres

1
2
3
4
5
6
7
8
9
10
11
12
13
14
postgresql:
restart: always
image: sameersbn/postgresql:9.6-2
volumes:
- $PWD:/var/lib/postgresql
- /var/run/postgresql/:/var/run/postgresql/
- /home/nucleus-d1/rsyncd/data/:/home/nucleus-d1/rsyncd/data/
- /home/postgres/zhangxiaohao/:/home/postgres/zhangxiaohao/
environment:
- DB_USER=postgres
- DB_PASS=xxxxx
- DB_EXTENSION=
ports:
- "0.0.0.0:5432:5432"

9.6/main/pg_hba.conf # 权限配置

1
2
3
4
5
6
7
8
9
10
# "local" is for Unix domain socket connections only
local all all trust
host all all 112.94.5.240/28 md5
host all all 192.168.0.0/16 md5
host all all 0.0.0.0/0 md5
# IPv4 local connections:
host all all 127.0.0.1/32 trust
host all all 112.94.5.240/28 md5
host all all 192.168.0.0/16 md5
host all all 0.0.0.0/0 md5

开放办公室ssh通道连接pgsql数据库

centos 安装postgresql-client

1
yum -y install postgresql

修改默认密码

1
alter user postgres  with password xxx

配置java应用连接pgsql数据库

1
2
3
- data_center_jdbc_url=jdbc:postgresql://192.168.8.143:5432/d1_statistics?autoReconnect=true&useUnicode=true&rewriteBatchedStatements=true&useSSL=false
- data_center_jdbc_username=postgres
- data_center_jdbc_password=xxx