mysql iscsi_iscsi服务配置(NAS)

环境介绍

server:192.168.0.91(scsi服务器)

client: 192.168.0.191

Server端将本地的一个分区(最好是格式化好的,但不要挂载)、lvm、整个硬盘共享出去

Client端将server共享出来的设备导入到本地,进行正常的分区、格式化、挂载,就像使用本地端硬盘一样

Server配置(192.168.0.91)

1.安装rpm包

yum -y install scsi*

查看具体的rpm包端包名

[root@desktop91 ~]# rpm -qa | grep scsi

lsscsi-0.23-2.el6.x86_64

iscsi-initiator-utils-6.2.0.873-2.el6.x86_64

scsi-target-utils-1.0.24-2.el6.x86_64

根据具体的包名,查看安装出来的命令和配置文件

[root@desktop91 ~]# rpm -ql scsi-target-utils

/etc/rc.d/init.d/tgtd

/etc/sysconfig/tgtd

/etc/tgt/targets.conf

/usr/sbin/tgt-admin

/usr/sbin/tgt-setup-lun

/usr/sbin/tgtadm

/usr/sbin/tgtd

/usr/sbin/tgtimg

/usr/share/doc/scsi-target-utils-1.0.24

/usr/share/doc/scsi-target-utils-1.0.24/README

/usr/share/doc/scsi-target-utils-1.0.24/README.iscsi

/usr/share/doc/scsi-target-utils-1.0.24/README.iser

/usr/share/doc/scsi-target-utils-1.0.24/README.lu_configuration

/usr/share/doc/scsi-target-utils-1.0.24/README.mmc

/usr/share/man/man5/targets.conf.5.gz

/usr/share/man/man8/tgt-admin.8.gz

/usr/share/man/man8/tgt-setup-lun.8.gz

/usr/share/man/man8/tgtadm.8.gz

2.修改主配置文件

[root@desktop91 ~]# vim /etc/tgt/targets.conf

38 #39 #    backing-store /dev/LVM/somedevice

40 #

找到该文件的38行(大概),复制该3行的内容进行修改

38 #39 #    backing-store /dev/sda6      //此处是server提前化好的分区,注意:此处的backing-store配置项是真对lvm、分区进行使用的,如果是整个硬盘就使用 direct-store配置项(可以参考配置文件中模板,进行修改)

incominguser user uplooking  //此配置项的作用是client导入时需要进行验证的,否则导入失败,imcominguser 是配置项,user是用户、uplooking是密码

initiator-address 192.168.0.91 //此项是允许该client端进行使用该共享服务器端资源,除此IP之外其他的都拒绝。

40 #

注意:如果此处设备的配置项用的是整个硬盘的配置项,会报以下错误

[root@desktop91 ~]# bash /etc/init.d/tgtd start

Starting SCSI target daemon:                               [  OK  ]

Both SCSI INQUIRY and fetching ATA information failed on /dev/sda6

inquiry: pass through os error: Inappropriate ioctl for device

inquiry: failed, res=-1

READ CAPACITY (16) failed [res=-1], try with '-v'

3.启动服务

注意:该服务启动脚本中用shell是sh,所以在启动该服务时一定要用bash,否则会报错

[root@desktop91 ~]# /etc/init.d/tgtd start

Starting SCSI target daemon:                               [FAILED]

[root@desktop91 ~]# bash /etc/init.d/tgtd start

Starting SCSI target daemon:                               [  OK  ]

Client配置(192.168.0.191)

1.安装rpm包

[root@server91 ~]# yum -y install iscsi*

找到具体端rpm包端包名

[root@server91 ~]# rpm -qa | grep iscsi

iscsi-initiator-utils-6.2.0.872-41.el6.x86_64

iscsi-initiator-utils-devel-6.2.0.872-41.el6.x86_64

根据具体的包名,查看安装出来的命令和配置文件

[root@server91 ~]# rpm -ql iscsi-initiator

package iscsi-initiator is not installed

[root@server91 ~]# rpm -ql iscsi-initiator-utils

/etc/NetworkManager

/etc/NetworkManager/dispatcher.d

/etc/NetworkManager/dispatcher.d/04-iscsi

/etc/iscsi

/etc/iscsi/iscsid.conf

/etc/logrotate.d/iscsiuiolog

/etc/rc.d/init.d/iscsi

/etc/rc.d/init.d/iscsid

