Moving a Perforce Server
PROBLEM
How do I move a Perforce server from one machine to another?
SOLUTION
This article describes how to move a Perforce server between machines with identical case-sensitivity, architecture and text file format.
For information on how to migrate a Perforce server between machines with different case-sensitivities, architectures and/or text file formats, please consult Cross-Platform Perforce Server Migration. For information on changing the port or moving parts of Perforce within the same server, see Moving Server Components on the Same Machine.
Prior to moving a Perforce server, consider these questions; if the answer to any of them is "No", a cross-platform migration must be performed:
-
Do both machines deal with case-sensitivity the same way?
Windows is case-insensitive, UNIX-based operating systems are typically case-sensitive but Mac OS X is case-insensitive.
-
Do both machines store text files with the same line-ending format?
Windows uses CR/LF, UNIX-based operating systems use LF.
-
Do both machines store numbers the same way?
X86-based machines are little-endian, PPC and SPARC are big-endian, regardless of the operating system used.
If all three items are true, a Perforce server can be safely moved using the method described below. If not, please consult Cross-Platform Perforce Server Migration.
To move a Perforce server between machines with identical case-sensitivity, architecture, and text file format do the following:
-
Update the license file
If the IP address of the new machine is different from the old machine and the Perforce license is current, obtain a new license file to reflect the new IP address. Fill out a Change of Server Request at http://www.perforce.com/purchase/change_server_request or contact support@perforce.com for an updated license.
-
Install Perforce
If not already done, install the Perforce server software on the new machine. Use the same release on the new machine as on the original machine; however, use the latest patch of that release. For more information on how to install Perforce, consult the Perforce System Administrator's Guide. Older versions of Perforce can be obtained from ftp://ftp.perforce.com/perforce. For example, the 2009.2 version of the 64-bit Windows installer is located in ftp://ftp.perforce.com/perforce/r09.2/bin.ntx64/perforce64.exe, where r09.2 refers to Perforce 2009.2 and bin.ntx64 refers to Windows 64-bit operating systems.
-
Verify the archive files
To ensure there are no missing or corrupted archive files, run the following command on the original server:
p4 verify -q //... > verify.errors
Examine the verify.errors file for errors. Ideally this file will be empty (no errors found). If any errors or listed, please contact Perforce Support at support@perforce.com for assistance, or see our Knowledge Base articles, "How to Handle p4 verify BAD Errors" and "MISSING! errors from p4 verify".
-
Compute missing checksums
To provide signatures for any files that do not already have them, run the following command on the original server:
p4 verify -qu //... > verify.update
This will allow all revisions of all files to be checked following the move.
-
Stop the server
Run "p4 admin stop" to shut down the original Perforce server. This will prevent access to the server while it is relocated.
-
Copy the server root directory
Copy the database (db.*) files and versioned files of the original Perforce server root directory (P4ROOT) to the new machine. The versioned files usually reside in directories under the root directory. To avoid overwriting any executables, either rename, or do not copy p4d, p4d.exe, or p4s.exe. Files and directories can be moved using tar and ftp, a network copy or any other method that preserves the files as they were on the original server.
-
Install the new license file
Copy the new license file into the new Perforce server P4ROOT in place of the old license file.
-
Start the new server privately
This step is optional, but recommended. To prevent unwanted connections while performing work on the new server, use "localhost" for the P4PORT setting when starting the server (this will deny remote connections while allowing access from the server host itself), or start the server on a non-standard port.
For example:p4d -r <P4ROOT> -p localhost:1666
Or:p4d -r <P4ROOT> -p 6666
Where <P4ROOT> is the directory of the database (db.*) files. For more information on how to configure and start Perforce, consult our System Administrator's Guide.
This allows a "sanity check" of the server with the command:
p4 -p 6666 changes -t -m 10
This command will verify that the last changes submitted to the original Perforce server are on the new machine.
-
Re-verify the archive files
To ensure that all archive files were copied successfully, run p4 verify on the new server using the same command(s) as in step three above. If any errors are encountered, confirm that the archive files were successfully copied into the correct location and, if necessary, contact Support for assistance.
-
Restart the new server
Stop and restart the new server using the production host and port number to allow full access. To stop the server, run the "p4 admin stop" command as in step five. Consult the Perforce System Administrator's Guide for more information on how to configure and start Perforce. Stop the old server or change the port number on the old server so users will not accidentally connect to the wrong server.
Note:
In addition to the steps detailed above, check for any automated processes that might access the Perforce server. Check for the following to see if any need to be updated and migrated:
- Custom triggers.
- daemons (such as the review daemon or p4thumb).
- cron jobs or scheduled tasks (such as an automated backup or checkpointing script).
- Perforce server startup script(s) (Linux or Unix) or launchd plist file (Mac OS X).
If the name server name or alias name of the new machine is different, users will likely need to change their P4PORT settings. Perforce client software defaults to connecting to a server called "perforce" at port 1666. So, if the Perforce server is run on the default port of 1666 with a name service alias for the machine running the server set to "perforce", users never need to set P4PORT. In that case, when changing the machine running the Perforce server, update the company name server (DNS) so that the name record "perforce" refers to the new machine rather than the old. This will make the move completely transparent to the Perforce users.
