Le bdf hpux fait parfois un retour chariot pénible comme ci dessous avec /appl/autotree.
Le problème est que l’on a plus même nombre de colonnes (5 au lieu de 6), ce qui empêche de faire des sommes.
root@hx04031a: /root/home/root # bdf
Filesystem kbytes used avail %used Mounted on
/dev/vg00/lvol3 1048576 298432 744424 29% /
/dev/vg00/lvol1 1835008 329800 1493520 18% /stand
/dev/vg00/lvol8 8912896 7199008 1703728 81% /var
/dev/vg00/lvol9 10485760 3833009 6238725 38% /var/adm/crash
/dev/vg00/lvol7 5505024 3088424 2397816 56% /usr
/dev/vg00/lvol4 524288 115672 405496 22% /tmp
/dev/vg00/lvol6 9633792 6518920 3090656 68% /opt
/dev/vg00/lvol5 131072 16248 113960 12% /home
/dev/vg00/lvautotree
1048576 41159 944483 4% /appl/autotree
La « commande » ci dessus utilise perl pour fixer le problème.
root@hx04031a: /root/home/root # bdf | sed 's/^\//###\//g' | perl -pe 's/\s+/\t/g' | perl -pe 's/\n//g' | perl -pe 's/###/\n/g' && echo
Filesystem kbytes used avail %used Mounted on
/dev/vg00/lvol3 1048576 298496 744360 29% /
/dev/vg00/lvol1 1835008 329800 1493520 18% /stand
/dev/vg00/lvol8 8912896 7199016 1703728 81% /var
/dev/vg00/lvol9 10485760 3833009 6238725 38% /var/adm/crash
/dev/vg00/lvol7 5505024 3088424 2397816 56% /usr
/dev/vg00/lvol4 524288 115672 405496 22% /tmp
/dev/vg00/lvol6 9633792 6518920 3090656 68% /opt
/dev/vg00/lvol5 131072 16248 113960 12% /home
/dev/vg00/lvautotree 1048576 41159 944483 4% /appl/autotree
On peut donc maintenant sommer les colonnes.
bdf | sed 's/^\//###\//g' | perl -pe 's/\s+/\t/g' | perl -pe 's/\n//g' | perl -pe 's/###/\n/g' \
| awk '{sumt+=$2;sumu+=$3;suma+=$4}END{printf("Total : %.2f %.2f %.2f\n",sumt/1024,sumu/1024,suma/1024)}'
Total : 38208.00 20938.31 16731.11
Petite astuce pour hpux.
La commande usermod de hpux n’a pas de fonction append comme sous Linux.
L’ajout d’un group a un utilisateur oblige a redéfinir entièrement l’utilisateur.
La « commande » ci dessous simplifie cette opération :
account=grid && newgrp=dclicdba && echo "usermod -g $(id -g $account) -G $(id -G $account | sed 's/ /,/g'),$newgrp $account"
Résultat :
usermod -g 107 -G 107,108,109,110,111,112,114,dclicdba grid
Plus qu’a exécuter la ligne ci dessus pour ajouter le groupe.
Si le login est deja utilisé, alors il faut ajouter l’option -F –> usermod -F -g 107 -G 107,108,109,110,111,112,114,dclicdba grid
Procédure d’export/import d’un VG d’une machine vers une autre.
- Exporte la map du vg
root@hx000140: /root/home/root # vgexport -s -v -p -m /tmp/stage.map /dev/stage
Beginning the export process on Volume Group "/dev/stage".
vgexport: Volume group "/dev/stage" is still active.
/dev/dsk/c34t0d0
/dev/dsk/c35t0d0
vgexport: Preview of vgexport on volume group "/dev/stage" succeeded.
- Copier la map sur l’autre node
scp /tmp/stage.map hx000141:/tmp
- Importer en mode previous (-p) pour verifier que c’est ok
root@hx000141: /root/home/root # vgimport -s -v -p -m /tmp/stage.map /dev/stage
Beginning the import process on Volume Group "/dev/stage".
Logical volume "/dev/stage/stagelv" has been successfully created
with lv number 1.
vgimport: Volume group "/dev/stage" has been successfully created.
Warning: A backup of this volume group may not exist on this machine.
Please remember to take a backup using the vgcfgbackup command after activating the volume group.
- Importer le vg
root@hx000141: /root/home/root # vgimport -s -v -m /tmp/stage.map /dev/stage
Beginning the import process on Volume Group "/dev/stage".
Logical volume "/dev/stage/stagelv" has been successfully created
with lv number 1.
vgimport: Volume group "/dev/stage" has been successfully created.
Warning: A backup of this volume group may not exist on this machine.
Please remember to take a backup using the vgcfgbackup command after activating the volume group.
- Vérifier que le VG est maintenant dans la conf
root@hx000141: /root/home/root # vgdisplay stage
vgdisplay: Volume group not activated.
vgdisplay: Cannot display volume group "stage".
- Démonter le fs sur le 1er node
root@hx000140: /root/home/root # umount /staging
- Désactiver le VG sur le 1er node
root@hx000140: /root/home/root # vgchange -a n /dev/stage
Volume group "/dev/stage" has been successfully changed.
- Exporter le VG (effacement de la conf) sur le 1er node
root@hx000140: /root/home/root # vgexport /dev/stage
vgexport: Volume group "/dev/stage" has been successfully removed.
- Activer le VG sur le 2nd node
root@hx000141: /root/home/root # vgchange -a y /dev/stage
Activated volume group.
Volume group "/dev/stage" has been successfully changed.
- Vérification que le vg est ok sur le 2nd node
root@hx000141: /root/home/root # vgdisplay -v /dev/stage
--- Volume groups ---
VG Name /dev/stage
VG Write Access read/write
VG Status available
Max LV 255
Cur LV 1
Open LV 1
Max PV 16
Cur PV 1
Act PV 1
Max PE per PV 32000
VGDA 2
PE Size (Mbytes) 32
Total PE 31999
Alloc PE 31360
Free PE 639
Total PVG 0
Total Spare PVs 0
Total Spare PVs in use 0
VG Version 1.0
VG Max Size 16000g
VG Max Extents 512000
--- Logical volumes ---
LV Name /dev/stage/stagelv
LV Status available/syncd
LV Size (Mbytes) 1003520
Current LE 31360
Allocated PE 31360
Used PV 1
--- Physical volumes ---
PV Name /dev/dsk/c33t0d0
PV Name /dev/dsk/c35t0d0 Alternate Link
PV Status available
Total PE 31999
Free PE 639
Autoswitch On
Proactive Polling On
- Vérification que le vg est ok sur le 2nd node
Commenter :
/dev/stage/stagelv /staging vxfs defaults 0 2
dans /etc/fstab sur le 1er node
De-commenter :
/dev/stage/stagelv /staging vxfs defaults 0 2
dans /etc/fstab sur le 2nd node
- Vérifier que le point de montage est présent
root@hx000141: /root/home/root # ll -d /staging
drwxr-xr-x 2 root sys 96 Feb 3 15:12 /staging
- Montage et vérification
root@hx000141: /root/home/root # mount -aQ
root@hx000141: /root/home/root # mount
/ on /dev/vg00/lvol3 ioerror=mwdisable,largefiles,delaylog,dev=40000003 on Thu Jan 6 14:54:02 2011
/stand on /dev/vg00/lvol1 ioerror=mwdisable,nolargefiles,log,tranflush,dev=40000001 on Thu Jan 6 14:54:12 2011
/var on /dev/vg00/lvol8 ioerror=mwdisable,largefiles,delaylog,dev=40000008 on Thu Jan 6 14:54:53 2011
/var/adm/crash on /dev/vg00/lvol10 ioerror=mwdisable,largefiles,delaylog,dev=4000000a on Thu Jan 6 14:54:53 2011
/usr on /dev/vg00/lvol7 ioerror=mwdisable,largefiles,delaylog,dev=40000007 on Thu Jan 6 14:54:54 2011
/tmp on /dev/vg00/lvol4 ioerror=mwdisable,largefiles,delaylog,dev=40000004 on Thu Jan 6 14:54:54 2011
/opt on /dev/vg00/lvol6 ioerror=mwdisable,largefiles,delaylog,dev=40000006 on Thu Jan 6 14:54:54 2011
/home on /dev/vg00/lvol5 ioerror=mwdisable,largefiles,delaylog,dev=40000005 on Thu Jan 6 14:54:54 2011
/appl on /dev/vg01/lvol1 ioerror=mwdisable,largefiles,delaylog,dev=80000001 on Thu Jan 6 14:54:55 2011
/net on -hosts ignore,indirect,nosuid,soft,nobrowse,dev=4000002 on Thu Jan 6 14:56:19 2011
/staging on /dev/stage/stagelv ioerror=mwdisable,largefiles,delaylog,dev=40010001 on Thu Feb 3 15:13:08 2011