開源虛擬磁帶庫MHVTL 安裝on RHEL6.2

silencelion99發表於2016-05-09

    server端使用RHEL6.2

    client使用windows 2008

    一、安裝MHVTL

    1、安裝需要的rpm包

    yum -y install zlib-devel mtx mt-st lsscsi kernel-devel kernel-headers sg3_utils gcc

    2、安裝mhvtl,
    編譯核心

    [root@MHVTL mhvtl]# cd mhvtl-0.18/

    [root@MHVTL mhvtl-0.18]# cd kernel/

    [root@MHVTL kernel]#

    [root@MHVTL kernel]# make

    make -C /lib/modules/2.6.32-220.el6.x86_64/build SUBDIRS=/mhvtl/mhvtl-0.18/kernel modules

    make[1]: Entering directory `/usr/src/kernels/2.6.32-220.el6.x86_64'

    CC [M] /mhvtl/mhvtl-0.18/kernel/mhvtl.o

    /mhvtl/mhvtl-0.18/kernel/mhvtl.c:316: warning: initialization from incompatible pointer type

    Building modules, stage 2.

    MODPOST 1 modules

    CC /mhvtl/mhvtl-0.18/kernel/mhvtl.mod.o

    LD [M] /mhvtl/mhvtl-0.18/kernel/mhvtl.ko.unsigned

    NO SIGN [M] /mhvtl/mhvtl-0.18/kernel/mhvtl.ko

    make[1]: Leaving directory `/usr/src/kernels/2.6.32-220.el6.x86_64'

    [root@MHVTL kernel]#

    [root@MHVTL kernel]# make install

    install -o root -g root -m 644 mhvtl.ko /lib/modules/`uname -r`/kernel/drivers/scsi/; \

    depmod -ae; \

    if [ -f "/etc/modprobe.d/unsupported-modules" ]; then \

    sed -e 's/^allow_unsupported_modules 0/allow_unsupported_modules 1/' /etc/modprobe.d/unsupported-modules > /etc/new; \

    /bin/mv /etc/new /etc/modprobe.d/unsupported-modules; \

    fi

    [root@MHVTL kernel]#

    [root@MHVTL kernel]# cd ..

    [root@MHVTL mhvtl-0.18]# make

    make -C usr USR=vtl GROUP=vtl MHVTL_HOME_PATH=/opt/mhvtl MHVTL_CONFIG_PATH=/etc/mhvtl

    make[1]: Entering directory `/mhvtl/mhvtl-0.18/usr'

    cc -Wall -Wshadow -g -O2 -D_LARGEFILE64_SOURCE -I../kernel -DMHVTL_VERSION=\"0.18.9\" -DMHVTL_DEBUG -DUSR=\"vtl\" -DMHVTL_HOME_PATH=\"/opt/mhvtl\" -DMHVTL_CONFIG_PATH=\"/etc/mhvtl\" -c -fpic vtllib.c

    cc -Wall -Wshadow -g -O2 -D_LARGEFILE64_SOURCE -I../kernel -DMHVTL_VERSION=\"0.18.9\" -DMHVTL_DEBUG -DUSR=\"vtl\" -DMHVTL_HOME_PATH=\"/opt/mhvtl\" -DMHVTL_CONFIG_PATH=\"/etc/mhvtl\" -c -fpic spc.c

    cc -shared -o libvtlscsi.so vtllib.o spc.o

    cc -Wall -Wshadow -g -O2 -D_LARGEFILE64_SOURCE -I../kernel -DMHVTL_VERSION=\"0.18.9\" -DMHVTL_DEBUG -DUSR=\"vtl\" -DMHVTL_HOME_PATH=\"/opt/mhvtl\" -DMHVTL_CONFIG_PATH=\"/etc/mhvtl\" -c -o vtltape.o vtltape.c

    cc -Wall -Wshadow -g -O2 -D_LARGEFILE64_SOURCE -I../kernel -DMHVTL_VERSION=\"0.18.9\" -DMHVTL_DEBUG -DUSR=\"vtl\" -DMHVTL_HOME_PATH=\"/opt/mhvtl\" -DMHVTL_CONFIG_PATH=\"/etc/mhvtl\" -c -o vtlcart.o vtlcart.c

    cc -Wall -Wshadow -g -O2 -D_LARGEFILE64_SOURCE -I../kernel -DMHVTL_VERSION=\"0.18.9\" -DMHVTL_DEBUG -DUSR=\"vtl\" -DMHVTL_HOME_PATH=\"/opt/mhvtl\" -DMHVTL_CONFIG_PATH=\"/etc/mhvtl\" -c -o q.o q.c

    cc -Wall -Wshadow -g -O2 -D_LARGEFILE64_SOURCE -I../kernel -DMHVTL_VERSION=\"0.18.9\" -DMHVTL_DEBUG -DUSR=\"vtl\" -DMHVTL_HOME_PATH=\"/opt/mhvtl\" -DMHVTL_CONFIG_PATH=\"/etc/mhvtl\" -o vtltape vtltape.o vtlcart.o q.o -lz -L. -lvtlscsi

    cc -Wall -Wshadow -g -O2 -D_LARGEFILE64_SOURCE -I../kernel -DMHVTL_VERSION=\"0.18.9\" -DMHVTL_DEBUG -DUSR=\"vtl\" -DMHVTL_HOME_PATH=\"/opt/mhvtl\" -DMHVTL_CONFIG_PATH=\"/etc/mhvtl\" -c -o dump_tape.o dump_tape.c

    cc -Wall -Wshadow -g -O2 -D_LARGEFILE64_SOURCE -I../kernel -DMHVTL_VERSION=\"0.18.9\" -DMHVTL_DEBUG -DUSR=\"vtl\" -DMHVTL_HOME_PATH=\"/opt/mhvtl\" -DMHVTL_CONFIG_PATH=\"/etc/mhvtl\" -o dump_tape dump_tape.o vtlcart.o -L. -lvtlscsi

    cc -Wall -Wshadow -g -O2 -D_LARGEFILE64_SOURCE -I../kernel -DMHVTL_VERSION=\"0.18.9\" -DMHVTL_DEBUG -DUSR=\"vtl\" -DMHVTL_HOME_PATH=\"/opt/mhvtl\" -DMHVTL_CONFIG_PATH=\"/etc/mhvtl\" -c -o vtlcmd.o vtlcmd.c

    cc -Wall -Wshadow -g -O2 -D_LARGEFILE64_SOURCE -I../kernel -DMHVTL_VERSION=\"0.18.9\" -DMHVTL_DEBUG -DUSR=\"vtl\" -DMHVTL_HOME_PATH=\"/opt/mhvtl\" -DMHVTL_CONFIG_PATH=\"/etc/mhvtl\" -o vtlcmd q.o vtlcmd.o

    cc -Wall -Wshadow -g -O2 -D_LARGEFILE64_SOURCE -I../kernel -DMHVTL_VERSION=\"0.18.9\" -DMHVTL_DEBUG -DUSR=\"vtl\" -DMHVTL_HOME_PATH=\"/opt/mhvtl\" -DMHVTL_CONFIG_PATH=\"/etc/mhvtl\" -c -o dump_messageQ.o dump_messageQ.c

    cc -Wall -Wshadow -g -O2 -D_LARGEFILE64_SOURCE -I../kernel -DMHVTL_VERSION=\"0.18.9\" -DMHVTL_DEBUG -DUSR=\"vtl\" -DMHVTL_HOME_PATH=\"/opt/mhvtl\" -DMHVTL_CONFIG_PATH=\"/etc/mhvtl\" -o dump_messageQ dump_messageQ.o q.o

    cc -Wall -Wshadow -g -O2 -D_LARGEFILE64_SOURCE -I../kernel -DMHVTL_VERSION=\"0.18.9\" -DMHVTL_DEBUG -DUSR=\"vtl\" -DMHVTL_HOME_PATH=\"/opt/mhvtl\" -DMHVTL_CONFIG_PATH=\"/etc/mhvtl\" -c -o mktape.o mktape.c

    cc -Wall -Wshadow -g -O2 -D_LARGEFILE64_SOURCE -I../kernel -DMHVTL_VERSION=\"0.18.9\" -DMHVTL_DEBUG -DUSR=\"vtl\" -DMHVTL_HOME_PATH=\"/opt/mhvtl\" -DMHVTL_CONFIG_PATH=\"/etc/mhvtl\" -o mktape mktape.o vtlcart.o -L. -lvtlscsi

    cc -Wall -Wshadow -g -O2 -D_LARGEFILE64_SOURCE -I../kernel -DMHVTL_VERSION=\"0.18.9\" -DMHVTL_DEBUG -DUSR=\"vtl\" -DMHVTL_HOME_PATH=\"/opt/mhvtl\" -DMHVTL_CONFIG_PATH=\"/etc/mhvtl\" -c -o vtllibrary.o vtllibrary.c

    cc -Wall -Wshadow -g -O2 -D_LARGEFILE64_SOURCE -I../kernel -DMHVTL_VERSION=\"0.18.9\" -DMHVTL_DEBUG -DUSR=\"vtl\" -DMHVTL_HOME_PATH=\"/opt/mhvtl\" -DMHVTL_CONFIG_PATH=\"/etc/mhvtl\" -o vtllibrary vtllibrary.o q.o -L. -lvtlscsi

    sed -e s'/@HOME_PATH@/\/opt\/mhvtl/' make_vtl_media.in > make_vtl_media.1

    sed -e s'/@CONF_PATH@/\/etc\/mhvtl/' make_vtl_media.1 > make_vtl_media

    rm -f make_vtl_media.1

    make[1]: Leaving directory `/mhvtl/mhvtl-0.18/usr'

    make -C etc USR=vtl GROUP=vtl MHVTL_HOME_PATH=/opt/mhvtl MHVTL_CONFIG_PATH=/etc/mhvtl

    make[1]: Entering directory `/mhvtl/mhvtl-0.18/etc'

    make[1]: `mhvtl' is up to date.

    make[1]: Leaving directory `/mhvtl/mhvtl-0.18/etc'

    make -C scripts MHVTL_HOME_PATH=/opt/mhvtl MHVTL_CONFIG_PATH=/etc/mhvtl

    make[1]: Entering directory `/mhvtl/mhvtl-0.18/scripts'

    make[1]: `update_device.conf' is up to date.

    make[1]: Leaving directory `/mhvtl/mhvtl-0.18/scripts'

    [root@MHVTL mhvtl-0.18]#

    [root@MHVTL mhvtl-0.18]# make install

    make usr

    make[1]: Entering directory `/mhvtl/mhvtl-0.18'

    make -C usr USR=vtl GROUP=vtl MHVTL_HOME_PATH=/opt/mhvtl MHVTL_CONFIG_PATH=/etc/mhvtl

    make[2]: Entering directory `/mhvtl/mhvtl-0.18/usr'

    make[2]: Nothing to be done for `all'.

    make[2]: Leaving directory `/mhvtl/mhvtl-0.18/usr'

    make[1]: Leaving directory `/mhvtl/mhvtl-0.18'

    make -C usr install /usr

    make[1]: Entering directory `/mhvtl/mhvtl-0.18/usr'

    install -d -m 755 /usr/lib64

    install -o root -g bin -m 755 libvtlscsi.so /usr/lib64/

    install -d -m 755 /usr/bin

    install -o root -g vtl -m 4750 vtltape /usr/bin/

    install -o root -g vtl -m 4750 vtllibrary /usr/bin/

    install -o vtl -g vtl -m 750 vtlcmd /usr/bin/

    install -o vtl -g vtl -m 750 mktape /usr/bin/

    install -o vtl -g vtl -m 750 dump_tape /usr/bin/

    install -m 700 build_library_config /usr/bin/

    install -m 700 make_vtl_media /usr/bin/

    install -m 700 make_vtl_devices /usr/bin/

    make[1]: Warning: File `/usr' has modification time 2.3e+04 s in the future

    make[1]: Nothing to be done for `/usr'.

    make[1]: warning: Clock skew detected. Your build may be incomplete.

    make[1]: Leaving directory `/mhvtl/mhvtl-0.18/usr'

    make scripts

    make[1]: Entering directory `/mhvtl/mhvtl-0.18'

    make -C scripts MHVTL_HOME_PATH=/opt/mhvtl MHVTL_CONFIG_PATH=/etc/mhvtl

    make[2]: Entering directory `/mhvtl/mhvtl-0.18/scripts'

    make[2]: `update_device.conf' is up to date.

    make[2]: Leaving directory `/mhvtl/mhvtl-0.18/scripts'

    make[1]: Leaving directory `/mhvtl/mhvtl-0.18'

    make -C scripts install

    make[1]: Entering directory `/mhvtl/mhvtl-0.18/scripts'

    install -m 700 update_device.conf /usr/bin/

    make[1]: Leaving directory `/mhvtl/mhvtl-0.18/scripts'

    make etc

    make[1]: Entering directory `/mhvtl/mhvtl-0.18'

    make -C etc USR=vtl GROUP=vtl MHVTL_HOME_PATH=/opt/mhvtl MHVTL_CONFIG_PATH=/etc/mhvtl

    make[2]: Entering directory `/mhvtl/mhvtl-0.18/etc'

    make[2]: `mhvtl' is up to date.

    make[2]: Leaving directory `/mhvtl/mhvtl-0.18/etc'

    make[1]: Leaving directory `/mhvtl/mhvtl-0.18'

    make -C etc install

    make[1]: Entering directory `/mhvtl/mhvtl-0.18/etc'

    install -d -m 755 /etc

    install -d -m 755 /etc/init.d

    install -m 700 mhvtl /etc/init.d/

    test ! -x /sbin/insserv || /sbin/insserv mhvtl

    make[1]: Leaving directory `/mhvtl/mhvtl-0.18/etc'

    啟動mhvtl服務

    [root@MHVTL mhvtl-0.18]# service mhvtl start

    vtltape: version 0.18.9

    vtltape: version 0.18.9

    vtltape: version 0.18.9

    vtltape: version 0.18.9

    vtltape: version 0.18.9

    vtltape: version 0.18.9

    vtltape: version 0.18.9

    vtltape: version 0.18.9

    vtllibrary: version 0.18.9

    vtllibrary process PID is 3733

    vtllibrary: version 0.18.9

    vtllibrary process PID is 3737


    檢視帶庫狀態

    [root@MHVTL mhvtl-0.18]# lsscsi -g

    [1:0:0:0] cd/dvd NECVMWar VMware IDE CDR10 1.00 /dev/sr0 /dev/sg0

    [2:0:0:0] disk VMware, VMware Virtual S 1.0 /dev/sda /dev/sg1

    [3:0:0:0] mediumx STK L700 /dev/sch0 /dev/sg10

    [3:0:1:0] tape IBM ULT3580-TD5 /dev/st0 /dev/sg2

    [3:0:2:0] tape IBM ULT3580-TD5 /dev/st1 /dev/sg3

    [3:0:3:0] tape IBM ULT3580-TD4 /dev/st2 /dev/sg4

    [3:0:4:0] tape IBM ULT3580-TD4 /dev/st3 /dev/sg5

    [3:0:8:0] mediumx STK L80 /dev/sch1 /dev/sg11

    [3:0:9:0] tape STK T10000B /dev/st4 /dev/sg6

    [3:0:10:0] tape STK T10000B /dev/st5 /dev/sg7

    [3:0:11:0] tape STK T10000B /dev/st6 /dev/sg8

    [3:0:12:0] tape STK T10000B /dev/st7 /dev/sg9



    3、設定開機自啟動mhvtl服務

    [root@MHVTL mhvtl]# chkconfig mhvtl on



    檢視生成的檔案 和配置檔案目錄

    clip_image001



    檢視配置檔案,預設每個磁帶大小500M

    clip_image002



    二、配置iscsi

    安裝scsi-target-utils 執行以下命令,RHEL6.2 DVD裡面install scsi-target-utils 這個包

    [root@MHVTL mhvtl]# yum -y install scsi-target-utils

    啟動服務,設定開機自啟動

    clip_image003



    檢視現有的target配置

    clip_image004



    新建一個target配置,並檢視

    clip_image005



    檢視現有的驅動器和機械臂

    clip_image006



    新增機械臂和驅動器到已建立的target

    clip_image007



    上一步報錯tgtadm: invalid reques,解決方法:先關掉selinux

    clip_image008



    檢視現有的target配置

    [root@MHVTL kernel]# tgtadm --lld iscsi --op show --mode target

    Target 1: iqn.2014-08.com.example:storage.vtl.liuzhen

    System information:

    Driver: iscsi

    State: ready

    I_T nexus information:

    LUN information:

    LUN: 0

    Type: controller

    SCSI ID: IET 00010000

    SCSI SN: beaf10

    Size: 0 MB, Block size: 1

    Online: Yes

    Removable media: No

    Readonly: No

    Backing store type: null

    Backing store path: None

    Backing store flags:

    LUN: 1

    Type: passthrough

    SCSI ID: IET 00010001

    SCSI SN: beaf11

    Size: 0 MB, Block size: 1

    Online: Yes

    Removable media: No

    Readonly: No

    Backing store type: sg

    Backing store path: /dev/sg10

    Backing store flags:

    LUN: 2

    Type: passthrough

    SCSI ID: IET 00010002

    SCSI SN: beaf12

    Size: 0 MB, Block size: 1

    Online: Yes

    Removable media: No

    Readonly: No

    Backing store type: sg

    Backing store path: /dev/sg2

    Backing store flags:

    LUN: 3

    Type: passthrough

    SCSI ID: IET 00010003

    SCSI SN: beaf13

    Size: 0 MB, Block size: 1

    Online: Yes

    Removable media: No

    Readonly: No

    Backing store type: sg

    Backing store path: /dev/sg3

    Backing store flags:

    LUN: 4

    Type: passthrough

    SCSI ID: IET 00010004

    SCSI SN: beaf14

    Size: 0 MB, Block size: 1

    Online: Yes

    Removable media: No

    Readonly: No

    Backing store type: sg

    Backing store path: /dev/sg4

    Backing store flags:

    LUN: 5

    Type: passthrough

    SCSI ID: IET 00010005

    SCSI SN: beaf15

    Size: 0 MB, Block size: 1

    Online: Yes

    Removable media: No

    Readonly: No

    Backing store type: sg

    Backing store path: /dev/sg5

    Backing store flags:

    Account information:

    ACL information:

    設定targets訪問控制策略,允許同一網段訪問

    clip_image009



    關掉防火牆

    clip_image010



    windows client端連線測試

    clip_image011



    進入裝置管理器已經能夠看到機械臂和驅動器

    clip_image012





    前面命令有好多在截圖裡,在這裡列出
      tgtadm --lld iscsi --op show --mode target
      tgtadm --lld iscsi --op new --mode target --tid 1 -T iqn.2014-08.com.example:storage.vtl.liuzhen
      tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 --bstype=sg --device-type=pt -b /dev/sg10
      tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 2 --bstype=sg --device-type=pt -b /dev/sg2
      tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 3 --bstype=sg --device-type=pt -b /dev/sg3
      tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 4 --bstype=sg --device-type=pt -b /dev/sg4
      tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 5 --bstype=sg --device-type=pt -b /dev/sg5
      tgtadm --lld iscsi --op show --mode target
      tgtadm --lld iscsi --op bind --mode target --tid 1 -I 10.1.1.0/24

    使用tgtadm可以配置targets,但只是臨時生效,重啟tgtd服務後,配置全部消失

    如需永久生效,使用下面的方法修改配置檔案,修改完後重啟tgt服務即看到效果

    [root@MHVTL tgt]# pwd

    /etc/tgt

    [root@MHVTL tgt]# tail targets.conf

     

    <target iqn.2014-08.com.mhvtl75.nbusyd.com.liuzhen:mhvtl.target1>

     

           device-type pt

           bs-type sg

     

    include /etc/tgt/mhvtl_targets.conf

     

           allow-in-use yes

    </target>

    [root@MHVTL tgt]#

    [root@MHVTL tgt]# cat /etc/tgt/mhvtl_targets.conf

    backing-store /dev/sg10

    backing-store /dev/sg2

    backing-store /dev/sg3

    backing-store /dev/sg4

    backing-store /dev/sg5

     

    檢視target狀態   ,下面命令和 tgtadm --lld iscsi --op show --mode target 功能基本一樣

     

    [root@MHVTL tgt]# tgt-admin  --show

    Target 1: iqn.2014-08.com.mhvtl75.nbusyd.com.liuzhen:mhvtl.target1

        System information:

            Driver: iscsi

            State: ready

        I_T nexus information:

            I_T nexus: 1

                Initiator: iqn.1991-05.com.microsoft:win-opi7pesls6t

                Connection: 1

                    IP Address: 10.1.1.10

        LUN information:

            LUN: 0

                Type: controller

                SCSI ID: IET     00010000

                SCSI SN: beaf10

                Size: 0 MB, Block size: 1

                Online: Yes

                Removable media: No

                Readonly: No

                Backing store type: null

                Backing store path: None

                Backing store flags:

            LUN: 1

                Type: passthrough

                SCSI ID: IET     00010001

                SCSI SN: beaf11

                Size: 0 MB, Block size: 1

                Online: Yes

                Removable media: No

                Readonly: No

                Backing store type: sg

                Backing store path: /dev/sg10

                Backing store flags:

            LUN: 2

                Type: passthrough

                SCSI ID: IET     00010002

                SCSI SN: beaf12

                Size: 0 MB, Block size: 1

                Online: Yes

                Removable media: No

                Readonly: No

                Backing store type: sg

                Backing store path: /dev/sg2

                Backing store flags:

            LUN: 3

                Type: passthrough

                SCSI ID: IET     00010003

                SCSI SN: beaf13

                Size: 0 MB, Block size: 1

                Online: Yes

                Removable media: No

                Readonly: No

                Backing store type: sg

                Backing store path: /dev/sg3

                Backing store flags:

            LUN: 4

                Type: passthrough

                SCSI ID: IET     00010004

                SCSI SN: beaf14

                Size: 0 MB, Block size: 1

                Online: Yes

                Removable media: No

                Readonly: No

                Backing store type: sg

                Backing store path: /dev/sg4

                Backing store flags:

            LUN: 5

                Type: passthrough

                SCSI ID: IET     00010005

                SCSI SN: beaf15

                Size: 0 MB, Block size: 1

                Online: Yes

                Removable media: No

                Readonly: No

                Backing store type: sg

                Backing store path: /dev/sg5

                Backing store flags:

        Account information:

        ACL information:

            ALL

     配置完成。

     此次只是做了簡單的連線使用測試,使用的是0.18版本,目前已經有1.5版本,還有很多細節需要完善,以後再一一測試。




來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30186176/viewspace-2096560/,如需轉載,請註明出處,否則將追究法律責任。

相關文章