Introduction
The purpose of the cctrl
command is to provide easy access to the Tungsten Manager layer, which in turn controls the entire cluster.
In this post we will explore the cctrl> service
command and the power it provides to the admin.
I was inspired to write this post by giving a customer demo. To show the cluster in action, the MySQL Server daemon is stopped on the current Primary database node to cause that node to fail and trigger the failover.
It would of course be possible to ssh into the database node and use the command line to issue either a service or systemctl command to stop the running process.
Instead, it is possible to easily control the MySQL Server processes directly from the cctrl command, keeping the operation entirely within the Tungsten sphere. More below ;-}
The cctrl> service
Command
To get started, let’s explore what process control actually looks like in action.
Invoke the cctrl
command and use the service
subcommand to get the desired results.
The syntax is: service {nodename}/{servicename} {action}
.
For example, service names include mysql
and replicator
, and actions include start
and stop
.
Let’s stop MySQL Server on host db7 while logged into host db9:
db9-demo shell> cctrl
cctrl> service db7-demo.continuent.com/mysql stop
+---------------------------------------------------------------------------------+
|db7-demo.continuent.com |
+---------------------------------------------------------------------------------+
|
+---------------------------------------------------------------------------------+
And with that, MySQL is stopped on db7 - it is just that simple! If the cluster policy is Automatic, then the Manager layer will invoke a failover automatically.
To start a MySQL Server, there are two possibilities in cctrl
, either just issue the recover
command to ask the Manager layer to heal the cluster, or do it manually using service {nodename}/mysql start
.
This is what a recover
operation looks like:
[LOGICAL] /north > recover
RECOVERING DATASERVICE 'north
SET POLICY: AUTOMATIC => MAINTENANCE
FOUND PHYSICAL DATASOURCE TO RECOVER: 'db7-demo.continuent.com@north'
RECOVERING DATASOURCE 'db7-demo.continuent.com@north'
STARTING SERVICE 'db7-demo.continuent.com/mysql'
VERIFYING THAT WE CAN CONNECT TO DATA SERVER 'db7-demo.continuent.com'
Verified that DB server notification 'db7-demo.continuent.com' is in state 'ONLINE'
DATA SERVER 'db7-demo.continuent.com' IS NOW AVAILABLE FOR CONNECTIONS
RECOVERING 'db7-demo.continuent.com@north' TO A REPLICA USING 'db9-demo.continuent.com@north' AS THE PRIMARY
SETTING THE ROLE OF DATASOURCE 'db7-demo.continuent.com@north' FROM 'primary' TO 'replica'
RECOVERY OF DATA SERVICE 'north' SUCCEEDED
REVERT POLICY: MAINTENANCE => AUTOMATIC
RECOVERED 1 DATA SOURCES IN SERVICE 'north'
Bonus: Advanced Command-Line Usage
If you wanted to execute the command non-interactively, simply pipe it to the cctrl
command like this:
shell> echo 'service db9-demo.continuent.com/mysql stop' | cctrl -expert
Tungsten Clustering 7.0.2 build 161
north: session established, encryption=true, authentication=true
jgroups: encrypted, database: encrypted
/north > service db9-demo.continuent.com/mysql stop
+---------------------------------------------------------------------------------+
|db9-demo.continuent.com |
+---------------------------------------------------------------------------------+
|
+---------------------------------------------------------------------------------+
/north >
Exiting...
Wrap-Up
The cctrl> service
command enables direct access to the OS-level services like mysql
and replicator
. This makes it easy to control and test the various nodes. For more information about the cctrl> service
command and other cctrl subcommands, please visit the online documentation at https://docs.continuent.com/tungsten-clustering-7.0/cmdline-tools-cctrl-commands.html#cmdline-tools-cctrl-commands-service.
Comments
Add new comment