Skytools安装配置管理(四)

Skytools安装配置管理(四),第1张

概述2.4.1.3 创建函数 [postgres@localhost  ~]$ cd /opt/pg93/share/extension/ [postgres@localhost  extension]$ psql part_root < hashlib--1.0.sql CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION C 2.4.1.3 创建函数

[postgres@localhost~]$ cd /opt/pg93/share/extension/

[postgres@localhostextension]$ psql part_root < hashlib--1.0.sql

CREATE FUNCTION

[postgres@localhostextension]$ psql part_part0 < hashlib--1.0.sql

[postgres@localhostextension]$ psql part_part1 < hashlib--1.0.sql

part_root=# \df

listof functions

Schema | name | Result data type | Argument data types | Type

--------+----------------+------------------+-----------------------------+--------

public | hash128_string | bytea | bytea,text | normal

public | hash128_string | bytea | text,Simsun;vertical-align:baseline;">public | hash64_string | bigint | bytea,Simsun;vertical-align:baseline;">public | hash64_string | bigint | text,Simsun;vertical-align:baseline;">public | hash_int4 | integer | bigint,Simsun;vertical-align:baseline;">public | hash_int4 | integer | integer,Simsun;vertical-align:baseline;">public | hash_int8 | bigint | bigint,Simsun;vertical-align:baseline;">public | hash_string | integer | bytea,integer | normal

public | hash_string | integer | text,Simsun;vertical-align:baseline;">(19 rows)

2.4.1.4 创建扩展

[postgres@localhostextension]$ psql part_root -c 'create extension hashlib'

CREATE EXTENSION

[postgres@localhostextension]$ psql part_part0 -c 'create extension hashlib'

[postgres@localhostextension]$ psql part_part1 -c 'create extension hashlib'

part_root=# \dx

listof installed extensions

name |Version | Schema | Description

---------+---------+------------+------------------------------

hashlib | 1.1 | public | Stable hash functions

plpgsql | 1.0 | pg_catalog | PL/pgsql procedural language

(2 rows)

2.4.2 基础配置 2.4.2.1 配置数据库连接进程信息

[postgres@localhostconf]$ cat part_root.ini

[londiste3]

job_name = part_root

db = dbname=part_root

queue_name = replika

logfile = /opt/skytools/londiste/log/part_root.log

pIDfile = /opt/skytools/londiste/pID/part_root.pID

[postgres@localhostconf]$ cat part_part0.ini

job_name = part_part0

db = dbname=part_part0

logfile = /opt/skytools/londiste/log/part_part0.log

pIDfile = /opt/skytools/londiste/pID/part_part0.pID

[postgres@localhostconf]$ cat part_part1.ini

job_name = part_part1

db = dbname=part_part1

logfile = /opt/skytools/londiste/log/part_part1.log

pIDfile = /opt/skytools/londiste/pID/part_part1.pID

2.4.2.2 创建root节点(node1)并启动worker

[postgres@localhostconf]$ londiste3 part_root.ini create-root node1 dbname=part_root

2013-10-11 15:07:24,186 29307 WARNING No host= in public connect string,bad IDea

2013-10-11 15:07:25,350 29307 INFO pgq.get_batch_cursor is installed

2013-10-11 15:07:26,126 29307 INFO Installing londiste

[postgres@localhostconf]$ londiste3 -d part_root.ini worker

[postgres@localhostconf]$ ps -ef | grep worker

postgres 29327 1 0 15:08 ? 00:00:00 /opt/python25/bin/python /opt/skytools/bin/londiste3 -d part_root.ini worker

postgres 29335 27861 0 15:08 pts/2 00:00:00 grep worker

2.4.2.3 创建leaf1节点(node2_0)并启动worker

[postgres@localhostconf]$ londiste3 part_part0.ini create-leaf node2_0 dbname=part_part0 --provIDer=dbname=part_root

2013-10-11 15:09:33,157 29361 WARNING No host= in public connect string,165 29361 INFO plpgsql is installed

2013-10-11 15:09:34,301 29361 INFO pgq.get_batch_cursor is installed

2013-10-11 15:09:36,634 29361 INFO londiste.global_add_table is installed

2013-10-11 15:09:37,523 29361 INFO Initializing node

2013-10-11 15:09:39,935 29361 INFO Location registered

2013-10-11 15:09:40,254 29361 INFO Location registered

2013-10-11 15:09:41,001 29361 INFO Done

[postgres@localhostconf]$ londiste3 -d part_part0.ini worker

2.4.2.4 创建leaf2节点(node2_1)并启动worker

[postgres@localhostconf]$ londiste3 part_part1.ini create-leaf node2_1 dbname=part_part1 --provIDer=dbname=part_root

2013-10-11 15:10:05,861 29380 WARNING No host= in public connect string,867 29380 INFO plpgsql is installed

2013-10-11 15:10:07,291 29380 INFO pgq.get_batch_cursor is installed

2013-10-11 15:10:08,319 29380 INFO londiste.global_add_table is installed

2013-10-11 15:10:10,610 29380 INFO Location registered

2013-10-11 15:10:11,041 29380 INFO Node "node2_1" initialized for queue "replika" with type "leaf"

[postgres@localhostconf]$ londiste3 -d part_part1.ini worker