/sbin/brcm_iscsiuio

/sbin/iscsi-iname

/sbin/iscsiadm

/sbin/iscsid

/sbin/iscsistart

/sbin/iscsiuio

/usr/lib64/libiscsi.so.0

/usr/lib64/python2.6/site-packages/libiscsimodule.so

/usr/share/doc/iscsi-initiator-utils-6.2.0.872

/usr/share/doc/iscsi-initiator-utils-6.2.0.872/README

/usr/share/man/man8/iscsi-iname.8.gz

/usr/share/man/man8/iscsiadm.8.gz

/usr/share/man/man8/iscsid.8.gz

/usr/share/man/man8/iscsistart.8.gz

/usr/share/man/man8/iscsiuio.8.gz

/var/lib/iscsi

/var/lib/iscsi/ifaces

/var/lib/iscsi/isns

/var/lib/iscsi/nodes

/var/lib/iscsi/send_targets

/var/lib/iscsi/slp

/var/lib/iscsi/static

/var/lock/iscsi

2.在client的配置文件中输入用验证端用户名和密码

[root@server91 ~]# vi /etc/iscsi/iscsid.conf

53 node.session.auth.authmethod = CHAP //打开此处要认证的方式

54

55 # To set a CHAP username and password for initiator

56 # authentication by the target(s), uncomment the following lines:

57 node.session.auth.username = user  //要认证端用户名

58 node.session.auth.password = uplooking  //要认证端密码

59

60 # To set a CHAP username and password for target(s)

61 # authentication by the initiator, uncomment the following lines:

62 #node.session.auth.username_in = username_in

63 #node.session.auth.password_in = password_in

64

65 # To enable CHAP authentication for a discovery session to the target

66 # set discovery.sendtargets.auth.authmethod to CHAP. The default is None.

67 #discovery.sendtargets.auth.authmethod = CHAP

68

69 # To set a discovery session CHAP username and password for the initiator

70 # authentication by the target(s), uncomment the following lines:

71 discovery.sendtargets.auth.username = user   //发现需要认证的用户名

72 discovery.sendtargets.auth.password = uplooking //发现需要认证端密码

3.发现设备

[root@server91 ~]# iscsiadm  -m discovery -t st -p 192.168.0.91

Starting iscsid:                                           [  OK  ]

192.168.0.91:3260,1 iqn.2013-10.com.example:redhat.target3

4.导入设备

[root@server91 ~]# iscsiadm  -m node -T iqn.2013-10.com.example:redhat.target3 -p 192.168.0.91 -l

Logging in to [iface: default, target: iqn.2013-10.com.example:redhat.target3, portal: 192.168.0.91,3260] (multiple)

Login to [iface: default, target: iqn.2013-10.com.example:redhat.target3, portal: 192.168.0.91,3260] successful.

5.进行正常的分区、格式化、挂载、正常的使用

[root@server91 ~]# fdisk /dev/sda

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier 0x10907c53.

Changes will remain in memory only, until you decide to write them.

After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to

switch off the mode (command 'c') and change display units to

sectors (command 'u').

Command (m for help): p

Disk /dev/sda: 10.7 GB, 10742183424 bytes

64 heads, 32 sectors/track, 10244 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

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

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

Disk identifier: 0x10907c53

Device Boot      Start         End      Blocks   Id  System

Command (m for help): n

Command action

e   extended

p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-10244, default 1):

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-10244, default 10244):

Using default value 10244

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

[root@server91 ~]# ls /dev/sda

sda   sda1

[root@server91 ~]# mkfs.ext4 /dev/sda1

mke2fs 1.41.12 (17-May-2010)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks

655776 inodes, 2622460 blocks

131123 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=2688548864

81 block groups

32768 blocks per group, 32768 fragments per group

8096 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Writing inode tables: done

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 35 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@server91 ~]# mount /dev/sda1 /mnt

[root@server91 ~]#

[root@server91 ~]#

[root@server91 ~]# cd /mnt/

[root@server91 mnt]#

[root@server91 mnt]#

[root@server91 mnt]# ls

lost+found

[root@server91 mnt]# echo 1234 > file1

[root@server91 ~]# ls -ld /mnt/file1

-rw-r--r--. 1 root root 5 Oct 20 04:24 /mnt/file1

阅读(3293) | 评论(0) | 转发(0) |

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值