作者:hqiang1984
安装postgresql odbc驱动
Postgres-XC单机安装
gmake
gmake install
./initdb -D /usr/local/pgsql/data_coord1 –nodename coord1
./initdb -D /usr/local/pgsql/data_datanode1 –nodename datanode1
./initdb -D /usr/local/pgsql/data_datanode2 –nodename datanode2
./initgtm -D /usr/local/pgsql/data_gtm -Z gtm
./postgres -X -p 15432 -D /usr/local/pgsql/data_datanode1 &
./postgres -X -p 15433 -D /usr/local/pgsql/data_datanode2 &
./postgres -C -D /usr/local/pgsql/data_coord1 &
./psql
create node datanode1 with(type=’datanode’, port=15432);
create node datanode2 with(type=’datanode’, port=15433);
select pgxc_pool_reload();
./psql test
create table user_info_hash(id int primary key,firstname text,lastname text,info text) distribute by hash(id) to node datanode1,datanode2;
insert into user_info_hash select generate_series(1,10000),’zhou’,’digoal’,’DBA’;
使用Oracle gateway连接GP时编译plsql包太慢
oracle 跨库查询greenplum慢
Postgresql无法远程连接
环境: CentOS 5, Postgresql 9, WinXp
通过winXP上的psql连接远程服务器上postgresql服务,出现错误:
C:\\Documents and Settings\\rand>psql -U postgres -d postgres -h 10.71.88.251 -p 5432
psql: 无法联接到服务器: Connection refused (0x0000274D/10061)
服务器是否在主机 “10.71.88.251” 上运行并且准备接受在端口
5432 上的 TCP/IP 联接?
之前配置过pg_hba.conf上的信息:
host all all 10.71.88.252/32 trust –注10.71.88.252为winxp的IP地址
经排错,发现postgresql.conf中有一个监听器地址参数为#listen_addresses = ‘localhost’, 必须将其修改为listen_addresses = ‘*’,以便可以让其它客户端来访问。
Greenplum安装dblink模块
Postgresql日志归档设置
环境:winXP, postgresql
当需要对postgresql数据库进行定点恢复的时候,需要设置归档日志。具体如下:
wal_level:设置信息级别至wal.
archive_mode:表示是否进行归档操作,默认值为off(关闭)。
archive_command:由管理员设置的用于归档WAL日志的命令。
archive_time:表示归档周期,在超过该参数设定的时间时强制切换WAL段,默认值为0。
将参数设置wal_level=archive, archive_mode=on, archive_command=’copy “%p” “D:/program/pgsql/archived_log/%f”‘, archive_time=3600
Postgresql的调度pgAgent
环境: winxp, postgresql 9.0 , pgAgent-3.0.0
pgAgent是Postgresql的一个调度程序,在之前postgresql 9.0之前一直附带在pgAdmin包下,只是默认不安装。在之后的版本就单独作为一个安装包。在http://www.pgadmin.org/download/pgagent.php可以下载pgAgent程序。将下载的程序解压放在pgAdmin III目录下,运行pgagent.sql脚本,psql -U postgres -f $pginstall\\pgAdmin III\\pgAgent\\pgagent.sql。然后安装pgagent服务,$pginstall\\pgAdmin III\\pgAgent INSTALL pgAgent -u postgres
-p secret hostaddr=127.0.0.1 dbname=postgres user=postgres password=secret
这样在windows服务界面上有PostgreSQL Scheduling Agent – pgAgent服务,启动它才可以运行设定的批处理程序或sql语句。
PostgreSQL归档日志配置
环境: windows sever 2003 , postgresql 8.4
在PostgreSQL的安装目录下找到postgresql.conf文件,将其中的archive_mode , archive_command 修改为如下:
# – Archiving –
archive_mode = on # allows archiving to be done
# (change requires restart)
archive_command = ‘copy “%p” D:\\\\\\\\program\\\\\\\\postgresql_archivedlog\\\\\\\\”%f”‘ # command to use to archive a logfile segment
archive_timeout = 600 # force a logfile segment switch after this
# number of seconds; 0 disables
日志切换:
postgresql =# select pg_switch_xlog();