Centos8.3 nfs-ganesha使用GlusterFS后端

本文介绍了如何在Centos8.3系统上利用GlusterFS作为后端,部署和配置nfs-ganesha服务,包括安装相关包、配置ganesha、启动服务并设置开机启动,以及在客户端部署nfs-utils并进行挂载操作。

在任意一台GlusterFS节点部署nfs-ganesha相关包

dnf install centos-release-nfs-ganesha30 -y
dnf install nfs-ganesha-gluster -y

配置ganesha

cat /etc/ganesha/ganesha.conf
EXPORT{
    Export_Id = 1 ;   # Export ID unique to each export
    Path = "/gv0";  # Path of the volume to be exported. Eg: "/test_volume"

    FSAL {
        name = GLUSTER;
        hostname = "${ip}"; #one of the nodes in the trusted pool
        volume = "gv0";  # Volume name. Eg: "test_volume"
    }

    Access_type = RW;    # Access permissions
    Squash = No_root_squash; # To enable/disable root squashing
    Disable_ACL = TRUE;  # To enable/disable ACL
    Pseudo = "/gv0_pseudo";  # NFSv4 pseudo path for this export. Eg: "/test_volume_pseudo"
    Protocols = "3","4" ;    # NFS protocols supported
    Transports = "UDP","TCP" ; # Transport protocols supported
    SecType = "sys";     # Security flavors supported
}

启动nfs-ganesha并设置开机自启动

systemctl
你现在的输出显示: ``` Could not retrieve mirrorlist http://mirrorlist.centos.org?arch=x86_64&release=7&repo=storage-nfs-ganesha-28 ... repolist: 0 ``` 并且所有仓库的 `status` 都是 **0**,说明 **YUM 根本没有成功加载任何软件包元数据**。 --- ## 🔍 问题定位 虽然你已经使用了阿里云镜像(如 `mirrors.aliyun.com`),但系统中仍然启用了多个 **已失效的 CentOS Special Interest Group (SIG) 源**,包括: - `centos-nfs-ganesha28/7/x86_64` - `centos-qemu-ev/7/x86_64` 这些源来自以下 `.repo` 文件: - `/etc/yum.repos.d/CentOS-Storage.repo` - `/etc/yum.repos.d/CentOS-Virt.repo` 它们试图通过 `http://mirrorlist.centos.org` 获取镜像列表,而这个域名服务在 **CentOS 7 EOL 后已彻底关闭**,所以 DNS 解析失败(`Could not resolve host`)。 即使你用了阿里云的基础源,只要这些“坏源”还存在并启用,`yum makecache` 就会尝试连接它们 → 超时或失败 → 导致整体命令中断。 --- ## ✅ 终极解决方案:禁用或删除所有失效的 SIG 源 ### ✅ 步骤 1:确认并删除问题 `.repo` 文件 ```bash # 查看是否有 Storage 和 Virt 相关源 ls /etc/yum.repos.d/CentOS-{Storage,Virt}*.repo ``` 你应该会看到类似: ``` CentOS-Storage.repo CentOS-Virt.repo ``` > ⚠️ 这两个文件就是罪魁祸首! #### 删除它们: ```bash sudo rm -f /etc/yum.repos.d/CentOS-Storage.repo sudo rm -f /etc/yum.repos.d/CentOS-Virt.repo ``` > 💡 提示:`nfs-ganesha` 和 `qemu-ev` 都是由这两个文件引入的。 --- ### ✅ 步骤 2:确保基础源为阿里云版本 检查是否已替换为阿里云的 `CentOS-Base.repo`: ```bash cat /etc/yum.repos.d/CentOS-Base.repo | grep baseurl ``` ✅ 正确输出应包含: ``` baseurl=http://mirrors.aliyun.com/centos/7/os/$basearch/ ``` ❌ 如果还是 `mirrorlist=` 或指向 `mirror.centos.org`,必须更换! #### 更换为阿里云源: ```bash # 备份原文件 sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup # 下载阿里云版本 sudo curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo ``` --- ### ✅ 步骤 3:更新 EPEL 源也为阿里云版本(避免同样问题) ```bash # 安装 epel-release(如果还没装) sudo yum install -y epel-release # 替换为阿里云 EPEL 源 sudo curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo ``` --- ### ✅ 步骤 4:彻底清理缓存 ```bash # 清除所有 yum 缓存 sudo yum clean all # 强制删除缓存目录(关键!) sudo rm -rf /var/cache/yum/* ``` > 📌 注意:有些系统有多个缓存目录,比如: > > - `/var/cache/yum/x86_64/7/base` > - `/var/cache/yum/x86_64/7/updates` > - `/var/cache/yum/x86_64/7/epel` > > 全部删掉最保险。 --- ### ✅ 步骤 5:重建元数据缓存 ```bash sudo yum makecache ``` ✅ 成功标志是出现: ``` Metadata Cache Created ``` 并且过程不再报错。 --- ### ✅ 步骤 6:验证当前启用的仓库 ```bash yum repolist enabled ``` 你应该只看到如下正常的仓库: ``` repo id repo name base CentOS-7 - Base - mirrors.aliyun.com extras CentOS-7 - Extras - mirrors.aliyun.com updates CentOS-7 - Updates - mirrors.aliyun.com epel Extra Packages for Enterprise Linux 7 - x86_64 ``` 而 `centos-nfs-ganesha28`、`centos-qemu-ev` 等 **不应再出现**。 --- ## 🛠️ 补充建议:如何防止未来再出问题? | 建议 | 操作 | |------|------| | ❌ 不要随意安装 `centos-release-*` 包 | 如 `yum install centos-release-storage` 会自动添加死亡源 | | ✅ 手动管理 `.repo` 文件 | 只保留必要的源 | | ✅ 使用 `yum-config-manager --disable` 禁用而非删除(可逆) | | #### 示例:临时禁用某个源(替代删除) ```bash # 禁用 NFS Ganesha 源 sudo yum-config-manager --disable centos-nfs-ganesha28 # 禁用 QEMU-EV 源 sudo yum-config-manager --disable centos-qemu-ev ``` 这样不会删除文件,但让 YUM 忽略它。 --- ## ✅ 最终验证脚本(一键测试) ```bash echo "=== 当前启用的仓库 ===" yum repolist enabled echo -e "\n=== 测试列出可用软件包 ===" yum list available | head -5 echo -e "\n✅ 如果无错误且能列出包,则 YUM 已恢复正常!" ``` ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值