How to run master and slaves

Run Master

Running master could be as simple as following;

	> ./bangdb-server

Here all the necessary information is being taken from the bangdb.config file

Following are the parameters that bangdb-server can take as command line arguments and if not provided then default from the bangdb.config file.

  • master or slave - this can be defined by the SERVER_TYPE config param (0 = master and 1 = slave)
  • replication on or off - this can be set using ENABLE_REPLICATION. Need to be ON for adding slaves
  • transaction or not - default is off but can be set using command line argument
  • db name - can be set using BANGDB_DATABASE_NAME
  • server ip - can set using SERVER_ID
  • server port - can be set using SERV_PORT

Note that all these values can be provided as command line arguments which also overrides the ones defined in the bangdb.config file

Following is the help on command line arguments that server takes


 Usgae: -i [master | slave] -r [yes | no] -t [yes | no] -d [dbname] -s [IP:PORT] -m [IP:PORT] -b [yes | no]
 -i: defines the server's identity [master | slave], default is SERVER_TYPE as defined in bangdb.config
 -r: defines replication state [yes | no], default is ENABLE_REPLICATION as defined in bangdb.config 
 -t: defines if transaction is enabled(yes) or disabled(no) [yes | no], default is no 
 -d: defines the dbname, default is BANGDB_DATABASE_NAME as defined in bangdb.config 
 -s: defines IP:Port of this server, default is SERVER_ID:SERV_PORT as defined in bangdb.config
 -m: defines IP:Port of the master (required only for slave as it declares master with this option)
 -b: defines if server to be run in background as daemon
     default is MASTER_SERVER_ID:MASTER_SERV_PORT as defined in the bangdb.config
  Hence to run master with other values as defined in the bangdb.config, issue following command
	 ./bangdb-server -s
  To run master
	 ./bangdb-server -i master -s
  To run slave for this master with default other values..
	 ./bangdb-server -i slave -s -m

Here is how the shell would look when bangdb-server is run

Adding slaves

Adding slaves in the cluster is simple, it's only about running the server with slave identity. Hence like above we just need to provide the identity of the server (-i slave in this case), provide the ip:port combination for the server(slave, -s switch) and for the master (-m switch)

This can be done any time as long as master is running. Note that we don't need to worry about halting the server or denying the service during the initial synchronization. We can just bring the slaves up whenever it's needed