...
Change into the bin directory and type the following command.{{
./admin.sh -url <URL> -loadschema
}}Replace URL with the JDBC url for your configuration database. Voila! You now have a cluster configuration database installed. As mentioned, this doesn't get you very far. So let's look next at creating a replication cluster from scratch using existing databases.
...
This command will allow a user to create a completely new replication cluster from an existing database(s). First let's look at the command line.{{
./admin.sh -url <URL> -loadschema -data <DATA_FILE> -initnodeschema -operation CLEAN_INSERT -initsnapshots MASTER
}}In this case, admin.sh will make a connection to URL, load the configuration schema onto that database to create a CCDB, load <DATA_FILE> into the CCDB, and wipe out any existing configuration that may have been there before. We've already covered the -loadschema option, so I won't mention that except to say that if you performed the -loadschema command in our first example, you can leave this option out.
The data file that the admin tool uses is a simple XML file that describes a data set. There is example in sample/config.xml in the replication distribution. A small sample of that file looks like so:{{
| Code Block |
|---|
...
| ||
<dataset> <table name="yf_node"> |
...
<column>id</column> |
...
<column>available</column> |
...
<column>name</column> |
...
<column>uri</column> |
...
<column>includetable</column> |
...
<row> <value>1</value> <value>true</value> <value>Cluster 0 - Primary master</value> <value>jdbc:postgresql://localhost:5432/bruce_master?user=lball</value> |
...
<value>replication_test\..+</value> |
...
</row> |
...
<!-- More rows and other tables follow --> |
...
</dataset> |
}}As you can see, the format is very straightforward and easy to understand. You declare the tables and columns, and then add rows with values for each column. Using this sample, you can quickly and easily get a replication cluster up and running in no time. Simply alter the database URLs and includetable regular expressions in the datafile to point to your database and tables. Then run the command above and startup the replication daemon.
...
This use case is very similar to creating a new replication cluster from scratch as previously demonstrated. Except in this case, you just want to add configuration for a new cluster or new nodes, so you don't need the -loadschema option, and you'll want to change CLEAN_INSERT to INSERT. The command now looks like this:{{
./admin.sh -url <URL> -data <DATA_FILE> -operation INSERT
...
Update existing configuration data into the CCDB, changing existing data
To update existing configuration data with new values, simply change the operation to UPDATE.{{
./admin.sh -url <URL> -data <DATA_FILE> -operation UPDATE
...
Completely refresh the CCDB with new data, replacing existing data
If you think about it, this is just like starting from scratch. You are clearing out the configuration to nothing. Then you are installing a new configuration. The command is the same as mentioned above for starting from scratch.{{
./admin.sh -url <URL> -loadschema -data <DATA_FILE> -operation CLEAN_INSERT
...
Display the current Cluster configuration node topology with all node metadata
This command makes no changes to the CCDB at all. Instead, its purpose is to help administrators keep up with the tables being replicated by each node in the system. That command and some sample output looks like this:{{
| Panel |
|---|
mercury:bin lanceball$ ./admin.sh -url jdbc:postgresql://localhost:5432/bruce_config?user=lanceball -list Slaves Name: Cluster 0 - Slave Dos |
}}As you can see, the output displays the cluster name "ClusterOne", the master for the cluster, and each slave. It displays the user-specified metadata for each node, such as the URL and the Include table regular expression. In addition, if a connection can be made to the node, the database is examined and a list of tables that will be replicated by the system is displayed. In the example above, the sample/config.xml file was used to create a new replication cluster from scratch. Each node in the cluster has a schema called replication_test and a table called replicate_this which will be replicated. Note that the admin tool will not create the tables you want to replicate. If you are using the example data file, you'll want to add a replication_test schema and a replication_test.replicate_this table to each node in the cluster.
