From 35f1321e1419e744f81b5ced6f2c68ed526510c5 Mon Sep 17 00:00:00 2001 From: Ian Wienand <iwienand@redhat.com> Date: Fri, 26 Jul 2019 12:52:15 +1000 Subject: [PATCH] AFS server restart and audit logging : helper script This script helps restart the AFS servers, which is useful when updating parameters. It can also enable audit logging. It can also stop and start the servers, although it's unlikely we'd want all the servers offline at the same time so stopping has a warning included. Documentation is updated to refer to the helper script Change-Id: Idcb3e43a3f6e614cdb787d4334e692a98bffdd15 --- doc/source/afs.rst | 14 +++-- tools/afs-server-restart.sh | 120 ++++++++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+), 4 deletions(-) create mode 100755 tools/afs-server-restart.sh diff --git a/doc/source/afs.rst b/doc/source/afs.rst index cdc69437f4..26b5455054 100644 --- a/doc/source/afs.rst +++ b/doc/source/afs.rst @@ -286,10 +286,16 @@ It is worth evaluating these settings periodically Updating Settings ~~~~~~~~~~~~~~~~~ -If you wish to update the settings for an existing server, you can -stop and remove the existing ``bnode`` (the collection of processes -the overseer is monitoring, created via ``bos create`` above) and -recreate it. +The helper script :git_file:`tools/afs-server-restart.sh` is a helper +script to restart AFS servers, and optionally enable audit logging on +the servers which is sometimes useful for debugging afs clients. You +can edit settings in the script and run ``afs-server-restart.sh +restart`` (or ``restart-auditing``). + +If you wish to update the settings for an existing server manually, +you can stop and remove the existing ``bnode`` (the collection of +processes the overseer is monitoring, created via ``bos create`` +above) and recreate it. For example :: diff --git a/tools/afs-server-restart.sh b/tools/afs-server-restart.sh new file mode 100755 index 0000000000..d5394fb28f --- /dev/null +++ b/tools/afs-server-restart.sh @@ -0,0 +1,120 @@ +#!/bin/bash + +# Copyright 2019 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +# +# Start/stop AFS servers +# +# Usage: +# +# 1) run this authenticated with admin account +# (mirror-update.opendev.org is one choice with everything setup, +# but can do locally) +# +# $ kinit $username/admin +# $ aklog +# +# 2) afs-service-restart.sh <restart|restart-auditing|start|start-auditing|stop> +# +# 3) If enabled, audit logs will be in a timestampped /opt file +# +# + +SERVERS=(afs01.dfw.openstack.org afs02.dfw.openstack.org afs01.ord.openstack.org) + +# See AFS system-config documentation for discussion of parameters +DAFILESERVER_OPTS=" +-L -p 242 -busyat 600 -rxpck 700 +-s 1200 -l 1200 -cb 2000000 -b 240 -vc 1200 +-udpsize 131071 -sendsize 131071" + +TIMESTAMP=$(date +%s) + +function stop_server { + local afs_host=$1 + + echo "Stopping server $afs_host" + bos stop -server $afs_host -instance dafs -wait + sleep 5 + bos delete -server $afs_host -instance dafs + sleep 5 + echo "Done" +} + +function start_server { + local afs_host=$1 + local audit_log=$2 + local opts=$DAFILESERVER_OPTS + local with_log="" + + if [[ $audit_log == "true" ]]; then + opts+=" -auditlog /opt/dafileserver.audit.$TIMESTAMP.log" + with_log=" (with audit logging) " + fi + + echo "Enable server $afs_host $with_log" + + bos create -server $afs_host -instance dafs -type dafs \ + -cmd "/usr/lib/openafs/dafileserver ${opts}" \ + -cmd /usr/lib/openafs/davolserver \ + -cmd /usr/lib/openafs/salvageserver \ + -cmd /usr/lib/openafs/dasalvager +} + +if [[ $1 == "start" ]]; then + + for server in ${SERVERS[@]}; do + start_server $server false + done + +elif [[ $1 == "start-auditing" ]]; then + + for server in ${SERVERS[@]}; do + start_server $server true + done + +elif [[ $1 == "restart" ]]; then + + for server in ${SERVERS[@]}; do + stop_server $server + sleep 2 + start_server $server false + done + +elif [[ $1 == "restart-auditing" ]]; then + + for server in ${SERVERS[@]}; do + stop_server $server + sleep 2 + start_server $server true + done + +elif [[ $1 == "stop" ]]; then + + echo "*** JUST CHECKING YOU REALLY WANT TO STOP ALL SERVERS ***" + echo "It may be better to restart so the servers aren't all offline" + echo "I will wait 10 seconds, ctrl-c to cancel now" + sleep 10 + + for server in ${SERVERS[@]}; do + stop_server $server + done + +else + + echo "*** usage: <restart|restart-auditing|start|start-auditing|stop>" + exit 1 + +fi