顯示具有 hp-ux 標籤的文章。 顯示所有文章
顯示具有 hp-ux 標籤的文章。 顯示所有文章

星期四, 5月 23, 2013

hp-ux system backup (WITHOUT Mirror/UX License)


1. Insert Backup Disk into server slot 2.
2. Check if server can detect new disk.
server # ioscan -fnC disk
Class     I  H/W Path      Driver S/W State   H/W Type     Description
======================================================================
disk      0  0/0/1/1.15.0  sdisk CLAIMED     DEVICE       HP 18.2GMAN3184MC
                          /dev/dsk/c1t15d0   /dev/rdsk/c1t15d0
disk      0  0/0/1/3.15.0  sdisk CLAIMED     DEVICE       HP 18.2GMAN3184MC
                          /dev/dsk/c3t15d0   /dev/rdsk/c3t15d0

3. c1t15d0 is system disk, c3t15d0 is backup disk.
4. Start to duplicate disk...
#dd if=/dev/rdsk/c1t15d0 of=/dev/rdsk/c3t15d0 bs=1024k
5. When finished, back to prompt,
6. Unplug Backup Disk from server slot 2, and then insert this backup disk into backup-server slot1.
7. Do not connect LAN.
8. Power on backup-server
9. Make sure primaty boot order is 0/0/1/1.15.0
10. Boot from Backup Disk.
11. When boot into hp-ux finished, login by root
12. Stop platform first.
#p7stop -s
13. Make sure this backup-server is date/time correct, if not correct, please correct it first.
14. You can correct time/date by connect backup-server onto lan, and using NTP server. But please change ip first.
15. HP-UX How to Change IP

# ioscan -fnC lan

Class     I  H/W Path       Driver   S/W State   H/W Type     Description
==========================================================================
lan       0  0/0/0/1/0      btlan    CLAIMED     INTERFACE    HP PCI 10/100Base-TX Core
                           /dev/diag/lan0  /dev/ether0     /dev/lan0


15.1. 若看不到卡,請使用 ioscan 判斷是否有網路卡但需要驅動程式或未正確驅動 (UNCLAIMED)。
# ioscan -fn

15.2. 檢視有綁定 IP 位址的卡片資訊。
server # netstat -in
Name           Mtu Network            Address                 Ipkts      Opkts
lan0          1500 140.133.26.0       140.133.26.13          719753     724185
lo0           4136 127.0.0.0          127.0.0.1               24396      24396

15.3. 針對每一個介面執行 ifconfig,確認正確的 IP、網路遮罩和廣播位址。例如:
server # ifconfig lan0
lan0: flags=843<UP,BROADCAST,RUNNING,MULTICAST>
        inet 140.133.26.13 netmask ffffff00 broadcast 140.133.26.255

15.4. 設定IP(永久性的)
要永久性的設定IP,請透過sam(System Admin Manager)來設定,
使用sam設定IP,之後即使重開機,網路設定仍會被記住。
sam->network and communication -> interface card

如果知道自己在做什麼,也可以考慮直接編輯網路的設定檔,例如:
# vi /etc/rc.config.d/netconf
# /sbin/init.d/net start

15.5. 設定IP(非永久性的加IP,重開機後設定即消失),給他一個temporary IP (140.133.26.20)
# ifconfig lan0 140.133.26.20 netmask 255.255.255.0 up

15.6. Ping CHT-I NTP server 140.133.31.126

16. HP-UX NTP設定, make sure backup-server is date/time the same with lan.
16.1. 編輯設定檔 /etc/ntp.conf ,加入CHT-I ntp server為ntp server (其實已經設好了,不須更動,除非要改ntp server).

   server 140.133.31.126  #  NTP server

16.2. 重新啟動 NTP 服務

   # /sbin/init.d/xntpd restart
 
16.3.過一段時間後,再檢查是否與ntp server 對時

   # /usr/sbin/ntpq -p

   成功的話,會出現對時的ntp server ip,及對時後調整時間的訊息。

   如出現 No association ID's returned 則表示沒有成功。

16.4. 下列我實際的查詢結果(有啟用xntpd)

   # ps -ef |grep ntp
       root  1807     1  0  Aug 20  ?        20:11 /usr/sbin/xntpd

  server # ntpq -p
       remote           refid      st t when poll reach   delay   offset    disp
  =========================================================
  *NTP             192.168.33.4     5 u   43   64  377     8.87    0.533    1.62

17. 確定NTP已經sync成功後,接著就可以準備切換備機。

18. 切換備機程序:
19. In server
19.1. stop platform
19.2. unplug lan

20. In backup-server
20.1. make sure IP is the same with server 140.133.26.13  , if not, please change ip the same with server.
#ifconfig lan0 140.133.26.13 netmask 255.255.255.0 up
20.2. connect lan.
20.3. start platform
...
...
...
21. 恭喜,備機已經上線。

hp-ux system backup procedure (with Mirror/UX License)


HP-UX HDD Backup SOP

2013/2/8 更新 by Henry
2013/2/21 更新,加入4.1, 4.2

1. Shutdown
2. 拔出一顆硬碟,作為備份硬碟, 代號HDD0。
3. 開機,確保還在主機上的硬碟可正確開機,代號HDD1。
PS.若要確保備份硬碟代號HDD0也可以正常開機運作,待HDD1開機確認後,關機,拔出HDD1,插入HDD0,開機確認系統可正常運作。

