歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Unix知識 >> 關於Unix

SOLARIS磁盤鏡象(RAID1)親身體驗


  系統裝完了,客戶要求兩塊盤做一個鏡象,對於我來說是大姑娘上轎--頭一回。SOLARIS10已經自帶了DiskSuite軟件,可以直接做鏡象,於是找來資料,從下午兩點半弄到下午6點鐘,同步可能要4個小時,基本上是晚上12點才能同步完,當然,是因為中間搞錯了,花時間來整好了,新手都是難免的~~基本情況是機器配有兩塊硬盤(c1t0d0,c1t1d0)各140G,裝系統的時候選0號盤c1t0d0,分區是這樣的:s0給/,s1給/var,s2是整個硬盤,s3給swap,s4給/export/home,s5給/opt,s6和s7各留了200M用來做鏡象用(刪除文件系統名,只留空間),此文檔不含理論,只有實際操作,涉及到的命令請參考其他文檔,下面是詳細的鏡象過程,用root用戶操作。
--------------------------------------
實施之前做好規劃,規劃如下:
--根分區
d0 d10 d20 / s0
--VAR分區
  d1 d11 d21 /var s1
--SWAP分區
  d2 d12 d22 swap s3
--export/home分區
  d3 d13 d23 /export/home s4
--/opt分區
d4 d14 d24 /opt s5
d0,d1,d2,d3,d4為對應各個分區的metadevice名字;d10等是每個metadevice對應的子鏡像
--------------------------------------


一、先用format和df -k查看一下磁盤的情況0號盤是c1t0d0,1號盤是c1t1d0
# format
Searching for disks...done
AVAILABLE DISK SELECTIONS:
0. c1t0d0
/pci@9,600000/SUNW,qlc@2/fp@0,0/ssd@w21000014c3cf585b,0
1. c1t1d0
/pci@9,600000/SUNW,qlc@2/fp@0,0/ssd@w21000014c3cf787a,0
Specify disk (enter its number): 1
selecting c1t1d0
[disk formatted]
FORMAT MENU:
disk - select a disk
type - select (define) a disk type
partition - select (define) a partition table
current - describe the current disk
format - format and analyze the disk
repair - repair a defective sector
label - write label to the disk
analyze - surface analysis
defect - defect list management
backup - search for backup labels
verify - read and display labels
save - save new disk/partition definitions
inquiry - show vendor, product and revision
volname - set 8-character volume name
! - execute , then return
quit
format> quit
# format
Searching for disks...done
AVAILABLE DISK SELECTIONS:
0. c1t0d0
/pci@9,600000/SUNW,qlc@2/fp@0,0/ssd@w21000014c3cf585b,0
1. c1t1d0
/pci@9,600000/SUNW,qlc@2/fp@0,0/ssd@w21000014c3cf787a,0
Specify disk (enter its number): 0
selecting c1t0d0
[disk formatted]
Warning: Current Disk has mounted partitions.
/dev/dsk/c1t0d0s0 is currently mounted on /. Please see umount(1M).
/dev/dsk/c1t0d0s1 is currently mounted on /var. Please see umount(1M).
/dev/dsk/c1t0d0s3 is currently used by swap. Please see swap(1M).
/dev/dsk/c1t0d0s4 is currently mounted on /export/home. Please see umount(1M).
/dev/dsk/c1t0d0s5 is currently mounted on /opt. Please see umount(1M).
FORMAT MENU:
disk - select a disk
type - select (define) a disk type
partition - select (define) a partition table
current - describe the current disk
format - format and analyze the disk
repair - repair a defective sector
label - write label to the disk
analyze - surface analysis
defect - defect list management
backup - search for backup labels
verify - read and display labels
save - save new disk/partition definitions
inquiry - show vendor, product and revision
volname - set 8-character volume name
! - execute , then return
quit
format> quit
# df -k
Filesystem kbytes used avail capacity Mounted on
/dev/dsk/c1t0d0s0 20174017 4058187 15914090 21% /
/devices 0 0 0 0% /devices
ctfs 0 0 0 0% /system/contract
proc 0 0 0 0% /proc
mnttab 0 0 0 0% /etc/mnttab
swap 23318320 1032 23317288 1% /etc/svc/volatile
objfs 0 0 0 0% /system/object
fd 0 0 0 0% /dev/fd
/dev/dsk/c1t0d0s1 698295 104196 538236 17% /var
swap 23317608 320 23317288 1% /tmp
swap 23317336 48 23317288 1% /var/run
/dev/dsk/c1d0t0s5 60509964 323494 59581371 1% /opt
/dev/dsk/c1d0t0s4 43194138 42945 42719252 1% /export/home
二、備份一下/etc/vfstab和/etc/system文件,以備不時之需
#cp /etc/vfstab /etc/vfstab.bak
#cp /etc/system /etc/system.bak
三、磁盤分區同步(使兩塊盤分區大小一樣)
# prtvtoc /dev/rdsk/c1t0d0s2 | fmthard -s - /dev/rdsk/c1t1d0s2
fmthard: New volume table of contents now in place.

