首页 技术 正文
技术 2022年11月15日
0 收藏 322 点赞 4,162 浏览 1853 个字

NFS 即network file system

可用于向k8s集群提供持久存储

最小化安装centos后  把网卡设置好了后

1.关闭防火墙

[root@NFS ~]# systemctl stop firewalld
[root@NFS ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@NFS ~]# firewall-cmd --state
not running

2.关闭 selinux

[root@NFS ~]#  setenforce
[root@NFS ~]# sed -i 's/^ *SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

重启后生效

[root@NFS ~]# reboot
[root@NFS ~]# sestatus
SELinux status: disabled

3.yum安装 配置 nfs服务端

yum update一下再安装

yum -y install  nfs-utils

配置 任意ip可以以root的权限对/k8s文件夹进行读写

[root@NFS ~]# cat /etc/exports
/k8s *(rw,sync,no_root_squash)
#创建一个k8s目录
[root@NFS ~]# mkdir /k8s
#给权限
[root@NFS /]# chmod 777 /k8s

设置开机自启 并启动

[root@NFS /]# systemctl enable rpcbind
[root@NFS /]# systemctl enable nfs-server
Created symlink from /etc/systemd/system/multi-user.target.wants/nfs-server.service to /usr/lib/systemd/system/nfs-server.service.
[root@NFS /]# systemctl start rpcbind
[root@NFS /]# systemctl start nfs-server

加载配置并查看

[root@NFS /]# exportfs -r
[root@NFS /]# exportfs
/k8s <world>

4.安装配置 nfs客户端,  在每个k8s节点上做.

yum安装

yum -y install nfs-utils

创建要挂载nfs的文件夹

mkdir /nfs

查看nfs   我的nfs服务端安装在192.168.1.250 上

[root@m1 ~]# showmount -e 192.168.1.250
Export list for 192.168.1.250:
/k8s *

挂载nfs 中的k8s目录到 /nfs

[root@m1 ~]# mount -t nfs 192.168.1.250:/k8s /nfs

自动挂载

[root@m1 ~]# cat /etc/rc.local
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.touch /var/lock/subsys/local
mount -t nfs 192.168.1.250:/k8s /nfs

给权限防止因为权限没有执行 除了root,其他用户的只有读和执行的权限

chmod  /etc/rc.local

测试

[root@m1 nfs]# vi hello
[root@m1 nfs]# ll
total
-rw-r--r--. root root Nov : hello

至此 nfs实践结束

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,028
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,518
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,365
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,146
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,780
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,857