#!/bin/bash #------------------------------------------------------------------------------ # Copyright (c) Perforce Software, Inc., 2007-2014. All rights reserved # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PERFORCE # SOFTWARE, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR # TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH # DAMAGE. #------------------------------------------------------------------------------ # DO NOT RUN THIS SCRIPT MANUALLY. # See notes at top of reseed_ffr-run_on_p4d-01.sh first. # Assumptions: # Perforce SDP is used, and we're replicating for Instance 1. # Port 1666 is used on both hosts. # p4d-01 is the master server. # p4d-02 is a filtered forwarding replica, with service user svc_p4d-02, # and a password file /p4/common/bin/.p4passwd.svc_p4d-02. # The server spec pfd-02 defines the 'RevisionDataFilter:' field that # defines the scope of the filtering. # Perforce runs as the 'perforce' user. # This script is intended to be called only remotely from another script, # p4d-01:/p4/1/bin/reseed_fr-run_on_p4d-01.sh (where p4d01 is the name # if the master Perforce server). # This script does not require 'perforce' to be logged in on the replica. # It does a Unix 'kill' command on p4d_1_bin, which is not the preferred # way to shut a normal server down. But since it does this on a set of # databases that are about to be regenerated from a checkpoint, it is safe. if [[ ${HOSTNAME%%.*} == "p4d-02" ]]; then echo "Verified: Operating on ${HOSTNAME%%.*}" else echo "Error: Run only on p4d-02." exit 1 fi echo -e "\nStarting remote processing on $HOSTNAME\n" echo -e "\nReseeding p4d-02 from filtered checkpoint.\n" cd /p4/1/checkpoints || exit 1 echo "Operating in $PWD" FilteredCkp=$(ls -1t /p4/1/checkpoints/p4_1.ckp.*.filtered.p4d-02.gz|head -1) if [[ ! -r "$FilteredCkp" ]]; then echo -e "\nError: Could not see filtered checkpoint [$FilteredCkp].\n" exit 1 fi echo -e "\nShutting down p4d_1_bin by killing pids on replica." pids=$(ps -ef | grep p4d_1_bin | awk '{print $2}') if [[ -n "$pids" ]]; then echo "Running: kill $pids" kill $pids sleep 2 pids=$(ps -ef | grep p4d_1_bin | awk '{print $2}') fi cd /p4/1/logs || exit 1 echo "Operating in $PWD" echo "Running: /bin/rm -f journal log* checkpoint* p4login.log" /bin/rm -f journal log* checkpoint* p4login.log cd /p4/1/root || exit 1 echo "Operating in $PWD" echo "Running: /bin/rm -rf server.locks" /bin/rm -rf server.locks echo "Running: /bin/rm -f db.* rdb.* state" /bin/rm -f db.* rdb.* state echo "Running: /p4/1/bin/p4d_1 -r $PWD -J off -z -jr $FilteredCkp" /p4/1/bin/p4d_1 -r $PWD -J off -z -jr $FilteredCkp Jnl=${FilteredCkp##*.ckp.} Jnl=${Jnl%%.*} echo "Running: echo $Jnl ;gt; state" echo $Jnl > state echo "Running: /bin/rm -rf /p4/1/depots/*" /bin/rm -rf /p4/1/depots/* echo "Running: p4d_1_init start" nohup p4d_1_init start < /dev/null > /dev/null 2>&1 & sleep 1 # Note: This assumes that the replica was setup with: # p4 configure set p4d-02#serviceUser=svc_p4d-02 # The svc_p4d-02 user should be a user of type 'service', # with 'super' access. It should have a password set, and # that password should appear in the file # /p4/common/bin/p4passwd.svc_p4d-02, which can and probably # should be a different password from other service accounts. echo "Logging svc_p4d-02 into the master server." p4 -u svc_p4d-02 -p p4d-01:1666 login < /p4/common/bin/.p4passwd.svc_p4d-02 echo "Logging svc_p4d-02 into local filtered forwarding replica." p4 -u svc_p4d-02 -p 1666 login < /p4/common/bin/.p4passwd.svc_p4d-02
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 16536 | C. Thomas Tyler | Refactoring to Workshop dir. | ||
//guest/tom_tyler/ffr_reseed/main/reseed_ffr-run_on_p4d-02.sh | |||||
#1 | 16513 | C. Thomas Tyler |
Refactored ffr_reseed to the new Workshop stanard for personal projects. |
||
//guest/tom_tyler/sw/main/ffr_reseed/reseed_ffr-run_on_p4d-02.sh | |||||
#1 | 11495 | C. Thomas Tyler |
Added sample filtered forwarding replica reseed script. While a proper README file is needed, these scripts have lots of internal documentation. |