Thursday 9 December 2010

Using P4Broker With Replica Servers

Article #:1354Created:12/08/10Modified:12/08/10

One of the most common uses of using a Perforce replica server is to re-direct read-only commands using the P4Broker application. This allows Perforce administrators to create a single server and host address for their users, and transparently enforce key commands to use the appropriate Perforce server to reduce overall server load.

For this example:

The broker is at port "broker:33333"The production server is at port "master:11111"The read only replica is at port "replica:22222"

Installing and configuring P4Broker:

Install the P4Broker software for your platform. Create a blank broker configuration file: p4broker -C > /p4broker/root/p4broker.confEdit the P4Broker configuration file to add the target, listen port, and other broker information: target = master:11111;listen = 33333;directory = /p4broker/root/;logfile = broker.log;debug-level = server=1;admin-name = "your name";admin-phone = x1234;admin-email = your.name@yourcompany.com;redirection = selective;

Add an "altserver" for the replica:

altserver: replica1{ target = replica:22222;}

Add command handlers to re-direct read only commands to the replica:

command: annotate{ action = redirect; destination = replica1;}command: branches{ action = redirect; destination = replica1;}command: changes{ action = redirect; destination = replica1;}command: clients{ action = redirect; destination = replica1;}command: counters{ action = redirect; destination = replica1;}command: depots{ action = redirect; destination = replica1;}command: describe{ action = redirect; destination = replica1;}command: diff2{ action = redirect; destination = replica1;}command: dirs{ action = redirect; destination = replica1;}command: filelog{ action = redirect; destination = replica1;}command: files{ action = redirect; destination = replica1;}command: show{ action = redirect; destination = replica1;}command: fstat{ action = redirect; destination = replica1;}command: grep{ action = redirect; destination = replica1;}command: groups{ action = redirect; destination = replica1;}command: jobs{ action = redirect; destination = replica1;}command: labels{ action = redirect; destination = replica1;}command: print{ action = redirect; destination = replica1;}command: sizes{ action = redirect; destination = replica1;}command: fixes{ action = redirect; destination = replica1;}command: verify{ action = redirect; destination = replica1;}command: where{ action = redirect; destination = replica1;} command: workspaces{ action = redirect; destination = replica1;} command: users{ action = redirect; destination = replica1;}# Read/Write Commands with Read-Only flags:## sync -p does not write anything to db.have, so it goes to the replica:command: sync{ flags = -p; action = redirect; destination = replica1;}# Specifications using the -o flag to output to STDOUT also do not write to the DB:command: *{ flags = -o; action = redirect; destination = replica1;}Start the broker: p4broker -c /p4broker/root/p4broker.conf &

Now any read-only commands directed to the P4Broker at port "broker:33333" are directed to the replica at port "replica:22222".

Note: Any commands not matching the above handlers are re-directed to the master server "master:11111" by default.

Details on how to use P4Broker can be found here.

Details on setting up a replica server can be found in the replication chapter of the Perforce System Administrator's Guide.

View the original article here

No comments:

Post a Comment