Perforce Public Knowledge Base - Installing a Proxy Server
Reset Search
 

 

Article

Installing a Proxy Server

« Go Back

Information

 
Problem

How to set up a Perforce proxy server on Windows or Unix.

 

 

Solution

A Perforce proxy server is a machine that only caches the files of the master Perforce server. Note that only files are stored on the proxy, not metadata. Therefore any database queries (such as finding a description of the last changes), are forwarded from the proxy to the master Perforce server.

The advantages of a proxy server are that there is only one central repository, so there are no synchronization issues, and that the proxy server supports real-time read/write development from any location. The disadvantage is that the proxy connection must always be live; if the connection to the master server goes down, the proxy immediately becomes unavailable and users must work disconnected, reconciling changes when the network comes availalbe again.

Windows proxy configuration

  1. Set up TCP/IP VPN connectivity

    You need TCP connectivity between the remote site and the main Perforce server. It is recommended that you use a VPN or ssh tunnel to encrypt communications between the servers, and to only open up the minimum number of ports.
     
  2. Download the appropriate Windows Perforce server installer, for example helix-versioning-engine-x64.exe (Note: Versions of the server installer prior to 2015.1 are still called perforce.exe)

    Choose a proxy release compatible with your Perforce server. See the P4P release notes for details.

    Place helix-versioning-engine-x64.exe onto a machine at the remote location that will become the proxy server. Clients will connect to this proxy server, and it will talk to the main Perforce server.
     
  3. Run helix-versioning-engine-x64.exe.

    The InstallShield dialog box comes up.
     
  4. Select features

    Next to Server (P4D), choose the dropdown "This feature will not be installed".
    Next to Proxy (P4P), choose the dropdown "This feature will be installed on local hard drive"
    Next to Command-Line Client (P4), keep the default of "This feature will be installed on local hard drive"
     
  5. Choose an installation directory

    Click the Change button to select where you want to place the proxy server. Note that the proxy server might be as large as the directories with versioned files on the main server, so you need plenty of space. Then click Next.
     
  6. Click the Next button.
     
  7. Start the installation

    Click the Start button.
    When prompted, press Finish
     
  8. Optional: Change parameters as desired

    For example:
    mkdir E:\proxydir
    p4 set -S "Perforce Proxy" P4PCACHE=E:\proxydir
    p4 set -S "Perforce Proxy"
    
    
    A proxy cache can also be a UNC path, for example:
    p4 set -S "Perforce Proxy" P4PCACHE="\\gabriel\proxydir"

    Restart the proxy service to recognize the variables.
     
  9. Test that the proxy works

    Assuming that the default 1667 is chosen, open a command prompt and run: 
    p4 -p <proxyserver>:1667 info
    
    
    Note the new line beginning with Proxy version. Also notice that you are not directly connecting to the main server. Instead, you are connecting to the proxy server which in turn connects to the main server. All P4V and P4Win clients should connect to this proxy and not to the main server.

    Users should set their P4PORT to point to the new proxy server as follows:
    p4 set P4PORT=<proxyserver>:1667
    
    
    On the Proxy machine, display the proxy configuration settings with this command:
    p4 set -S "Perforce Proxy"
    
    
    To determine whether the proxy is properly caching files, find the line above that displays the P4PCACHE directory. Look there under the "depot\depot" subdirectory to finding files ending with ,v or ,d.  These are cached file revisions.

    Alternatively, from a client, sync a file twice (the first time loads the proxy) and use the -Z proxyverbose flag to see "delivered from proxy server"
    E:\Client\depot\A>p4 -p localhost:1667 -Zproxyverbose sync -f file.txt
    //depot/A/file.A#6 - refreshing E:\Client\depot\A\file.txt
    File E:\Client\depot\A\file.txt delivered from proxy server
    
    
  10. Set up protections (optional)

    Add protections if desired. For example, you could force users to only connect in through the proxy such as:
    list    group    remoteuser    10.0.0.*       -//...
    write   group    remoteuser    proxy-10.0.0.* //depot/main/release2/...
    
    where 10.0.0.* covers the IP addresses of the remote user (and is not the IP address of the proxy server) and
    //depot/main/release2/... restricts the proxy users to only a portion of the depot.
     
  11. Set up a pre-load script on a dummy client (optional)

    Have your proxy preload the latest file versions during off-hours so the file is waiting for users when they come in.

    First create a dummy client workspace to sync files thereby populating the proxy cache.
    cd <newdirwithmuchspace> 
    mkdir proxyclient
    cd proxyclient
    p4 -p localhost:1667 client proxyclient
    
    
    Take the defaults and save and quit. Then get the latest files to pre-populate the cache.
    p4 -p localhost:1667 -Zproxyload sync
    
    
    Next, create a scheduled task that runs the above sync command every night.
    Create a file named "sync.bat" and add the above sync line:
    notepad sync.bat
    and type in
    date /t > sync.txt 2>&1
    time /t >> sync.txt 2>&1
    p4 -u <username> -p localhost:1667 -c proxyclient -Zproxyload sync >> sync.txt 2>&1 
    where <username> is a valid Perforce user.

    Then save and run this script as a scheduled task:

    Start->Control Panel->Scheduled Tasks->Add Scheduled Task->Next
    Browse <to location of sync.bat>->Open-><choose name>->Daily->Next
    <Choose start time a few minutes from now>->Next-><enter passwords>->Finish

    Wait to see whether the script runs. Adjust the scheduled task time to off-hours. Debug problems by looking at "sync.txt".

Unix proxy configuration

  1. Download the Perforce proxy executable (p4p)

    Choose a proxy release compatible with your Perforce server. See the P4P release notes for details.
     
  2. Change the permission of p4p  to executable
    chmod 755 p4p
    
    
  3. Create a file cache directory with plenty of space to hold versioned files.
    mkdir /opt/proxydir
    
    
  4. Start the proxy

    Below, 1667 should be  the proxy port, perforce:1666 should be the main Perforce server and port number, -r should be the directory that caches versioned files, -v 1 turns on debugging information, and -d places the script into the background.
    $ ./p4p -p 1667 -t perforce:1666 -r /opt/proxydir -v 1 -d
    NetTcpEndPoint 0.0.0.0:1667 listening
    Perforce proxy info:
            2008/10/10 13:31:16
    Perforce Proxy starting... 
    An automated startup script can be made from this command.
     
  5. Write a cron job to get the head revision of all files during off-hours

    Create a client on the proxy server such as:
    $ mkdir proxyclient
    $ cd proxyclient
    $ p4 -u perforce -p localhost:1667 login
    $ p4 -u perforce -p localhost:1667 client proxyclient
    where perforce is replaced by a valid Perforce username. Take defaults and save.

    Write a script to get the latest revision of files from the server to this client. Debug problems by examining "proxyclient.txt".
    $ cd <script dir>
    $ cat proxysync.sh
     
    #!/bin/bash
    p4 -u perforce -p localhost:1667 -c proxyclient -Zproxyload sync > proxyclient.txt 2>&1
    
    $ chmod 755 proxysync.sh
    
    $ ./proxysync.sh
    
    $ cat proxyclient.txt
        
  6. Create a cron job to run this script in one minute, and if this works, run the script during off-hours. The p4 sync command causes the proxy to be populated. You can check to see if files have been added to the proxy cache directory.
More information on the Perforce Proxy can be found in the Multi-site Deployment guide, formerly Distributing Perforce.
Related Links

Feedback

 

Was this article helpful?


   

Feedback

Please tell us how we can make this article more useful.

Characters Remaining: 255