postgres 29397 1 0 15:10 ? 00:00:00 /opt/python25/bin/python /opt/skytools/bin/londiste3 -d part_part1.ini worker

postgres 29403 1 0 15:10 ? 00:00:00 /opt/python25/bin/python /opt/skytools/bin/londiste3 -d part_part0.ini worker

postgres 29412 27861 0 15:10 pts/2 00:00:00 grep worker

2.4.2.5 配置ticker并启动

[postgres@localhostconf]$ cat pgqd.ini

[pgqd]

logfile = /opt/skytools/londiste/log/pgqd.log

pIDfile = /opt/skytools/londiste/pID/pgqd.pID

[postgres@localhostconf]$ pgqd -d pgqd.ini

2013-10-11 15:12:42.278 29452 LOG Starting pgqd 3.1.5

[postgres@localhostconf]$ ps -ef | grep pgqd

postgres 29454 1 0 15:12 ? 00:00:00 pgqd -d pgqd.ini

postgres 29469 27861 0 15:12 pts/2 00:00:00 grep pgqd

2.4.3 在node1上创建同步表

part_root=# create table t1(ID integer primary key);

CREATE table

part_root=# insert into t1 values (1);

INSERT 0 1

part_root=# insert into t1 values (2);

part_root=# select * from t1;

ID

----

1

2

2.4.4 向root与leaf节点添加复制表

[postgres@localhostconf]$ londiste3 part_root.ini add-table t1 --handler=part --handler-arg=key=ID

2013-10-12 00:14:52,824 4394 INFO table added: public.t1

[postgres@localhostconf]$ londiste3 part_part0.ini add-table t1 --create --handler=part --handler-arg=key=ID

2013-10-12 00:14:59,093 4399 INFO Creating public.t1

[postgres@localhostconf]$ londiste3 part_part1.ini add-table t1 --create --handler=part --handler-arg=key=ID

2013-10-12 00:15:04,608 4404 INFO Creating public.t1

part_root=# \d t1

table"public.t1"

Column | Type | ModifIErs

--------+---------+-----------

ID | integer | not null

Indexes:

"t1_pkey"PRIMARY KEY,btree (ID)

Triggers:

_londiste_replikaAFTER INSERT OR DELETE OR UPDATE ON t1 FOR EACH ROW EXECUTE PROCEDURE pgq.logutriga('replika','ev_extra3=''hash=''||partconf.get_hash_raw(ID)')

_londiste_replika_truncate AFTER TruncATE ON t1 FOR EACH STATEMENT EXECUTE PROCEDURE pgq.sqltriga('replika')

part_part0=# \d t1

_londiste_replika_truncate AFTER TruncATE ON t1 FOR EACH STATEMENT EXECUTE PROCEDURE pgq.sqltriga('replika',Simsun;Font-weight:bold;vertical-align:baseline;">part_part1=# \d t1

part_part0=# select * from t1;

(1 row)

part_part1=# select * from t1;

{可以看到之前表里的初始数据已经分配给了两个leaf节点}

part_root=# insert into t1 values (3);

3

(2 rows)

{分配给leaf2}

part_root=# insert into t1 values (4);

4

{分配给leaf1}

part_root=# insert into t1 values (5);

part_root=# insert into t1 values (6);

5

(3 rows)

6

【根据上面的测试可以发现其分配规律为12211221的分配方式】

2.5、使用walmgr3配置流复制 @H_685_502@

HOSTname

IP

PG_VERSION

USER

PASSWORD

PORT

RolE

db1

192.168.100.37

9.3.2 for centos6.4-x64

postgres

highgo

5432

master

db2

192.168.100.38

9.3.2 for centos6.4-x64

postgres

highgo

5432

slave

2.5.1 配置hosts

[root@master~]# cat /etc/hosts

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4

:#:1 localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.100.37 db1

192.168.100.38 db2

[root@slave~]# cat /etc/hosts

127.0.0.1 localhost.localdomain localhost localhost4.localdomain4 localhost4

# @R_502_6843@-generated hostname. Please do not remove this comment.

#::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.100.38 db2

2.5.2 配置用户验证

[postgres@db1 ~]$ cd .ssh/

[postgres@db1 .ssh]$ ls

[postgres@db1 .ssh]$ ssh-keygen -t rsa

Generating public/private rsa key pair.

Enter file in which to save the key (/home/postgres/.ssh/ID_rsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your IDentification has been saved in /home/postgres/.ssh/ID_rsa.

Your public key has been saved in /home/postgres/.ssh/ID_rsa.pub.

The key fingerprint is:

f1:87:23:aa:01:74:b7:f7:9b:74:7b:e6:e9:d6:80:2d postgres@db1

The key's randomart image is:

+--[ RSA 2048]----+

| |

| . . . . |

| . . . . o . |

| . . S + .o |

| . o o oE o |

| . . o .. o |

| o . + .+..|

| . o .*+ |

+-----------------+

总结

以上是内存溢出为你收集整理的Skytools安装配置管理(四)全部内容,希望文章能够帮你解决Skytools安装配置管理(四)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/1176912.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-02
下一篇 2022-06-02

发表评论

登录后才能评论

评论列表(0条)

保存