The db_cluster class contains methods that are performed on the cluster as a whole.
database_name - the name of the database to be administered.
master_ip - the IP address of the master server.
control_host - the IP address of the control host
slave_ip_list - a list of slave IP addresses
root_password - the password of the root MySQL user
db_user_pw - the password of the MySQL user 'db_user'
slave_user_pw - the password of the replication MySQL user
Load settings from config file and from the log.
Return a cluster object.
Example:
import db_cluster_utils
cluster = db_cluster_utils.db_cluster()Load settings from config file, ignoring setting in the status log.
Example:
import db_cluster_utils
cluster = db_cluster_utils.db_cluster()
cluster.init_cluster()
Initialize a server, get and save its log file and position, and grant replication privileges for the slaves.
Example:
import db_cluster_utils
cluster = db_cluster_utils.db_cluster()
cluster = cluster.init_master()Initialize a server, get and save its log file and position, set it read only, and tell it which master to use.
Argument
Example:
import db_cluster_utils
cluster = db_cluster_utils.db_cluster()
for host in cluster.slave_ip_list:
cluster.init_slave(host)
Delete a database from each server listed in the server pool.
Argument
Example:
import db_cluster_utils
cluster = db_cluster_utils.db_cluster()
cluster.stop_replication ()
cluster.wipe (cluster.database_name)
Add a slave to the cluster.
Get the master server's log file and position.
Grant replication privileges for the new slave on the master.
Initialize the slave.
Argument
Example:
import db_cluster_utils
cluster = db_cluster_utils.db_cluster()
cluster.add_slave(arg)
Remove a slave from the cluster.
Remove the host's record from the status log file.
Revoke replicatio privileges for this host on the master server.
Stop the slave.
Argument
Example:
import db_cluster_utils
cluster = db_cluster_utils.db_cluster()
cluster.remove_slave (arg)
Load the cluster configuration information and print it.
Example:
import db_cluster_utils
cluster = db_cluster_utils.db_cluster()
cluster.print_config ()Demote a master to a slave.
Reset all slaves.
Revoke replication privileges for all slaves.
Update role in status file.
Set read only.
Example:
import db_cluster_utils
cluster = db_cluster_utils.db_cluster()
cluster.stop_replication ()
cluster.demote_cluster_master()Promote a slave to a master.
Stop replication across the whole cluster.
Clear read only on the new master.
Update status log file.
Update slave IP address list.
Set the slave as a master.
Tell all the other slaves to use the new master.
Argument
Example:
import db_cluster_utils
cluster = db_cluster_utils.db_cluster()
cluster.promote_cluster_slave (arg)
cluster.start_replication ()Start replication on all slaves in the cluster.
Example:
import db_cluster_utils
cluster = db_cluster_utils.db_cluster()
cluster.start_replication ()Stop replication on all slaves in the cluster.
Example:
import db_cluster_utils
cluster = db_cluster_utils.db_cluster()
cluster.stop_replication ()Move the database to a new slave.
Dump the database from the master.
Use the scp command to transfer the database file to the destination host.
Import the database on the destination host.
Argument
Example:
import db_cluster_utils
cluster = db_cluster_utils.db_cluster ()
cluster.move_db (arg)Get the master server's IP address from the status log.
Return the IP address of master.
Example:
import db_cluster_utils
cluster = db_cluster_utils.db_cluster ()
master_ip = cluster.get_master_ip ()Get an updated slave list from the status log.
Example:
import db_cluster_utils
slave_list = []
cluster = db_cluster_utils.db_cluster ()
slave_list = cluster.update_slave_ip_list()
Update the role field in a status log file.
Arguments
Example:
import db_cluster_utils
cluster = db_cluster_utils.db_cluster ()
cluster.update_bin_log_role (host, "master")
Get the log file and log position information for a host from the status log file.
Return the log file and its postition.
Argument
Example:
import db_cluster_utils
cluster = db_cluster_utils.db_cluster ()
binlog_file, binlog_position = cluster.get_master_bin_log (host)Save log file and log position information for a host.
Arguments
Example:
import db_cluster_utils
cluster = db_cluster_utils.db_cluster ()
mysql_bin_file, bin_log_pos = server.get_master_status ()
cluster.save_master_bin_log (server.ip_addr, mysql_bin_file, bin_log_pos, "slave")Remove a host's record from the status log.
Argument
Example:
import db_cluster_utils
cluster = db_cluster_utils.db_cluster ()
cluster.remove_bin_log(host)Share this page: