[命令] Linux 命令 dig (从 DNS 服务器获取主机信息)

内容一:dig 命令简介

dig 即 domain information groper,主要功能是从 DNS 服务器获取主机信息

内容二:dig 命令的使用案例

2.1 案例一:显示互联网上所有 DNS 根服务器的信息

# dig

2.2 案例二:直接通过域名获取主机信息

# dig eternalcenter.com

(补充:这里以通过 eternalcenter.com 域名获取主机信息为例)

2.3 案例三:直接通过域名获取主机信息,但只显示最基础的内容

# dig eternalcenter.com +short

(补充:这里以通过 eternalcenter.com 域名获取主机信息为例)

2.4 案例四:直接通过域名获取主机信息,并指定显示的内容

# dig eternalcenter.com +noall +answer

(补充:这里以通过 eternalcenter.com 域名获取主机信息,并显示 noall 和 answer 部分的内容为例)

2.5 案例五:从指定的 DNS 服务器和端口号通过域名获取主机信息

# dig @8.8.8.8 -p 53 eternalcenter.com

(补充:这里以通过 eternalcenter.com 域名从 IP 地址是 8.8.8.8 端口是 53 的 DNS 服务器获取主机信息为例)

2.6 案例六:通过 IP 地址获取主机信息

# dig -x 8.8.8.8

(补充:这里以通过 IP 地址 8.8.8.8 获取主机信息为例)

2.7 案例七:通过 IP 地址获得主机信息,但只显示最基础的内容

# dig -x 8.8.8.8  +short

(补充:这里以通过 IP 地址 8.8.8.8 获取主机信息为例)

2.8 案例八:直接通过域名获取主机信息,同时显示获取的过程

# dig eternalcenter.com +trace

(补充:这里以通过 eternalcenter.com 域名获取主机信息为例)

[排错] 解决 Red Hat Satellite 发布新版本 Content Views 时报错 “Unable to find content with the ID “……””

报错代码

Unable to find content with the ID "......"

分析

当 Content Views 里包含有问题的软件源时,发布新版本 Content View 时就会报此类错误

解决方法

步骤一:根据报错时出现的 ID 显示出问题的软件名称

# su - postgres -c "psql candlepin -c \"select uuid, content_id, contentUrl, label, type, vendor from cp2_content where content_id = '9210'\""

(补充:这里以显示 ID 9210 的软件名称为例)

步骤二:给服务器系统打一个快照

(步骤略)

步骤三:强制停止出问题的任务

Monitor –> Tasks –> Paused –> “select the task which publish a new Content View version” –> Cancel

(注意:操作前需要确保左上角的组织是否正确)

或者:

步骤三:将出问题的软件源从要布新版本的 Content Views 里删除

Content –> Content Views –> “select the Content View which whill publish a new version” –> Yum Content –> Repository –> “select the repository which is error” –> Remove Repositories

步骤四:重新发布新版本的 Content Views

(步骤略)

[内容] SUSE Repository Mirroring Tool (RMT) 服务端的设置 (软件源)

内容一:显示软件源

1.1 显示所有的 SUSE 软件源产品

# rmt-cli products list --all

1.2 显示所有已经启用的 SUSE 软件源产品

# rmt-cli products list

1.3 显示所有指定版本且指定架构的 SUSE 软件源产品

# rmt-cli products list --all --version=15.4 --arch=x86_64

(补充:这里以显示所有 15.4 版本且 x86_64 架构的 SUSE 软件源产品为例)

1.4 显示所有已启用指定版本且指定架构的 SUSE 软件源产品

# rmt-cli products list --version=15.4 --arch=x86_64

(补充:这里以显示所有已其应用 15.4 版本且 x86_64 架构的 SUSE 软件源产品为例)

内容二:启用软件源

2.1 启用某个软件源

# rmt-cli products enable <id>

或者:

# rmt-cli products enable <string>

2.2 开启所有指定版本且指定架构的 SUSE 软件源产品

# for i in `rmt-cli products list --all --version=15.4 --arch=x86_64 | awk '{print $2}' | egrep -v '\||ID|^$'`;do rmt-cli products enable $i;done

(补充:这里以开启所有 15.4 版本且 x86_64 架构的 SUSE 软件源产品)

内容三:取消启用软件源

3.1 取消启用某个软件源

# rmt-cli products disable <id>

或者:

# rmt-cli products disable <string>

3.2 取消所有指定版本且指定架构的 SUSE 软件源产品

# for i in `rmt-cli products list --all --version=15.4 --arch=x86_64 | awk '{print $2}' | egrep -v '\||ID|^$'`;do rmt-cli products disable $i;done

(补充:这里以取消开启所有 15.4 版本且 x86_64 架构的 SUSE 软件源产品)

参考文献:

https://documentation.suse.com/sles/15-SP4/single-html/SLES-rmt/index.html#sec-rmt-tools-rmt-cli

[步骤] Red Hat Satellite 无法停止任务的强制停止

步骤一:打一个快照

(步骤略)

步骤二:显示运行结果是错误的任务

# sudo su - postgres -c "psql -d foreman -c 'select label,count(label),state,result from foreman_tasks_tasks where state <> '\''stopped'\'' group by label,state,result ORDER BY label;'"
                        label                         | count |   state   | result  
------------------------------------------------------+-------+-----------+---------
 Actions::Katello::ContentView::Publish               |     1 | paused    | error
 ......

(补充:从这里可以看出运行结果是错误的任务标签是 Actions::Katello::ContentView::Publish)

步骤三:强制停止 Red Hat Satellite 无法停止的任务

# foreman-rake foreman_tasks:cleanup TASK_SEARCH='label = Actions::Katello::ContentView::Publish' STATES='paused' VERBOSE=true

(补充:这里以强制停止标签为 Actions::Katello::ContentView::Publish 的任务为例)