Chapter 1
Welcome to Perforce:
Installing and Upgrading
This chapter describes how to install a Perforce server or upgrade an existing installation.
This chapter includes a brief overview of things to consider at installation time, along with some basic security and administration tips. More detailed information on administrative tasks is found in later chapters.
Windows
|
Where the UNIX and Windows versions of Perforce differ, a note to that effect is made. For Windows-specific information, see "Perforce and Windows" on page 109.
Many of the examples in this book are based on the UNIX version of the Perforce server. In most cases, the examples apply equally to both Windows and UNIX installations.
|
OS X
|
The material for UNIX also applies to MacOS X.
|
Getting Perforce
Perforce requires at least two executables: the server (p4d), and at least one Perforce client program (such as p4 on UNIX, or p4.exe or p4win.exe on Windows).
The server and client executables are available from the Downloads page on the Perforce web site:
Go to the web page, select the files for your platform, and save the files to disk.
Installing Perforce on UNIX
Although p4 and p4d can be installed in any directory, on UNIX the Perforce client programs typically reside in /usr/local/bin, and the Perforce server is usually located either in /usr/local/bin or in its own server root directory. Perforce client programs can be installed on any machine that has TCP/IP access to the p4d host.
To limit access to the Perforce server files, ensure that the p4d executable is owned and run by a Perforce user account that has been created for that purpose.
After downloading p4 and p4d, you need to do a few more things before you can start using Perforce:
- Make the downloaded p4 and p4d files executable.
- Create a server root directory to hold the Perforce database and versioned files.
- Provide a TCP/IP port to p4d to tell the Perforce server what port to listen to.
- Provide the name of the Perforce server and the p4d port number to the Perforce client program(s).
- Start the Perforce server (p4d).
Download the files and make them executable
On UNIX (or MacOS X), you must also make the Perforce executables (p4 and p4d) executable. After downloading the programs, use the chmod command to make them executable, as follows:
Create a Perforce server root directory
The Perforce server stores all user-submitted files and system-generated metadata in files and subdirectories beneath its own root directory. This directory is called the server root.
To specify a server root, set the environment variable P4ROOT to point to the server root, or use the -r root_dir flag when invoking p4d. Perforce client programs never use the P4ROOT directory or environment variable; the p4d server is the only process that uses the P4ROOT variable.
Because all Perforce files are stored beneath the server root, the contents of the server root will grow over time. See "Installation and Administration Tips" on page 18 for a brief overview of diskspace requirements, and "Disk space allocation" on page 96 for more detail.
A Perforce server requires no privileged access; there is no need to run p4d as root or any other privileged user. For more information, see the section entitled "UNIX: Run p4d as a non-privileged user" on page 22.
The server root can be located anywhere, but the account that runs p4d must have read, write, and execute permissions on the server root and all directories beneath it. For security purposes, set the umask(1) file creation-mode mask of the account that runs p4d to a value that denies other users access to the server root directory.
Telling Perforce servers on which port to listen
The p4d server and Perforce client programs communicate with each other using TCP/IP. When p4d starts, it listens (by default) on port 1666. The Perforce client assumes (also by default) that its p4d server is located on a host named perforce, listening on port 1666.
If p4d is to listen on a different port, specify that port with the -p port_num flag when starting p4d (as in, p4d -p 1818), or set the port with the P4PORT environment or registry variable.
Unlike P4ROOT, the environment variable P4PORT is used by both the Perforce server and Perforce client programs, and must be set on both Perforce server machines and Perforce client workstations.
Telling Perforce client programs which port to connect to
Perforce client programs need to know on what machine the p4d server resides, and on which TCP/IP port the p4d server program is listening. Set each Perforce user's P4PORT environment variable to host:port#, where host is the name of the machine on which p4d is running, and port# is the port on which p4d is listening.
Examples:
If P4PORT is...
|
Then...
|
---|
dogs:3435
|
The client program connects to the p4d server on host dogs listening at port 3435.
|
x.com:1818
|
The client program connects to the p4d server on host x.com listening at port 1818.
|
If the Perforce client program is running on the same host as p4d. only the p4d port number need be provided in P4PORT. If p4d is running on a host named or aliased perforce, and is listening on port 1666, the definition of P4PORT for the client can be dispensed with altogether. For example:
If P4PORT is...
|
Then...
|
---|
3435
|
The client program connects to the p4d server on its local host listening at port 3435.
|
<not set>
|
The client program connects to the p4d server on the host named or aliased perforce listening on port 1666.
|
If your p4d host is not named perforce, you can simplify life somewhat for your Perforce users by setting perforce as an alias to the true host name in your users' workstations' /etc/hosts files, or by doing so via Sun's NIS or Internet DNS.
Starting the Perforce server
After setting p4d's P4PORT and P4ROOT environment variables, start the server by running p4d in the background with the command:
Although the example shown is sufficient to run p4d, other flags that control such things as error logging, checkpointing, and journaling, can be provided.
Example:
Starting a Perforce server.
P4PORT can be overridden by starting p4d with the -p flag, and P4ROOT can be overridden by
starting p4d with the -r flag. A journal file can be specified with the -J flag, and errors can
be logged to a file specified with a -L flag. A startup command that overrides the environment
variables might look like this:
p4d -r /usr/local/p4root -J /var/log/journal -L /var/log/p4err -p 1818 &
|
Stopping the Perforce server
To shut down a Perforce server, use the command:
to gracefully shut down the Perforce server. Only a Perforce superuser can use p4 admin stop.
If you are running a release of Perforce from prior to 99.2, you must find the process ID of the p4d server and kill the process manually from the UNIX shell. Use kill -15 (SIGTERM) instead of kill -9 (SIGKILL), as p4d might leave the database in an inconsistent state if p4d is in the middle of updating a file when a SIGKILL signal is received.
Installing Perforce on Windows
To install Perforce on Windows, use the Perforce installer (perforce.exe) from the Downloads page of the Perforce web site.
The Perforce installer allows you to:
- Install Perforce client software ("User install").
- This option allows you to install p4.exe (the Perforce Command-Line Client), p4win.exe (P4Win, the Perforce Windows Client), and p4scc.dll (Perforce's implementation of the Microsoft common SCM interface).
- Install Perforce as either a Windows server or service as appropriate. ("Administrator typical" and "Administrator custom" install).
- These options allow you to install Perforce client programs and the Perforce Windows server (p4d.exe) and service (p4s.exe) executables, or to automatically upgrade an existing Perforce server or service running under Windows.
- Under Windows 2000 or higher, you must have Administrator privileges to install Perforce as a service, and Power User privileges to install Perforce as a server.
- Uninstall Perforce: remove the Perforce server, service, and client executables, registry keys, and service entries. The Perforce database and the depot files stored under your server root are preserved.
For more about installing on Windows, see "Using the Perforce installer" on page 109.
Terminology: Windows services and servers
The terms "Perforce server" and "p4d" are used interchangeably to refer to "the process which handles requests from Perforce client programs". In cases where the distinction between an NT server and an NT service is important, the distinction is made.
On UNIX systems, there is only one Perforce "server" program (p4d) responsible for this back-end task. On Windows, however, the back-end program can be started either as a Windows service (p4s.exe) process that runs at boot time, or as a server (p4d.exe) process that must be invoked from a command prompt.
The Perforce service (p4s.exe) and the Perforce server (p4d.exe) executables are copies of each other; they are identical apart from their filenames. When run, the executables use the first three characters of the name with which they were invoked (either p4s or p4d) to determine their behavior. (For example, invoking copies of p4d.exe named p4smyservice.exe or p4dmyserver.exe invoke a service and a server, respectively.)
In most cases, it is preferable to install Perforce as a service, not a server. For a more detailed discussion of the distinction between services and servers, see "Windows services vs. Windows servers" on page 112.
Starting and stopping Perforce on Windows
If you install Perforce as a service under Windows, the service starts whenever the machine boots. Use the Services applet in the Control Panel to control the Perforce service's behavior.
If you install Perforce as a server under Windows, invoke p4d.exe from a command prompt. The flags for p4d under Windows are the same as those used under UNIX.
To stop a Perforce service (or server) at Release 99.2 or above, use the command:
Only a Perforce superuser can use p4 admin stop.
For older revisions of Perforce, shut down services manually by using the Services applet in the Control Panel. Shut down servers running in command prompt windows by typing CTRL-C in the window or by clicking on the icon to Close the command prompt window.
Although these manual shutdown options work with Release 99.2 and earlier versions of Perforce, they are not necessarily "clean", in the sense that the server or service is shut down abruptly. With the availability of the p4 admin stop command in 99.2, the manual shutdown options are obsolete.
Upgrading a Perforce Server
Whether your Perforce server is installed on Windows or UNIX, you must back up your server (see "Backup Procedures" on page 31) as part of any upgrade process.
Warning!
|
If you are upgrading to 2001.1 or later, it is imperative that you read the notes pertaining to the 2001.1 upgrade.
|
Using old client programs with a new server
Although older Perforce client programs (p4, p4.exe, p4win.exe, and p4scc.dll) generally work with newer server versions, some features in new server releases require upgrades to Perforce client programs. In general, users with older client programs are able to use features available from the Perforce server at the client program's release level, but are not able to use the new server features offered by subsequent server upgrades.
Perforce's remote depot support is an exception: remote depot support is not guaranteed to work unless all Perforce servers are at or above Release 98.2.
Important Notes for 2001.1 and later
On small installations (installations with fewer than 1000 submitted changelists), installing a 2001.1 (or more recent) server automatically upgrades the underlying database from versions 98.2 and up.
On larger installations, you must upgrade the database manually. Although the upgraded database is typically smaller than a pre-2001.1 database, the upgrade process requires approximately three times the size of the existing database to store temporary files required during the upgrade.
Note
|
If you have limited disk space, see the Release Notes for a more precise estimate of the amount of disk space required.
By turning off journaling during the upgrade (by setting P4JOURNAL to off), you can reduce the amount of disk space required for the upgrade. (Remember to turn journaling back on when the upgrade is complete!)
|
If you are upgrading from Release 97.3 or earlier to 2001.1 or later, the automatic or manual upgrade procedures will not work; you will likely have to make an intermediate checkpoint. Contact Perforce technical support for assistance before upgrading a Release 97.3 or earlier server.
UNIX upgrades
To upgrade your current Perforce server to a newer version, your Perforce license file must be current. Expired licenses do not work with upgraded servers. (Restrictions on license files are not an issue for users running a two-user installation with no license.)
You must back up your server as described in "Backup Procedures" on page 31 as part of any upgrade process.
For additional safety, run p4 verify as part of your upgrade. See "Verifying during server upgrades" on page 44 for details.
Warning!
|
Upgrading to Release 2001.1 or later requires an upgrade of your database files. Downgrading thereafter requires a that you restore from backups.
If you wish to keep your pre-2001.1 server available as a fallback option when upgrading to 2001.1 or higher, you must back up your entire server root (including the db.* files) after stopping the server.
|
Upgrading from UNIX Release 98.2 or later
If you have a valid license (or require no license) and are upgrading from Release 98.2 or later:
- Download the new p4d executable for your platform
- Stop the current instance of p4d
- Make a checkpoint and back up your old installation
- Install the new p4d in the desired location
- Run p4d -xu to upgrade the database.
Note
|
If your server has fewer than 1000 changes, the upgrade runs automatically. Larger installations require that you run p4d -xu manually.
You must have sufficient disk space to complete the upgrade. The required amount is typically two to three times the size of the larger of the db.have or db.integ files.
The db.have and db.integ files reside in your P4ROOT directory.
|
- Restart the new p4d with your site's usual parameters.
Your users should then be able to use the new server.
Windows upgrades
On Windows, download the installer (perforce.exe) and follow the installation dialog.
The upgrade process on Windows is extremely conservative; in the event of an error condition during an upgrade, you will be able to revert to your pre-upgrade Perforce server or service.
Note
|
If your server has fewer than 1000 changes, the upgrade runs automatically. Larger installations require that you run p4d -xu manually.
Either way, you must have sufficient disk space to complete the upgrade. The required amount is typically two to three times the size of the larger of the db.have or db.integ files.
The db.have and db.integ files reside in your P4ROOT directory.
|
If you have any questions or difficulties during an upgrade, contact Perforce technical support.
Installation and Administration Tips
Release and license information
Perforce servers are licensed according to how many users they support.
Licensing information is contained in a file called license in the server root directory. The license file is a plain text file supplied by Perforce Software. Without the license file, the Perforce server limits itself to two users and two client workspaces.
To view current licensing information, invoke p4d -V from the server root directory where the license file resides, or by specifying the server root directory either on the command line (p4d -V -r server_root) or in the P4ROOT environment variable.
If the server is running, you can also use p4 info to view your licensing information.
The server version is also displayed when invoking p4d -V or p4 -V.
Observe proper backup procedures
Regular backups of your Perforce data are vital. The key concepts are:
- Make sure journaling is active,
- Create checkpoints regularly, and
- Use p4 verify regularly.
See "Supporting Perforce: Backup and Recovery" on page 25 for a full discussion of backup and restoration procedures.
Use separate physical drives for server root and journal
Whether installing on UNIX or Windows, it is advisable to have your P4ROOT directory (that is, the directory containing your database and versioned files) on a different physical drive than your journal file.
By storing the journal on a separate drive, you can be reasonably certain that if a disk failure corrupts the drive containing P4ROOT, such a failure will not affect your journal file. You can then use the journal file to restore any lost or damaged metadata.
Further details are available in "Supporting Perforce: Backup and Recovery" on page 25.
Use protections and passwords
Until you define a Perforce superuser, every Perforce user is a Perforce superuser, and can run any Perforce command on any file. After starting a new Perforce server, use:
as soon as possible to define a Perforce superuser. To learn more about how p4 protect works, see "Administering Perforce: Protections" on page 67.
Without passwords, any user is able to impersonate any other Perforce user, either with the -u flag or by setting P4USER to an existing Perforce user name. Use of Perforce passwords prevents such impersonation. See the Perforce User's Guide for details.
To set (or reset) a user's password, use p4 passwd username (as a Perforce superuser), and enter the new password for the user, or invoke p4 user -f username (also while as a Perforce superuser) and enter the new password into the user specification form. The former command is supported in release 99.1 or later; the latter command is supported under all releases from 97.3 onwards.
The security-conscious Perforce superuser also uses p4 protect to ensure that no access higher than list is granted to non-privileged users, and to ensure that each user has a Perforce password.
Allocate disk space for anticipated growth
Because the collection of versioned files grows over time, a good guideline is to allocate sufficient space in your P4ROOT directory to hold three times the size of your users' present collection of versioned files, plus an additional 0.5K per user per file to hold the database files that store the list of depot files, file status, and file revision histories.
For a more detailed example of a disk sizing estimate, see "Disk space allocation" on page 96.
Managing disk space after installation
All of Perforce's versioned files reside in subdirectories beneath the server root, as do the database files, and (by default) the checkpoints and journals. If you are running low on disk space, consider the following approaches to limit disk space usage:
- Configure Perforce to store the journal file on a separate physical disk. Use the P4JOURNAL environment variable or p4d -J to specify the location of the journal file.
- Checkpoint on a daily basis to keep the journal file short.
- Compress checkpoints, or use the -z option to tell p4d to compress checkpoints on the fly.
- Use the -jc prefix option with the p4d command to write the checkpoint to a different disk. Alternately, use the default checkpoint files, but back up your checkpoints to a different drive and then delete the copied checkpoints from the root directory. Moving checkpoints to separate drives is good practice not only in terms of diskspace, but due to the fact that old checkpoints are needed when recovering from a hardware failure, and if your checkpoint and journal files reside on the same disk as your depot, a hardware failure could leave you without the ability to restore your database.
- On UNIX systems, you can relocate some or all of the depot directories to other disks by using symbolic links. If you use symbolic links to shift depot files to other volumes, create the links only after stopping the Perforce server.
- If your installation's database files have grown to more than 10 times the size of a checkpoint, you may be able to reduce the size of the files by recreating them from a checkpoint. See "Checkpoints for Database Tree Rebalancing" on page 107.
Large filesystem support
Early versions of the Perforce server, as well as some operating systems, limit Perforce database files (the db.* files in the P4ROOT directory that hold your site's metadata) to 2GB in size. The db.have file holds the list of files currently synced to client workspaces, and tends to grow the most quickly.
If you anticipate any of your Perforce database files growing beyond the 2GB level, install the Perforce server on a platform with support for large files. The following combinations of operating system and Perforce server revision support database files larger than 2GB:
Operating System
|
OS version:
|
Perforce Server Revision
|
---|
Tru64 UNIX (a.k.a. Digital UNIX, OSF/1)
|
All versions
|
98.2/5713 or higher
|
FreeBSD
|
All versions
|
98.2/5713 or higher
|
Windows NT, 2000
|
All versions, SP6 recommended for NT
|
98.2/8127 or higher
|
SGI IRIX 6.2
|
All versions
|
98.2/5713 or higher
|
SGI IRIX 5.3
|
Only with the SGI-supplied xfs upgrade
|
98.2/5713 or higher
xfs OS upgrade required
|
Solaris
|
2.6 and higher
|
98.2/7488 compiled for 2.6 or higher
|
UNIX and NFS support
The Perforce server process has been tested and is supported on the Solaris 2.6 implementation of NFS. Because Perforce client programs never directly access the files in P4ROOT, the only process needing access to P4ROOT is the p4d server itself.
Consequently, under Solaris 2.6 or higher, you can store your journal, log, depot, and db.* files on NFS-mounted filesystems.
Some issues still remain regarding file locking on non-commercial implementations of NFS (for instance, Linux and FreeBSD). On these platforms, store your journal, log, depot, and db.* files on a drive local to the server machine, not on an NFS-mounted volume.
These issues affect only the Perforce Server process (p4d). Perforce client programs, (such as p4, the Perforce Command-Line Client) have always been able to work with client workspaces on NFS-mounted drives, such as client workspaces located in users' home directories.
Windows: Username and password required for network drives
By default, the Perforce service runs under the Windows local System account. Because Windows requires a real account name and password to access files on a network drive, if Perforce is installed as a service under Windows with P4ROOT pointing to a network drive, the installer requires an account name and a password. The Perforce service is then configured with the supplied data and run as the specified user instead of System. (The account running the service must have Administrator privileges on the machine.)
Although Perforce operates reliably with its root directory on a network drive, it does so only at a substantial performance penalty, as all writes to the database are performed over the network. For optimal performance, install the Windows service to use local drives rather than networked drives.
For more information, see "Installing the Perforce service on a network drive" on page 113.
UNIX: Run p4d as a non-privileged user
The Perforce server process does not require privileged access. For security reasons, do not run p4d as root or otherwise grant the owner of the p4d process root-level privileges.
Create a non-privileged UNIX user (for example, "perforce") to manage p4d and (optionally) a UNIX group for it (for example, "p4admin"). Use the umask(1) command to ensure that the server root (P4ROOT) and all files and directories created beneath it are writable only by the UNIX user perforce, and (optionally) readable by members of the UNIX group p4admin.
Under this configuration, the Perforce server (p4d), running as UNIX user perforce, can write to files in the server root, but no users are able to read or overwrite its files. Access to read the files created by p4d (that is, the depot files, checkpoints, journals, and so on) can subsequently be granted to trusted users by making them members of the UNIX group p4admin.
Windows
|
On Windows, directory permissions are set securely by default; when running as a server, the Perforce server root is accessible only to the user who invoked the server from the command prompt. When installed as a service, the files are owned by the LocalSystem account, and are accessible only to those with Administrator access.
|
Logging errors
Use the -L flag to p4d or the environment variable P4LOG to specify the Perforce server's error output file. If no error output file is defined, errors are dumped to the p4d process' standard error.
Although p4d tries to ensure that all error messages reach the user, if an error occurs and the client program disconnects before the error is received, p4d also logs these errors to its error output.
The Perforce server also supports trace flags used for debugging purposes. See "Perforce server trace flags" on page 55 for details.
Case sensitivity issues
Whether your Perforce server is running on Windows or UNIX, if your site is involved in cross-platform development (that is, if you are using Perforce client programs on both Windows and UNIX workstations), your users must be aware of certain details regarding case sensitivity issues. See "Case sensitivity and multi-platform development" on page 52 for details.
Tune for performance
Perforce is an efficient consumer of network bandwidth and CPU power. The most important variables that determine server performance are the efficiency of your server's disk I/O subsystem and the number of files referenced in any given user-originated Perforce operation.
For more detailed performance tuning information, see "Tuning Perforce for Performance" on page 95.
Please send comments and questions about this manual to
[email protected].
Copyright 1999-2003 Perforce Software. All rights reserved.
Last updated: 12/12/03