This installation record is based on a sample from the Symmetricds Quick Start Guide and is installed on two machines.
Installation Environment
Machine1:hadoop3.highgo.com
Machine2:hadoop4.highgo.com
Installing Symmetricds
1. Download the SYMMETRICDS server program, currently Symmetric-3.6.14, download the Symmetric-3.6.14-server.zip file. Unzip to the/opt/directory of both machines and change the Symmetricds root owner to Highgo.
2. Hadoop4.highgo.com as root, responsible for the corp database, hadoop3.highgo.com as the store side, responsible for store001 database. On the HADOOP4 side, Copy the Corp-000.properties file under the Samples directory under the root directory of the Symmetricds installation copy to the engines directory, and HADOOP3 the Symmetricds directory under Samples installation replica root under STORE-001.PR The operties file is copied to the engines directory. To modify the database information for the two configuration files, my configuration is as follows:
Db.driver=org.postgresql.driverdb.url=jdbc:postgresql://hadoop3/4.highgo.com/store001db.user=highgodb.password=highgo
3. The configuration file on the store side needs to be configured Registration.url
registration.url=http://hadoop4.highgo.com:8080/sync/corp-000
Symmetricds level of the master-slave relationship, that is, to really run up, Symmetricds is the same as its name symmetric, each node is equivalent.
Install databases, create business tables, import initial data, create system tables
1. A PostgreSQL database instance is installed on two machines, each creating a database user Highgo, and a password of Highgo. Create store001 database on hadoop3.highgo.com, owner is Highgo, create Corp database on Hadoop4.highgo.com, owner is Highgo.
2. Execute the following command under the Samples directory of the Symmetricds installation copy on the HADOOP4 side:
.. /bin/dbimport--engine corp-000--format xmlcreate_sample.xml
This is the procedure on the document, but after executing the above command, the error, cannot find create_sample.xml this file. So open this file discovery is the definition of several tables, is defined in the common format of XML. Altogether four sheets item,item_selling_price,sale_transaction,sale_return_line_item. Simply write the SQL statement as described in the XML file, with the following SQL statement:
CreateTable Item (item_id integer PRIMARY key,name VARCHAR) createtable item_selling_price (item_id integer REFERENCES Item (ITEM_ID), Store_idvarchar (5), Pricedecimal (10,2), Costdecimal (10,2), PRIMARYKEY (item_id,store_id)) CreateTable sale_transaction (tran_id INTEGER PRIMARY KEY, store_id varchar (5) Not null,workstation varchar (3) not Null,day VARCHAR (Ten) not null,seq integers not NULL) createtable sale_return_line_item (tran_id integer PRIMARY KEY referenc ES sale_transaction (tran_id), item_id INTEGER not NULL REFERENCES item (item_id), Price DECIMAL (10,2) not null,quantity Integer not null,returned_quantity integer)
These four tables are the business tables of our example of this distribution business.
3. On the HADOOP4 side, execute the following command:
.. /bin/symadmin--engine Corp-000create-sym-tables
This command is to create a system table of Symmetricds, which succeeds, without error or anything.
4. On the HADOOP4 side, execute the following command:
.. /bin/dbimport--engine Corp-000insert_sample.sql
Insert_sample.sql files are mainly divided into two parts, one is to insert sample data into the business table, and the other part is to insert the system data of this sample into the system table of Symmetricds. First, two nodes were created, then two channel was created, 6 trigger were created, 3 Router were created, and 6 Trigger-router Links were created, and the so-called creation is actually inserting the created information into the system table.
By the way, when this command executes, it is also an error, cannot find the Insert_sample.sql file, I opened this file, part of it, executed at PostgreSQL command line. The estimated execution of the entire file is also possible.
5. On the HADOOP3 side, enter the samples directory under the root directory of the Symmetricds installation copy of store001, and execute the following command:
.. /bin/dbimport--engine store-001--format xmlcreate_sample.xml
This command is the same as the purpose of the second execution on the HADOOP4 side, which is the business table that created the sample. Of course, execution is also an error, cannot find the file, the top of the SQL statement, in this can be done again.
Start Symmetricds
1. On the hadoop4 side, the root side, the corp side, execute the following command under the Samples directory in the root directory of the Symmetricds installation replica:
.. /bin/sym--engine corp-000--port 8080
This process creates components such as the necessary trigger and so on, based on the previous configuration file and the data inserted in the SYMMETRICDS system table. Then wait for the other node to register.
2. On the HADOOP3 side, the client side, the store side executes the following command under the Samples directory in the root directory of the Symmetricds installation replica:
.. /bin/sym--engine store-001--port 8080
This command launches the SYMMETRICDS program on the HADOOP3. and try to connect to the root node based on the configuration information. Of course, due to this time, the root of the registration has not been opened, at this time, the root can receive HADOOP3 on the Symmetricds registration request, but the authentication will fail.
Registering nodes
Execute the following command under the Samples directory under the root directory of the Symmetricds installation replica on HADOOP4:
.. /bin/symadmin--engine corp-000open-registration Store 001
Start registering for Store 001, and you'll see the registration success message. For convenience, you can first shut down the firewall for both machines.
Initiating initial load
We started to insert a few data on the business table on the HADOOP4 side of the database, but the business table for the database on HADOOP3 was empty. Since we have to synchronize, we must first synchronize this part of the data, this part of the data synchronization is called synchronous initial load. To initiate this initial load synchronization, execute the following command, or in the Samples directory of the Symmetricds installation copy of HADOOP3:
.. /bin/symadmin--engine Corp-000reload-node 001
Push data
The data inserted into the SYMMETRICDS system table from the upper Insert_sample.sql file can be known, the Item table and the Item_selling_ The Price table's synchronization configuration is from the corp side (HADOOP4) to the store side (HADOOP3), one-way, that is, we insert a piece of data from the corp side, the data will be pushed to the store side, and we add a data from the store side, Will not affect the data at the Corp end.
Below we insert two data in the corp End database:
INSERT INTO "item" ("item_id", "name") VALUES (110000055, ' Soft Drink ') and insert INTO "Item_selling_price" ("item_id", " store_id "," Price ") VALUES (110000055, ' 001 ', 0.65); INSERT INTO "Item_selling_price" ("item_id", "store_id", "Price") VALUES (110000055, ' 002 ', 1.00);
After executing these two INSERT statements at the HADOOP4 end, the data on the HADOOP3 side is viewed and the data should be synchronized.
Pull data
The data inserted into the SYMMETRICDS system table from the upper Insert_sample.sql file can be known, sale_transaction tables and Sale_return_line_ The synchronization configuration of the item table is synchronized from the store side (HADOOP3) to the corp side (HADOOP4), one-way, that is, we add a data from the store side (HADOOP3), the data is pushed to the Corp side (HADOOP4), Adding a piece of data from the Corp side (HADOOP4) does not affect the data on the store side (HADOOP3).
Below we insert two data in the store side database:
INSERT INTO "sale_transaction" ("tran_id", "store_id", "workstation", "Day", "seq") VALUES (1000, ' 001 ', ' 3 ', ' 2007-11-01 ') , insert INTO "Sale_return_line_item" ("tran_id", "item_id", "Price", "Quantity") values (1000, 110000055, 0.65, 1);
After executing these two INSERT statements on the HADOOP3 side, the database on the HADOOP4 side is viewed and the data should be synchronized.
Symmetricds Installation Record