Slony1-1.0.2

xiaoxiao2021-03-17  184

Simply say two words: Prerequisites: There is a source code of PostgreSQL and compile (not installed). Steps: 1, first download this: http://laser.dyndns.zhengmai.net.cn/download/slony1-1.0.2.tar.gz Decomposed, there is a Slony1-1.0.2 directory.

2, enter this directory, configure --with-pgsourcetree = 3, make & makestall4, with a database user, I will say a simplest, all tables have primary keys, point-to-point The master-slave replication plan, we need to write the following script: #! / Bin / shcluster = "Your cluster name, free" dbname1 = "Source database you need to copy" DBNAME2 = "Destination database you need to copy" Host1 = " Source library IP or host name "Host2 =" destination library IP or host name "slony_user =" source library database super user name "pgbench_user =" source library user name, no use "slonik << _ EOF_ # This sentence is defined cluster name cluster name = $ CLUSTER; # define these two nodes replicate node 1 admin conninfo = 'dbname = $ DBNAME1 host = $ HOST1 user = $ SLONY_USER'; node 2 admin conninfo = 'dbname = $ DBNAME2 host = HOST2 user $ = $ Pgbench_user '; # Initializing the cluster, the ID starts from 1, if there is only one cluster, then it is definitely written some of his own comments in 1 # comment, free INIT Cluster (id = 1, comment =' node 1 '); # creation A copy set, ID is also from 1 Create set (id = 1, origin = 1, comment = 'all pgbench tables'); # 自己 自己 集 集 集 集, each of the tables that need to be copied, a set command, # The ID starts from 1, successively, steps 1; #Fully Qualified name is the full name of the table: mode name. Table name # Here the copy set ID needs to be consistent with the previously created copy ID, origin keyword # 这里游Do not explain the set add table (set id = 1, origin = 1, id = 1, full qualified name = 'public.accounts', comment = 'table accounts'); set add table (set id = 1, Origin = 1, ID = 2, fully qualified name = 'public.branches', comment = 'Table Branches'); Set Add Table (Set ID = 1, Origin = 1, ID = 3, Fully Qualified Name = 'public.teellers', Comment = 'Table Tellers'); ## If a table has no primary key, However, there is a unique keyword, then you can use the key keyword # to specify it as a copy key, if not, you need to add a # primary key, let's talk later (set id = 1, Origin) = 1, ID = 4, full Qualified Name = '

Public.history ', key = "column", comment =' table history '); # 存 主 主 从 从 信息 信息 #;;;;;;;;;;;;;;; (4 Is the main point of connection parameters Store Path (Server = 1, Client = 2, Conninfo = 'DBNAME = $ dbname1 host = $ host1 user = $ slony_user'); # below is the connection parameters of the node (Server = 2, Client = 1, connInfo = 'dbname = $ dbname2 host = $ host = $ pgbench_user'); # Settings the role in the copy, the main node is the original provider, from the node is the recipient Store Listen (Origin = 1, provider = 1 , Receiver = 2); Store Listen (ORIGIN = 2, provider = 2, receiver = 1); _ EOF_5, then execute this script, can get the authentication problem under any database users. 6. Run commands on the source library (primary server): SLON "Your Cluster" "DBNAME =" Source Database Required Copy "User =" Source Library Database Super User Name "& 7, in the destination library (from the server Run the command: SLON "Your cluster name" "DBNAME =" Destination database you need to copy "User =" Source Library Database Super User Name "& 8, submit the copy set, you can use the following script: #! / Bin / shcluster = "Your cluster name, free" DBNAME1 = "Source database you need to copy" DBNAME2 = "Destination database you need to copy" Host1 = "source library IP or host name" Host2 = "destination IP or host name" SLONY_USER = "Source Library Database Super User Name" pgbench_user = "Source Library User Name, Nothing Use" Slonik << _ EOF_ # ---- # this defines Which namespace the replication system users # ---- Cluster Name = $ cluster ; # supply connection parameters node 1 admin conninfo = 'dbname = $ DBNAME1 host = $ HOST1 user = $ SLONY_USER'; node 2 admin conninfo = 'dbname = $ DBNAME2 host = $ HOST2 user = $ PGBENCH_USER'; # submitted copy sets subscribe Set (id = 1, provider = 1, receiver = 2, forward = no); _ EOF_SLONY1 is a replication technology made based on PostgreSQL's asynchronous notification mechanism, which is very fast, and the result I test is near real. At present, my BBS uses this replication technology to make backups, huh, in addition to the conflict, very easy to use! Because of the time relationship, more complex hierarchy copies we will talk later. Slony's own document is not old. I've been busy recently.

转载请注明原文地址:https://www.9cbs.com/read-129566.html

New Post(0)