本文共 6039 字,大约阅读时间需要 20 分钟。
yum install -y lrzszyum install -y sysstatyum install -y e4fsprogsyum install -y ntpyum install -y readline-develyum install -y zlibyum install -y zlib-develyum install -y opensslyum install -y openssl-develyum install -y pam-develyum install -y libxml2-develyum install -y libxslt-devel/usr/sbin/ntpdate asia.pool.ntp.org && /sbin/hwclock --systohc-- 临时关闭防火墙, 生产中则配置一下, 开放互访监听端口service iptables stopvi /etc/sysctl.confkernel.shmmni = 4096kernel.sem = 50100 64128000 50100 1280fs.file-max = 7672460net.ipv4.ip_local_port_range = 9000 65000net.core.rmem_default = 1048576net.core.rmem_max = 4194304net.core.wmem_default = 262144net.core.wmem_max = 1048576net.ipv4.tcp_tw_recycle = 1net.ipv4.tcp_max_syn_backlog = 4096net.core.netdev_max_backlog = 10000vm.overcommit_memory = 0net.ipv4.ip_conntrack_max = 655360fs.aio-max-nr = 1048576net.ipv4.tcp_timestamps = 0sysctl -pvi /etc/security/limits.conf* soft nofile 131072* hard nofile 131072* soft nproc 131072* hard nproc 131072* soft core unlimited* hard core unlimited* soft memlock 50000000* hard memlock 50000000vi /etc/sysconfig/selinuxSELINUX=disabledcd /data03/soft_baktar -jxvf flex-2.5.35.tar.bz2cd flex-2.5.35./configure && make && make install32位机器上
useradd platform32vi /home/platform32/.bash_profileexport PGPORT=1616export PGDATA=/home/platform32/pg_rootexport LANG=en_US.utf8export PGHOME=/home/platform32/pgsqlexport LD_LIBRARY_PATH=$PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/libexport DATE=`date +"%Y%m%d%H%M"`export PATH=$PGHOME/bin:$PATH:.export MANPATH=$PGHOME/share/man:$MANPATHalias rm='rm -i'alias ll='ls -lh'64位机器上
useradd platform64vi /home/platform64/.bash_profile export PGPORT=1616export PGDATA=/home/platform64/pg_rootexport LANG=en_US.utf8export PGHOME=/home/platform64/pgsqlexport LD_LIBRARY_PATH=$PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/libexport DATE=`date +"%Y%m%d%H%M"`export PATH=$PGHOME/bin:$PATH:.export MANPATH=$PGHOME/share/man:$MANPATHalias rm='rm -i'alias ll='ls -lh'2. 编译安装PostgreSQL 9.1.4
64位机器./configure --prefix=/home/platform64/pgsql --with-pgport=1616 --with-perl --with-openssl --with-pam --without-ldap --with-libxml --with-libxslt --enable-thread-safety --with-wal-blocksize=16 && gmake worldsudo gmake install-world32位机器./configure --prefix=/home/platform32/pgsql --with-pgport=1616 --with-perl --with-openssl --with-pam --without-ldap --with-libxml --with-libxslt --enable-thread-safety --with-wal-blocksize=16 && gmake worldsudo gmake install-world3. 在32bit 机器上初始化数据库
initdb -D $PGDATA -E UTF8 --locale=C -U postgres -Wvi pg_hba.confhost replication replica 192.168.101.35/32 md5host all all 0.0.0.0/0 md5vi postgresql.conflisten_addresses = '0.0.0.0'port = 1616max_connections = 100shared_buffers = 1024MBmaintenance_work_mem = 512MBmax_stack_depth = 8MBwal_level = hot_standbycheckpoint_segments = 32max_wal_senders = 32wal_sender_delay = 10mswal_keep_segments = 64hot_standby = onpg_ctl startpsql -h 127.0.0.1 postgres postgrescreate role replica nosuperuser nocreatedb nocreaterole noinherit login replication connection limit 32 encrypted password 'REPLICA';vi /home/platform32/.pgpass192.168.101.66:1616:replication:replica:REPLICA192.168.101.35:1616:replication:replica:REPLICAchmod 400 /home/platform32/.pgpass4. 配置standby
vi /home/platform64/.pgpass192.168.101.66:1616:replication:replica:REPLICA192.168.101.35:1616:replication:replica:REPLICAchmod 400 /home/platform64/.pgpassvi $PGDATA/recovery.confrecovery_target_timeline = 'latest'standby_mode = onprimary_conninfo = 'host=192.168.101.66 port=1616 user=replica keepalives_idle=60'trigger_file = '/home/platform64/pg_root/.1616.PG.trigger'5. 初始化standby
pg_basebackup -D $PGDATA -F p -x -l base -P -v -h 192.168.101.66 -p 1616 -U replica6. 启动standby
pg_ctl start报错FATAL: incorrect checksum in control file7. 修改pg_controlfile的checksum源码, 不check.
vi src/backend/access/transam/xlog.c注释checksum部分 /* if (!EQ_CRC32(crc, ControlFile->crc)) ereport(FATAL, (errmsg("incorrect checksum in control file"))); */
FATAL: database files are incompatible with serverDETAIL: The database cluster was initialized with MAXALIGN 1093850759, but the server was compiled with MAXALIGN 8.HINT: It looks like you need to initdb.在控制文件差别 :
32 位机器的控制文件信息 : Maximum data alignment: 4Maximum size of a TOAST chunk: 200064 位机器(initdb 后)的控制文件信息 : Maximum data alignment: 8Maximum size of a TOAST chunk: 1996
在src/backend/access/transam/xlog.c这里面有很多的check, 不一一列出.要在64 bit的机器上使用到底应该怎么办呢?其实和程序有关系, 只要把32bit 上编译的pgsql程序拷贝过来就可以了10. 在64bit的机器上使用32bit的pgsql做standby .
scp -r root@32bit:/home/platform32/pgsql /home/platform64/pg_ctl start在primary上插入测试数据 :
[platform32@192_168_101_66 pg_root]$ psql postgres postgres -h 127.0.0.1 psql (9.1.4) Type "help" for help. postgres=# \dt List of relations Schema | Name | Type | Owner --------+------+-------+---------- public | t | table | postgres (1 row) postgres=# create table test (id int); CREATE TABLE postgres=# insert into test select generate_series (1,10000); INSERT 0 10000在standby上验证 :
[platform64@db-192-168-101-35 ~]$ psql -h 127.0.0.1 postgres postgrespsql (9.1.4)Type "help" for help.postgres=# select count(*) from test; count ------- 10000(1 row)
[platform32@192_168_101_66 ~]$ pg_ctl --help -bash: /home/platform32/pgsql/bin/pg_ctl: cannot execute binary file[platform32@192_168_101_66 ~]$ postgres --help -bash: /home/platform32/pgsql/bin/postgres: cannot execute binary file
转载地址:http://toebm.baihongyu.com/