四、制作metadb
# metadb -a -f -c 3 c1t0d0s7 c1t1d0s7

五、做根分區的兩路子鏡像
# metainit -f d10 1 1 c1t0d0s0
d10: Concat/Stripe is setup
# metainit d20 1 1 c1t1d0s0
d20: Concat/Stripe is setup

六、制作根分區的鏡像盤
# metainit d0 -m d10
d0: Mirror is setup

七、修改vfstab文件中關於根分區的項目
-----------------------------------------------------------------------------------
# more /etc/vfstab
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
#
fd - /dev/fd fd - no -
/proc - /proc proc - no -
/dev/dsk/c1t0d0s3 - - swap - no -
/dev/dsk/c1t0d0s0 /dev/rdsk/c1t0d0s0 / ufs 1 no -
/dev/dsk/c1t0d0s1 /dev/rdsk/c1t0d0s1 /var ufs 1 no -
/dev/dsk/c1t0d0s4 /dev/rdsk/c1t0d0s4 /export/home ufs 2 yes -
/dev/dsk/c1t0d0s5 /dev/rdsk/c1t0d0s5 /opt ufs 2 yes -
/devices - /devices devfs - no -
ctfs - /system/contract ctfs - no -
objfs - /system/object objfs - no -
swap - /tmp tmpfs - yes -
-----------------------------------------------------------------------------------
# metaroot d0
# lockfs


八、改完後重啟
#reboot
九、做/var分區的兩路子鏡像和/var分區的鏡象盤
# metainit -f d11 1 1 c1t0d0s1
d11: Concat/Stripe is setup
# metainit d21 1 1 c1t1d0s1
d21: Concat/Stripe is setup
# metainit d1 -m d11
d1: Mirror is setup

十、修改vfstab文件中關於/var分區的項目
# vi /etc/vfstab

"/etc/vfstab" 14 lines, 525 characters
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
#
fd - /dev/fd fd - no -
/proc - /proc proc - no -
/dev/dsk/c1t0d0s3 - - swap - no -
/dev/md/dsk/d0 /dev/md/rdsk/d0 / ufs 1 no -
/dev/md/dsk/d1 /dev/md/rdsk/d1 /var ufs 1 no -
/dev/dsk/c1t0d0s4 /dev/rdsk/c1t0d0s4 /export/home ufs 2 yes -
/dev/dsk/c1t0d0s5 /dev/rdsk/c1t0d0s5 /opt ufs 2 yes -
/devices - /devices devfs - no -
ctfs - /system/contract ctfs - no -
objfs - /system/object objfs - no -
swap - /tmp tmpfs - yes -
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"/etc/vfstab" 14 lines, 519 characters
十二、重啟系統
#reboot


十三、做swap分區的兩路子鏡像和swap分區的鏡象盤
# metainit -f d12 1 1 c1t0d0s3
d12: Concat/Stripe is setup
# metainit d22 1 1 c1t1d0s3
d22: Concat/Stripe is setup
# metainit d2 -m d12
d2: Mirror is setup
十四、修改vfstab文件中關於swap分區的項目
# vi /etc/vfstab

"/etc/vfstab" 14 lines, 519 characters
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
#
fd - /dev/fd fd - no -
/proc - /proc proc - no -
/dev/md/dsk/d2 - - swap - no -
/dev/md/dsk/d0 /dev/md/rdsk/d0 / ufs 1 no -
/dev/md/dsk/d1 /dev/md/rdsk/d1 /var ufs 1 no -
/dev/dsk/c1t0d0s4 /dev/rdsk/c1t0d0s4 /export/home ufs 2 yes -
/dev/dsk/c1t0d0s5 /dev/rdsk/c1t0d0s5 /opt ufs 2 yes -
/devices - /devices devfs - no -
ctfs - /system/contract ctfs - no -
objfs - /system/object objfs - no -
swap - /tmp tmpfs - yes -
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"/etc/vfstab" 14 lines, 516 characters
十五、重啟系統
#reboot

