linux下通过mount挂载iscsi ntfs nfs详解

本文发布时间: 2019-Mar-22
通常服务器本机自带磁盘空间有限,都需要额外加载磁盘,可以采用mount方式把远程的共享存储磁盘加载进来,目前用过的有iscsi、ntfs、nfs三种类型一,mount挂载iscsi类型1,查找下准备挂载的磁盘或者存储器[root@localhost /]# iscsiadm -m discovery -t st -p 1x.xx.0.22:32601x.xx.0.22:3260,1 iqn.2001-05.com.equallogic:0-8a0906-6dac38009-c1b1cac2d434efec-pddata1x.xx.0.22:3260,1 iqn.2001-05.com.equallogic:0-8a0906-4061f7f09-29d248cfaed54b9d-daxxxx[root@localhost /]#[root@localhost ~]# iscsiadm -m iqn.2001-05.com.equallogic:0-8a0906-4061f7f09-29d248cfaed54b9d-daxxxx -T /daxxxx -p 1x.xx.0.22:3260 -lTry `iscsiadm --help' for more information.[root@localhost ~]# iscsiadm --helpiscsiadm -m discoverydb [ -hV ] [ -d debug_level ] [-P printlevel] [ -t type -p ip:port -I ifaceN ... [ -Dl ] ] | [ [ -p ip:port -t type] [ -o operation ] [ -n name ] [ -v value ] [ -lD ] ]iscsiadm -m discovery [ -hV ] [ -d debug_level ] [-P printlevel] [ -t type -p ip:port -I ifaceN ... [ -l ] ] | [ [ -p ip:port ] [ -l | -D ] ]iscsiadm -m node [ -hV ] [ -d debug_level ] [ -P printlevel ] [ -L all,manual,automatic ] [ -U all,manual,automatic ] [ -S ] [ [ -T targetname -p ip:port -I ifaceN ] [ -l | -u | -R | -s] ] [ [ -o operation ] [ -n name ] [ -v value ] ]iscsiadm -m session [ -hV ] [ -d debug_level ] [ -P printlevel] [ -r sessionid | sysfsdir [ -R | -u | -s ] [ -o operation ] [ -n name ] [ -v value ] ]iscsiadm -m iface [ -hV ] [ -d debug_level ] [ -P printlevel ] [ -I ifacename | -H hostno|MAC ] [ [ -o operation ] [ -n name ] [ -v value ] ] [ -C ping [ -a ip ] [ -b packetsize ] [ -c count ] [ -i interval ] ]iscsiadm -m fw [ -l ]iscsiadm -m host [ -P printlevel ] [ -H hostno|MAC ] [ [ -C chap [ -o operation ] [ -v chap_tbl_idx ] ] | [ -C flashnode [ -o operation ] [ -A portal_type ] [ -x flashnode_idx ] [ -n name ] [ -v value ] ] ]iscsiadm -k priority[root@localhost ~]#默认情况下,iscsi发起方和目标方之间通过端口3260连接。假设已知iscsi的目标方IP是192.xxx.1.1,运行下列命令:iscsiadm -m node -T iqn.2001-05.com.equallogic:0-8a0906-4061f7f09-29d248cfaed54b9d-daxxxx -p 1x.xx.0.22:3260 -l如果要在系统启动时自动登入iscsiadm -m node –T iqn.1997-05.com.test:raid -p 192.xxx.1.1:3260 --op update -n node.startup -v automatic2,登录节点[root@localhost ~]# iscsiadm -m node -T iqn.2001-05.com.equallogic:0-8a0906-4061f7f09-29d248cfaed54b9d-daxxxx -p 1x.xx.0.22:3260 -lLogging in to [iface: iscsi_eth0, target: iqn.2001-05.com.equallogic:0-8a0906-4061f7f09-29d248cfaed54b9d-daxxxx, portal: 1x.xx.0.22,3260] (multiple)Login to [iface: iscsi_eth0, target: iqn.2001-05.com.equallogic:0-8a0906-4061f7f09-29d248cfaed54b9d-daxxxx, portal: 1x.xx.0.22,3260] successful.[root@localhost ~]#3,运行fdisk -l查看节点,如下所示。[root@localhost ~]# fdisk -lWARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util fdisk doesn't support GPT. Use GNU Parted.Disk /dev/sda: 146.0 GB, 145999527936 bytes255 heads, 63 sectors/track, 17750 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000Device Boot Start End Blocks Id System/dev/sda1 1 17751 142577663+ ee GPTDisk /dev/mapper/VolGroup-lv_root: 53.7 GB, 53687091200 bytes255 heads, 63 sectors/track, 6527 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000Disk /dev/mapper/VolGroup-lv_swap: 9487 MB, 9487515648 bytes255 heads, 63 sectors/track, 1153 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000Disk /dev/mapper/VolGroup-lv_home: 82.1 GB, 82086723584 bytes255 heads, 63 sectors/track, 9979 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000Disk /dev/sdb: 1099.5 GB, 1099526307840 bytes255 heads, 63 sectors/track, 133676 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0xcb8879dbDevice Boot Start End Blocks Id System/dev/sdb1 1 133676 1073752438+ 83 LinuxDisk /dev/sdc: 1099.5 GB, 1099526307840 bytes255 heads, 63 sectors/track, 133676 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000[root@localhost ~]#可以看到新挂载的Disk /dev/sdc: 1099.5 GB, 1099526307840 bytes4,登入需验证码的节点:开启认证iscsiadm -m node -T iqn.2001-05.com.equallogic:0-8a0906-4061f7f09-29d248cfaed54b9d-daxxxx -o update -name node.session.auth.authmethod -value=CHAP*.使用-o同--op5,格式化设备[root@localhost baimo]# mount /dev/sdc /daxxxxmount: you must specify the filesystem type[root@localhost baimo]#查看原有的磁盘文件系统格式:[root@localhost ~]# df -T文件系统 类型 1K-块 已用 可用 已用% 挂载点/dev/mapper/VolGroup-lv_rootext4 51606140 30446060 18538640 63% /tmpfs tmpfs 9261428 3099716 6161712 34% /dev/shm/dev/sda2 ext4 495844 77683 392561 17% /boot/dev/sda1 vfat 204580 260 204320 1% /boot/efi/dev/mapper/VolGroup-lv_homeext4 78904232 72142868 2753224 97% /home/dev/sdb1 ext4 1056902612 730470180 272744812 73% /data[root@localhost ~]#看到为ext4格式,如欲将设备格式化为ext4文件系统,运行# mkfs.ext4 /dev/sdc,如下所示:[root@localhost ~]# mkfs.ext4 /dev/sdcmke2fs 1.41.12 (17-May-2010)/dev/sdc is entire device, not just one partition!无论如何也要继续? (y,n) yDiscarding device blocks: failed - 输入/输出错误文件系统标签=操作系统:Linux块大小=4096 (log=2)分块大小=4096 (log=2)Stride=0 blocks, Stripe width=0 blocks67117056 inodes, 268439040 blocks13421952 blocks (5.00%) reserved for the super user第一个数据块=0Maximum filesystem blocks=42949672968193 block groups32768 blocks per group, 32768 fragments per group8192 inodes per groupSuperblock backups stored on blocks:32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,102400000, 2149908486,开始挂接设备在/mnt下创建iscsi目录mkdir -p /daxxxx运行mount命令:# mount -t /dev/sdc /daxxxx针对iscsi设备的特殊mount选项,运行df –h可以看到/daxxxx目录:[root@localhost ~]# mount /dev/sdc /daxxxx[root@localhost ~]# df -h文件系统 容量 已用 可用 已用%% 挂载点/dev/mapper/VolGroup-lv_root50G 30G 18G 63% /tmpfs 8.9G 3.0G 5.9G 34% /dev/shm/dev/sda2 485M 76M 384M 17% /boot/dev/sda1 200M 260K 200M 1% /boot/efi/dev/sdc 1008G 200M 957G 1% /daxxxx[root@localhost ~]#看到,iscsi设备被成功挂接,可以当作常规存储设备使用了。如果要在系统启动时自动挂接编辑/etc/fstab加入一行:/dev/sdc /daxxxx ext4 default 0 07,登出节点首先解除挂接#umount /mnt/iscsi登出# iscsiadm -m node –T iqn.2001-05.com.equallogic:0-8a0906-4061f7f09-29d248cfaed54b9d-daxxxx -p 1x.xx.0.22:3260 –u8,报错问题记录ifconfig eth0 192.xxx.0.1 netmask 255.255.255.0 up[root@localhost ~]# iscsiadm -m discovery -t st -p 1x.xx.0.22:3260iscsiadm: connect to 1x.xx.0.22 timed outiscsiadm: connect to 1x.xx.0.22 timed outiscsiadm: connect to 1x.xx.0.22 timed out^Ciscsiadm: caught SIGINT, exiting...[root@localhost ~]#报错,去check下看是否可以ping通[root@localhost /]# ping 1x.xx.0.22PING 1x.xx.0.22 (1x.xx.0.22) 56(84) bytes of data.^C--- 1x.xx.0.22 ping statistics ---172 packets transmitted, 0 received, 100% packet loss, time 171475ms[root@localhost /]#去查看网络配置[root@localhost /]# ifconfigeth0 Link encap:Ethernet HWaddr 5C:F3:FC:1B:73:B4inet6 addr: fe80::5ef3:fcff:fe1b:73b4/64 Scope:LinkUP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1RX packets:27910750 errors:0 dropped:243 overruns:0 frame:0TX packets:4909669 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1000RX bytes:2068014537 (1.9 GiB) TX bytes:409283724 (390.3 MiB)eth3 Link encap:Ethernet HWaddr 5C:F3:FC:1B:73:B6inet addr:192.xxx.1xx.107 Bcast:192.xxx.1xx.255 Mask:255.255.255.0inet6 addr: fe80::5ef3:fcff:fe1b:73b6/64 Scope:LinkUP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1RX packets:37927936 errors:0 dropped:1563 overruns:0 frame:0TX packets:41504235 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1000RX bytes:21039621446 (19.5 GiB) TX bytes:34187439193 (31.8 GiB)lo Link encap:Local Loopback原来eth0的网络ip没有配置,只配置了eth3的,所以需要ifconfg一下[root@localhost /]# ifconfig eth0 1x.xx.0.107 netmask 255.255.255.0[root@localhost /]# ifconfigeth0 Link encap:Ethernet HWaddr 5C:F3:FC:1B:73:B4inet addr:1x.xx.0.107 Bcast:1x.xx.0.255 Mask:255.255.255.0inet6 addr: fe80::5ef3:fcff:fe1b:73b4/64 Scope:LinkUP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1RX packets:27913798 errors:0 dropped:243 overruns:0 frame:0TX packets:4910226 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1000RX bytes:2068233906 (1.9 GiB) TX bytes:409330163 (390.3 MiB)eth3 Link encap:Ethernet HWaddr 5C:F3:FC:1B:73:B6inet addr:192.xxx.1xx.107 Bcast:192.xxx.1xx.255 Mask:255.255.255.0inet6 addr: fe80::5ef3:fcff:fe1b:73b6/64 Scope:LinkUP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1RX packets:38546864 errors:0 dropped:1563 overruns:0 frame:0TX packets:42148624 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1000RX bytes:21287430291 (19.8 GiB) TX bytes:34555423236 (32.1 GiB)查看到ifconfig已经正常,然后去ping下,已经正常。[root@localhost /]# ping 1x.xx.0.22PING 1x.xx.0.22 (1x.xx.0.22) 56(84) bytes of data.64 bytes from 1x.xx.0.22: icmp_seq=1 ttl=255 time=1.00 ms64 bytes from 1x.xx.0.22: icmp_seq=2 ttl=255 time=0.082 ms64 bytes from 1x.xx.0.22: icmp_seq=3 ttl=255 time=0.150 ms^C--- 1x.xx.0.22 ping statistics ---3 packets transmitted, 3 received, 0% packet loss, time 2334msrtt min/avg/max/mdev = 0.082/0.411/1.003/0.419 ms[root@localhost /]#二,mount挂载ntfs类型1,安装软件Fuse以及Ntfs-3g从http://fuse.sourceforge.net上下载源代码wget http://easynews.dl.sourceforge.net/sourceforge/fuse/fuse-2.7.1.tar.gz解压缩源代码:tar zxf fuse-2.7.1.tar.gz编译和安装fuse源代码cd fuse-2.7.1./configure --exec-prefix=/; make; make installNtfs-3g安装从网站http://www.tuxera.com/community/ntfs-3g-download/上下载源代码包:wget http://tuxera.com/opensource/ntfs-3g_ntfsprogs-2011.4.12.tgz解压缩安装:tar zxf ntfs-3g_ntfsprogs-2011.4.12.tgz编译和安装ntfs-3g源代码。cd ntfs-3g_ntfsprogs-2011.4.12./configuremakemake install2,挂载如果在安装过程中没有出现错误,NTFS卷可以mount到Linux上,并且具有读写权限。fdisk -l | grep NTFS(/dev/sdb1 2 62016256 1953512032+ 7 HPFS/NTFS)mount -t ntfs-3g /dev/sdb1 /data/oracle三,mount挂载nfs磁盘类似1,在linux上安装nfs软件yum -y install nfs-utils portmayum install nfs -y/etc/rc.d/init.d/nfs status/etc/rc.d/init.d/nfs start|stop|restart2,挂载windows的共享磁盘先测试下挂载的服务器showmount -e 192.168.1.225再进行挂载操作mount -o username=administrator //1xx.xx.180.252/backdate/baimo /home/baimo3,挂载linux下的共享磁盘mount -t nfs 1xx.xx.0.231:/nfs/frank /mnt/oracle4,挂载USB移动硬盘:mount -t ntfs /dev/sdc1 /root/usb5,解除挂载umount /mnt/oracle原博客地址: http://blog.itpub.net/26230597/viewspace-1413077/原作者:黄杉 (mchdba)


(以上内容不代表本站观点。)
---------------------------------
本网站以及域名有仲裁协议。
本網站以及域名有仲裁協議。

2024-Mar-04 02:09pm
栏目列表