Search
1
GPU硬件直通
187 阅
2
Ceph集群换盘
183 阅
3
Ceph 简单维护命令详解与示例
174 阅
4
Centos7源
142 阅
5
Centos7 网络聚合
123 阅
首页
分类
默认分类
闲话
登 录
最新消息
暂无任何消息!
Search
标签搜索
Ceph
魔方云
Python
Ran
首页
栏目
默认分类
闲话
登录
登 录
默认分类
共 15 篇
88 人围观
魔方云 windwos镜像制作
1.关机实例 挂载安装iso和virtio驱动iso 选择引导方式为图中(注:开机后 打开控制台 控制台会出现iso引导 按回车进入iso引导 不点击会进入原盘)2.安装选择自定义安装3.通过我们挂载的virtio-win-0.1.229 识别硬盘驱动 点击Next4.安装完成后 返回 就可以看到磁盘 在进行新建分区5.然后点击Next开始安装6.输入登录密码(2012镜像需要 此步骤非必须)7.安装完成后进入系统 这时默认是没有网络的 还需要安装virtio网卡驱动8.打开设备管理器9.点击黄色感叹设备 点击选择更新驱动程序 选择浏览我的电脑安装10.路径选择挂载的virtio iso点击ok点击下一步11.搜索到网卡驱动 点击安装12.将所有驱动安装完成 13.安装完成后 进行手动配置IP14.配置完成后 参考https://www.idcsmart.com/wiki_list/874.html 进行cloudbase-init, qemu-guest-agent安装默认ie浏览器可能会无法下载 关闭一下这个15.将cloudbase-init, qemu-guest-agent 和配置文件下载到机器内16.安装cloudbase-init17.安装qemu-guest-agent18.安装完成验证19.将配置文件放置到C:\Program Files\Cloudbase Solutions\Cloudbase-Init\conf 目录下20.然后清理下载记录 21.关闭防火墙22.开启远程桌面23.然后关机实例24.在计算节点实例磁盘目录进行磁盘压缩 qemu-img convert -c -O qcow2 kvm11342-system.qcow2 en-windwos-2012r2.qcow2
9月12日
0
0
68 人围观
监控脚本
目前遇到一个问题 云服务器经常死机 所以写了一个脚本进行监控#!/usr/bin/env python3 import os import psutil import time import logging import subprocess log_file = "/var/log/resource_monitor.log" logging.basicConfig(filename=log_file, level=logging.INFO, format='%(asctime)s - %(message)s') cpu_threshold = 201.0 overall_cpu_threshold = 60.0 memory_threshold = 0.2 load_threshold = 20.0 ping_host = "qq.com" def log_top_processes(): current_pid = os.getpid() # 获取当前脚本的PID top_procs = sorted(psutil.process_iter(['pid', 'name', 'cpu_percent', 'memory_info']), key=lambda p: p.info['cpu_percent'], reverse=True)[:3] for proc in top_procs: if proc.info['pid'] == current_pid: continue # 跳过记录当前脚本进程 proc_info = proc.info memory_usage = proc_info['memory_info'].rss / (1024 * 1024 * 1024) logging.info(f"进程 {proc_info['name']} (PID: {proc_info['pid']}) 使用的CPU: {proc_info['cpu_percent']}%,内存使用: {memory_usage:.2f}GB") def log_system_status(): cpu_usage = psutil.cpu_percent(interval=1) memory_available = psutil.virtual_memory().available / (1024 * 1024 * 1024) load_avg = os.getloadavg()[0] logging.info(f"当前 CPU 使用率: {cpu_usage}%, 可用内存: {memory_available:.2f}GB, 负载平均: {load_avg}") for proc in psutil.process_iter(['pid', 'name', 'cpu_percent']): if proc.info['cpu_percent'] > cpu_threshold: logging.warning(f"进程 {proc.info['name']} (PID: {proc.info['pid']}) 使用的CPU达到了 {proc.info['cpu_percent']}%,超过了阈值 {cpu_threshold}%") log_top_processes() break if cpu_usage > overall_cpu_threshold or memory_available < memory_threshold or load_avg > load_threshold: logging.warning(f"系统资源使用率超出阈值!记录前3个占用资源最高的进程:") log_top_processes() sys_log = os.popen('tail -n 5 /var/log/messages').read() logging.info(f"最近的系统日志:\n{sys_log}") def check_system_unresponsive(): try: result = subprocess.run(['ping', '-c', '1', ping_host], stdout=subprocess.PIPE, stderr=subprocess.PIPE) if result.returncode != 0: logging.error(f"无法 ping {ping_host},可能系统卡死!") log_top_processes() sys_log = os.popen('tail -n 10 /var/log/messages').read() logging.info(f"最近的系统日志:\n{sys_log}") except Exception as e: logging.error(f"检查系统是否卡死时出错: {e}") def monitor_resources(): while True: log_system_status() check_system_unresponsive() time.sleep(120) # 调整监控频率 if __name__ == "__main__": monitor_resources() ##日志输出/var/log/resource_monitor.log ## 杀死进程 pkill -f resource_monitor.py信息输出保存为resource_monitor.pychmod +x resource_monitor.py && python resource_monitor.py
9月11日
0
0
123 人围观
Centos7 网络聚合
Bonding的模式一共有7种 mode=0 (balance-rr) (Round-robin policy :平衡抡循环策略) #特点:传输数据包顺序是依次传输(即:第1个包走eth0,下一个包就走eth1….一直循环下去, 直到最后一个传输完毕),此模式提供负载平衡和容错能力;但是我们知道如果一个连接或者会话的数据包 从不同的接口发出的话,中途再经过不同的链路,在客户端很有可能会出现数据包无序到达的问题, 而无序到达的数据包需要重新要求被发送,这样网络的吞吐量就会下降 mode=1 (active-backup) (Active-backup policy :主-备份策略) #特点:只有一个设备处于活动状态,当一个宕掉另一个马上由备份转换为主设备。 mac地址是外部可见的,从外面看来,bond的MAC地址是唯一的,以避免switch(交换机)发生混乱。 此模式只提供了容错能力;由此可见此算法的优点是可以提供高网络连接的可用性, 但是它的资源利用率较低,只有一个接口处于工作状态,在有 N 个网络接口的情况下,资源利用率为1/N mode=2 (balance-xor) (XOR policy :平衡策略) #特点:基于指定的传输HASH策略传输数据包。缺省的策略是:(源MAC地址 XOR 目标MAC地址) % slave数量。 其他的传输策略可以通过xmit_hash_policy选项指定,此模式提供负载平衡和容错能力 mode=3 (broadcast) (broadcast :广播策略) #特点:在每个slave接口上传输每个数据包,此模式提供了容错能力 mode=4 (802.3ad) (IEEE 802.3ad 动态链接聚合),这是常见服务器推荐使用的模式 #特点:创建一个聚合组,它们共享同样的速率和双工设定。根据802.3ad规范将多个slave工作在同一个 激活的聚合体下。外出流量的slave选举是基于传输hash策略,该策略可以通过xmit_hash_policy选项从缺省的XOR策略改变到其他策略。 需要注意的是,并不是所有的传输策略都是802.3ad适应的,尤其考虑到在802.3ad标准43.2.4章节提及的包乱序问题。 不同的实现可能会有不同的适应性。 必要条件: #条件1:组成bond的网卡速率和双工设定要一致,可以用ethtool测试网卡属性(比如Speed: 2000Mb/s;Duplex: Full) #条件2:交换机要支持802.3ad动态聚合,(华为叫LACP) #条件3:交换机要启用端口聚合,并将聚合端口,如eth-trunk 设置为lacp模式 hash策略: #L2 :MAC #L2+L3 :MAC+IP #L3+L4 :IP+Port 经测试L3+L4在ip端口应用中流量很容易进行平衡负载(类似rr效果) mode=5 (balance-tlb) (Adaptive transmit load balancing :适配器传输负载均衡) #特点:不需要任何特别的switch(交换机)支持的通道bonding。在每个slave上根据当前的 负载(根据速度计算)分配外出流量。如果正在接受数据的slave出故障了,另一个slave接管失败的slave的MAC地址。 #必要条件:ethtool支持获取每个slave的速率 mode=6 (balance-alb) (Adaptive load balancing :适配器适应性负载均衡) #特点:该模式包含了balance-tlb模式,同时加上针对IPV4流量的 接收负载均衡(receive load balance, rlb),而且不需要任何switch(交换机)的支持。 接收负载均衡是通过ARP协商实现的。 bonding驱动截获本机发送的ARP应答,并把源硬件地址改写为bond中某个slave的唯一硬件地址, 从而使得不同的对端使用不同的硬件地址进行通信。mode1主-备份策略 方式:只有一个设备处于活动状态,当一个宕掉另一个马上由备份转换为主设备, 优点: 提供了容错能力,由此可见此算法的优点是可以提供高网络连接的可用性 缺点: 资源利用率较低,只有一个接口处于工作状态创建bond接口创建配置文件ifcfg-bond配置文件内写入对应配置信息vi /etc/sysconfig/network-scripts/ifcfg-bond0 DEVICE=bond0 TYPE=Bond NAME="bond0" BONDING_MASTER=yes B00TPROTO=none #是否开启dhcp ONBOOT=yes #开机启动 BONDING_OPTS="mode=1 miimon=100" #mode=1热备模式,miimon=100代表链路检测间隔100ms IPADDR="10.1.1.2" PREFIX=24将物理接口添加到聚合端口配置物理接口eth0(可根据具体接口名称配置,多为ens33)vi /etc/sysconfig/network-scripts/ifcfg-eth0 TYPE="Ethernet" BOOTPROTO=none NAME="eth0" DEVICE="eth0" ONBOOT="yes" MASTER=bond0 SLAVE=yes USERCTL=no配置物理接口eth1(可根据具体接口名称配置,多为ens34)TYPE="Ethernet" BOOTPROTO=none NAME="eth1" DEVICE="eth1" ONBOOT="yes" MASTER=bond0 SLAVE=yes USERCTL=no测试联通systemctl restart network cat /proc/net/bonding/bond0配置VPCSip地址,并进行ping测试ip 10.1.1.3 24 10.1.1.1现将pc开启ping功能并进行长pingping 10.1.1.2 -t开启ping后断开其中一根线缆丢包一个后网络恢复设置主备线缆规则可以通过在bond0配置文件内增加如下配置vi /etc/sysconfig/network-scripts/ifcfg-bond0 通过配置 BONDING_OPTS="mode=1 miimon=100 primary=eth0"
9月5日
0
0
142 人围观
Centos7源
#国内 cat > /etc/yum.repos.d/CentOS-Base.repo << EOF [base] name=CentOS-7 - Base - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/7/os/\$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-7 - Updates - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/7/updates/\$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] name=CentOS-7 - Extras - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/7/extras/\$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-7 - Plus - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/7/centosplus/\$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #contrib - packages by Centos Users [contrib] name=CentOS-7 - Contrib - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/7/contrib/\$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 EOFcat > /etc/yum.repos.d/CentOS-Base.repo << 'EOF' # CentOS-Base.repo [C7.0.1406-base] name=CentOS-7.0.1406 - Base baseurl=http://vault.centos.org/7.0.1406/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.0.1406-updates] name=CentOS-7.0.1406 - Updates baseurl=http://vault.centos.org/7.0.1406/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.0.1406-extras] name=CentOS-7.0.1406 - Extras baseurl=http://vault.centos.org/7.0.1406/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.0.1406-centosplus] name=CentOS-7.0.1406 - CentOSPlus baseurl=http://vault.centos.org/7.0.1406/centosplus/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.0.1406-fasttrack] name=CentOS-7.0.1406 - Fasttrack baseurl=http://vault.centos.org/7.0.1406/fasttrack/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 # C7.1.1503 [C7.1.1503-base] name=CentOS-7.1.1503 - Base baseurl=http://vault.centos.org/7.1.1503/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.1.1503-updates] name=CentOS-7.1.1503 - Updates baseurl=http://vault.centos.org/7.1.1503/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.1.1503-extras] name=CentOS-7.1.1503 - Extras baseurl=http://vault.centos.org/7.1.1503/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.1.1503-centosplus] name=CentOS-7.1.1503 - CentOSPlus baseurl=http://vault.centos.org/7.1.1503/centosplus/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.1.1503-fasttrack] name=CentOS-7.1.1503 - Fasttrack baseurl=http://vault.centos.org/7.1.1503/fasttrack/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 # C7.2.1511 [C7.2.1511-base] name=CentOS-7.2.1511 - Base baseurl=http://vault.centos.org/7.2.1511/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.2.1511-updates] name=CentOS-7.2.1511 - Updates baseurl=http://vault.centos.org/7.2.1511/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.2.1511-extras] name=CentOS-7.2.1511 - Extras baseurl=http://vault.centos.org/7.2.1511/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.2.1511-centosplus] name=CentOS-7.2.1511 - CentOSPlus baseurl=http://vault.centos.org/7.2.1511/centosplus/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.2.1511-fasttrack] name=CentOS-7.2.1511 - Fasttrack baseurl=http://vault.centos.org/7.2.1511/fasttrack/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 # C7.3.1611 [C7.3.1611-base] name=CentOS-7.3.1611 - Base baseurl=http://vault.centos.org/7.3.1611/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.3.1611-updates] name=CentOS-7.3.1611 - Updates baseurl=http://vault.centos.org/7.3.1611/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.3.1611-extras] name=CentOS-7.3.1611 - Extras baseurl=http://vault.centos.org/7.3.1611/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.3.1611-centosplus] name=CentOS-7.3.1611 - CentOSPlus baseurl=http://vault.centos.org/7.3.1611/centosplus/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.3.1611-fasttrack] name=CentOS-7.3.1611 - Fasttrack baseurl=http://vault.centos.org/7.3.1611/fasttrack/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 # C7.4.1708 [C7.4.1708-base] name=CentOS-7.4.1708 - Base baseurl=http://vault.centos.org/7.4.1708/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.4.1708-updates] name=CentOS-7.4.1708 - Updates baseurl=http://vault.centos.org/7.4.1708/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.4.1708-extras] name=CentOS-7.4.1708 - Extras baseurl=http://vault.centos.org/7.4.1708/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.4.1708-centosplus] name=CentOS-7.4.1708 - CentOSPlus baseurl=http://vault.centos.org/7.4.1708/centosplus/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.4.1708-fasttrack] name=CentOS-7.4.1708 - Fasttrack baseurl=http://vault.centos.org/7.4.1708/fasttrack/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 # C7.5.1804 [C7.5.1804-base] name=CentOS-7.5.1804 - Base baseurl=http://vault.centos.org/7.5.1804/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.5.1804-updates] name=CentOS-7.5.1804 - Updates baseurl=http://vault.centos.org/7.5.1804/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.5.1804-extras] name=CentOS-7.5.1804 - Extras baseurl=http://vault.centos.org/7.5.1804/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.5.1804-centosplus] name=CentOS-7.5.1804 - CentOSPlus baseurl=http://vault.centos.org/7.5.1804/centosplus/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.5.1804-fasttrack] name=CentOS-7.5.1804 - Fasttrack baseurl=http://vault.centos.org/7.5.1804/fasttrack/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 # C7.6.1810 [C7.6.1810-base] name=CentOS-7.6.1810 - Base baseurl=http://vault.centos.org/7.6.1810/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.6.1810-updates] name=CentOS-7.6.1810 - Updates baseurl=http://vault.centos.org/7.6.1810/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.6.1810-extras] name=CentOS-7.6.1810 - Extras baseurl=http://vault.centos.org/7.6.1810/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.6.1810-centosplus] name=CentOS-7.6.1810 - CentOSPlus baseurl=http://vault.centos.org/7.6.1810/centosplus/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.6.1810-fasttrack] name=CentOS-7.6.1810 - Fasttrack baseurl=http://vault.centos.org/7.6.1810/fasttrack/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 # C7.7.1908 [C7.7.1908-base] name=CentOS-7.7.1908 - Base baseurl=http://vault.centos.org/7.7.1908/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.7.1908-updates] name=CentOS-7.7.1908 - Updates baseurl=http://vault.centos.org/7.7.1908/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.7.1908-extras] name=CentOS-7.7.1908 - Extras baseurl=http://vault.centos.org/7.7.1908/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.7.1908-centosplus] name=CentOS-7.7.1908 - CentOSPlus baseurl=http://vault.centos.org/7.7.1908/centosplus/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.7.1908-fasttrack] name=CentOS-7.7.1908 - Fasttrack baseurl=http://vault.centos.org/7.7.1908/fasttrack/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 # C7.8.2003 [C7.8.2003-base] name=CentOS-7.8.2003 - Base baseurl=http://vault.centos.org/7.8.2003/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.8.2003-updates] name=CentOS-7.8.2003 - Updates baseurl=http://vault.centos.org/7.8.2003/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.8.2003-extras] name=CentOS-7.8.2003 - Extras baseurl=http://vault.centos.org/7.8.2003/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.8.2003-centosplus] name=CentOS-7.8.2003 - CentOSPlus baseurl=http://vault.centos.org/7.8.2003/centosplus/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.8.2003-fasttrack] name=CentOS-7.8.2003 - Fasttrack baseurl=http://vault.centos.org/7.8.2003/fasttrack/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 # C7.9.2009 [C7.9.2009-base] name=CentOS-7.9.2009 - Base baseurl=http://vault.centos.org/7.9.2009/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.9.2009-updates] name=CentOS-7.9.2009 - Updates baseurl=http://vault.centos.org/7.9.2009/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.9.2009-extras] name=CentOS-7.9.2009 - Extras baseurl=http://vault.centos.org/7.9.2009/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.9.2009-centosplus] name=CentOS-7.9.2009 - CentOSPlus baseurl=http://vault.centos.org/7.9.2009/centosplus/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 [C7.9.2009-fasttrack] name=CentOS-7.9.2009 - Fasttrack baseurl=http://vault.centos.org/7.9.2009/fasttrack/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 enabled=0 EOF
9月2日
0
0
187 人围观
GPU硬件直通
显卡直通 第一:主板BIOS需启用 IOMMU / VT-d、bove 4G Decoding、SR-IOV。 -------------------------------------------------- ● IOMMU:是一种地址映射技术,而 VT-d 是 Intel 对该技术的别称 ● Above 4G Decoding:关系到 PCI-E 设备 RAM 的 64 位寻址能力, 通常用于需要让 CPU 访问全部显存的场景,使用 vGPU 时推荐开启 ● SR-IOV:允许一个 PCI-E 设备被多个虚拟机使用,常用于网卡等设备共享。 第二:确认CPU硬件是否支持虚拟化、关闭selinux --------------------------- # 核查是否支持cpu虚拟化 egrep -o '(vmx|svm)' /proc/cpuinfo # 关闭selinux sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config 第三:CPU启用iommu ------------- # intel_iommu=on iommu=pt # Intel添加: rd.driver.pre=vfio-pci intel_iommu=on video=efifb:off,vesafb:off # AMD添加: rd.driver.pre=vfio-pci amd_iommu=on video=efifb:off,vesafb:off [root@sv-gpu-node-001 ~]# cat /etc/default/grub GRUB_TIMEOUT=5 GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)" GRUB_DEFAULT=saved GRUB_DISABLE_SUBMENU=true GRUB_TERMINAL_OUTPUT="console" GRUB_CMDLINE_LINUX="crashkernel=auto resume=/dev/mapper/cs-swap rd.lvm.lv=cs00/root rd.lvm.lv=cs/swap rhgb quiet rd.driver.pre=vfio-pci intel_iommu=on video=efifb:off,vesafb:off" GRUB_DISABLE_RECOVERY="true" GRUB_ENABLE_BLSCFG=true 第四:更新grub --------- sudo grub2-mkconfig -o /boot/grub2/grub.cfg # 参数说明: # vfio-pci 显卡直通虚拟话需要的驱动 # iommu开启直通分组 # efifb:off 禁用efi启动的显示设备 # vesafb:off 禁用legacy启动的显示设备 第五:加载显卡直通所需的驱动模块 ---------------- cat > /etc/modules-load.d/vfio.conf << EOF vfio vfio_iommu_type1 vfio_pci vfio_virqfd EOF 第六:禁用原本的英伟达显卡驱动和开源驱动nouveau,避免直通出错 ---------------------------------- cat > /etc/modprobe.d/blacklist.conf << EOF blacklist nouveau blacklist nvidia options nouveau modeset=0 EOF 第七:重构 ----- # 先备份 mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r)-nouveau.img # 重建 dracut /boot/initramfs-$(uname -r).img $(uname -r) # 重启 reboot 第八:验证 ----- # 验证IOMMU是否开启 [root@sv-gpu-node-001 ~]# dmesg | grep -e DMAR -e IOMMU [ 0.000000] ACPI: DMAR 0x000000007DF6D650 000160 (v01 A M I OEMDMAR 00000001 INTL 00000001) [ 0.000000] ACPI: Reserving DMAR table memory at [mem 0x7df6d650-0x7df6d7af] [ 0.000000] DMAR: IOMMU enabled # 这是未屏蔽开源显卡驱动的情况 [root@localhost ~]# lsmod | grep nouveau nouveau 2355200 4 video 53248 1 nouveau mxm_wmi 16384 1 nouveau wmi 32768 2 mxm_wmi,nouveau drm_display_helper 151552 1 nouveau i2c_algo_bit 16384 2 ast,nouveau drm_kms_helper 167936 5 drm_vram_helper,ast,drm_display_helper,nouveau drm_ttm_helper 16384 3 drm_vram_helper,ast,nouveau ttm 81920 3 drm_vram_helper,drm_ttm_helper,nouveau drm 577536 13 drm_kms_helper,drm_vram_helper,ast,drm_display_helper,drm_ttm_helper,ttm,nouveau # 这是已经成功屏蔽开源显卡驱动的情况(这是期待的结果-表示成功) [root@localhost ~]# lsmod | grep nouveau [root@localhost ~]# # 如下分别是禁用nvidia驱动后,未分配给虚拟机使用 和 已分配给虚拟机使用 的情况 [root@localhost ~]# lspci -v -s 85:00.0 85:00.0 VGA compatible controller: NVIDIA Corporation GM107GL [Tesla M10] (rev a2) (prog-if 00 [VGA controller]) Subsystem: NVIDIA Corporation Tesla M10 Flags: bus master, fast devsel, latency 0, IRQ 304, NUMA node 1, IOMMU group 78 Memory at f8000000 (32-bit, non-prefetchable) [size=16M] Memory at 39ffa0000000 (64-bit, prefetchable) [size=256M] Memory at 39ffb0000000 (64-bit, prefetchable) [size=32M] I/O ports at c000 [size=128] Capabilities: [60] Power Management version 3 Capabilities: [68] MSI: Enable+ Count=1/1 Maskable- 64bit+ Capabilities: [78] Express Endpoint, MSI 00 Capabilities: [100] Virtual Channel Capabilities: [258] L1 PM Substates Capabilities: [128] Power Budgeting <?> Capabilities: [420] Advanced Error Reporting Capabilities: [600] Vendor Specific Information: ID=0001 Rev=1 Len=024 <?> Capabilities: [900] Secondary PCI Express Kernel driver in use: nvidia # 这是还未直通给虚拟机用时 Kernel modules: nouveau, nvidia_drm, nvidia [root@localhost ~]# lspci -v -s 85:00.0 85:00.0 VGA compatible controller: NVIDIA Corporation GM107GL [Tesla M10] (rev a2) (prog-if 00 [VGA controller]) Subsystem: NVIDIA Corporation Tesla M10 Flags: fast devsel, IRQ 38, NUMA node 1, IOMMU group 76 Memory at fa000000 (32-bit, non-prefetchable) [size=16M] Memory at 39ffe0000000 (64-bit, prefetchable) [size=256M] Memory at 39fff0000000 (64-bit, prefetchable) [size=32M] I/O ports at e000 [size=128] Capabilities: [60] Power Management version 3 Capabilities: [68] MSI: Enable- Count=1/1 Maskable- 64bit+ Capabilities: [78] Express Endpoint, MSI 00 Capabilities: [100] Virtual Channel Capabilities: [250] Latency Tolerance Reporting Capabilities: [258] L1 PM Substates Capabilities: [128] Power Budgeting <?> Capabilities: [420] Advanced Error Reporting Capabilities: [600] Vendor Specific Information: ID=0001 Rev=1 Len=024 <?> Capabilities: [900] Secondary PCI Express Kernel driver in use: vfio-pci # 这是已经直通给虚拟机用后 Kernel modules: nouveau, nvidia_drm, nvidia ##将pcie组分配给虚拟机 [root@localhost ~]# lspci | grep NVIDIA 03:00.0 VGA compatible controller: NVIDIA Corporation GA102 [GeForce RTX 3080] (rev a1) 03:00.1 Audio device: NVIDIA Corporation GA102 High Definition Audio Controller (rev a1)
9月2日
0
0
1
2
3
首页
碎语
归档
关于