1. 程式人生 > >Oracle之利用iscsi構建RAC共享儲存測試

Oracle之利用iscsi構建RAC共享儲存測試

Centos下配置iscsi 共享儲存

ISCSI儲存分為服務端(server,提供target儲存給客戶端掛載使用)和客戶段(client,使用服務端提供的target來存放檔案等),Centos6.8下對應的agent為scsi-target-utils(服務端安裝)和iscsi-initiator(客戶端安裝),以下的安裝,全部是用虛擬機器安裝的。

我們在搭建RAC的時候會用到iscsi來構建共享儲存,下面就介紹利用iscsi 怎樣構建RAC的共享儲存.

1. 環境資訊

rac1:192.168.180.2

rac2:192.168.180.3

這裡我們選rac1為iscsi伺服器,然後把其上的磁碟共享給rac2使用

注意:這裡我們可以選用這個2個節點任何一臺或者其他機器作為iscsi伺服器,這裡為了方便就在rac1上搭建iscsi伺服器

首先我們在rac1上新增需要共享的磁碟,也就是rac的磁碟組。這裡我已經在rac1上分配了6塊盤,說明如下:

Ocrvotedisk 3塊 4G

Data            2塊 50G

FRA_ARC   1 塊 60G


在rac1上檢視:

[[email protected] ~]# fdisk -l

Disk /dev/sda: 64.4 GB,64424509440 bytes

255 heads, 63sectors/track, 7832 cylinders

Units = cylinders of 16065* 512 = 8225280 bytes

Sector size(logical/physical): 512 bytes / 512 bytes

I/O size(minimum/optimal): 512 bytes / 512 bytes

Disk identifier:0x0000d707

   Device Boot      Start         End      Blocks  Id  System

/dev/sda1               1        5222   41943040   83  Linux

/dev/sda2   *       5222        6528    10485760  83  Linux

/dev/sda3            6528        7293    6144000   82  Linux swap / Solaris

Disk /dev/sdb: 4294 MB,4294967296 bytes

255 heads, 63sectors/track, 522 cylinders

Units = cylinders of 16065* 512 = 8225280 bytes

Sector size(logical/physical): 512 bytes / 512 bytes

I/O size(minimum/optimal): 512 bytes / 512 bytes

Disk identifier:0x00000000

Disk /dev/sdd: 4294 MB,4294967296 bytes

255 heads, 63sectors/track, 522 cylinders

Units = cylinders of 16065* 512 = 8225280 bytes

Sector size (logical/physical):512 bytes / 512 bytes

I/O size(minimum/optimal): 512 bytes / 512 bytes

Disk identifier:0x00000000

Disk /dev/sde: 53.7 GB,53687091200 bytes

255 heads, 63sectors/track, 6527 cylinders

Units = cylinders of 16065* 512 = 8225280 bytes

Sector size(logical/physical): 512 bytes / 512 bytes

I/O size(minimum/optimal): 512 bytes / 512 bytes

Disk identifier:0x00000000

Disk /dev/sdf: 53.7 GB,53687091200 bytes

255 heads, 63sectors/track, 6527 cylinders

Units = cylinders of 16065* 512 = 8225280 bytes

Sector size(logical/physical): 512 bytes / 512 bytes

I/O size(minimum/optimal): 512 bytes / 512 bytes

Disk identifier:0x00000000

Disk /dev/sdg: 64.4 GB,64424509440 bytes

255 heads, 63sectors/track, 7832 cylinders

Units = cylinders of 16065* 512 = 8225280 bytes

Sector size(logical/physical): 512 bytes / 512 bytes

I/O size(minimum/optimal): 512 bytes / 512 bytes

Disk identifier:0x00000000

Disk /dev/sdc: 4294 MB,4294967296 bytes

255 heads, 63sectors/track, 522 cylinders

Units = cylinders of 16065* 512 = 8225280 bytes

Sector size(logical/physical): 512 bytes / 512 bytes

I/O size(minimum/optimal): 512 bytes / 512 bytes

Disk identifier:0x00000000

以上說明磁碟已經在rac1上掛載上,下面就利用iscsi 共享給rac2

2.配置iscsi服務端(在rac1上操作)

a)安裝scsi-target-utils

[[email protected] os]# ll scsi-target-utils-1.0.24-18.el6.x86_64.rpm

[[email protected] os]# rpm -ivh scsi-target-utils-1.0.24-18.el6.x86_64.rpm

注意:在安裝的時候有可能提示缺少依賴包,先將這些依賴包安裝上以後就可以了

b)配置targets.conf

