英文好的朋友,进来帮忙看看.
9812 2003-04-21 06:45:32 How To Install and configure Postgres-R with Spread
Note: These instructions are based on RH7, so your install experience may vary. Please note any changes or comments, and share with the list.
Download Spread (spread-3.17.0 @ www.spread.org/).
Compiling Spread. After un-tarring the source, cd to the spread_src-3.17.0 directory, create a symbolic link for Makefile using the existing platform specific make files (ln -s LINUX_makefile Makefile), and then make. This will create the spread deamon (spread) and libtsp.a (/spread_src-3.17.0/libtsp.a). Note: This Spread set up is for the source compile and more detailed information is in the user guide .
Configuring Spread. Create a Spread configuration file from the sample.spread.conf file in the spread_src-3.17.0 directory. A list of systems needs to be defined in the Spread_Segemnt section. Here is an example, for more information see the user guide .
Spread_Segment 192.168.1.255:4803 {
sync1 192.168.1.81
sync2 192.168.1.82
sync3 192.168.1.83
sync4 192.168.1.84
}
Starting Spread. For postgres-r a spread daemon must be running on each system participating in replication. To start the Spread daemon (spread -c spread.conf -l y &)
Create the postgres user, and create the installation destination directory (default is /usr/local/pgsql). Make sure the directory is read/writeable by postgres and/or the user ID of installer.
Down load the latest postgres-r code using the Download instructions. To compile and configure the postgres-r code, cd to the pgsql-r-v7.2/ directory, and run the configure script. Use the following parameters in the configure scrpt.
configure --with-repl-spread=path to spread directory
Next type "make", and if all goes well type "make install" using the UID from step 5.
Set up the postgresql.conf file, and put it in the postgresql data directory (default is /usr/local/pgsql/data). Below is an example of the replcation settings of this file. These entries take the place of the environment variables used in the working model.
repl_max_remote_processes = 4 # number of remote backends
repl_mgr_port = 5430 # Replication manager port
repl_spread_port = 4803 # Port used for the spread daemon (see spread.conf file)
repl_spread_host = 'localhost' # Host of the spread daemon
repl_spread_group = 'replicationGroup' # The name of the spread group
repl_database = 'testing' # Name of the database being replicated
repl_user = 'postgres' # Name of the user used to replicate data (from step 5)
Database setup. As the postgres user, initialize the database by "/usr/local/pgsql/bin/initdb". The postmaster can now be started (in regular mode) by "/usr/local/pgsql/bin/postmaster -i &" . Once postmaster is running correctly, the replication database has to be created using "/usr/local/pgsql/bin/createdb (repl_database from postgresql.config file). Next the tables and users would be created, currently these statements are not replicated, so we are still in stand alone mode here. Make sure all tables have a primary key, or replication will not work. Steps 1 - 9 need to be executed on each machine before proceding to step 10.
Stop any/all postmasters/postgres daemons. Make sure the postgres shared memory segments are removed, using "ipcs" and "ipcrm". Start one of the posstgres-r servers in master replication mode with "postmaster -r -X &". This step will only be executed on the master system. All other systems (slaves) in the replica will be started in slave replication mode with "postmaster -r &".
Replicating SQL commands. Create a text file with a SQL transaction (example below). Then use /usr/local/pgsql/bin/psql -r < "text file w/ SQL transaction" on the master server. Verify by selecting test table information on each server in the replica.
begin;
insert into status_table values (0, 'zero');
insert into status_table values (1, 'one');
insert into status_table values (2, 'two');
end;