oracle gi 使用 iscsi 實現共享儲存

2021-09-23 20:47:57 字數 4561 閱讀 5439

os: centos 6.8

在不太容易實現共享儲存的地方,可以通過iscsi輕易實現.

只是生產環境慎用.

iscsi 分為 target(server) 和 initiator(client)

資訊如下:

192.168.56.102 nodea2

# yum install gcc gcc-c++

# cd /lib/modules/2.6.32-754.11.1.el6.x86_64/

# ln -s ../../../usr/src/kernels/2.6.32-754.11.1.el6.x86_64 build

# cd /opt

# wget

# tar zxvf iscsitarget-1.4.20.2.tar.gz

# cd iscsitarget-1.4.20.2

# make

# make install

# ls -l /etc/init.d/ |grep -i scsi

-rwxr-xr-x 1 root root 4535 jun 10 2017 iscsi

-rwxr-xr-x 1 root root 3990 jun 10 2017 iscsid

-rwxr-xr-x 1 root root 1430 may 23 11:42 iscsi-target

# /etc/init.d/iscsi status

iscsi is stopped

# /etc/init.d/iscsid status

iscsid is stopped

# /etc/init.d/iscsi-target status

iscsi target stopped

# chkconfig --list |grep -i iscsi

iscsi 0:off 1:off 2:off 3:on 4:on 5:on 6:off

iscsid 0:off 1:off 2:off 3:on 4:on 5:on 6:off

# chkconfig iscsi-target on

target 上掛載磁碟

# fdisk -l 

disk /dev/vdb: 536.9 gb, 536870912000 bytes

disk /dev/vdc: 214.7 gb, 214748364800 bytes

disk /dev/vdd: 322.1 gb, 322122547200 bytes

disk /dev/vde: 547.6 gb, 547608330240 bytes

disk /dev/vdf: 225.5 gb, 225485783040 bytes

disk /dev/vdg: 332.9 gb, 332859965440 bytes

# cd /etc/iet

# cp targets.allow targets.allow.bak

# vi targets.allow

all 192.168.56.0/24

# cp initiators.allow initiators.allow.bak

# vi initiators.allow

iqn.2019-05.com.example:sharedisk.uatclustera 192.168.56.101, 192.168.56.102

iqn.2019-05.com.example:sharedisk.uatclusterb 192.168.56.101, 192.168.56.102

# cp ietd.conf ietd.conf.bak

# vi ietd.conf

target iqn.2019-05.com.example:sharedisk.uatclustera

lun 0 path=/dev/vdb,type=fileio,iomode=wb

lun 1 path=/dev/vdc,type=fileio,iomode=wb

lun 2 path=/dev/vdd,type=fileio,iomode=wb

target iqn.2019-05.com.example:sharedisk.uatclusterb

lun 0 path=/dev/vde,type=fileio,iomode=wb

lun 1 path=/dev/vdf,type=fileio,iomode=wb

lun 2 path=/dev/vdg,type=fileio,iomode=wb

# /etc/init.d/iscsi-target start

# dmesg

檢視當前伺服器 iscsi target 服務以及連線狀態命令

# cat /proc/net/iet/session

tid:2 name:iqn.2019-05.com.example:sharedisk.uatclusterb

tid:1 name:iqn.2019-05.com.example:sharedisk.uatclustera

檢視當前虛擬單元清單。

# cat /proc/net/iet/volume

tid:2 name:iqn.2019-05.com.example:sharedisk.uatclusterb

lun:0 state:0 iotype:fileio iomode:wb blocks:1069547520 blocksize:512 path:/dev/vde

lun:1 state:0 iotype:fileio iomode:wb blocks:440401920 blocksize:512 path:/dev/vdf

lun:2 state:0 iotype:fileio iomode:wb blocks:650117120 blocksize:512 path:/dev/vdg

tid:1 name:iqn.2019-05.com.example:sharedisk.uatclustera

lun:0 state:0 iotype:fileio iomode:wb blocks:1048576000 blocksize:512 path:/dev/vdb

lun:1 state:0 iotype:fileio iomode:wb blocks:419430400 blocksize:512 path:/dev/vdc

lun:2 state:0 iotype:fileio iomode:wb blocks:629145600 blocksize:512 path:/dev/vdd

較好的方案是在 target 端設定 /etc/iet/targets.allow 和 /etc/iscsi/iscsid.conf 密碼

# yum install iscsi-initiator-utils-* 

# systemctl status iscsid;

systemctl status iscsi;

# systemctl start iscsi

# systemctl enable iscsid;

systemctl enable iscsi;

檢視目前連線狀態

# iscsiadm -m session
探測某台機器的target

# iscsiadm -m discovery -t sendtargets -p 192.168.56.90

# ll -r /var/lib/iscsi/nodes/

# cd /var/lib/iscsi/nodes/

刪除不需要掛載的 target(或者在 target 端設定 targets.allow)

掛載到本地

# iscsiadm -m node

# iscsiadm -m node -t iqn.2019-05.com.example:sharedisk.uatclustera -p 192.168.56.90 --login

# lsblk

退出登陸

# iscsiadm -m node -t iqn.2019-05.com.example:sharedisk.uatclustera --logout
刪除登陸資料

# iscsiadm -m node -t iqn.2019-05.com.example:sharedisk.uatclustera -o delete
如果 target 端設定了密碼,那麼 initiator 端也要設定相應的登陸密碼

# vi /etc/iscsi/iscsid.conf
啟動、停止、重啟iscsi-target 服務

/etc/init.d/iscsi-target start

/etc/init.d/iscsi-target stop

/etc/init.d/iscsi-target restart

參考:

使用linux連線ISCSI

這幾天做資料庫集群。需要用共享儲存。我公司有買了乙個xx備份儲存櫃。裡面有iscsi硬碟4塊。首先開啟終端。確認是否有裝iscsi rpm qa grep iscsi 嘗試啟動服務 service iscis 沒關係。沒註冊。直接在目錄下啟動 etc init.d iscsi restart 上面犯...

ISCSI部署及使用

iscsi 一種基於c s架構的虛擬磁碟技術,共享磁碟空間.埠號 3260 軟體包 targetcli iscsi磁碟構成 backstore 後端儲存 共享的裝置,需要起乙個管理名稱 target 磁碟組 是客戶端訪問的目標,有多個lun組成 lun 邏輯單元 每乙個lun關聯某乙個後端儲存,在客...

CentOS7 ISCSI簡單使用

一 iscsi簡介 iscsi實現網路儲存,提供儲存端叫 target,使用儲存端叫 initiator。target 上可以提供儲存空間,initiator負責連線iscsi裝置,在iscsi裝置中建立檔案系統,以及訪問資料,在 initiator 上看上去是多了一塊硬碟。伺服器端配置target...