Moving the Control Server
Existing control server preparation and backup
The existing control server must be on the latest version. You should fully update before proceeding.
Stop the scheduler process
systemctl stop vf-schedule.timer
Make a copy of the main configuration file
cat /opt/virtfusion/app/control/.env
Which should output something similar to this:
APP_KEY=base64:vBJSynHOLyOwTVP+MGk7wy0E4CVM/5do/UDB5Ij0qtk=
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE="vf_d_H2aJvrdwS6A67g62cGRw"
DB_USERNAME="vf_u_SAZJ8WOZt5cZpy3VdTtN"
DB_PASSWORD="PB4oFYFc7ucs07I7bwXTi"
WSS_STORE_TYPE=push
JWT_SIGNING_TYPE=RS256
JWT_EXPIRE_SECONDS=60
JWT_SECRET_KEY="vtw5pfOZfU2O1ljukJ31oK8yVxh7SC"
JWT_PRIVATE_KEY=/opt/virtfusion/app/control/store/jwt_rs256_signing.key
JWT_PUBLIC_KEY=/opt/virtfusion/app/control/store/jwt_rs256_signing.key.pub
WSS_LISTEN_HOST=127.0.0.1
WSS_LISTEN_PORT=6001
WSS_SECRET_KEY="P4wTuVC8BOYeOgLjcJ5FPAV4wmys8M"
WSS_REDIS_HOST=127.0.0.1
WSS_REDIS_PASSWORD=null
WSS_REDIS_PORT=6379
The APP_KEY is the most vital part of the configuration file. Without the correct key, the database will be of no
use.
Backup the database
mariadb-dump --skip-ssl --user=root `cat /opt/virtfusion/app/control/.env | grep 'DB_DATABASE' | cut -d'"' -f2` > /tmp/database.sql
Once the command has completed, a database backup called database.sql will be placed in the /tmp folder.
Put the system into maintenance mode
vfcli-ctrl down
New control server preparation and restore
Installation
Install the control software on the new server as normal but don't log in and configure it.
The new installation must be running the exact same version as the old installation. If you were running the testing version on the old installation, you should update the new installation to match.
Replace the app key
Edit /opt/virtfusion/app/control/.env:
nano /opt/virtfusion/app/control/.env
Replace APP_KEY with the APP_KEY from the old installation and save the configuration.
Restore the database backup
Copy the database backup you made earlier to the new server and place it in /tmp.
mariadb --user=root `cat /opt/virtfusion/app/control/.env | grep 'DB_DATABASE' | cut -d'"' -f2` < /tmp/database.sql
Restart VirtFusion
vfcli-ctrl app:restart
SSL certificate
A stock installation will generate a self-signed SSL certificate but this is probably not what you need. You can generate a signed set of certificates for your domain at no cost using a free SSL service or use your own custom certificate.
Let's Encrypt
acme.sh
You must have an A record pointing to the new control server IP in your DNS records before proceeding to setup a certificate. As you are most likely reusing the same domain, update the existing record to point to the new server's IP.
Install acme.sh (Official Website)
wget -O - https://get.acme.sh | sh
. ~/.bashrc
The installer will perform 3 actions:
- Create and copy acme.sh to your home dir
($HOME): ~/.acme.sh/. All certs will be placed in this folder too. - Create alias for:
acme.sh=~/.acme.sh/acme.sh. - Create daily cron job to check and renew the certs if needed.
Generate a certificate (replace DOMAIN.COM with your own domain).
acme.sh --issue \
--webroot /opt/virtfusion/nginx/acme \
--keylength 4096 \
--server letsencrypt \
-d DOMAIN.COM
Install the certificate (replace DOMAIN.COM with your own domain).
acme.sh --installcert \
--keypath /opt/virtfusion/ssl/ssl.key \
--fullchainpath /opt/virtfusion/ssl/ssl.crt \
--reloadcmd "systemctl reload vf-nginx" \
-d DOMAIN.COM
Custom Certificate
The location of the key and certificate should be the following.
/opt/virtfusion/ssl/ssl.key
/opt/virtfusion/ssl/ssl.crt
Once your key and certificate are in place, you simply reload the web server.
systemctl reload vf-nginx
Log in
If you receive an error stating that your host is not allowed, you may need to reconfigure your trusted hosts. Instructions for editing the allowed hosts can be found here.
Once logged in, you may receive a license error. You must re-issue the license to work on the new server. You may do this by logging in at account.virtfusion.com and ticking the re-issue box under your license.
Finally, rebuild the VNC configuration for the new control server. Navigate to Settings > General > Misc > VNC Configuration and click the Rebuild button.
Hypervisors
Communication between the control server and hypervisors will be lost due to the ip change from the old server to the new one. You will need to update the authentication file on each hypervisor.
Edit the file /opt/virtfusion/app/hypervisor/conf/auth.json:
nano -w /opt/virtfusion/app/hypervisor/conf/auth.json
It will look similar to this:
{
"ip": "192.168.100.19",
"token": "CqlsVq6zS4vwLQEZqlVo5tHmkgBzvdZYQ2NJnr5qyB1s2JjgYjSqR72wUYmjGcQbnTf8EWQgHnsqaUU8d8TxhPvaad2fz0zyKMxb5wmfJ9IulHQARYvqHFAabL9I56q7eMQtYSFhtRvNp4K4AmEXYUfW7HiD41fQSHgyIFpaAwP8n1TZVX59AwvIxVAvmlGYnghvvCrt",
"hash": "bc1a53dd974e54c903399fcbe8d05550b35842ca052bc583ecb7b0fe4cf64b86"
}
Replace the ip with the new ip of the control server and save the file.