鲲鹏社区首页
中文
注册
开发者
我要评分
获取效率
正确性
完整性
易理解
在线提单
论坛求助

环境配置

本节以三个Server和三个Client为例说明环境配置步骤。

  1. 在各节点上分别配置节点名称。
    1
    2
    3
    4
    5
    6
    hostnamectl set-hostname ceph1
    hostnamectl set-hostname ceph2
    hostnamectl set-hostname ceph3
    hostnamectl set-hostname client1
    hostnamectl set-hostname client2
    hostnamectl set-hostname client3
    
  2. 在ceph1~ceph3节点上配置机器名称解析。
    1. 执行以下命令打开文件。
      1
      vim /etc/hosts
      
    2. “i”键进入编辑模式,在文件中加入以下内容。
      1
      2
      3
      4
      5
      6
      192.168.3.166 ceph1
      192.168.3.167 ceph2
      192.168.3.168 ceph3
      192.168.3.160 client1
      192.168.3.161 client2
      192.168.3.162 client3
      
      • 命令中的IP地址为环境组网中所规划的IP地址,仅为示例,请根据实际情况进行修改。可通过ip a命令查询实际IP地址。
      • 本文规划集群为三台服务端节点和三台客户端节点,请根据实际节点数量对文件内容进行调整。
    3. “Esc”键退出编辑模式,输入:wq!并按“Enter”键保存退出文件。
  3. 配置免密登录,在ceph1/ceph2/ceph3三个节点上分别执行如下命令。
    1
    2
    ssh-keygen -t rsa 
    for i in {1..3};do ssh-copy-id ceph$i;done
    
  4. 关闭防火墙。
    1
    2
    3
    systemctl stop firewalld
    systemctl disable firewalld
    systemctl status firewalld
    
    • 仅在可信内网或离线测试环境中关闭防火墙。
    • 生产环境必须启用防火墙,并精确放行所需的端口,如MON的端口为6789,OSD的端口为6800-7300等。
  5. 关闭SELinux。
    1
    2
    setenforce 0
    sed -i 's/=permissive/=disabled/g' /etc/selinux/config
    
    • 禁用SELinux将导致系统强制访问控制(MAC)机制失效,建议仅在测试环境中禁用SELinux。
    • 生产环境应保持enforcing模式,并通过audit2allow工具生成适配业务的自定义策略。
  6. 在ceph1/ceph2/ceph3节点上配置时钟同步。
    1. 安装Chrony服务。
      1
      dnf install -y chrony
      
    2. 备份配置文件。
      1
      mv /etc/chrony.conf /etc/chrony.conf.bak
      
    3. 修改配置文件。
      1
      2
      3
      4
      5
      cat > /etc/chrony.conf <<EOF
      server [IP1] iburst
      allow [IP/MASK]
      local stratum 10
      EOF
      
      • [IP1]为提供时钟服务的服务器在网络中的IP地址或域名,如:192.168.3.166。
      • [IP/MASK] 是本地网络的IP地址范围,如:192.168.1.0/24,表示只有这个子网的机器才能与服务器进行时钟同步。
    4. 重启chronyd。
      1
      2
      systemctl restart chronyd
      systemctl enable chronyd
      
    5. 查看时间同步状态。
      1
      2
      3
      chronyc -a makestep  #强制同步系统时间
      chronyc sourcestats   #显示当前时间源的同步统计信息
      chronyc sources -v    #显示当前时间源的同步信息