为什么显示我自己的微信转账显示账户异常常

database(33)
备注:主要是参考pgpool-II官方文件搭建,但某些步骤可能是因为版本问题和实际环境,需略作修改
本文环境:操作系统Version:Ubuntu 14.10
& & & & &postgresql&Version:9.3.1
& & & & &pgpool-II Version:pgpool-II-3.3.6
& & & & 2台服务器:1台放置pg和pgpool-II(localhost)
& & & & & & & & & 1台放置pg(192.168.100.137)
Step1:安装pgpool-II
&&&&& 1.1 下载网址:,选择Source中的一个版本,
& & & &&本文采用的是3.4.1(pgpool-II-3.3.6.tar)
& &&1.2 解压:tar gvxf pgpool-II-3.3.6.tar
& &&1.3&进入解压后的目录:./configure
& & & & & & & & & & & & & &make
& & & & & & & & & & & & & &make install
& &&&ps:如果你的postgresql安装路径不是在默认的路径(/usr/local/pgsql),则在编译的时候需要加上参数./configure
--with-pgsql&安装路径
& & & &&不然可能出现错误:configure:
error: libpq is not installed or libpq is old
Step2:配置pgpool-II
& &&2.1 配置pgpool.conf
& &&& & &root@ubuntu:~# cp /usr/local/etc/pgpool.conf.sample /usr/local/etc/pgpool.conf
& & &root@ubuntu:~# gedit /usr/local/etc/pgpool.conf
& & &具体修改项如下
& & &listen_addresses = '*'&
& & &添加pg服务器节点信息(实验中使用2台pg服务器,一台与pgpool服务器放在同一台上,另一台pg服务器IP是192.168.100.137)
& & &backend_hostname0 = 'localhost'
& & &backend_port0 = 5432
& & &backend_weight0 = 1
& & &backend_hostname1 = '192.168.100.137'
& & &backend_port1 = 5432
& & &backend_weight1 = 1
&&& &ps:2.1.1backend_hostname,backend_port,backend_weight
分别是节点的主机名,端口号和负载均衡系数。
& & & & & & &backend_weight 参数都为 1 ,这意味着 SELECT 查询被平均分配到三台服务器上
& & & & &2.1.2在每个参数串的后面,必须通过添加从0开始(例如 0,1,2,…)的整数来指出节点编号,
& & & & &2.1.3pgpool-II 默认只接受到 9999 端口的本地连接。如果希望从其他主机接受连接,则需设置 listen_addresses 为 '*'
&2.2 配置pcp.conf
& &&root@ubuntu:~# cp /usr/local/etc/pcp.conf.sample /usr/local/etc/pcp.conf
& &root@ubuntu:~# gedit /usr/local/etc/pcp.conf
& & & &在pcp.conf中定义一个用户名和密码,这里我们添加如下用户名和密码,密码使用md5 哈希加密的格式
& & & &添加如下一行
&&&ps:我们可以通过如下命令获取md5加密后的密码--&以如下为例,即&postgres“的md5加密后是e8ac69dfc
& & &&/usr/bin/pg_md5 postgres
& & &&e8ac69dfc5
& & &这里我们使用默认的9898作为pcp_port端口
&2.3 尝试启动、停止 pgpool-II
& &&启动pgpool-II命令:&pgpool -n -d &/tmp/pgpool.log 2&&1 &
& &&ps:以上命令持续追加日志消息到
/tmp/pgpool.log 中
&&& & 停止pgpool-II命令:&pgpool
&& & & &ps:如果还有客户端连接着,
pgpool-II 等待它们断开连接,然后才结束运行。如果想强制关闭 pgpool-II ,则可以执行以下命令&
& & && & & &&pgpool -m fast stop
Step3:配置并行查询模式
&3.1配置并行查询
& &修改/usr/local/etc/pgpool.conf,具体修改如下
& &parallel_mode = true
& &replication_mode = false
& &&load_balance_mode = true
3.2配置系统数据库
& &修改/usr/local/etc/pgpool.conf,以下其实也是pgpool.conf的默认设置,可不用修改
& &system_db_hostname = 'localhost'
& &&system_db_port = 5432
& &&system_db_dbname = 'pgpool'
& &&system_db_schema = 'pgpool_catalog'
& &&system_db_user = 'pgpool'
& & system_db_password = ''
& &建立一个叫做“pgpool”的用户,并建立一个属主为“pgpool”的名为“pgpool”的数据库
& &postgres@ubuntu:~$ createuser -p 5432 pgpool
& &postgres@ubuntu:~$ createdb -p 5432 -O pgpool pgpool
3.3在“pgpool”数据库中安装dblink
& 3.3.1如果在安装postgresql数据库时,使用了&make world&和&make install-word&进行安装,
& & & &则只需要连接到pgpool数据库时,执行如下命令
& & & &pgpool=# cre
& 3.3.2如果在安装postgresql数据库时,使用了&make &和&make install&进行安装,
& & & &则需先进入到postgresql源代码目录的contrib/dblink下,执行make,make install安装dblink插件
& & & &然后再连接到pgpool数据库时,执行如下
& & & &pgpool=# cre
&&ps:以上2种方式只需选择一种
&3.4定义 dis_def表和定义replicate_def表
& 3.4.1定义dis_def表
&&在数据库“pgpool”中定义一个“dist_def”表,用于保存分区规则。
&&在 pgpool-II 安装后,你会得到一个 system_db.sql,它是一个可用于生成系统数据库的 psql 脚本。
& &postgres@ubuntu:~$ psql -f /usr/local/share/pgpool-II/system_db.sql -p 5432 -U pgpool pgpool
&&有关dis_def表的说明如下
& &dist_def 表被建立到 pgpool_catalog 这个 schema 中。
&&如果你配置 system_db_schema 使用了其他的 schema,你需要相应地编辑 system_db.sql。
&&“dist_def的定义如下,且表名不能被改变。
& &CREATE TABLE pgpool_catalog.dist_def (
& & dbname text, -- database name
& & schema_name text, -- schema name
& & table_name text, -- table name
& & col_name text NOT NULL CHECK (col_name = ANY (col_list)), -- distribution key-column
& & col_list text[] NOT NULL, -- list of column names
& & type_list text[] NOT NULL, -- list of column types
& & dist_def_func text NOT NULL, -- distribution function name
& & PRIMARY KEY (dbname, schema_name, table_name)
&“dist_def”中保存的 tuple 可以被分为两类。
分发规则 (col_name, dist_def_func)
表的元信息 (dbname, schema_name, table_name, col_list, type_list)
分发规则确定如何分发数据到特定节点。数据将依赖“col_name”的值来进行分发。“dist_def_func”是一个函数,它使用“col_name”列的值做参数,返回一个指出数据将要存储的数据库节点 ID 的适当整数。
元信息用于重写查询。并行查询必须重写查询比便让从后台节点返回的数据可以被合并为一个结果集。
&3.4.2 定义replicate_def
& & &&&&如果你想在 SELECT 语句的并行模式中使用复制的表,你需要在一个叫做 replicate_def 的表中注册这些表的信息(复制规则)。 & & & & & & replicate_def
表在定义 dist_def 表的时候已经由 system_db.sql 创建。replicate_def 表的定义如下。
& &&CREATE TABLE pgpool_catalog.replicate_def (
& & dbname text, -- database name
& & schema_name text, -- schema name
& & table_name text, -- table name
& & col_list text[] NOT NULL, -- list of column names
& & type_list text[] NOT NULL, -- list of column types
& & PRIMARY KEY (dbname, schema_name, table_name)
&3.5定义分发规则和复制规则
& 3.5.1定义分发规则
& & 在本实验中我们将定义规则用于分发 pgbench 的示例数据到两个数据库节点中。
& &&示例数据将通过“pgbench -i -s 3”(例如比例因子为3)建立。在本小节,我们将建立一个叫“bench_parallel”的新数据库。
& & &在 pgpool-II 的源码中在,你可以在 sample 目录中找到 dist_def_pgbench.sql 文件。
&&&&ps:因为实验中只有2个数据库节点,而且我们要分发的表名是pgbench_accounts,pgbench_tellers等,
& & & &&所以我们要对dist_def_pgbench.sql先进行一些修改&&
&&修改后的dist_def_pgbench.sql见附件(dist_def_pgbench.docx)& & &仅需要修改附件中的红色字体部分
& & 修改完成后执行如下命令,其中“/home/postgres/pgpool-II-3.3.6&是pgpool-II的源码目录
& &&postgres@ubuntu:~$ psql -f /home/postgres/pgpool-II-3.3.6/sample/dist_def_pgbench.sql -p pgpool
& & & &&&ps:以下为
dist_def_pgbench.sql 的说明。
& & & &&在 dist_def_pgbench.sql中,我们往“dist_def”表中插入一行。
& & & &这里有一个为&pgbench_accounts 表准备的分发函数。作为关键列,aid 被定义在每个&pgbench_accounts
表中(也是主键)。
& & &&INSERT INTO pgpool_catalog.dist_def VALUES (
& & & & & & &'bench_parallel',
& & & & & & &'public',
& & & & & &&&'pgbench_accounts',
& & & & & & &'aid',
& & & & & &&&ARRAY['aid', 'bid', 'abalance', 'filler'],
& & & & & & &ARRAY['integer', 'integer', 'integer', 'character(84)'],
& & & & & & &'pgpool_catalog.dist_def_accounts'
& & &&现在,我们必须为&&pgbench_accounts表定义分发函数。注意你可以对不同的表使用相同的函数。而且,你可以使用
SQL 之外的语言定义函数(例如 PL/pgSQL,PL/Tcl 等等)。
&pgbench_accounts表在初始化时指定了比例因子为
3,aid 的值为 1 到 300000。函数被定义为使数据分布到2个数据库节点中。
& & &&SQL 函数将定义为返回数据库节点的编号。
& & &&CREATE OR REPLACE FUNCTION pgpool_catalog.dist_def_branches(anyelement)
& & &&RETURNS integer AS $$
& & & & &SELECT CASE WHEN $1 & 0 AND $1 &= 1 THEN 0
& & & & WHEN $1 & 1 AND $1 &= 2 THEN 1
& & & & ELSE 1
& & & & &END;
& & &&$$ LANGUAGE
&&3.5.2定义复制规则
& 复制规则是定义某个表是否被复制的规则。
& &&本实验忽略此步骤,可参考的说明进行定义
Step4检查并行模式
& &&4.1要使
pgpool.conf 中的改动生效,pgpool-II 必须重启
& 4.2我们需要建立一个用于分发的数据库。我们将给它命名为“bench_parallel”。
& &&这个数据库需要在所有节点上被建立。通过 pgpool-II 使用 createdb 命令,则数据库将被奖励在所有节点上。
& & &$ createdb -p 9999 bench_parallel
& 4.3我们将使用 -i -s 3 选项执行 pgbench 。-i 选项使用预定义的表和数据初始化数据库。 -s 选项指出用于初始化的比例因子。
& & &$ pgbench -i -s 3 -p 9999 bench_parallel
& 4.4检查数据是否被正确分发的一个方法是通过 pgpool-II 和直接在后台节点执行一个 SELECT 查询,然后比较两个结果
& & 查看本机:postgres@ubuntu:~$ psql -c &SELECT min(aid), max(aid) FROM pgbench_accounts& &bench_parallel
& & & & & & &&&min | &max &&
& & & & & & & -----+--------
& & & & & & & &&&1 | 100000
& & & & & &&(1 row)
& & 查看192.168.100.137:psql -c &SELECT min(aid), max(aid) FROM pgbench_accounts& -h 192.168.100.137 &bench_parallel &
& & & & & &&min | &max &&
& & & & & & -----+--------
& & & & & 100001 | 300000
& & & & & & (1 row)
& &通过pgpool-II查看:psql -c &SELECT min(aid), max(aid) FROM pgbench_accounts& -p 9999 bench_parallel
& &但是通过pgpool-II查看时,结果会出错,提示需要密码;
& &根据&&,
& 备注:未找到解决方法,在pgpool的新版本中已经放弃parallel并行查询模式!
& &备注:还可以参考链接:进行配置
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:93214次
积分:1994
积分:1994
排名:第15947名
原创:64篇
转载:320篇
(2)(7)(2)(6)(2)(1)(4)(4)(11)(9)(12)(1)(15)(44)(7)(19)(22)(5)(7)(12)(7)(18)(48)(19)(55)(15)(13)(14)(1)温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
二 系统配置 ( 两台 )--2.1 创建 pgxc 系统用户并赋权[root@redhatB bin]# groupadd pgxc[root@redhatB bin]# useradd pgxc -g pgxc [root@redhatB bin]# passwd pgxcChanging password for user pgxc.New password: BAD PASSWORD: it is based on a dictionary wordRetype new password: passwd: all authentication tokens updated successfully.
[root@redhatB pgxc]# chown -R pgxc:pgxc /pgdata_xc
--2.2&&系统层面其它配置
&&&&& 根据需要配置其它系统层参数,由于是在虚拟机上运行,其它系统参数暂不修改。&
三 安装 postgresql-xc ( 两台都安装 )--3.1 &pgxc_v1.0beta2 下载下载 pgxc_v1.0beta2.tar.gz
--3.2 将安装包解压 ( 两台 )
&cd /opt/soft_baktar zxvf pgxc_v1.0beta2.tar.gz &&&
备注:解压后,产生目录 pgxc
-3.3 -配置
&./configure --prefix=/opt/pgsql_xc& --with-segsize=8 --with-wal-segsize=64 --with-wal-blocksize=64 --with-perl --with-python --with-openssl --with-pam --with-ldap --with-libxml --with-libxslt --enable-thread-safety&&&
&&& 备注:conifugre 过程中如有提示缺少相关包,yum 安装即可。
--3.4 编译&
&gmake &&&
&备 注:编译后,如果出现"All of PostgreSQL successfully made. Ready to install.",说明编译成功。&&--3.5 安装 PostgreSQL XC
&gmake install&&&
&& 备注:安装后如果提示 "PostgreSQL installation complete." 说明安装成功。&& &&四 配置数据节点 ( 192.168.1.36 ) --4.1 修改环境变量( .bash_profile )
&export PGPORT=15431export PGDATA=/pgdata_xc/db_1/pg_rootexport LANG=en_US.utf8
export PGHOME=/opt/pgsql_xcexport 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'&& &&&
--4.2 创建数据目录
&pgxc@redhatB pgdata_xc]$ mkdir -p /pgdata_xc/db_1/pg_root[pgxc@redhatB pgdata_xc]$ mkdir -p /pgdata_xc/db_2/pg_root&&&
--4.3 初始化数据节点1
&initdb -D /pgdata_xc/db_1/pg_root --nodename db_1& -E UTF8 --locale=C -U postgres -W&&&
--4.4 修改数据节点一配置文件 postgresql.conf 参数
&# - Connection Settings -port = 15431
# - Where to Log -log_destination = 'csvlog'logging_collector = on& log_directory = 'pg_log'& log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'log_truncate_on_rotation = on log_rotation_age = 1d& log_rotation_size = 10MB& gtm_host = 'localhost'
# GTM CONNECTIONgtm_host = '192.168.1.35'gtm_port = 6666 pgxc_node_name = 'db_1'
# DATA NODES AND CONNECTION POOLINGpooler_port = 6667 max_pool_size = 100 &&&
--4.5修改数据节点一 pg_hba.conf ,增加以下
host all all 192.168.1.35/32 trusthost all all 0.0.0.0/0 md5&&&
--4.6 初始化数据节点2
&initdb -D /pgdata_xc/db_2/pg_root --nodename db_2& -E UTF8 --locale=C -U postgres -W&&&
--4.7 修改数据节点二配置文件 postgresql.conf 参数
&# - Connection Settings -port = 15432
# - Where to Log -log_destination = 'csvlog'logging_collector = on& log_directory = 'pg_log'& log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'log_truncate_on_rotation = on log_rotation_age = 1d& log_rotation_size = 10MB& gtm_host = 'localhost'
# GTM CONNECTIONgtm_host = '192.168.1.35'gtm_port = 6666 pgxc_node_name = 'db_2'
# DATA NODES AND CONNECTION POOLINGpooler_port = 6667 max_pool_size = 100
&&&&--4.8 修改数据节点一 pg_hba.conf ,增加以下
&host all all 192.168.1.35/32 trusthost all all 0.0.0.0/0 md5 &&&&&五 配置 gtm 节点 ( 192.168.1.35 )--5.1 修改 .bash_profile
&export PGPORT=1921export PGDATA=/database/1922/pgdata1/pgdata_xc/coord1export LANG=en_US.utf8
export PGHOME=/opt/pgsql_xc
export 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'&&&
&--5.2 创建 gtm 数据目录
&[pgxc@redhat6 pgdata_xc]$ mkdir -p /database/1922/pgdata1/pgdata_xc/gtm&&&
--5.3 install gtm
&[pgxc@redhat6 bin]$ initgtm -Z gtm -D /database/1922/pgdata1/pgdata_xc/gtmThe files belonging to this GTM system will be owned by user "pgxc".This user must also own the server process.
fixing permissions on existing directory /database/1922/pgdata1/pgdata_xc/gtm ... okcreating configuration files ... ok
Success. You can now start the GTM server using:
&&& gtm -D /database/1922/pgdata1/pgdata_xc/gtmor&&& gtm_ctl -Z gtm -D /database/1922/pgdata1/pgdata_xc/gtm -l logfile start&&&
六 配置 coordinator 节点--6.1 创建 coordinator 数据目录
&[pgxc@redhat6 pgdata_xc]$ mkdir -p /database/1922/pgdata1/pgdata_xc/coord1[pgxc@redhat6 pgdata_xc]$ mkdir -p /database/1922/pgdata1/pgdata_xc/coord2&&&
--6.2 install coord1
&initdb -D /database/1922/pgdata1/pgdata_xc/coord1 --nodename coord1& -E UTF8 --locale=C -U postgres -W&&&
--6.3 修改 coord1 配置文件 postgresql.conf
&# - Connection Settings -listen_addresses = '*'port = 1921
# - Where to Log -log_destination = 'csvlog'logging_collector = on& log_directory = 'pg_log'& log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'log_truncate_on_rotation = on log_rotation_age = 1d& log_rotation_size = 10MB& gtm_host = 'localhost'
# GTM CONNECTIONgtm_host = 'localhost'gtm_port = 6666 pgxc_node_name = 'coord1'
# DATA NODES AND CONNECTION POOLINGpooler_port = 6667max_pool_size = 100 &&&
--6.4 配置 coord1 pg_hba.conf
&host all all 192.168.1.36/32 trusthost all all 0.0.0.0/0 md5 &&&&
--6.5 install coord2
&initdb -D /database/1922/pgdata1/pgdata_xc/coord2 --nodename coord2& -E UTF8 --locale=C -U postgres -W&&&
--6.6 配置 coord2 配置文件 postgresql.conf
# - Connection Settings -listen_addresses = '*'port = 1925
# - Where to Log -log_destination = 'csvlog'logging_collector = on& log_directory = 'pg_log'& log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'log_truncate_on_rotation = on log_rotation_age = 1d& log_rotation_size = 10MB& gtm_host = 'localhost'
# GTM CONNECTIONgtm_host = 'localhost'gtm_port = 6666 pgxc_node_name = 'coord2'
# DATA NODES AND CONNECTION POOLINGpooler_port = 6668max_pool_size = 100 &&&
--6.7 配置 coord1 pg_hba.conf
&host all all 192.168.1.36/32 trusthost all all 0.0.0.0/0 md5 &&&
--6.8 修改防火墙,打开相应端口 ( 两台)&&& 为了测试简便,先暂时关闭防火墙和 seliniux。&
七 启动 PostgreSQL-XC--7.1 start gtm
&[pgxc@redhat6 bin]$ gtm -D /database/1922/pgdata1/pgdata_xc/gtm && [1] 6185&&&
--查看 gtm 是否启动
&[pgxc@redhat6 bin]$ gtm_ctl status -S gtm -D /database/1922/pgdata1/pgdata_xc/gtmpid: 6185data: /database/1922/pgdata1/pgdata_xc/gtmactive: 1
[pgxc@redhat6 bin]$ ps -ef | grep gtmpgxc&&&&& & 0 20:50 pts/4&&& 00:00:00 gtm -D /database/1922/pgdata1/pgdata_xc/gtm&&
& 备注: gtm 进程已经正常启动。
--7.2 启动数据节点( 192.168.1.36 )
&postgres -X -D /pgdata_xc/db_1/pg_root -p 15431& -i &postgres -X -D /pgdata_xc/db_2/pg_root -p 15432& -i &
&&&& 备注:-X 表示&datanode 节点。&
-- 查看数据节点是否启动
&[pgxc@redhatB pg_log]$ ps -ef | grep pgxcroot&&&&&& 371&& 351& 0 09:16 pts/0&&& 00:00:00 su - pgxcpgxc&&&&&& 372&& 371& 0 09:16 pts/0&&& 00:00:00 -bashroot&&&&&& 420&& 398& 0 09:16 pts/1&&& 00:00:00 su - pgxcpgxc&&&&&& 421&& 420& 0 09:16 pts/1&&& 00:00:00 -bashpgxc&&&&&& 588&& 421& 0 09:28 pts/1&&& 00:00:00 postgres -X -D /pgdata_xc/db_1/pg_root -p 15431 -ipgxc&&&&&& 589&& 588& 0 09:28 ?&&&&&&& 00:00:00 postgres: logger process&&&&&&&&&&&&&&&&&&&&&&&&& pgxc&&&&&& 591&& 588& 0 09:28 ?&&&&&&& 00:00:00 postgres: writer process&&&&&&&&&&&&&&&&&&&&&&&&& pgxc&&&&&& 592&& 588& 0 09:28 ?&&&&&&& 00:00:00 postgres: wal writer process&&&&&&&&&&&&&&&&&&&&& pgxc&&&&&& 593&& 588& 0 09:28 ?&&&&&&& 00:00:00 postgres: autovacuum launcher process&&&&&&&&&&&& pgxc&&&&&& 594&& 588& 0 09:28 ?&&&&&&& 00:00:00 postgres: stats collector process&&&&&&&&&&&&&&&& pgxc&&&&&& 595&& 421& 0 09:28 pts/1&&& 00:00:00 postgres -X -D /pgdata_xc/db_2/pg_root -p 15432 -ipgxc&&&&&& 596&& 595& 0 09:28 ?&&&&&&& 00:00:00 postgres: logger process&&&&&&&&&&&&&&&&&&&&&&&&& pgxc&&&&&& 598&& 595& 0 09:28 ?&&&&&&& 00:00:00 postgres: writer process&&&&&&&&&&&&&&&&&&&&&&&&& pgxc&&&&&& 599&& 595& 0 09:28 ?&&&&&&& 00:00:00 postgres: wal writer process&&&&&&&&&&&&&&&&&&&&& pgxc&&&&&& 600&& 595& 0 09:28 ?&&&&&&& 00:00:00 postgres: autovacuum launcher process&&&&&&&&&&&& pgxc&&&&&& 601&& 595& 0 09:28 ?&&&&&&& 00:00:00 postgres: stats collector process&&&&&&&&&&&&&&&&&
--7.3 启动 coordinator 节点
&postgres -C -D /database/1922/pgdata1/pgdata_xc/coord1 -p 1921& -i &postgres -C -D /database/1922/pgdata1/pgdata_xc/coord2 -p 1925& -i &
&& 备注:-C 表示 &&coordinator 节点。
--查看 coordinator 节点是否启来
pgxc&&&& 1& 0 10:25 pts/3&&& 00:00:00 postgres -C -D /database/1922/pgdata1/pgdata_xc/coord1 -p 1921 -ipgxc&&&& & 0 10:25 ?&&&&&&& 00:00:00 postgres: logger process&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& pgxc&&&& & 0 10:25 ?&&&&&&& 00:00:00 postgres: pooler process&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& pgxc&&&& & 0 10:25 ?&&&&&&& 00:00:00 postgres: writer process&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& pgxc&&&& & 0 10:25 ?&&&&&&& 00:00:00 postgres: wal writer process&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& pgxc&&&& & 0 10:25 ?&&&&&&& 00:00:00 postgres: autovacuum launcher process&&&&&&&&&&&&&&&&&&&&&&&&&&& pgxc&&&& & 0 10:25 ?&&&&&&& 00:00:00 postgres: stats collector process&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& pgxc&&&& 1& 0 10:25 pts/3&&& 00:00:00 postgres -C -D /database/1922/pgdata1/pgdata_xc/coord2 -p 1925 -ipgxc&&&& & 0 10:26 ?&&&&&&& 00:00:00 postgres: logger process&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& pgxc&&&& & 0 10:26 ?&&&&&&& 00:00:00 postgres: pooler process&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& pgxc&&&& & 0 10:26 ?&&&&&&& 00:00:00 postgres: writer process&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& pgxc&&&& & 0 10:26 ?&&&&&&& 00:00:00 postgres: wal writer process&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& pgxc&&&& & 0 10:26 ?&&&&&&& 00:00:00 postgres: autovacuum launcher process&&&&&&&&&&&&&&&&&&&&&&&&&&& pgxc&&&& & 0 10:26 ?&&&&&&& 00:00:00 postgres: stats collector process&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& pgxc&&&& & 0 10:53 ?&&&&&&& 00:00:00 postgres: postgres postgres ::1(13531) idle&&&&&&&&&&&&&&&&&&&&& pgxc&&&& & 0 11:01 ?&&&&&&& 00:00:00 postgres: postgres postgres ::1(14789) idle&&&&&&&&&&&&&&&&&&&&& pgxc&&&& & 0 11:16 ?&&&&&&& 00:00:00 postgres: francs francs ::1(14825) idle&&&
&&& 备注:coord1,coord2 节点分别多了个&&&&&pooler process 进程,pooler process 用来与数据节点进行通信的。
--7.4 查看GTM,POOL连接
&[root@redhat6 ~]# netstat -anp | grep gtmtcp&&&&&&& 0&&&&& 0 0.0.0.0:6666&&&&&&&&&&&&&&& 0.0.0.0:*&&&&&&&&&&&&&&&&&& LISTEN&&&&& 11620/gtm&&&&&&&&&& tcp&&&&&&& 0&&&&& 0 :::6666&&&&&&&&&&&&&&&&&&&& :::*&&&&&&&&&&&&&&&&&&&&&&& LISTEN&&&&& 11620/gtm&&&&&&&&&& tcp&&&&&&& 0&&&&& 0 ::1:6666&&&&&&&&&&&&&&&&&&& ::1:52228&&&&&&&&&&&&&&&&&& ESTABLISHED 11620/gtm&&&& &&&&& [root@redhat6 ~]# ps -ef | grep poolpgxc&&&& & 0 10:25 ?&&&&&&& 00:00:00 postgres: pooler process&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& pgxc&&&& & 0 10:26 ?&&&&&&& 00:00:00 postgres: pooler process&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& root&&&& & 0 11:53 pts/2&&& 00:00:00 grep pool
&&&备注:如果到了这步,没有看到 pooler process ,或者没有 gtm 相关连接,说明配置有问题。
八:注册节点--8.4 在 coord1,cord2 上注册数据节点
&CREATE NODE db_1 WITH (TYPE='datanode',HOST = '192.168.1.36', PORT=15431);CREATE NODE db_2 WITH (TYPE='datanode',HOST = '192.168.1.36', PORT=15432);CREATE NODE coord2 WITH (TYPE='coordinator',HOST = 'localhost', PORT=1925);CREATE NODE coord1 WITH (TYPE='coordinator',HOST = 'localhost', PORT=1921);&&&
[pgxc@redhat6 gtm]$ psql -p 1921 -U postgrespsql (PGXC 1.0beta2, based on PG 9.1.3)Type "help" for help.
postgres=# select * from pgxc_&node_name | node_type | node_port | node_host | nodeis_primary | nodeis_preferred |& node_id&& -----------+-----------+-----------+-----------+----------------+------------------+------------&coord1&&& | C&&&&&&&& |&&&&& 5432 | localhost | f&&&&&&&&&&&&& | f&&&&&&&&&&&&&&& | (1 row)
postgres=# CREATE NODE db_1 WITH (TYPE='datanode',HOST = '192.168.1.36', PORT=15431,PRIMARY, PREFERRED);CREATE NODEpostgres=# CREATE NODE db_2 WITH (TYPE='datanode',HOST = '192.168.1.36', PORT=15432);CREATE NODEpostgres=# CREATE NODE coord2 WITH (TYPE='coordinator',HOST = '192.168.1.35', PORT=1925);CREATE NODEpostgres=# select * from pgxc_&node_name | node_type | node_port |& node_host&& | nodeis_primary | nodeis_preferred |&& node_id&& -----------+-----------+-----------+--------------+----------------+------------------+-------------&coord1&&& | C&&&&&&&& |&&&&& 5432 | localhost&&& | f&&&&&&&&&&&&& | f&&&&&&&&&&&&&&& |& &db_1&&&&& | D&&&&&&&& |&&&& 15431 | 192.168.1.36 | f&&&&&&&&&&&&& | f&&&&&&&&&&&&&&& |& &db_2&&&&& | D&&&&&&&& |&&&& 15432 | 192.168.1.36 | f&&&&&&&&&&&&& | f&&&&&&&&&&&&&&& |& -&coord2&&& | C&&&&&&&& |&&&&& 1925 | localhost&&& | f&&&&&&&&&&&&& | f&&&&&&&&&&&&&&& | -
postgres=# select pgxc_pool_reload();&pgxc_pool_reload ------------------&t(1 row)&&&
&& & 备注:到了这里, PostgreSQL-XC 安装完成,接下来验证下。
九 测试--9.1 coord1 创建测试库和表
&[pgxc@redhat6 coord2]$ psql -p 1921 -U postgrespsql (PGXC 1.0beta2, based on PG 9.1.3)Type "help" for help.
postgres=# \l&&&&&&&&&&&&&&&&&&&&&&&&&&&& List of databases&& Name&&& |& Owner&& | Encoding | Collate | Ctype |&& Access privileges&&& -----------+----------+----------+---------+-------+------------------------&francs&&& | postgres | UTF8&&&& | C&&&&&& | C&&&& | =Tc/postgres&&&&&&&&& +&&&&&&&&&& |&&&&&&&&& |&&&&&&&&& |&&&&&&&& |&&&&&& | postgres=CTc/postgres +&&&&&&&&&& |&&&&&&&&& |&&&&&&&&& |&&&&&&&& |&&&&&& | francs=C*T*c*/postgres&postgres& | postgres | UTF8&&&& | C&&&&&& | C&&&& | &template0 | postgres | UTF8&&&& | C&&&&&& | C&&&& | =c/postgres&&&&&&&&&& +&&&&&&&&&& |&&&&&&&&& |&&&&&&&&& |&&&&&&&& |&&&&&& | postgres=CTc/postgres&template1 | postgres | UTF8&&&& | C&&&&&& | C&&&& | =c/postgres&&&&&&&&&& +&&&&&&&&&& |&&&&&&&&& |&&&&&&&&& |&&&&&&&& |&&&&&& | postgres=CTc/postgres(4 rows)
postgres=# create database test_CREATE DATABASE
postgres=# \l&&&&&&&&&&&&&&&&&&&&&&&&&&&& List of databases&& Name&&& |& Owner&& | Encoding | Collate | Ctype |&& Access privileges&&& -----------+----------+----------+---------+-------+------------------------&postgres& | postgres | UTF8&&&& | C&&&&&& | C&&&& | &template0 | postgres | UTF8&&&& | C&&&&&& | C&&&& | =c/postgres&&&&&&&&&& +&&&&&&&&&& |&&&&&&&&& |&&&&&&&&& |&&&&&&&& |&&&&&& | postgres=CTc/postgres&template1 | postgres | UTF8&&&& | C&&&&&& | C&&&& | =c/postgres&&&&&&&&&& +&&&&&&&&&& |&&&&&&&&& |&&&&&&&&& |&&&&&&&& |&&&&&& | postgres=CTc/postgres&test_xc&& | postgres | UTF8&&&& | C&&&&&& | C&&&& | (5 rows)
postgres=# \c test_xcYou are now connected to database "test_xc" as user "postgres".test_xc=# create table test_1 (id integer,name varchar(32));CREATE TABLEtest_xc=# insert into test_1 select generate_series(1,100),'test_xc';INSERT 0 100
&&& 备注:在 coord1 节点上创建了测试库 test_xc,并在里面创建了一张表,接下来看看 coord2, db_1,db_2 节点情况。&&&
--9.2 coord2 上验证
&[pgxc@redhat6 pg_log]$ psql -p 1925 -U postgrespsql (PGXC 1.0beta2, based on PG 9.1.3)Type "help" for help.
postgres=# \l&&&&&&&&&&&&&&&&&&&&&&&&&&&& List of databases&& Name&&& |& Owner&& | Encoding | Collate | Ctype |&& Access privileges&&& -----------+----------+----------+---------+-------+------------------------&postgres& | postgres | UTF8&&&& | C&&&&&& | C&&&& | &template0 | postgres | UTF8&&&& | C&&&&&& | C&&&& | =c/postgres&&&&&&&&&& +&&&&&&&&&& |&&&&&&&&& |&&&&&&&&& |&&&&&&&& |&&&&&& | postgres=CTc/postgres&template1 | postgres | UTF8&&&& | C&&&&&& | C&&&& | =c/postgres&&&&&&&&&& +&&&&&&&&&& |&&&&&&&&& |&&&&&&&&& |&&&&&&&& |&&&&&& | postgres=CTc/postgres&test_xc&& | postgres | UTF8&&&& | C&&&&&& | C&&&& | (5 rows)
postgres=# \c test_xcYou are now connected to database "test_xc" as user "postgres".test_xc=# \d&&&&&&&& List of relations&Schema |& Name& | Type& |& Owner&& --------+--------+-------+----------&public | test_1 | table | postgres(1 row)
test_xc=# select count(*) from test_1;&count -------&& 100(1 row)&&&
--9.3 数据节点 db_1 上验证
&[pgxc@redhatB pg_log]$ psql -p 15431 -U postgres -d test_xcpsql (PGXC 1.0beta2, based on PG 9.1.3)Type "help" for help.
test_xc=# \dWARNING:& Do not have a GTM snapshot availableWARNING:& Do not have a GTM snapshot available&&&&&&&& List of relations&Schema |& Name& | Type& |& Owner&& --------+--------+-------+----------&public | test_1 | table | postgres(1 row)
test_xc=# select count(*) from test_1;WARNING:& Do not have a GTM snapshot availableWARNING:& Do not have a GTM snapshot available&count -------&&& 42(1 row)&&&
--9.4 数据节点 db_2 上验证
&[pgxc@redhatB pg_log]$ psql -p 15432 -U postgres -d test_xcpsql (PGXC 1.0beta2, based on PG 9.1.3)Type "help" for help.
test_xc=# select count(*) from test_1;WARNING:& Do not have a GTM snapshot availableWARNING:& Do not have a GTM snapshot available&count -------&&& 58(1 row)&&&
& 备注:表共有100条记录,数据节点一分布了 42 条,数据节点二分布了 58 条,可见数据已经分片到数据节点上。&&&&&&&&&&& 当然在创建表时,也可以设置 replication 模式,这样数据就会完全复制到每个节点。
&& 十 可能出现的ERROR
&[pgxc@redhat6 coord1]$ psql -p 1921 -U postgrespostgres=# ERROR:& Failed to get pooled connections&&&
& 备注:如果在 coord1 节点上操作时,报 "ERROR:& Failed to get pooled connections",可能的原因很多,&&&&&&&&&&& 可能是节点没有注册好,这时要查看 pgxc_node 视图;也有可能是 pg_hba.conf,防火墙,selinux &&&&&&& && &等问题,总之逐一排查。
&&&&&&&&&&& 1 本次测试只是简单将 PostgreSQL-XC 搭建起来了,其中 gmt_standby&,GTM-Proxy 没有配置,这个以后可
&&&&&&&& 以测试下;
&&&&&&&2 由于在 PostgreSQL-XC 体系中,coordinator 并不存储数据,数据被分片在数据节点中,这种机制与GreenPlumn
&&&&&&&& 有点类似;而 coordinator 节点新增了 pooler process 进程,个人觉得 coordinator 很像一个连接池。
&&&&&& 3 PostgreSQL-XC 所谓的多主节点( muti-master) 同时对外服务,实际上对应用服务的是 coordinator 节点,而
&&&&&&&&&不是数据&节点本身;原来俺的理解是数据节点同时读写(多份数据,mater 同时读写),而在 PostgreSQL-XC 中
&&&&&&&& 并不是这样。
&&&&&&&4 由于每个数据节点存储一部分数据,那么如果数据节点 down 掉,整个 PostgreSQL-XC 将不可用,不知是否有
&&&&&&&&&更好的方案,例如给每个数据节点配置个 standby 节点?
&&&&&& 5& 由于在 PostgreSQL-XC 体系中数据分片在多个数据节点中,IO 性能会提升,同时对网络压力会提升;具体性能
&&&&&&&&& 目前还没有测试。
&&&&&&&&&&& 6& 尽管疑问重多,但还是要感谢来自日本的 PostgreSQL-XC 开发团队,他们为 PostgreSQL 带来了 muti-master
&&&&&&&&&&&&&& &的集群方案。&&&&
francs推荐阅读:
阅读(37117)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
loftPermalink:'',
id:'fks_',
blogTitle:'PostgreSQL-XC : Installation',
blogAbstract:'
& & & & & &上篇( '
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}

我要回帖

更多关于 饿了么显示账户异常 的文章

 

随机推荐