十六、做/export/home分區的兩路子鏡像和/export/home分區的鏡象盤
# metainit -f d13 1 1 c1t0d0s4
d13: Concat/Stripe is setup
# metainit d23 1 1 c1t1d0s4
d23: Concat/Stripe is setup
# metainit d3 -m d13
d3: Mirror is setup
十七、修改vfstab文件中關於/export/home分區的項目
# vi /etc/vfstab
"/etc/vfstab" 14 lines, 516 characters
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
#
fd - /dev/fd fd - no -
/proc - /proc proc - no -
/dev/md/dsk/d2 - - swap - no -
/dev/md/dsk/d0 /dev/md/rdsk/d0 / ufs 1 no -
/dev/md/dsk/d1 /dev/md/rdsk/d1 /var ufs 1 no -
/dev/md/dsk/d3 /dev/md/rdsk/d3 /export/home ufs 2 yes -
/dev/dsk/c1t0d0s5 /dev/rdsk/c1t0d0s5 /opt ufs 2 yes -
/devices - /devices devfs - no -
ctfs - /system/contract ctfs - no -
objfs - /system/object objfs - no -
swap - /tmp tmpfs - yes -
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"/etc/vfstab" 14 lines, 510 characters
十八、重啟系統
#reboot

-------------------------------------------------------
注意:
做到這步時,我犯了一個錯誤,用solaris的話來說,是fatal的,我vi時把本該寫成/dev/md/dsk/d3 /dev/md/rdsk/d3 /export/home的卻寫成了/dev/md/dsk/d4 /dev/md/rdsk/d4 /export/home,因為/export/home是在s4分區,我習慣性的把s4對應成了d4了,結果重啟後檢查文件系統時就啟不來了。於是查資料,解決過程如下:
現在使用的是完整的機器,也就是說有鼠標鍵盤和顯示器,默認顯示輸出也是SUN顯示器,而不是終端了。
先接上串口線連到終端上來,打開超級終端,此時我發現專用的鍵盤不起作用了,由於默認顯示輸出是SUN顯示器,在超級終端上是看不到輸出,但超級終端上的鍵盤是起作用的(這兩個鍵盤和顯示器的關系讓我出了一身冷汗),於是我在超級終端的鍵盤上按CTRL+BREAK進入OK狀態,通過SUN顯示器可以看到,然後把SOLARIS的啟動盤插入光驅並在OK狀態下輸入boot cdrom -s,用光盤單用戶啟動,就不加載文件系統了。系統起來後,用fsck檢查一遍根分區,命令為fsck -y /dev/rdsk/c1t0d0s0,很快檢查完了,再掛載到臨時文件系統上,命令為mount -F ufs /dev/rdsk/c1t0d0s0 /mnt,由於要用vi來修改/etc/vfstab文件,所以還要設置一下環境變量,(TERM=vt100; export TERM),這樣就可以vi /etc/vfstab了,改的時候我發現終端鍵盤的方向鍵不能用,只好用H,J,K,L來控制方向了,看來掌握方向是多麼的重要啊,改完保存後,把文件系統卸載下來,命令為umount /mnt,reboot重啟機器,正常了。
-------------------------------------------------------
十九、做/opt分區的兩路子鏡像和/opt分區的鏡象盤
# metainit -f d14 1 1 c1t0d0s5
d14: Concat/Stripe is setup
# metainit d24 1 1 c1t1d0s5
d24: Concat/Stripe is setup
# metainit d4 -m d14
d4: Mirror is setup

二十、修改vfstab文件中關於/opt分區的項目
# vi /etc/vfstab
"/etc/vfstab" 14 lines, 510 characters
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
#
fd - /dev/fd fd - no -
/proc - /proc proc - no -
/dev/md/dsk/d2 - - swap - no -
/dev/md/dsk/d0 /dev/md/rdsk/d0 / ufs 1 no -
/dev/md/dsk/d1 /dev/md/rdsk/d1 /var ufs 1 no -
/dev/md/dsk/d3 /dev/md/rdsk/d3 /export/home ufs 2 yes -
/dev/md/dsk/d4 /dev/md/rdsk/d4 /opt ufs 2 yes -
/devices - /devices devfs - no -
ctfs - /system/contract ctfs - no -
objfs - /system/object objfs - no -
swap - /tmp tmpfs - yes -
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"/etc/vfstab" 14 lines, 504 characters

二十一、重啟系統
#reboot

二十二、將另外一路子鏡像盤加入到鏡像盤中
# metattach d0 d20
d0: submirror d20 is attached
# metattach d1 d21
d1: submirror d21 is attached
# metattach d2 d22
d2: submirror d22 is attached
# metattach d3 d23
d3: submirror d23 is attached
# metattach d4 d24
d4: submirror d24 is attached
二十三、查看鏡象同步狀態
# metastat | grep %
Resync in progress: 0 % done
Resync in progress: 0 % done
Resync in progress: 27 % done
Resync in progress: 0 % done
Resync in progress: 0 % done
# metastat | grep %
Resync in progress: 22 % done
Resync in progress: 58 % done
Resync in progress: 56 % done
Resync in progress: 5 % done
# metastat | grep %
Resync in progress: 39 % done
Resync in progress: 94 % done
Resync in progress: 9 % done


二十四、同步完之後記得打補丁
Copyright © Linux教程網 All Rights Reserved