4. 執行
#vgexport /dev/vg00
讓lvm重新搜尋現有的PV與更新/etc/lvmtab 設定。
否則無法成功執行下面指令(lvreduce or vgreduce...)
確認vgexport 成功。

If that fails then you should do a vgscan.
1) mv /etc/lvmtab /etc/lvmtab.sav
2) vgscan -a

4.1 Reducing mirror from root vg -- vg00
for i in 1 2 3 4 5 6 7 8 9 10;do lvreduce -m 0 /dev/vg00/lvol$i;done
vgreduce -f vg00
or
vgreduce /dev/vg00 /dev/dsk/c2t1d0

還未插入新硬碟(代號HDD2)時,只抓到一顆硬碟(HDD0)。
server # ioscan -fnC disk
Class     I  H/W Path       Driver  S/W State   H/W Type     Description
=========================================================================
disk      0  0/0/2/0.0.0.0  sdisk   CLAIMED     DEVICE       TEAC    DV-28E-N
                           /dev/dsk/c0t0d0   /dev/rdsk/c0t0d0
disk      1  0/1/1/0.0.0    sdisk   CLAIMED     DEVICE       HP 146 GST3146855LC
                           /dev/dsk/c2t0d0   /dev/rdsk/c2t0d0
                           ^^^^^^^^^^^
                             代號HDD0

5. online插入新硬碟(HDD2)。

6. 執行#ioscan -fnC disk 確認新硬碟(HDD2)有被抓到。

EXAMPLE:

插入新硬碟後,會抓到第二顆HDD (HDD2)。
server # ioscan -fnC disk
Class     I  H/W Path       Driver  S/W State   H/W Type     Description
=========================================================================
disk      0  0/0/2/0.0.0.0  sdisk   CLAIMED     DEVICE       TEAC    DV-28E-N
                           /dev/dsk/c0t0d0   /dev/rdsk/c0t0d0
disk      1  0/1/1/0.0.0    sdisk   CLAIMED     DEVICE       HP 146 GST3146855LC
                           /dev/dsk/c2t0d0   /dev/rdsk/c2t0d0
disk      2  0/1/1/0.1.0    sdisk   CLAIMED     DEVICE       COMPAQ  BF14688577
                           /dev/dsk/c2t2d0   /dev/rdsk/c2t2d0
                          ^^^^^^^^^^^
                                  HDD2

7.  Adding mirroring to the root vg - vg00

7.1. pvcreate -B /dev/rdisk/c2t2d0

* Create the PV on the second disk so that LVM can manage it
* -B makes it a bootable volume

7.2. mkboot /dev/rdsk/c2t2d0

* Installs the boot files on the second disk

7.3. mkboot -a "hpux -lq (;0)/stand/vmunix" /dev/rdsk/c2t2d0

* Creates an autoboot file on the disk, with information on how to boot

7.4. vgextend /dev/vg00 /dev/dsk/c2t2d0

* extends the volume group to include this second disk.

7.5. vgdisplay -v vg00

* To verify that the second disk is now part of the volume group

7.6. lvlnboot -v

* To verify that the system thinks this disk can boot

7.7. lvextend -m 1 /dev/vg00/lvol1 /dev/dsk/c2t2d0

* This extends the logical volume to the mirrored disk, effectively creating the mirrored copy.
* This command needs to be run for each logical volume in the volume group
注意:每一個lvol*都要做。

EXAMPLE:

server # lvextend -m 1 /dev/vg00/lvol$i /dev/dsk/c2t1d0;done            
The newly allocated mirrors are now being synchronized. This operation will
take some time. Please wait ....
Logical volume "/dev/vg00/lvol1" has been successfully extended.
Volume Group configuration for /dev/vg00 has been saved in /etc/lvmconf/vg00.conf
The newly allocated mirrors are now being synchronized. This operation will
take some time. Please wait ....
Logical volume "/dev/vg00/lvol2" has been successfully extended.
Volume Group configuration for /dev/vg00 has been saved in /etc/lvmconf/vg00.conf

7.8 偷懶方式如下:跑回圈一次lvextend全部
for i in 1 2 3 4 5 6 7 8 9 10;do lvextend -m 1 /dev/vg00/lvol$i /dev/dsk/c2t1d0;done

8. done~~

星期三, 5月 22, 2013

hp-ux console 好用指令

面對客戶的hp-ux,最常見的就是backspace不能用,還有行數太大,螢幕無法完全顯示,因此會有文字被遮住,分享我的作法:

1. Backspace不能用:
a. Using "Shift + Backspace", it is working.
b. 定義 erase = ^? , Backspace就可以用了:
#stty erase ^?

2. 行數太大:
a. 定義行數為24行
#stty rows 24

ps. 可用下列指令來看目前定義的stty

# stty -a
speed 9600 baud; line = 0;
rows = 0; columns = 0
min = 1; time = 0;
intr = ^C; quit = ^\; erase = ^H; kill = ^U
eof = ^D; eol = ^@; eol2 <undef>; swtch <undef>
stop = ^S; start = ^Q; susp <undef>; dsusp <undef>
werase <undef>; lnext <undef>
-parenb -parodd cs8 -cstopb hupcl cread -clocal -loblk -crts
-ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl -iuclc
ixon ixany ixoff -imaxbel -rtsxoff -ctsxon -ienqak
isig icanon -iexten -xcase echo echoe echok -echonl -noflsh
-echoctl -echoprt -echoke -flusho -pendin
opost -olcuc onlcr -ocrnl -onocr -onlret -ofill -ofdel -tostop