
[[email protected] ~]# ls /dev/agpgart lp0 sda5 tty22 tty48 usbmon0autofs lp1 sdb //这个是我们新加的 tty23 tty49 usbmon1block lp2 sg0 tty24 tty5 usbmon2bsg lp3 sg1 tty25 tty50 vcsbtrfs-control mapper sg2 tty26 tty51 vcs1bus mcelog shm tty27 tty52 vcs2cdrom mem snapshot tty28 tty53 vcs3char mqueue snd tty29 tty54 vcs4console net sr0 tty3 tty55 vcs5core network_latency stderr tty30 tty56 vcs6cpu network_throughput stdin tty31 tty57 vcsacpu_dma_latency null stdout tty32 tty58 vcsa13.配置磁盘,格式化
[[email protected] ~]# fdisk /dev/sdb欢迎使用 fdisk (util-linux 2.23.2)。更改将停留在内存中,直到您决定将更改写入磁盘。使用写入命令前请三思。Device does not contain a recognized partition table使用磁盘标识符 0xe5bb6879 创建新的 DOS 磁盘标签。命令(输入 m 获取帮助):nPartition type: p primary (0 primary,0 extended,4 free) e extendedSelect (default p): p分区号 (1-4,默认 1):起始 扇区 (2048-41943039,默认为 2048):将使用默认值 2048Last 扇区,+扇区 or +size{K,M,G} (2048-41943039,默认为 41943039):将使用默认值 41943039分区 1 已设置为 linux 类型,大小设为 20 GiB命令(输入 m 获取帮助):wThe partition table has been altered!Calling ioctl() to re-read partition table.正在同步磁盘。[[email protected] ~]# mkfs.xfs /dev/sdb1Meta-data=/dev/sdb1 isize=512 agcount=4,agsize=1310656 blks = sectsz=512 attr=2,projID32bit=1 = crc=1 finobt=0,sparse=0data = bsize=4096 blocks=5242624,imaxpct=25 = sunit=0 swIDth=0 blksnaming =version 2 bsize=4096 ascii-ci=0 ftype=1log =internal log bsize=4096 blocks=2560,version=2 = sectsz=512 sunit=0 blks,lazy-count=1realtime =none extsz=4096 blocks=0,rtextents=0 4.自动挂载并且查看挂载状态 [[email protected] HTML]# vim /etc/fstab
/etc/fstab Created by anaconda on Sat Aug 10 00:09:52 2019 Accessible filesystems,by reference,are maintained under ‘/dev/disk‘ See man pages fstab(5),findfs(8),mount(8) and/or blkID(8) for more infoUUID=6885a615-3022-4e62-8685-1dc9aaa0b657 / xfs defaults 0 0UUID=91d30663-7fe2-4989-9ad9-9f9c7086a493 /boot xfs defaults 0 0UUID=121c8f14-d41e-4da5-a3eb-f973cde89040 /home xfs defaults 0 0UUID=89bc11a2-b2cc-4816-9638-8f061beae396 swap swap defaults 0 0/dev/sdb1 /mnt xfs defaults 0 0设备目录 挂载点 文件类型 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ :wq //保存退出
[[email protected] ~]# mount -a[[email protected] ~]# df -hT文件系统 类型 容量 已用 可用 已用% 挂载点/dev/sda2 xfs 10G 3.9G 6.2G 39% /devtmpfs devtmpfs 898M 0 898M 0% /devtmpfs tmpfs 912M 0 912M 0% /dev/shmtmpfs tmpfs 912M 9.0M 903M 1% /runtmpfs tmpfs 912M 0 912M 0% /sys/fs/cgroup/dev/sda5 xfs 10G 37M 10G 1% /home/dev/sda1 xfs 6.0G 174M 5.9G 3% /boottmpfs tmpfs 183M 4.0K 183M 1% /run/user/42tmpfs tmpfs 183M 16K 183M 1% /run/user/0/dev/sdb1 xfs 20G 33M 20G 1% /mnt5.装NFS共享和远程调用工具包
[[email protected] ~]# yum install nfs-utils rpcbind -y //NFS共享和远程调用工具包已加载插件:fastestmirror,langpacksLoading mirror speeds from cached hostfile * base: mirrors.163.com * extras: centos.ustc.edu.cn * updates: mirrors.163.com正在解决依赖关系--> 正在检查事务---> 软件包 nfs-utils.x86_64.1.1.3.0-0.48.el7 将被 升级---> 软件包 nfs-utils.x86_64.1.1.3.0-0.61.el7 将被 更新---> 软件包 rpcbind.x86_64.0.0.2.0-42.el7 将被 升级---> 软件包 rpcbind.x86_64.0.0.2.0-47.el7 将被 更新6.编辑共享配置文件
[[email protected] ~]# vim /etc/exports //到共享配置文件中开始配置/mnt 192.168.17.0/24(rw,sync,no_root_squash) //可读可写,同步,不降级处理你共享出去的挂载点目录7.开启所有功能关闭防火墙,查看有没有被共享出去
[[email protected] ~]# systemctl start nfs //开启共享功能[[email protected] ~]# systemctl start rpcbind //开启远程调用[[email protected] ~]# netstat -ntap | grep rpc 查看TCP端口tcp 0 0 0.0.0.0:20048 0.0.0.0:* ListEN 3035/rpc.mountd tcp 0 0 0.0.0.0:45274 0.0.0.0:* ListEN 3033/rpc.statd tcp6 0 0 :::38508 :::* ListEN 3033/rpc.statd tcp6 0 0 :::20048 :::* ListEN 3035/rpc.mountd [[email protected] ~]# systemctl stop firewalld.service //关闭防火墙[[email protected] ~]# setenforce 0 //关闭增强功能[[email protected] ~]# showmount -e //查看我们有没有共享出去Export List for localhost.localdomain:/mnt 192.168.17.0/248.到客户段中,关闭所有功能,安装httpD服务
[[email protected] ~]# systemctl stop firewalld.service [[email protected] ~]# setenforce 0[[email protected] ~]# yum insatll httpd -y已加载插件:fastestmirror,langpacks9.把服务器的挂载点,挂载到我们httpD的站点下
[[email protected] ~]# mount 192.168.17.128:/mnt /var/www/HTML/ //站点[[email protected] ~]# df -hT文件系统 类型 容量 已用 可用 已用% 挂载点/dev/sda2 xfs 20G 4.5G 16G 23% /devtmpfs devtmpfs 898M 0 898M 0% /devtmpfs tmpfs 912M 0 912M 0% /dev/shmtmpfs tmpfs 912M 9.0M 903M 1% /runtmpfs tmpfs 912M 0 912M 0% /sys/fs/cgroup/dev/sda3 xfs 9.4G 37M 9.3G 1% /home/dev/sda1 xfs 5.6G 174M 5.5G 4% /boottmpfs tmpfs 183M 4.0K 183M 1% /run/user/42tmpfs tmpfs 183M 24K 183M 1% /run/user/0/dev/sr0 iso9660 4.3G 4.3G 0 100% /run/media/root/CentOS 7 x86_64192.168.17.128:/mnt nfs4 20G 32M 20G 1% /var/www/HTML10.使用另一种方法:自动挂载,配置
[[email protected] ~]# umount /var/www/HTML/ //先把之前的解挂[[email protected] ~]# df -hT文件系统 类型 容量 已用 可用 已用% 挂载点/dev/sda2 xfs 20G 4.5G 16G 23% /devtmpfs devtmpfs 898M 0 898M 0% /devtmpfs tmpfs 912M 0 912M 0% /dev/shmtmpfs tmpfs 912M 9.0M 903M 1% /runtmpfs tmpfs 912M 0 912M 0% /sys/fs/cgroup/dev/sda3 xfs 9.4G 37M 9.3G 1% /home/dev/sda1 xfs 5.6G 174M 5.5G 4% /boottmpfs tmpfs 183M 4.0K 183M 1% /run/user/42tmpfs tmpfs 183M 24K 183M 1% /run/user/0/dev/sr0 iso9660 4.3G 4.3G 0 100% /run/media/root/CentOS 7 x86_64[[email protected] ~]# vim /etc/fstab
/etc/fstabCreated by anaconda on Fri Aug 9 19:16:53 2019 Accessible filesystems,mount(8) and/or blkID(8) for more infoUUID=0857ae22-72c1-4ad4-bd8d-333df1d5c1a4 / xfs defaults 0 0UUID=2d335fb0-e4af-4a90-8777-1ce16ac58065 /boot xfs defaults 0 0UUID=d28abede-d7a4-439a-b830-64f95069ec17 /home xfs defaults 0 0UUID=1bc36e2d-3ba8-4980-9bf8-7b56280bb434 swap swap defaults 0 0192.168.17.128:/mnt /var/www/HTML nfs defaults,_netdev 0 0 [[email protected] ~]# mount -a[[email protected] ~]# df -hT文件系统 类型 容量 已用 可用 已用% 挂载点/dev/sda2 xfs 20G 4.5G 16G 23% /devtmpfs devtmpfs 898M 0 898M 0% /devtmpfs tmpfs 912M 0 912M 0% /dev/shmtmpfs tmpfs 912M 9.0M 903M 1% /runtmpfs tmpfs 912M 0 912M 0% /sys/fs/cgroup/dev/sda3 xfs 9.4G 37M 9.3G 1% /home/dev/sda1 xfs 5.6G 174M 5.5G 4% /boottmpfs tmpfs 183M 4.0K 183M 1% /run/user/42tmpfs tmpfs 183M 24K 183M 1% /run/user/0/dev/sr0 iso9660 4.3G 4.3G 0 100% /run/media/root/CentOS 7 x86_64192.168.17.128:/mnt nfs4 20G 32M 20G 1% /var/www/HTML11.在站点中写一个网页,并开启httpD服务
[[email protected] ~]# cd /var/www/HTML/[[email protected] HTML]# ls[[email protected] HTML]# vim index.HTMLh1>this is nfs</h1>~ ~ [[email protected] HTML]# cat index.HTML <h1>this is nfs</h1>[[email protected] HTML]# systemctl start httpd12.我们登录网站试一下(客户端的IP地址) 以上就是我们NFS共享存储的所有内容了 总结
以上是内存溢出为你收集整理的Linux Centos7 --- nfs共享存储空间全部内容,希望文章能够帮你解决Linux Centos7 --- nfs共享存储空间所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)