The following document contains a script used to create Oracle database volume groups, logical volumes, JFS logs, and file systems. It utilizes the entire range of physical partitions available on the "hdisk" specified for use with the volume group. This script also creates the Oracle database user and group, then changes the ownership of the filesystem it creates, to that user and group.
#!/usr/bin/ksh93
################################################################
douser()
{
UID=$( print "${U}" | sum -r )
UID="$(( ${UID// /} + 0 ))"
GID=$( print "${G}" | sum -r )
GID="$(( ${GID// /} + 0 ))"
rmuser ${U}
rmgroup ${G}
print "${G}=${GID}"
mkgroup id=${GID} ${G}
print "${U}=${UID}"
mkuser id=${UID} pgrp=${G} ${U}
lsuser ${U}
}
################################################################
dovg()
{
umount ${MTPT}
/usr/sbin/varyoffvg ${RG}${VGID}
/usr/sbin/exportvg ${RG}${VGID}
mkvg -f -y ${RG}${VGID} -V ${VGMJ} ${VGDISKS}
chvg -a n ${RG}${VGID}
chvg -c ${RG}${VGID}
varyoffvg ${RG}${VGID}
exportvg ${RG}${VGID}
importvg -y ${RG}${VGID} -V ${VGMJ} ${VGDISKS%%[$' \t\n']*}
varyonvg ${RG}${VGID}
/usr/sbin/mklv -y ${RG}${LGID}lv -t jfs2log -a e "${RG}${VGID}" 1
LVSIZE=$(( $( lsvg ${RG}${VGID} | grep "FREE PPs:" |
sed -e "s/.*FREE PPs: *//g;s/ (.*//g" ) ))
print "${LVSIZE}"
/usr/sbin/mklv -y ${RG}${LVID}lv -t jfs2 -a e "${RG}${VGID}" ${LVSIZE%%.*}
/usr/sbin/crfs -v jfs2 -d "${RG}${LVID}lv" -m "${MTPT}" -A y \
-p rw -a agblksize=4096 -a logname="${RG}${LGID}lv"
chown -R ${U}:${G} /${RG}
ls -ld ${MTPT}
ls -ld ${MTPT}
mount ${MTPT}
ls -ld ${MTPT}
ls -ld ${MTPT}
mkdir -p "${MTPT}/app/oracle/admin"
chuser home="${MTPT}/app/oracle/admin" ${U}
chown -R ${U}:${G} ${MTPT}
lsuser -a home ${U}
ls -ld ${MTPT}
print
lsvg
print
df
print
}
################################################################
# Resource Group name (CHANGE THIS)
RG="aixdtmx0"
# Oracle database administrator user name (CHANGE THIS)
U=orausr1
# Oracle database administrator group (CHANGE THIS)
G=dbaora
# Enterprise wide unique Volume Group number (CHANGE THIS)
VGMJ="101"
# The following line can be used to generate a list of hdisks from
# a SCSI adapter by specifing it's slot number. Two slot numbers
# are specifed because the disk can be presented from dual VIO's.
# (IF USED, CHANGE THE SLOT NUMBERS TO SUIT YOUR CONFIGURATION)
# VGDISKS=$( lscfg -l 'hdisk*' | egrep -- '-C240-|-C245-' | awk '{ print $1 }' )
# Instead of automatically generating the list of disks to use on
# the client LPAR, they can be specified individually here. (CHANGE THIS)
VGDISKS="hdisk6 hdisk7"
# Volume Group identifier ( 2 digits followed by "vg" ) (CHANGE THIS)
VGID="01vg"
# 4 character logical volume identifier (CHANGE THIS)
LVID="inst"
# 4 character log logical volume identifier (CHANGE THIS)
LGID="jfs1"
# Directory mount point (CHANGE THIS)
MTPT="/${RG}"
[[ "_${VGDISKS}" == "_" ]] && exit 1
douser
dovg