PostgreSQL安装笔记

安装PG

yum localinstall http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-centos94-9.4-1.noarch.rpm
yum install postgresql94-server postgresql94-devel postgresql94-contrib

systemctl enable postgresql-9.4
/usr/pgsql-9.4/bin/postgresql94-setup initdb
systemctl start postgresql-9.4

配置
修改认证方式为md5

vim /var/lib/pgsql/9.4/data/pg_hba.conf

添加

host    all             all             all                     md5

允许远程连接的ip

vim /var/lib/pgsql/9.4/data/postgresql.conf
listen_addresses = 'you_ip'

修改默认用户密码

su postgres
$ psql
postgres=# \password postgres

参考:
PostgreSQL本地登录trust、ident认证权限控制
如何在CentOS 7/6.5/6.4 下安装PostgreSQL 9.3 与 phpPgAdmin

修改性能选项

vim /var/lib/pgsql/9.4/data/postgresql.conf

添加/修改以下参数

shared_buffers = 32MBwork_mem = 16MBmaintenance_work_mem = 128MBcheckpoint_segments = 10dynamic_shared_memory_type = mmap

重启PG

systemctl restart postgresql-9.4

备份和恢复

备份pg

/usr/pgsql-9.4/bin/pg_dump -Fc -U  user  database_name | gzip >    filename

恢复pg

gunzip -c filename | /usr/pgsql-9.4/bin/pg_restore -d database_name -U user

用pg_dump_all 格式备份的必须用 psql命令恢复

gunzip -c pg.tgz | /usr/pgsql-9.4/bin/psql  -U user

参考:
http://www.postgresql.org/docs/9.4/static/backup-dump.html#BACKUP-DUMP-ALL
PgSql备份pg_dump与还原手记pg_restore(转)

你可能感兴趣的:(PostgreSQL安装笔记)