openafs-part1

  1. yum groupinstall -y “Development Tools”, on my vagrant box scalefactory/centos6 , need to isntall ncurses too.
  2. yum update -y
  3. download openafs server from openafs website OpenAFS 1.6.20.1, 16MB
  4. ./configure –prefix=/usr/local/packages/openafs
  5. make, make install
  6. copy /etc/openafs from existing server
  7. in /etc/openafs/server, there is
    1
    2
    3
    4
    5
    6
    7
    i. CellServDB
    >example.com
    10.0.2.15
    ii. ThisCell
    srv.example.com
    iii.UserList
    afsadmin
  8. in /etc/openafs there is cacheinfo
    1
    /afs:/usr/local/packages/cache:500000

    might want to make a folder called /usr/local/packages/cache for it..

  9. its dangerous to go alone, take this:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    #!/bin/bash
    #
    # Graceful AFS start and stop script.
    # Written by: [email protected]
    # Date 5th July 2008
    STOP_RETRIES=10 # seconds to attempt afs shutdown
    AFS=/usr/local/packages/openafs # where afs lives – symblink to current afs ver
    AFS_DB=”afs60 afs61 afs62″ # list of afs database servers
    case $1 in
    ‘start’)
    # Get a list of afs database servers first.
    DB=””
    REACHABLE=0
    CELLSERVDB=”$AFS/etc/openafs/CellServDB”
    for I in $AFS_DB ; do
    HOST=`grep $I $CELLSERVDB | awk ‘{print $1}’`
    if [ -z “$HOST” ] ; then
    echo “FATAL! Cannot locate $I in $CELLSERVDB”
    exit 1
    fi
    # do a simple ping test first.
    if [ “`uname -s`” = “SunOS” ] ; then
    ping -n -s $HOST 40 3 >/dev/null 2>/dev/null
    else
    ping -n -c 3 $HOST >/dev/null 2>/dev/null
    fi
    if [ $? -eq 0 ] ; then
    echo “$HOST ping test passed.”
    # use “bos” to test if afs database services are running.
    BOS=$AFS/bin/bos
    N=`$BOS status $HOST -noauth | grep running | wc -l | awk ‘{print $1}’`
    if [ $N -ge 4 ] ; then
    echo “$HOST bos status passed.”
    REACHABLE=1
    break
    else
    echo “WARNING! AFS services not running normally on $HOST.”
    fi
    else
    echo “WARNING! $HOST is not responding to ping.”
    fi
    done
    # only fire up AFS if at least 1 database server is reachable.
    if [ $REACHABLE -eq 0 ] ; then
    echo “FATAL! No AFS database servers reachable.”
    exit 1
    fi
    # check afs system call number (Solaris only) and load kernel module.
    if [ “`uname -s`” = “SunOS” ] ; then
    SYSNUM=`grep afs /etc/name_to_sysnum | awk ‘{print $2}’`
    if [ -z “$SYSNUM” ] ; then
    echo “FATAL! AFS name_to_sysnum not configured.”
    exit 1
    else
    if [ $SYSNUM -ne 65 ] ; then
    echo “FATAL! AFS name_to_sysnum not 65.”
    exit 1
    fi
    fi
    modload /kernel/fs/afs
    if [ $? -ne 0 ] ; then
    echo “FATAL! Failed to load AFS kernel module.”
    exit 1
    fi
    fi
    # on Linux we do a insmod
    if [ “`uname -s`” = “Linux” ] ; then
    insmod $AFS/lib/openafs/libafs.ko
    if [ $? -ne 0 ] ; then
    echo “FATAL! Failed to load AFS kernel module.”
    exit 1
    fi
    fi
    # the very last check is to make sure that /afs exists.
    if [ ! -d /afs ] ; then
    mkdir /afs
    if [ $? -ne 0 ] ; then
    exit 1
    fi
    fi
    # if we have a dedicated afs cache filesystem, mount it now,
    if [ -b /dev/zvol/dsk/mud/afs-cache ] ; then
    if [ ! -d /var/afs-cache ] ; then
    mkdir /var/afs-cache
    chmod 700 /var/afs-cache
    fi
    mount -o nologging /dev/zvol/dsk/mud/afs-cache /var/afs-cache
    fi
    # finally, check whether to use memory cache or not.
    mount | grep ‘/var/afs-cache’ >/dev/null
    if [ $? -eq 0 ] ; then
    $AFS/sbin/afsd
    else
    echo “starting with memcache”
    $AFS/sbin/afsd -memcache
    fi
    # allow setuid bit on /afs.
    if [ $? -eq 0 ] ; then
    $AFS/bin/fs setcell bii.a-star.edu.sg -suid
    fi
    ;;
    ‘stop’)
    # check if /afs is mounted, if not mounted, don’t bother.
    mount | grep AFS >/dev/null
    if [ “$?” != “0” ] ; then
    “FATAL! /afs is not mounted.”
    exit 1
    fi
    # check for processes using /afs, kill them before we continue.
    RETRIES=$STOP_RETRIES
    HALF_WAY=$(($STOP_RETRIES / 2))
    while [ $RETRIES -gt 0 ] ; do
    PIDS=`fuser /afs 2>/dev/null | cut -f 2- -d ‘ ‘ | sed -e ‘s/[^0-9 \t]//g’`
    if [ -z “$PIDS” ] ; then
    break
    fi
    if [ $RETRIES -gt $HALF_WAY ] ; then
    kill $PIDS
    else
    kill -9 $PIDS
    fi
    sleep 1
    RETRIES=$(($RETRIES – 1))
    done
    # at this point, it *should* be safe to umount /afs.
    $AFS/bin/fs flush
    umount /afs
    /sbin/rmmod libafs
    ;;
    ‘check’)
    $AFS/bin/fs checkservers
    $AFS/bin/fs checkvolumes
    ;;
    *)
    echo “Usage : $0 { start | stop | check }”
    ;;
    esac