About moving Redis
Use this procedure when Redis and MySQL compete for resources on the same node and you want to isolate their workloads.
You can move the Redis primary from a node that also runs other services, such as MySQL, to a dedicated node in your GitHub Enterprise Server cluster. Redis then uses the dedicated node's resources and data volume rather than sharing them with those services. This procedure does not attach a new disk to an existing node or use an external Redis service. It also does not apply to high availability configurations.
During a maintenance window, add a node with the redis-server role and let it replicate from the current Redis primary. Confirm that replication has caught up, then designate the new node as the primary. Keep the original node as a Redis replica so you can move the primary back later without restoring an older copy of the data.
The redis-master setting in the [cluster] section of /data/user/common/cluster.conf selects the Redis primary for the cluster. The redis-server setting in an individual node's section enables Redis on that node. Changing the Redis primary does not require changing mysql-master or removing MySQL from the original node.
The redis-master setting in the [cluster] section of /data/user/common/cluster.conf selects the Redis primary for the cluster. The redis-server setting in an individual node's section enables Redis on that node. Changing the Redis primary does not require changing mysql-master or removing MySQL from the original node. The existing colocated Redis and MySQL topology remains supported.
Prerequisites
Before you begin:
- Schedule a maintenance window for the topology change. Applying cluster configuration can interrupt service.
- Complete and verify a recent backup of your instance. See Backing up and restoring your instance.
- Ensure that every cluster node, including the new node, runs the same exact GitHub Enterprise Server release. Wait for any upgrade or configuration run to finish. For shared instructions to provision a node and configure its IP address, see steps 1 and 2 under Replacing a cluster node.
- Provision the new node with a unique hostname, enough memory for the Redis dataset, and a separate data volume with sufficient free space. Review the hardware and network requirements in About cluster nodes and Cluster network configuration.
- Ensure you have administrative SSH access to the cluster. See Accessing the administrative shell (SSH).
- Keep at least one healthy Redis replica in addition to the primary.
Important
Run the configuration commands from one existing cluster node that you will retain, such as the primary MySQL node. Edit /data/user/common/cluster.conf on that node and run ghe-cluster-config-init and ghe-cluster-config-apply there. The apply command distributes the configuration to the other nodes. Do not edit separate copies on each node.
Adding the dedicated node as a Redis replica
Add the node without changing the existing Redis primary.
-
Install GitHub Enterprise Server on the new node. Using the administrative shell or DHCP, configure only its IP address. Do not configure other settings. For these shared installation and IP configuration steps, see Initializing the cluster.
-
Back up
/data/user/common/cluster.conf, then open the file in a text editor. For the file's structure and node hostname and IP address requirements, see Initializing the cluster. -
Add a section for the dedicated node with
redis-server = true. ReplaceREDIS-NODE-HOSTNAME,IPV4-ADDRESS, andDATACENTERwith the new node's unique hostname, private IPv4 address, and the datacenter of the current primary Redis node. SetCONSUL-DATACENTERto the current primary Redis node'sconsul-datacentervalue.[cluster "REDIS-NODE-HOSTNAME"] hostname = REDIS-NODE-HOSTNAME ipv4 = IPV4-ADDRESS consul-datacenter = CONSUL-DATACENTER datacenter = DATACENTER redis-server = trueDo not assign
mysql-serveror other service roles to the dedicated node. Leave the existing[cluster]section, includingredis-masterandmysql-master, unchanged. Keep theredis-server = truesetting on the original Redis node and the existing Redis replicas.During your scheduled maintenance window, initialize the new node, then apply the configuration. Run both commands from the node where you edited
cluster.conf.
Important
Applying this configuration restarts Redis on every Redis node, including the current primary.
ghe-cluster-config-init
ghe-cluster-config-apply
-
Check Redis replication.
/usr/local/share/enterprise/ghe-cluster-status-redis -vWait until the new node's entry reports
okandreplication is in sync. The current primary's entry must also reportok. Initial replication time is proportional to the size of your Redis dataset and is usually in the order of minutes.
Warning
Stop here if either node remains unhealthy. Resolve the issue before continuing.
Promoting the dedicated node
Promote only a healthy replica that has caught up with the current primary.
Warning
Changing redis-master before the target replica has caught up can discard Redis data, including background-job queue state. Do not promote an empty or out-of-date node.
This procedure does not guarantee zero data loss. Background jobs can keep writing to Redis during maintenance mode, and writes made while the primary changes can be lost even after the replica has caught up.
-
During your scheduled maintenance window, enable maintenance mode and confirm that it is active.
ghe-cluster-maintenance -s ghe-cluster-maintenance -qFor details about cluster maintenance mode, see Enabling and scheduling maintenance mode.
-
Confirm that the target replica has caught up using Checking replication before promotion. Use the dedicated node as
TARGET-NODE-HOSTNAME. Do not changeredis-masteruntil these checks pass. -
On the existing node where you have been editing the configuration, back up the current
cluster.conf. In the file's existing[cluster]section, change onlyredis-masterto the dedicated node's hostname. ReplaceREDIS-NODE-HOSTNAMEwith that hostname.[cluster] redis-master = REDIS-NODE-HOSTNAMEThis snippet shows only the setting to change. Preserve all other settings in
[cluster], includingmysql-master, and all node sections. Do not putredis-masterinside a[cluster "HOSTNAME"]node section. -
Check the configuration, then apply it from the same node.
ghe-cluster-config-check /data/user/common/cluster.conf ghe-cluster-config-apply
Warning
Stop here if either command fails. Keep maintenance mode enabled and work with GitHub Support to resolve the failure.
-
Verify the result using Verifying the Redis primary. The dedicated node must be the primary, and the original node must be a healthy replica.
-
Disable maintenance mode.
ghe-cluster-maintenance -u -
Confirm that users can access the instance and that background jobs resume normally.
Checking replication before promotion
Use these checks immediately before promoting a Redis replica, whether you are moving Redis to the dedicated node or moving it back.
-
To compare Redis data and background-job queues after this transfer, run the following commands and save the output.
ghe-redis-cli INFO keyspace ghe-aqueduct status/usr/local/share/enterprise/ghe-cluster-status-redis -vThe current primary and target replica must report
ok. The target must reportreplication is in sync. -
Look up the current Redis and MySQL primary hostnames. Use the Redis primary hostname in the following commands. Confirm after applying the configuration that the MySQL primary has not changed.
ghe-config cluster.redis-master ghe-config cluster.mysql-master -
Read the target replica's replication information, then the current primary's information. Replace
TARGET-NODE-HOSTNAMEwith the node you want to promote andCURRENT-PRIMARY-HOSTNAMEwith the hostname from the previous step.ghe-redis-cli --remote -h TARGET-NODE-HOSTNAME INFO replication ghe-redis-cli --remote -h CURRENT-PRIMARY-HOSTNAME INFO replication -
Confirm that the target reports
role:slave,master_link_status:up, andmaster_sync_in_progress:0, and that itsmaster_hostidentifies the current primary. Confirm that the current primary reportsrole:master. -
Compare the target's
slave_repl_offsetwith the current primary'smaster_repl_offset. The values must match. Repeat both commands and confirm that the offsets still match immediately before changingredis-master, checking the target first. The cluster status check reports replication freshness, not exact offsets, so it does not replace this comparison.
Warning
Stop here if you cannot obtain matching offsets or replication is unhealthy. Do not change redis-master. Keep maintenance mode enabled and contact GitHub Support.
Verifying the Redis primary
After applying a primary change, verify both routing and replication before disabling maintenance mode.
-
Confirm that the configured Redis primary is the node you intended to promote and that the MySQL primary has not changed.
ghe-config cluster.redis-master ghe-config cluster.mysql-master -
Check cluster health and access to Redis through the default HAProxy endpoint.
ghe-cluster-status -ev /usr/local/share/enterprise/ghe-cluster-status-redis -v ghe-redis-cli PINGConfirm that the cluster checks are healthy, the new primary's entry reports
ok, andPINGreturnsPONG. The former primary must reportokandreplication is in sync. -
Check the Redis roles directly. Replace
NEW-PRIMARY-HOSTNAMEandFORMER-PRIMARY-HOSTNAMEwith the hostnames for this change.ghe-redis-cli --remote -h NEW-PRIMARY-HOSTNAME INFO replication ghe-redis-cli --remote -h FORMER-PRIMARY-HOSTNAME INFO replicationThe new primary must report
role:master. The former primary must reportrole:slave, amaster_hostthat identifies the new primary,master_link_status:up, andmaster_sync_in_progress:0. Repeat the replica check for every other Redis node. -
Run the following commands again and compare the output with what you saved before this transfer.
ghe-redis-cli INFO keyspace ghe-aqueduct status
Warning
Stop here if a check fails. Keep maintenance mode enabled. Do not point Redis back at another node without first checking that node's replication state.
Moving Redis back to the original node
Because the original node remains a Redis replica, moving Redis back does not require restoring an old dump or re-adding the node. Promote it from its current replica state. Redis data can have changed since the move, so do not restore an old dump or configuration file.
-
Confirm that the original node still has
redis-server = trueand appears as a healthy replica in/usr/local/share/enterprise/ghe-cluster-status-redis -v. Leave its other roles, includingmysql-server, unchanged. -
During a scheduled maintenance window, enable maintenance mode and confirm that it is active.
ghe-cluster-maintenance -s ghe-cluster-maintenance -q -
Complete Checking replication before promotion, using the original node as
TARGET-NODE-HOSTNAMEand the dedicated node as the current primary. Wait for matching offsets. -
On the retained cluster node where you manage
cluster.conf, back up the current file. Changeredis-masterin the existing[cluster]section to the original node's hostname. Keep both nodes'redis-server = truesettings and leavemysql-masterunchanged. -
Check and apply the configuration from that same node.
ghe-cluster-config-check /data/user/common/cluster.conf ghe-cluster-config-apply -
Complete Verifying the Redis primary. The original node must now be the primary, and the dedicated node must be a healthy replica. If a command or check fails, keep maintenance mode enabled and contact GitHub Support.
-
If you plan to remove the dedicated node, install the latest patch release for your feature release on every node first. Ensure that every node runs the same exact release, and wait for any upgrade or configuration run to finish.
-
Removing the dedicated node applies the cluster configuration and restarts Redis on the remaining nodes. From the primary MySQL node, run the following command, replacing
REDIS-NODE-HOSTNAMEwith the dedicated node's hostname.ghe-remove-node REDIS-NODE-HOSTNAMEAfter removal, confirm that the cluster is healthy. Do not remove the node while it is still the Redis primary. Retain the required Redis replicas for your cluster topology. For details about removal, see Command-line utilities.
-
Disable maintenance mode, then confirm that users can access the instance and background jobs resume.
ghe-cluster-maintenance -u