Migration to another system
There can be many reasons to migrate a specific PFMS Server and its Web Console, which are generally on the same physical or virtual machine (Pandora FMS monolith environment).
Possible cases:
- A new version of Pandora FMS might need a different operating system, for example, migrating from Rocky Linux 8 to RedHat Enterprise (RHEL) 8.
- It could also be the case of migrating from one web service provider to another: Pandora FMS uses fewer data than taking an image of the entire operating system.
- In the case of audits or to test new features, it is necessary to have a copy of the main server.
Procedure
Generally, the full path to the PFMS Web Console is:
/var/www/html/pandora_console
and in the following instructions it is abbreviated as $CONSOLE_PATH.
Data export
1.- Perform a database backup of the previous system. There are several steps, open a terminal window with administrator rights (root user).
- Make a logical copy of the database with the following command:
mysqldump \ --single-transaction \ --max_allowed_packet=512M \ -u root -p pandora \ > backup_pandora_X.Y.sql
- The resulting file above (
backup_pandora_X.Y.sql) must be compressed along with the data in the following points in order to have a single file for the move. backup_pandora_X.Y.tar.gzis a compressed format which preserves the intrinsic values of each file.- Compress all existing configuration files in the
/etc/pandora/*.confdirectory. - Compress the entire directory and subdirectories of
$CONSOLE_PATH/attachment/. - The custom images and icons in
$CONSOLE_PATH/images/, if any exist. - Compress the entire
/var/spool/pandora/data_in/directory.If migrating from an Ubuntu server to RHEL (or vice versa), you must adjust the permissions of the tokens
userandgroup. - Compress all server plugins located in
/usr/share/pandora_server/util/plugin/. If you have any server plugins located in another directory, they must also be compressed. - Compress all dependencies installed on the source server that are necessary for the correct operation of scripts and/or plugins installed on the source server and that are not found on the destination server. Advanced systems will need to fully install the integrated development environments or interactive development environments (in English Integrated Development Environment or IDE).
- Compress all SSL certificates and custom Apache web server configuration located in
/etc/httpd/, in case any of these types of files exist.
You are solely responsible for safeguarding your data. Write down with pen and paper the procedure you will choose for the data move. Be careful, use redundancy regarding backups and procedures with several people to help you in the process.
Data import
2.- Install the new Pandora FMS system from scratch, the online installation tool is recommended.
3.- Close all processes running on the new system, except MySQL; start with Pandora FMS (as of NG 754 version it has additional options for manual startup and shutdown of High Availability HA Environments):
systemctl stop pandora_server systemctl stop pandora_agent_daemon systemctl stop tentacle_serverd
4.- Stopping the Apache server will depend on the distribution being used:
systemctl stop apache2
systemctl stop httpd.service
5.- Next, send or copy, in whichever way is easiest, the backup_pandora_X.Y.tar.gz file from the old system to the new one. Unzip the files into their corresponding locations.
6.- Log in to MySQL with the root user. Access the Pandora FMS database on the new system, pandora by default, and import the database:
mysql -u root -p
USE pandora; SOURCE ~/backup_pandora_X.Y.sql;
This path will vary depending on the directory where you have the backup of the previous system, here it is assumed you have it in your user directory ($HOME).
7.- In the event of a migration to a major version, where the database structure changes, this would be the time to run the migration scripts as indicated in the major version upgrade procedure.
8.- If you have made a distribution change, keep in mind that the web Console route or PATH has been modified and in that case there are some fields in the database that have also been modified, such as the tconfig table and its attachment_store and fontpath fields. To modify these fields, you must enter these instructions (query). The example is for a migration to Rocky Linux 8; in other distributions change the Apache directory path.
mysql -u root -p> use pandora;
UPDATE tconfig SET VALUE = '/var/www/html/pandora_console/attachment' WHERE token LIKE 'attachment_store'; UPDATE tconfig SET VALUE = '/var/www/html/pandora_console/include/fonts/smallfont.ttf' WHERE token LIKE 'fontpath';
These PATHs must also be taken into account in the server and console configuration files (config.php and pandora_server.conf files).
9.- Once the database is migrated, you must check if the previous and new …/pandora_console/include/config.php and /etc/pandora/pandora_server.conf files contain the same data in the dbname, dbuser and dbpass fields.
- If they are identical go to step number 10.
- If they are different choose only one of the following options:
- Option ( a ): Replace the new files with the old ones.
- Option ( b ): Copy the data (
dbname,dbuseranddbpass) from the old files into the new ones. - Option ( c ): Grant permissions to the database with the new installation data. Assuming the new installation has these data:
dbname=pandora,dbuser=pandora1anddbpass=pandora2:
mysql -u root -p
GRANT ALL privileges ON pandora.* TO 'pandora1'@'localhost' IDENTIFIED BY 'pandora2'; FLUSH privileges;
10.- After this, start all the daemons again and you will be able to access the Pandora FMS Web Console, with all the Agents, Modules, alerts, etc.
11.- If the IP address or URL has changed on the new host, all local Agents will report to this new system.
For EndPoints, the server_ip parameter must be modified in each of them.
12.- Use Massive Operations, agent editing, to finish any pending details.