Ubuntu 14.04安装PostgreSQL 9.2(二)

2015-11-10 12:16:30 · 作者: · 浏览: 9

Removing apt.postgresql.org key from trusted.gpg: OK
Importing apt.postgresql.org key: OK
正在设置 postgresql-client-common (169.pgdg12.4+1) ...
正在设置 postgresql-client-9.2 (9.2.13-1.pgdg12.4+1) ...
update-alternatives: 使用 /usr/share/postgresql/9.2/man/man1/psql.1.gz 来提供 /usr/share/man/man1/psql.1.gz (psql.1.gz),于 自动模式 中。
正在设置 ssl-cert (1.0.28ubuntu0.1) ...
正在设置 postgresql-common (169.pgdg12.4+1) ...
Adding user postgres to group ssl-cert


Creating config file /etc/postgresql-common/createcluster.conf with new version


Creating config file /etc/logrotate.d/postgresql-common with new version
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
? en_us
Removing obsolete dictionary files:
?* No PostgreSQL clusters exist; see "man pg_createcluster"
正在设置 postgresql-9.2 (9.2.13-1.pgdg12.4+1) ...
Creating new cluster 9.2/main ...
? config /etc/postgresql/9.2/main
? data? /var/lib/postgresql/9.2/main
? locale zh_CN.UTF-8
? port? 5432
update-alternatives: 使用 /usr/share/postgresql/9.2/man/man1/postmaster.1.gz 来提供 /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz),于 自动模式 中。
?* Starting PostgreSQL 9.2 database server? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? [ OK ]
正在处理用于 libc-bin 的触发器...
ldconfig deferred processing now taking place


?4.配置远程访问


PostgreSQL刚安装好后的状态应该是,Ubuntu上的postgres用户密码未知,数据库上的postgres密码未设


若用root或允许sudo,可以直接强制以postgres用户登录,不需要知道postgres的密码


root  # su postgres
postgres  $ psql
psql (9.2.13)
输入 "help" 来获取帮助信息.


postgres=#


(非root,允许sudo的用户,这里设了免密)? ? $ sudo -u postgres psql
psql (9.2.13)
输入 "help" 来获取帮助信息.


postgres=#


登录后就给SQL的postgres设个密码


postgres#\password postgres


退出去找一个目录,要修改两个文件,postgresql.conf 和 pg_hba.conf


# find / -name postgresql.conf
/etc/postgresql/9.2/main/postgresql.conf
# cd /etc/postgresql/9.2/main/
# l
environment? pg_ctl.conf? pg_hba.conf? pg_ident.conf? postgresql.conf? start.conf


postgresql.conf 监听所有IP,默认端口,开启日志收集,每天一个新日志,还有很多不懂的参数可以调。



listen_addresses = '*'? ? ? ? ? # what IP address(es) to listen on;
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? # comma-separated list of addresses;
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? # defaults to 'localhost'; use '*' for all
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? # (change requires restart)
port = 5432? ? ? ? ? ? ? ? ? ? ? ? ? ? # (change requires restart)
logging_collector = on? ? ? ? ? # Enable capturing of stderr and csvlog
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? # into log files. Required to be on for
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? # csvlogs.
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? # (change requires restart)
log_directory = 'pg_log'? ? ? ? ? ? ? ? # directory where log files are written,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? # can be absolute or relative to PGDATA
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # log file name pattern,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? # can include strftime() escapes
log_truncate_on_rotation = off? ? ? ? ? # If on, an existing log file with the
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? # same name as the new log file will be
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? # truncated rather than appended to.
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? # But such truncation only occurs on
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? # time-driven rotation, not on restarts
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? # or size-driven rotation.? Default is
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? # off, meaning append to existing files
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? # in all cases.
log_rotation_age = 1d? ? ? ? ? ? ? ? ? # Automatic rotation of logfiles will
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? # happen after that time.? 0 disables.
log_rotation_size = 0? ? ? ? ?      # Automatic rotation of logfiles will
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? # happen a