# Lustre 分布式并行文件系统部署

#### 博客作者：联系请[点击](https://hezhiqiang.gitbook.io/about-the-author/lian-xi-zuo-zhe)，搬运不易，希望请作者喝咖啡，可以点击联系[博客作者](https://hezhiqiang.gitbook.io/about-the-author/lian-xi-zuo-zhe)

## 一、Lustre简介

Lustre 是一个具有高可用、高性能、可扩展的分布式并行文件系统。主要由 Manage Server、Meta Data Server 和 Data Server 组成。详细介绍可以参见 [Lustre 官网](http://lustre.org/) 。

#### 常用命令

* modprobe lustre：加载Lustre模块
* lustre\_rmmod：去除Lustre模块
* lctl：通过ioctl接口直接控制Lustre属性，允许调整相关的不同配置、管理和调试等属性。
  * lctl lustre\_build\_version：显示Lustre版本
  * lctl list\_nids：显示网络ID情况
  * lctl list\_param：显示配置参数
  * lctl dl：显示所有文件系统组件
* lnetctl：控制和显示网络信息
  * lnetctl net show：显示网络信息
  * lnetctl net add --net tcp0 --if eth0：添加网络
  * lnetctl net add --net tcp0 --if eth0：添加网络
  * lnetctl net del --net tcp0：删除网络
  * lnetctl route show：显示路由信息
* lfs：主要对与文件相关的属性进行配置及查询
  * lfs df：客户端上运行时，显示各MDT、OST等空间占用情况
  * lfs mdts /home：客户端上运行时，显示/home使用的MDT情况
  * lfs osts /home：客户端上运行时，显示/home使用的OST情况
* tunefs.lustre：在服务端运行，显示或调整mkfs.lustre生成的Lustre目标磁盘配置
  * tunefs.lustre /dev/mapper/mpathb：显示磁盘信息
  * tunefs.lustre --erase-params --param="failover.node=192.168.100.1\@tcp0:192.168.100.2\@tcp0" /dev/mapper/mpathb：修改配置
  * tunefs.lustre --writeconf /dev/mapper/mpathb：将修改后的配置写入
* 多挂载保护（Multiple-Mount Protection）
  * tune2fs -O mmp /dev/block\_device：禁止块设备同时被多个节点mount
  * tune2fs -O ^mmp /dev/block\_device：允许块设备同时被多个节点mount
* 强制卸载
  * umount -f /public ：系统无进程夯住，执行强制卸载命令
  * umount -f /home

#### 集群管理

这个命令必须在MGS上运行，查询Lustre文件系统中的所有节点

```
lctl get_param mgs.MGS.live.*
```

这个命令必须在MGS上运行，获取所有OST节点的名称和状态

```
lctl get_param lov.*-mdtlov.target_obd
```

`lctl dl`命令获取挂载的Lustre设备列表，并查看运行过程

```
lctl dl
```

在客户端查询挂载目录，获取所有OST节点的名称和状态

```
lfs osts /public
```

在客户端查询所有OST挂载情况及使用量

```
lfs df -h
```

在客户端或者MDT节点上激活运行完好，状态是 **INACTIVE** 的OST节点，通过`lctl dl` 命令获取设备号

```
lctl --device 7 activate
```

用`lctl deactivate`命令使完整的 OST 脱机停用

```
lctl --device 7 deactivate
```

**Lustre文件系统损坏，恢复操作**

参考文档

<https://www.cnblogs.com/zl-py/p/11274562.html>

第一步获取设备列表

```
lctl dl
```

第二步查看损坏OST节点的配置信息

```
lctl get_param osc.lustre-OST006a-osc-MDT0000.max_create_count
lctl get_param osc.lustre-OST006a-osc-MDT0000.active
```

第三步修改OST节点的配置信息，把active 和max\_create\_count的值都设置为0

```
lctl set_param osc.lustre-OST006a-osc-MDT0000.max_create_count=0
lctl conf_param lustre-OST006a-osc-MDT0000.active=0
lctl --device 11 deactivate
```

第四步再次查看状态由UP变为IN

```
lctl dl
```

第五步再将磁盘格式化为lustre格式

备注: --writeconf 必要参数，如果lustre版本是最新版的可以将--writeconf 替换为--replace

```
mkfs.lustre --fsname=lustre --reformat --ost --mgsnode=192.168.20.102@o2ib  --index=106 /dev/sdb1
```

第六步再次挂载ost

```
mount -t lustre  /dev/sdb1 /mnt/ost
```

第七步在mds节点上将active和max\_create\_count 恢复到原来的值

```
lctl set_param osc.lustre-OST006a-osc-MDT0000.max_create_count=20000
lctl conf_param lustre-OST006a-osc-MDT0000.active=1
lctl --device 11 activate
```

第八步在管理节点或者客户重新挂载即可

#### 网络检测（LNet）

```
lctl ping <nids>
列如：
```

测试连通性

```
lctl ping 192.168.20.102@o2ib
```

查询路由配置

```
lnetctl net show
```

## 二、Lustre 安装

`Lustre` 主要由 `MGS`、`MDS`、`OSS` 和 `Client` 组成

本次部署方案为：配置MGS， MDS为一台，9台 OSS 和36台 客户端 。

### 一、服务端软件安装

一、添加YUM仓库，在/etc/yum.repos.d/目录下创建 lustre.repo文件

**注意：设置YUM源,需要查询关于Lustre支持的内核列表，请参阅Lustre的**[**变动日志**](https://git.whamcloud.com/?p=fs/lustre-release.git;a=blob;f=lustre/ChangeLog)

**IB网络版YUM源**

```sh
vim /etc/yum.repos.d/lustre.repo 

[lustre-server]
name=lustre-server
baseurl=https://downloads.whamcloud.com/public/lustre/lustre-2.12.8-ib/MOFED-4.9-4.1.7.0/el7/server
exclude=*debuginfo*
gpgcheck=0
enabled=1
[lustre-client]
name=lustre-client
baseurl=https://downloads.whamcloud.com/public/lustre/lustre-2.12.8-ib/MOFED-4.9-4.1.7.0/el7/client
exclude=*debuginfo*
gpgcheck=0
enabled=1
[e2fsprogs-wc]
name=e2fsprogs-wc
baseurl=https://downloads.whamcloud.com/public/e2fsprogs/latest/el7
exclude=*debuginfo*
gpgcheck=0
enabled=1
```

**TCP网络版YUM源**

```sh
[lustre-server]
name=lustre-server
baseurl=https://downloads.whamcloud.com/public/lustre/lustre-2.12.8/el7/server/
exclude=*debuginfo*
gpgcheck=0
enabled=1
[lustre-client]
name=lustre-client
baseurl=https://downloads.whamcloud.com/public/lustre/lustre-2.12.8/el7/client/
exclude=*debuginfo*
gpgcheck=0
enabled=1
[e2fsprogs-wc]
name=e2fsprogs-wc
baseurl=https://downloads.whamcloud.com/public/e2fsprogs/latest/el7
exclude=*debuginfo*
gpgcheck=0
enabled=1
```

二、安装 `epel` 源:

```sh
yum -y install epel-release
```

三、删除相关软件包，清除yum源，更新内核

```sh
yum remove linux-firmware kernel-tools-libs
yum clean all
yum update
```

四、安装 `e2fsprogs` :

```sh
yum --nogpgcheck --disablerepo=* --enablerepo=e2fsprogs-wc install -y e2fsprogs
```

四、安装带Lustre补丁的内核包。通过禁用OS仓库，确保为内核包选择Lustre仓库：

```sh
yum --nogpgcheck --disablerepo=base,extras,updates --enablerepo=lustre-server install -y kernel kernel-devel kernel-headers kernel-tools kernel-tools-libs kernel-tools-libs-devel
```

重启机器：

```sh
reboot
```

安装LDISKFS`kmod`和其他Lustre软件包

```shell
yum --nogpgcheck --enablerepo=lustre-server install -y kmod-lustre kmod-lustre-osd-ldiskfs lustre-osd-ldiskfs-mount lustre lustre-resource-agents
```

加载相关的内核模块：

```sh
modprobe -v lustre
```

如有错误，排查错误日志命令：

```sh
dmesg
```

查看安装的版本

```sh
lctl get_param version
```

**在继续配置LNet之前，需要从内核卸载Lustre模块**

```sh
lustre_rmmod
```

### 二、客户端软件安装

Lustre客户端软件包括一个包含内核模块的包，以及用于管理客户端软件的用户空间工具的其他包,Lustre客户端不需要“带Lustre补丁”的内核，这简化了安装。

**注意：关于Lustre支持的内核列表，请参阅Lustre的**[**变动日志**](https://git.whamcloud.com/?p=fs/lustre-release.git;a=blob;f=lustre/ChangeLog)

```sh
yum update
```

重启机器：

```sh
reboot
```

查看内核版本

```sh
uname -r
```

安装 `Lustre Client` 相关软件包：

```sh
yum --nogpgcheck --enablerepo=lustre-client install -y kmod-lustre-client lustre-client
```

加载内核模块：

```sh
modprobe -v lustre
```

查看安装的版本

```sh
lctl get_param version
```

验证后，从内核卸载Lustre模块:

```sh
lustre_rmmod
```

<mark style="color:red;">**如下步骤不是必须操作，如报错卸载重新安装可参考如下步骤参考教程:**</mark>（<https://blog.csdn.net/qq\\_25605377/article/details/85845139>)

```sh
yum remove -y "*lustre*"
yum --enablerepo=lustre-server install -y "*OFED*" "*mlnx*" ibutils
yum --nogpgcheck --disablerepo=* --enablerepo=e2fsprogs-wc install -y e2fsprogs
yum -y remove kmod-mlnx-ofa_kernel-4.9-OFED.4.9.4.1.7.1.x86_64
yum --nogpgcheck --enablerepo=lustre-server install -y kmod-lustre kmod-lustre-osd-ldiskfs lustre-osd-ldiskfs-mount lustre lustre-resource-agents
```

**注意：卸载完成，在安装OFED后必须重启，否则配置网络无法识别o2ib内核模块**

```sh
reboot
```

### 三、Lustre（LNet网络配置）

#### 一、关闭 SELinux 和配置防火墙

```sh
setenforce 0            
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config

systemctl stop firewalld
systemctl disable firewalld
```

#### 二、服务端LNet网络配置步骤：

```sh
lustre_rmmod
modprobe -v lnet
lnetctl lnet configure

lnetctl net add --net o2ib --if ib0
lnetctl net add --net tcp --if eno3
lnetctl net show

lnetctl export > /etc/sysconfig/lnet.conf
systemctl enable lnet
```

#### 三、客户端LNet网络配置步骤：

```sh
lustre_rmmod
modprobe -v lnet
lnetctl lnet configure

lnetctl net add --net o2ib --if ib0
lnetctl net add --net tcp --if em1
lnetctl net show

lnetctl export > /etc/sysconfig/lnet.conf
systemctl enable lnet
```

静态配置

IB网络版

```sh
vim /etc/modprobe.d/lustre.conf
options lnet networks="o2ib(ib0),tcp(em1)"
```

TCP网络版

```sh
vim /etc/modprobe.d/lustre.conf
options lnet networks="tcp(em1)"
```

## 三、Lustre 服务端部署

> <mark style="color:red;">**注意：所有部署操作，必须在配置完LNet网络之后进行否则导致无法连接、挂载。**</mark>

### 一、磁盘分区

**注意：MGS和MDS 节点及OSS节点分区命令一致，初始化和挂载命令不同。**

```shell
#  查看系统未分区的磁盘块设备
lsblk 

# fdisk 无交互进行分区
vim partition.sh

#！/bin/bash
fdisk -u /dev/sdb << EOF
g
n
1


w
EOF

chmod +x partition.sh
bash partition.sh
```

分区完成后，在管理服务器上格式化磁盘为管理服务（MGS）和元数据服务（MDS）

> 其中 `fsname` 指定了文件系统名称，`index` 表示 `MDT` 的序号，每个 `MDT` 或者 `OST` 的序号必须唯一。

### 二、MGS和MDS 节点部署

MGS和MDS 节点同一台服务器格式化如下：

```sh
mkfs.lustre --fsname=lustre --mdt --mgs --index=0 --reformat /dev/sdb1
```

MGS和MDS 创建挂载目录，启动服务并挂载

```sh
mkdir -p /mnt/mg
mount.lustre  /dev/sdb1 /mnt/mg
```

写入开机挂载

**注意：只能执行一遍，/etc/fstab 文件如有错误，可能导致无法开机**

MGS和MDS 节点

```shell
echo "/dev/sdb1  /mnt/mg                              lustre  defaults,_netdev        0 0" >> /etc/fstab
```

### 三、OSS节点部署

OSS节点格式化如下，index序号需要变更：

```sh
mkfs.lustre --fsname=lustre --reformat --ost --mgsnode=192.168.20.102@o2ib0  --index=205 /dev/sdb1
```

OSS 创建挂载目录，启动服务并挂载

```
mkdir -p /mnt/ost
mount -t lustre  /dev/sdb1 /mnt/ost
```

写入开机挂载

> <mark style="color:red;">**注意：只能执行一遍，/etc/fstab 文件如有错误，可能导致无法开机**</mark>

OSS节点

```shell
echo "/dev/sdb1  /mnt/ost                      lustre  defaults,_netdev        0 0" >> /etc/fstab
```

## 四、Lustre 客户端部署

> <mark style="color:red;">**注意：所有部署操作，必须在配置LNet网络完成之后进行否则导致无法连接、挂载。**</mark>

### 一、客户端挂载：

> <mark style="color:red;">**注意：批量挂载客户端之前，需要先手动在某一台客户端挂载，创建对应的其他下层挂载目录**</mark>

```sh
mount.lustre 192.168.20.102@o2ib:/lustre /mnt
mkdir -p /mnt/home  /mnt/public
umount /mnt
sed -i '11s/^/#/' /etc/fstab
```

```sh
mkdir -p /public
mount -t lustre 192.168.20.102@o2ib:/lustre/public /public
mount -t lustre 192.168.20.102@o2ib:/lustre/home /home
```

```sh
mount -t lustre 192.168.10.102@tcp:/lustre/public /public
mount -t lustre 192.168.10.102@tcp:/lustre/home /home
```

写入开机挂载

> <mark style="color:red;">**注意：只能执行一遍，/etc/fstab 文件如有错误，可能导致无法开机**</mark>

IB网络版

```sh
echo "192.168.20.102@o2ib:/lustre/public /public lustre  ro,defaults,_netdev,noauto,x-systemd.automount,x-systemd.requires=lnet.service        0 0" >> /etc/fstab
echo "192.168.20.102@o2ib:/lustre/home /home lustre  defaults,_netdev,noauto,x-systemd.automount,x-systemd.requires=lnet.service      0 0" >> /etc/fstab
```

TCP网络版

```sh
echo "192.168.10.102@tcp:/lustre/public /public lustre  ro,defaults,_netdev,noauto,x-systemd.automount,x-systemd.requires=lnet.service        0 0" >> /etc/fstab
echo "192.168.10.102@tcp:/lustre/home /home lustre  defaults,_netdev,noauto,x-systemd.automount,x-systemd.requires=lnet.service      0 0" >> /etc/fstab
```

## 五、安装批量部署工具

> 所有部署调试完毕，执行多台批量部署，其中一些参数，细节，记得在批量部署时记得调整

[Ansible 语法学习参考](https://ansible-tran.readthedocs.io/en/latest/docs/intro.html)ll

```sh
– 安装 yum install -y ansible
– 验证 ansible --version
- 修改配置 
vim /etc/ansible/ansible.cfg 
14 inventory      = /etc/ansible/hosts                       # 主机定义分组
71 host_key_checking = False                                 # ssh 主机 key 验证配置参数,不需要输入yes,如果为 True,等待输入 yes
375 ssh_args = -C -o ControlMaster=auto -o ControlPersist=5d # 注意：ConrolPersist=5d, 这个参数是设置整个长连接保持时间为5天。
400 pipelining = True                                        # 加速 Ansible 执行速度,如果不使用 sudo，建议开启。
```

```
vim /etc/ansible/hosts                                       # 定义分组
[master]
192.168.10.101 ansible_ssh_user="root" ansible_ssh_pass="I0XJ85nz62SzndrR"
[oss]
192.168.10.[102:110] ansible_ssh_user="root" ansible_ssh_pass="I0XJ85nz62SzndrR"
[client]
192.168.10.[11:46]  ansible_ssh_user="root" ansible_ssh_pass="I0XJ85nz62SzndrR"
```

### 一、批量免密

```shell
# ssh-keygen免密生成秘钥，非交互式
# -t 秘钥类型
# -q 安静输出
# -P 提供密语
# -f 生成路径

ssh-keygen -t rsa -q -P "" -f ~/.ssh/id_rsa

# 编写免密剧本
vim ssh-keyadd.yml

---
- hosts: all
  gather_facts: no

  tasks:
  - name: install ssh key
    authorized_key: user=root
                    key="{{ lookup('file', '/root/.ssh/id_rsa.pub') }}"
                    state=present
                    
# 执行如下命令进行批量免密

ansible-playbook ssh-keyadd.yml
```

### 二、批量修改主机名

```sh
vim hostname.yml

---
- hosts : client
  remote_user : root
  tasks :
  - name : "批量修改主机名"
    shell : hostname
  - name : show ip
    command : ip a
  - hostname : name=c-96-256-worker000{{ ansible_default_ipv4.address.split('.')[-1] }}
  
ansible-playbook hostname.yml
```

### 三、批量获取主机名和IP重定向写入/etc/hosts文件

```sh
vim hosts.yml

---
- hosts: all
  remote_user: root
  vars:
    - name: "hezhiqiang"
  tasks:
    - name: "批量获取主机名和IP重定向写入/etc/hosts文件"
      shell: echo {{item.key}}     {{item.value.ansible_hostname}} >> /etc/hosts
      with_dict: "{{hostvars}}"
      no_log: True
      #loop_control:
         #label: ""
    - name: "任务结束"
      shell: wc -l /etc/hosts
      shell: echo "--结束--"

      
 
 ansible-playbook hosts.yml
```

#### 批量安装IB网络驱动程序，及初始化安装一些依赖

注意：下载驱动版本一定要下载对应系统版本否则内核无法加载，OFED驱动[下载网站](https://network.nvidia.com/products/infiniband-drivers/linux/mlnx_ofed/)

```shell
vim InfiniBand.yml

---
- hosts: client
  remote_user: root
  gather_facts: false
  tasks:
  - name: "配置yum源"
    shell: "yum -y install wget"
    shell: "wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo"
    shell: "wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo"
  - name: "安装软件"
    yum:
      update_cache: yes
    yum:
      name: epel-release,perl,perl-devel,gcc,gtk2,atk,cairo,libxml2-python,createrepo,pciutils,gcc-gfortran,tcsh,libusbx,lsof,tcl,fuse-libs,tk,vim,telnet,htop,tree,numactl,redhat-lsb,net-tools.x86_64,python-devel,kernel-devel-3.10.0-1160.59.1.el7.x86_64,redhat-rpm-config,rpm-build
      state: present
  - name: "卸载相关软件"
    yum:
      name: linux-firmware,kernel-tools-libs
      state: removed
  - name: "清除缓存"
    yum:
      update_cache: yes
  - name: "yum update 更新"
    yum:
      name: "*"
      state: latest
  - name: "重启Linux服务器"
    reboot:
      pre_reboot_delay: 300
      test_command: uptime
  - name: "复制相关文件到目标服务器"
    copy:
      src: "{{ item.src }}"
      dest: "{{ item.dest }}"
      owner: root
      group: root
      mode: 755
    with_items:
       - {src: "/tmp/MLNX_OFED_LINUX-5.0-2.1.8.0-rhel7.6-x86_64.iso", dest: "/tmp/MLNX_OFED_LINUX-5.0-2.1.8.0-rhel7.6-x86_64.iso" }
       - {src: "/etc/yum.repos.d/lustre.repo", dest: "/etc/yum.repos.d/lustre.repo" }
  - name: "挂载驱动安装程序"
    shell: "umount -f /mnt "
    shell: "mount -o loop /tmp/MLNX_OFED_LINUX-5.0-2.1.8.0-rhel7.6-x86_64.iso /mnt"
  - name: "安装驱动程序"
    shell: "/mnt/mlnxofedinstall --add-kernel-support"
  - name: "卸载驱动安装程序"
    shell: "umount /mnt"
  - name: "启动IB驱动"
    shell: "service openibd start"
  - name: "设置IB驱动开机自启动"
    shell: "systemctl enable openibd.service"
  - name: "启动子网管理器 opensmd "
    shell: "service opensmd start"
  - name: "设置子网管理器 opensmd 开机启动"
    shell: "chkconfig opensmd on"
  - name: "查看 HCA 端口状态,若 State 为 Active,则表示正常"
    shell: "ibstat"

      
      
ansible-playbook InfiniBand.yml
```

IB网络数据交互测试

参考文档

<https://blog.csdn.net/ljlfather/article/details/102925954>

<https://blog.csdn.net/bandaoyu/article/details/115798693>

```
服务端执行如下命令
ib_write_bw

客户端执行如下命令
ib_write_bw -d mlx4_0  -a -F 192.168.20.12
```

```shell
#编写剧本，进行批量安装软件、分区、并启动OST服务加入集群
vim oss.yml
---
- hosts: oss
  remote_user: root
  gather_facts: False
  vars:
    - list: [2,3,4,5,6,7,8,9,10]
  tasks:
    - name: this is loop
      debug: msg="{{ item }}"
      with_items: '{{list}}'
    - name:   
      shell："yum --nogpgcheck --enablerepo=lustre-server install -y kmod-lustre kmod-lustre-osd-ldiskfs lustre-osd-ldiskfs-mount lustre lustre-resource-agents"
    - name: "分区"
      shell: bash /root/partition.sh
    - name: "创建挂载目录"
      shell: mkdir -p /mnt/ost
    - name: "循环传参"
    - name:  "格式化磁盘"
      shell: mkfs.lustre --fsname=lustre --reformat --ost --mgsnode=192.168.10.101 --index="{{list}}" /dev/sdb1
    - name: "启动OSS服务,加入集群"
      shell: mount -t lustre /dev/sdb1 /mnt/ost
    - name："写入开机挂载"
      shell: echo "/dev/sdb1  /mnt/ost                              lustre  defaults,_netdev        0 0" >> /etc/fstab

# 执行如下命令进行批量安装软件、分区、并启动OST服务加入集群

ansible-playbook -i /etc/ansible/hosts -f oss.yml
```

<pre><code># 注意：批量挂载客户端之前，需要先手动挂载，创建对应挂载目录

<strong>mount.lustre 192.168.10.101@o2ib0:/lustre /mnt
</strong>mkdir -p /mnt/home  /mnt/public
umount /mnt
</code></pre>

```
# 编写剧本，进行批量安装客户端、并加入集群

vim client.yml
---
- hosts: client
  tasks:
    - name: "安装软件"
      yum:
        name: *
        state: latest
      yum:  
        update_cache: yes
    - name: "重启Linux服务器" 
      reboot:
        pre_reboot_delay: 300
        test_command: uptime
    - name: "批量安装客户端"
      shell："yum --nogpgcheck --enablerepo=lustre-client install -y kmod-lustre-client lustre-client"
    - name: "创建挂载目录"
      shell: mkdir -p /public
    - name: "注释/home旧挂载"
      shell: sed -i '11s/^/#/' /etc/fstab
    - name: "配置lustre 网络"
      shell: "modprobe -v lnet"
      shell: "lnetctl lnet configure"
      shell: "lnetctl net add --net tcp1 --if em1"
      shell: "lnetctl net add --net o2ib0 --if ib0"
    - name: "为避免主机被重启，导入LNet网络配置"
      shell: "lnetctl export /etc/lnet.conf"
    - name: "启动LNet网络"
      shell: "lctl network up"
    - name："挂载lustre并设置开机自启动"
      shell: echo "192.168.20.102@o2ib:/lustre/public /public lustre  ro,defaults,_netdev        0 0" >> /etc/fstab
      shell: echo "192.168.20.102@o2ib:/lustre/home /home lustre  defaults,_netdev        0 0" >> /etc/fstab
      shell: umount /home
      shell: mount -a

# 执行如下命令进行进行批量安装客户端、并加入集群

ansible-playbook -i /etc/ansible/hosts -f client.yml
```

### 四、批量获取内网IP并修改IB 网段

```sh
vim ip.yml

---
- hosts : client
  remote_user : root
  tasks :
  - name : "批量获取内网IP"
    shell : " sed -i s/IPADDR=192.168.20.11/IPADDR={{ ansible_all_ipv4_addresses | ipaddr('private') | first }}/g /etc/sysconfig/network-scripts/ifcfg-ib0 "
  - name : "批量修改网段"
    shell : " sed -i 4s/30/20/g /etc/sysconfig/network-scripts/ifcfg-ib0 "
  - name : "批量重启网络"
    shell : "systemctl restart network"
    
    
ansible-playbook ip.yml
```

## 六、常见问题处理

问题排查参考连接：

<https://blog.51cto.com/u\\_9099998/2445847>

```sh
此问题在客户端挂载时遇到
报错1:
[root@c-128-256-worker000140 ~]# modprobe -v lustre
insmod /lib/modules/3.10.0-1160.59.1.el7.x86_64/extra/lustre/net/libcfs.ko 
insmod /lib/modules/3.10.0-1160.59.1.el7.x86_64/extra/lustre/net/lnet.ko 
insmod /lib/modules/3.10.0-1160.59.1.el7.x86_64/extra/lustre/fs/obdclass.ko 
insmod /lib/modules/3.10.0-1160.59.1.el7.x86_64/extra/lustre/fs/ptlrpc.ko 
modprobe: ERROR: could not insert 'lustre': Cannot allocate memory
1.
2.
3.
4.
5.
6.

错误原因：服务器CPU，内存分配不匀，导致部分CPU未分配内存，无法加载lustre内核模块，表现如下

[root@c-128-256-worker000140 ~]# numactl -H
available: 2 nodes (0-1)
node 0 cpus: 0 1 2 3 4 5 6 7 8 9 20 21 22 23 24 25 26 27 28 29
node 0 size: 0 MB
node 0 free: 0 MB
node 1 cpus: 10 11 12 13 14 15 16 17 18 19 30 31 32 33 34 35 36 37 38 39
node 1 size: 32654 MB
node 1 free: 30680 MB
node distances:
node   0   1 
  0:  10  20 
  1:  20  10
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.

解决方案：协调IDC 机房同事重新插拔内存后调整状态，如果不行建议排查硬件故障

[root@c-128-256-worker000140 ~]# numactl -H
available: 2 nodes (0-1)
node 0 cpus: 0 1 2 3 4 5 6 7 8 9 20 21 22 23 24 25 26 27 28 29
node 0 size: 16270 MB
node 0 free: 15480 MB
node 1 cpus: 10 11 12 13 14 15 16 17 18 19 30 31 32 33 34 35 36 37 38 39
node 1 size: 16384 MB
node 1 free: 15504 MB
node distances:
node   0   1 
  0:  10  21 
  1:  21  1shelllshe'l'lshell
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hezhiqiang.gitbook.io/about-the-author/yun-wei-huan-jing-da-jian/lustre-fen-bu-shi-bing-xing-wen-jian-xi-tong-bu-shu.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
