Search

Migrate Installation

Migrate a Varnish Controller installation

Here, we show you how you can migrate one or more components of the Varnish Controller installation to new servers.

Overview

The process of migrating an installation is similar to a new installation. It differs from a new installation by the necessity to keep current parameters and, in case of migrating the PostgreSQL database, backing up the database on the old server and restoring it on the new one.

Migrating Agents, Routers, or API-GWs

Directly migrating either an Agent, a Router, or an API-GW is easy, but cannot be tested and results in an service interruption.

To avoid downtimes, we recommend to not just migrate an existing installation, but:

  • To install and configure a new instance of the software. Give Agents and Routers new names.
  • Add it to the Controller system.
  • Test the new installation, look out for error message in the log data.
  • Move all incoming traffic to the new server.
  • Turn off the old installation.

If it cannot be avoided to directly migrate a service, make sure to follow these steps:

  • Collect all configuration values from config files, environment variables and command parameters.
  • Replicate the configuration on the target server.
  • Turn off the old installation.
  • Turn on the new installation.

Migrating Brainz

Before migrating a Brainz node, make sure to collect all configuration values from files, command line parameters and environment variables to transfer them to the new installation.

Make sure all Brainz instances are connecting to the same database.

As long as at least one Brainz installation is active, you can add and remove Brainz installations without downtimes of the Varnish Controller.

Thus, a migration can easiest be performed by the following order of steps:

  • Install and configure the new instance. Make sure it has the same database and NATS connection settings as the existing Brainz installation(s).
  • Test the new installation. Check for any error messages in the log data.
  • Remove the old installation.

See the Brainz installation reference for details.

Migrating NATS

NATS can be run either on a standalone system or in a cluster configuration. It allows to minimize downtimes if NATS already runs in a cluster.

Migrating a server of a NATS cluster

  • Check if the server you want to migrate appears in the nats-server parameters of any Controller component (Brainz, Agent, Router, API-GW).
  • Setup the new NATS server and add it to the existing cluster.
  • Update the nats-server parameter of all components that refer to the old NATS server. Enter the new server and restart the Controller component. You can do this for one component at a time with no need to maintain one specific nats-server parameter among all components.
  • Remove the old server from the existing cluster. Make sure to update the configuration of all NATS servers.
  • It is now safe to turn off the old NATS server.

Migrating a single NATS server

Unlike other migrations described here, moving a single NATS server is best performed in one step. Do not convert a singe server to a temporary cluster. This avoids the multiple downtimes associated with converting NATS servers to a cluster and back to a single node again. It also lowers the risks of misconfiguration.

  • Create a list of all components that are connected to the NATS system: Brainz, API-GW, Agents, Routers.
  • Install, configure and start the new NATS instance.
  • If you use TLS connections to NATS, deploy the new NATS CA file to the client.
  • Turn off all components that are connected to NATS.
  • Update the NATS server name/address on all NATS connected components.
  • Start all components.
  • Test your installation and check for error messages in the log data.

Migrating PostgreSQL

For migrating a PostgreSQL database to a new server, a downtime of the Controller is necessary. We recommend to restore and a dump of the database on the new machine as a test before starting the actual migration.

The singe steps of the migration are:

  • Setting up a new PostgreSQL installation, including a creating a user.
  • Turning off all Brainz instances. To prevent missing or inconsistent data, ensure no Brainz instance is still connected.
  • Dump and restore the database.
  • Activate backup on the new server.
  • Reconfigure and restart all Brainz instances to work with the new server.

Setting up a new PostgreSQL installation, including a creating a user

Setup a your new database server as described in the Postgresql installation chapter, without creating a new database with the createdb command as it is described in the Create an application user and database chapter.

Create the new user (or the new “role”, as it is called in the PostgreSQL terminology) with exactly the same name as on the old one. Otherwise, restoring the database as described will fail.

Creating the database itself will be done automatically when restoring the database from the dump.

Turning off all Brainz instances

Stop all running Brainz instances and other pieces of software that are connected to the database. This is important to guarantee a consistent database on the new server.

You can check for remaining Brainz connections with the SQL command

SELECT * FROM pg_stat_activity;

No connections to your Controller-database should show up, except maybe the SQL client you’re using to run the command. PostgreSQL-internal server processes be be identified by [NULL] values for datid and datname can be ignored.

Dump and restore the database

Extracting all contents (dumping) is done by the pg_dump command. We recommend to use wit with the --create and --format=c parameters. --create creates a new database upon restoring and --format=c creates the dump in a custom format that allows for a faster restore.

Transfer the created dump to the new database host. There, you can restore the dump with the pg_restore command. It requires no extra parameters other than those required for login.

You can pipe the output of pg_dump directly into pg_restore. The following example assumes that you execute both commands on the old database server:

pg_dump -U [POSTGRES_USERNAME] --create --format=c | pg_restore -h [NEW_POSTGRES_SERVER] -U [POSTGRES_USERNAME] 

Verify the restored database. You should get exactly one row for the following SQL command:

SELECT * FROM pg_catalog.pg_tables WHERE tablename = 'migrations';

Activate backup on the new server

Enable your regular backup routine. If you use WAL archiving, it’s the best point in time to do the base backup.

Reconfigure and restart all Brainz instances to work with the new server

Go though all Brainz instances and reconfigure the connection parameters to the new database. Once the connection parameter has been updated,the Brainz instance can be restarted again.


®Varnish Software, Wallingatan 12, 111 60 Stockholm, Organization nr. 556805-6203