[[email protected] os]# vi /etc/tgt/targets.conf


注意:裡面新增的就是想要共享給rac2的磁碟

c)啟動tgtd

[[email protected] os]# servicetgtd start

Starting SCSI targetdaemon:                              [  OK  ]

[[email protected] os]# chkconfigtgtd on   

3.配置iscsi客戶端(在rac2上操作)

a)安裝iscsi-initiator-utils

[[email protected] Packages]# ll iscsi-initiator-utils-6.2.0.873-21.el6.x86_64.rpm

-r--r--r-- 3 root root747940 May 12  2016iscsi-initiator-utils-6.2.0.873-21.el6.x86_64.rpm

[[email protected] Packages]# rpm -ivh iscsi-initiator-utils-6.2.0.873-21.el6.x86_64.rpm

b)配置nitiatorname.iscsi

[[email protected] Packages]# vi /etc/iscsi/initiatorname.iscsi


注意:紅框中的值就是rac1上 /etc/tgt/targets.conf 裡配置的值

c)啟動iscsi

[[email protected] Packages]#service iscsi start

[[email protected] Packages]#chkconfig iscsi on

注意:如果我安裝作業系統時已經安裝了iscsi-initiator-utils軟體包所以不用再另外安裝,直接配置就行。

4.共享儲存(rac2上操作)

a)通過3260埠檢視開放了哪些共享儲存:
[[email protected] ~]#  iscsiadm -m discovery -tsendtargets -p 192.168.180.2:3260

192.168.180.2:3260,1 iqn.2008-09.com.example:server.target4

[[email protected] ~]# iscsiadm -m node -T discovery -T iqn.2008-09.com.example:server.target4 -p 192.168.180.2:3260

b)登入共享儲存:
# iscsiadm -m node -T iqn.2008-09.com.example:server.target4 -p 192.168.180.2:3260 -l

c)探測下共享儲存的目錄:
# partprobe
# fdisk -l

d)退出共享儲存目錄:
# iscsiadm -m node -T iqn.2008-09.com.example:server.target4 -p 192.168.1.251:3260  -u
# fdisk -l (
將檢視不到共享目錄)

e)刪除共享儲存目錄:
# service iscsi restart
# iscsiadm -m node -T iqn.2008-09.com.example:server.target4  -p 192.168.0.13:3260 -u
# iscsiadm -m node -T iqn.2008-09.com.example:server.target4  -p 192.168.0.13:3260 -o delete

f)重新服務並重新建立登入:

# service iscsi restart
# iscsiadm -m discovery -t sendtargets -p 192.168.180.2:3260
# iscsiadm -m node -T iqn.2008-09.com.example:server.target4 -p 192.168.0.13:3260  -l

g)為共享儲存分割槽建立目錄

# fdisk -l   我們發現多了一個sdb

然後就是給這個虛擬硬碟sdb分割槽,然後掛載

#fdisk /dev/sdb

Command (m for help): 在這裡按m,就會輸出幫助;
Command action
   a toggle a bootable flag
   b edit bsd disklabel
   c toggle the dos compatibility flag
   d delete a partition 注:這是刪除一個分割槽的動作;
   l list known partition types 注:l是列出分割槽型別,以供我們設定相應分割槽的型別;
   m print this menu 注:m 是列出幫助資訊;
   n add a new partition 注:新增一個分割槽;
   o create a new empty DOS partition table
   p print the partition table 注:p列出分割槽表;
   q quit without saving changes 注:不儲存退出;
   s create a new empty Sun disklabel
   t change a partition's system id 注:t 改變分割槽型別;
   u change display/entry units
   v verify the partition table
   w write table to disk and exit 注:把分割槽表寫入硬碟並退出;
   x extra functionality (experts only) 注:擴充套件應用,專家功能;

# partprobe
# mkfs -t ext3 /dev/sdb1
這一步如果硬碟容量大的話可能會非常慢,時間比較長

# mkdir /mnt/class
# echo "/dev/sdb1 /mnt/class ext3 _netdev 0 0">>/etc/fstab
# mount /mnt/class
# dd if=/dev/zero f=myfile bs=1M count=10    
(建立成功,可以使用)

h)解除安裝共享儲存:
# umount /mnt/class/
# rmdir /mnt/class/
# iscsiadm -m node -T iqn.2008-09.com.example:server.target4:disk1 -p 192.168.0.13:3260 –u
# iscsiadm -m node -T iqn.2008-09.com.example:server.target4:disk1 -p 192.168.0.13:3260 -o delete
# service iscsi stop
# chkconfig iscsi off

*******************************************客戶端配置結束****************************************