Spacewalk
Spacewalk 是上游的一个社区计划,而 Red Hat Network Satellite 产品是从它衍生出来。这个计划为分布于已登记的服务器及桌面计算机内的软件提供一个管理界面。
目录
Spacewalk
1. 参考
2. 服务器规范
3. SELinux
4. 防火墙
5. Oracle 数据库
5.1. 安装
5.2. 客户端设置
5.3. 创建 spacewalk 数据库用户
5.4. 额外设置
6. Yum
6.1. EPEL
6.2. Spacewalk
6.3. 额外 yum 软件库
6.4. 局部性 yum 软件库
6.5. GPG 金钥
7. Spacewalk 服务器
7.1. 安装
7.2. 设置
7.3. 升级
8. Spacewalk 客户端(基本设置)
9. 利用 Cobbler 来管理 Spacewalk 客户端
9.1. 填满发行目录树
9.2. 创建一个新的发行版本
9.3. 创建一个新的 kickstart 配置文件
9.4. TFTP 服务器
9.5. 网络设置
9.6. 客户端服务器
10. 利用 Spacewalk 来管理配置文件
10.1. 创建一个新的设置频道
10.2. 允许 Spacewalk 管理系统上的文件
11. 设置 OSAD(即时执行更新)
11.1. 设置客户端
12. 把软件库同步的脚本
12.1. 配置文件
12.2. 脚本
1. 参考
这份教学文档以收藏于 Spacewalk 官方网站上的文件作为基础,为 CentOS 用户创建一份简单的攻略。
Spacewalk 官方网站
官方文件
截图及 Spacewalk 计划概览
2. 服务器规范
• CentOS 5(i386 或 x86_64)
• 1024 MB 调换空间
• 最少 20 GB 存储空间,推荐 80 GB
• 一个完整域名(FQDN)—— 在这个样例里,我们采用 IANA 预留的 example.com 域名:spacewalk.example.com
提示:本作者推荐采用 CentOS 5 i386,因为 x86_64 结构所提供的大部份优点都被 Oracle XE 数据库服务器的限制所抵消。
3. SELinux
Spacewalk 服务器所须用的 Oracle 数据库服务器现在已经可以与 SELinux 「融洽相处」。请编辑 /etc/sysconfig/selinux 并将 SELinux 设为执行模式:
SELINUX=enforcing
重新启动服务器来应用这个改动。
4. 防火墙
以下对内的 TCP 端口在 Spacewalk 服务器上应该被打开:
• 69:TFTP(支持 PXE 的需要)
• 80:Spacewalk 网页界面
• 443:Spacewalk 网页界面(SSL)
• 4545:Spacewalk 监控
• 5222:假若你计划将行动推进客端系统
• 5269:假若你计划将行动推进一台 Spacewalk 代理服务器
• 9055:Oracle XE 网页访问
5. Oracle 数据库
在这份指南内,Spacewalk 将会与一台 Oracle 10g 数据库服务器一同安装;支持 PostgreSQL 作为后端的工作正在进行中,待它变为可行方案时,我们便会更新这页。Oracle Expression Edition 服务器运作上没有问题,虽然它有某些限制:
• 1 GB 内存(最多)—— 具备更多亦没有分别
• 4 GB 磁盘空间(最多)
• 1 个数据库(最多)
• 1 个处理器(最多)—— 就算具备多个处理器,耗用量顶多只会等同一个处理器的资源
5.1. 安装
要在 SELinux 引导情况下运行,oracle 用户的 uid 必须少于 500。以下两个指令将会在安装 oracle-xe-unix 组件前为 oracle 这位用户创建群组及帐户:
/usr/sbin/groupadd -r dba
/usr/sbin/useradd -r -M -g dba -d /usr/lib/oracle/xe -s /bin/bash oracle
在 x86_64 系统上:请留意你将会需要很多与 i386 兼容的组件,因此你并不需要:

exclude = *.i386

在 /etc/yum.conf 内;假若你保留这行,Oracle XE 的安装将会不明不白地失败
以下是 Oracle 数据库所需的组件。这样会安装 bc,以及在 x84_64 系统上依然需要的 32 位的 glibc 和 libaio:
yum install bc glibc.i686 libaio.i386
从 Oracle 的网站下载 Oracle XE。你将会需要登记才能下载那些 RPM。请选择 Oracle Database 10g Express Edition (Universal):
• oracle-xe-univ-10.2.0.1-1.0.i386.rpm
你亦会需要一个客户端来访问数据库。请根据你的服务器的结构来下载 Oracle Instant Client:i386 客户端或x86_64。请下载以下二个 RPM:
• oracle-instantclient11.2-basic-11.2.0.2.0.ARCH.rpm
• oracle-instantclient11.2-11.2.0.2.0.ARCH.rpm
注意:现时已知 Spacewalk 1.4 版能配合 Oracle Instant Client 11.2.0.2.0 版正常运作。
在 Spacewalk 服务器上安装已下载的 RPM:
rpm -Uvh oracle-xe-univ-10.2.0.1-1.0.i386.rpm
rpm -Uvh oracle-instantclient11.2-basic-11.2.0.2.0.*.rpm
rpm -Uvh oracle-instantclient11.2-sqlplus-11.2.0.2.0.*.rpm
在设置 Oracle 数据库前,我们需要从 Spacewalk 的软件库取得一些组件。因此我们需要安装 repo 文件:
rpm -Uhv http://spacewalk.redhat.com/yum/1.4/RHEL/5/x86_64/spacewalk-client-repo-1.4-1.el5.noarch.rpm
rpm -Uhv http://spacewalk.redhat.com/yum/1.4/RHEL/5/x86_64/spacewalk-repo-1.4-1.el5.noarch.rpm
从 Spacewalk 软件库安装下列组件:
yum install oracle-lib-compat
yum install oracle-xe-selinux oracle-instantclient-selinux oracle-instantclient-sqlplus-selinux
/etc/init.d/oracle-xe configure
除了 HTTP 端口,其它缺省值都没有问题。请改用 9055 而不是 8080。
注意:要修改设置值,请卸装并重装 RPM。
5.2. 客户端设置
我们须要设置数据库的 tns 名称。请编辑 /etc/tnsnames.ora:
XE =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = xe)
)
)
恢复文件的 SELinux 安全性脉络:
/sbin/restorecon -v /etc/tnsnames.ora
测试与 Oracle 数据库服务器的连接:
sqlplus system@xe
当被问到时,请输入 system 用户的密码。你应该看见以下信息:
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Dec 17 09:41:18 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
SQL>
输入 quit 来离开客户端界面。
5.3. 创建 spacewalk 数据库用户
利用 sqlplus 命令行界面创建 spacewalk 数据库用户:
sqlplus 'sys@xe as sysdba'
SQL> create user spacewalk identified by spacewalk default tablespace users;
User created.
SQL> grant dba to spacewalk;
Grant succeeded.
SQL> PASSWORD spacewalk;
Changing password for spacewalk
New password:
Retype new password:
Password changed
SQL> quit
5.4. 额外设置
Spacewalk 所需的数据库并存连接数量比缺省的(40)还要多。Spacewalk 开发者所推荐的设置值是 400。此外,Oracle XE 内的一个错误并可能导致 Spacewalk 出现 Internal Server Error(500)。针对这些问题,可以对设置作出以下改动:
sqlplus spacewalk/spacewalk@xe
SQL> alter system set processes = 400 scope=spfile;
System altered.
SQL> alter system set "_optimizer_filter_pred_pullup"=false scope=spfile;
System altered.
SQL> alter system set "_optimizer_cost_based_transformation"=off scope=spfile;
System altered.
SQL> quit
重新启动 Oracle 数据库:
/etc/init.d/oracle-xe restart
6. Yum
6.1. EPEL
Spacewalk 需要应用来自 EPEL 软件库的组件。请编辑 /etc/yum.repos.d/epel.repo:
[epel]
name=Extra Packages for Enterprise Linux 5 - $basearch
#baseurl=http://download.fedora.redhat.com/pub/epel/5/$basearch
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basearch
failovermethod=priority
gpgkey=http://download.fedora.redhat.com/pub/epel/RPM-GPG-KEY-EPEL
gpgcheck=1
enabled=1
includepkgs=bea-stax* cobbler editarea gc gc-devel git* jabberd jabberpy* jakarta-commons-cli jcommon \
jfreechart libapreq2 libgsasl* libntlm* libyaml perl-Algorithm-Diff perl-Apache-DBI \
perl-BerkeleyDB perl-Cache-Cache perl-Class-MethodMaker perl-Class-Singleton \
perl-Convert-BinHex perl-Config-IniFiles perl-Crypt-DES perl-Crypt-GeneratePassword \
perl-DateTime perl-DateTime-Format-Mail perl-DateTime-Format-W3CDTF perl-Error \
perl-FreezeThaw perl-Frontier-RPC perl-GD perl-Git perl-Math-FFT perl-HTML-TableExtract \
perl-IO-Capture perl-IO-stringy perl-IPC-ShareLite perl-libapreq2 perl-MIME-Lite \
perl-MIME-tools perl-Net-IPv4Addr perl-Net-SNMP perl-Params-Validate perl-Proc-Daemon \
perl-SOAP-Lite perl-TermReadKey perl-Text-Diff perl-Unix-Syslog perl-XML-RSS perl-version \
perlAlgorithm-Diff python-cheetah python-dmidecode python-hashlib python-netaddr PyYAML \
python-simplejson rhino tzdata-java udns*
6.2. Spacewalk
下列 yum 软件库收藏了 Spacewalk 1.4 版的核心组件。Spacewalk 依赖于 rhn-client-tools 以及 rhnlib,但它们已随着 CentOS 对更新器的改动而被删除[用来防止上游的旧版更新器不设置 CentOS 机器,导致上游供应商因为硬编码的软件库名称而受荷]。要解决这个问题,也需要安装 Spacewalk 客户端 repo。
rpm -Uhv http://spacewalk.redhat.com/yum/1.4/RHEL/5/x86_64/spacewalk-client-repo-1.4-1.el5.noarch.rpm
rpm -Uhv http://spacewalk.redhat.com/yum/1.4/RHEL/5/x86_64/spacewalk-repo-1.4-1.el5.noarch.rpm
6.3. 额外 yum 软件库
如果你想利用你的 Spacewalk 服务器来管现额外的 yum 软件库,我们推荐你创建一个名为 /etc/reposync.conf 的文件。以下样例档是用来管理 RPMforge 这个软件库的。我们强烈地推荐你利用 includepkgs 这个指令来保护发行版本的基本组件,及局限所占用的磁盘空间:
6.4. 局部性 yum 软件库
如果你想利用你的 Spacewalk 服务器来管现局部性 yum 软件库,我们推荐你创建一个名为 /etc/reposync.conf 的文件。以下是一个同时用来管理 EPEL 及 RPMforge i386 软件库的样例档。我们强烈地推荐你利用 includepkgs 这个指令来保护发行版本的基本组件,及局限所占用的磁盘空间:
[epel32]
name=Extra Packages for Enterprise Linux 5 - i386
baseurl=http://download.fedora.redhat.com/pub/epel/5/i386
#mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=i386
failovermethod=priority
gpgkey=http://download.fedora.redhat.com/pub/epel/RPM-GPG-KEY-EPEL
gpgcheck=1
enabled=1
includepkgs=bea-stax* cobbler editarea gc gc-devel git* jabberd jabberpy* jakarta-commons-cli jcommon \
jfreechart libapreq2 libgsasl* libntlm* libyaml perl-Algorithm-Diff perl-Apache-DBI \
perl-BerkeleyDB perl-Cache-Cache perl-Class-MethodMaker perl-Class-Singleton \
perl-Convert-BinHex perl-Config-IniFiles perl-Crypt-DES perl-Crypt-GeneratePassword \
perl-DateTime perl-DateTime-Format-Mail perl-DateTime-Format-W3CDTF perl-Error \
perl-FreezeThaw perl-Frontier-RPC perl-GD perl-Git perl-Math-FFT perl-HTML-TableExtract \
perl-IO-Capture perl-IO-stringy perl-IPC-ShareLite perl-libapreq2 perl-MIME-Lite \
perl-MIME-tools perl-Net-IPv4Addr perl-Net-SNMP perl-Params-Validate perl-Proc-Daemon \
perl-SOAP-Lite perl-TermReadKey perl-Text-Diff perl-Unix-Syslog perl-XML-RSS perl-version \
perlAlgorithm-Diff python-cheetah python-dmidecode python-hashlib python-netaddr PyYAML \
python-simplejson rhino tzdata-java udns*

[rpmforge32]
name = RPMforge for Enterprise Linux 5 - i386
baseurl = http://apt.sw.be/redhat/el5/en/i386/dag
gpgkey = http://dag.wieers.com/packages/RPM-GPG-KEY.dag.txt
gpgcheck=1
includepkgs=amavisd-new arc cabextract clamav* clamd freeze lha lzop nomarch perl-Archive-Zip perl-Convert-TNEF \
perl-Convert-UUlib perl-MailTools perl-Net-Server ripole unarj zoo
6.5. GPG 金钥
根据缺省值,Spacewalk 会拒绝发放未签署或以不认识的金钥所签署的 RPM。我们要确定已安装所有相关的 GPG 金钥:
wget http://download.fedora.redhat.com/pub/epel/RPM-GPG-KEY-EPEL
mv RPM-GPG-KEY-EPEL /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
wget http://www.redhat.com/security/db42a60e.txt
mv db42a60e.txt /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-former
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-former
wget http://www.redhat.com/security/37017186.txt
mv 37017186.txt /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
wget http://spacewalk.redhat.com/yum/RPM-GPG-KEY-spacewalk
mv RPM-GPG-KEY-spacewalk /etc/pki/rpm-gpg/RPM-GPG-KEY-spacewalk
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-spacewalk
wget http://dag.wieers.com/packages/RPM-GPG-KEY.dag.txt
mv RPM-GPG-KEY.dag.txt /etc/pki/rpm-gpg/RPM-GPG-KEY-dag
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-dag
当然这亦代表你把每位供应者加进一个获信赖的关系中,因为 yum 及 rpm 将会信赖任何以上述金钥所签署的内容。尤其是 EPEL 及 dag 这两个软件库,由于它们不会协调互相抵触的组件,互赖性的问题也许会出现。因为这些软件库并非由 CentOS 管理或控制,任何支持上的要求请在相关软件库的支持渠道里提出。
7. Spacewalk 服务器
7.1. 安装
假若 specspo 这个组件已存在,请删除它,因为它与 Spacewalk 互相抵触。
rpm -e specspo
安装下列 Spacewalk 所需、但不在它的依赖清单上的组件:
yum install perl-XML-LibXML-Common
我们用 yum 来取得 Spacewalk 软件所依赖的、颇长的组件清单:
yum install spacewalk-oracle
yum update
在 x86_64 系统上:你须要新增 /etc/ld.so.conf.d/spacewalk.conf 这个文件,包含着以下内容:

/usr/lib/oracle/10.2.0.4/client64/lib/
/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib/

请利用以下指令在你的系统上启用这个改动:
ldconfig -v
7.2. 设置
设置 Spacewalk 这个应用程序:
LANG=C; spacewalk-setup --disconnected
Available database backends:
oracle
postgresql
Database? oracle
* Setting up Oracle environment.
* Setting up database.
** Database: Setting up database connection.
DB User? spacewalk
DB Password?
DB SID? xe
DB hostname? localhost
DB port [1521]?
DB protocol [TCP]?
** Database: Testing database connection.
** Database: Populating database.
*** Progress: #############################################
* Setting up users and groups.
** GPG: Initializing GPG and importing key.
You must enter an email address.
Admin Email Address? webmaster@example.com
* Performing initial configuration.
* Activating Spacewalk.
** Loading Spacewalk Certificate.
** Verifying certificate locally.
** Activating Spacewalk.
* Enabling Monitoring.
* Configuring apache SSL virtual host.
Should setup configure apache's default ssl server for you (saves original ssl.conf) [Y]?
* Configuring jabberd.
* Creating SSL certificates.
CA certificate password?
Re-enter CA certificate password?
Organization? example.com
Organization Unit [spacewalk.example.com]?
Email Address [webmaster@example.com]?
City? Montreal
State? Quebec
Country code (Examples: "US", "JP", "IN", or type "?" to see a list)? CA
** SSL: Generating CA certificate.
** SSL: Deploying CA certificate.
** SSL: Generating server certificate.
** SSL: Storing SSL certificates.
* Deploying configuration files.
* Update configuration in database.
* Setting up Cobbler..
Cobbler requires tftp and xinetd services be turned on for PXE provisioning functionality. Enable these services [Y/n]?
* Restarting services.
Installation complete.
Use a web browser to view https://spacewalk.example.com to create the Spacewalk administrator account.
请利用以下指令引导监控:
/usr/share/spacewalk/setup/upgrade/rhn-enable-monitoring.pl
将你的浏览器指向 https://spacewalk.example.com 来创建卫星管理员的帐户(当中 example.com是一个由你在本地管理的本地 DNS 本地)
7.2.1. 引导金钥
利用 Spacewalk 的网页界面,创建一个缺省的引导金钥来登记你的系统。请进到 Systems -> Activation keys 并点击 create new key。
• Description: default key
• Universal default: 选用
7.2.2. 频道设置
若要用 Spacewalk 来管理 CentOS 服务器及桌面,我们首先必须设置及安装软件频道。由 Spacewalk 1.0 起,你已经可以通过 spacewalk-repo-sync 这个工具来直接访问 yum 软件库的内容。根据预先设置,组件将会被推往 /var/satellite 这个目录。如果你想更改这个参数,请进到 Admin -> Spacewalk Configuration -> General。
现在是时候在 Spacewalk 的网页界面内置立一个频道。请进到 Channels -> Manage Software Channels 并点击 create new channel。
7.2.2.1. 供 i386 使用的 CentOS 5 Base
以下是 CentOS 5 Base i386 频道的设置样例:
Basic Channel Details
* Channel Name: CentOS 5 Base - i386
* Channel Label: centos5-base-i386
* Parent Channel: None
* Parent Channel Architecture: IA-32
* Yum Repository Checksum Type: sha1
* Channel Summary: CentOS 5 Base for i386 architecture
Associated yum repository
* Repository URL: http://mirror.centos.org/centos/5/os/i386/
* Label: centos5-base-i386
* Sync Repo: enabled
Security: GPG
* GPG key URL: http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
* GPG key ID: E8562897
* GPG key Fingerprint: 473D 66D5 2122 71FD 51CC 17B1 A8A4 47DC E856 2897
编辑 /etc/cron.daily/spacewalk_sync.cron:
#!/bin/sh
# 尝试创建锁定文件并检查结果
LOCKFILE=/var/run/spacewalk_sync.lock
lockfile -r 0 ${LOCKFILE} 1>/dev/null 2>&1
status=$?
if [ ${status} -ne 0 ] ;then
echo "Another instance already running. Aborting."
exit 1
fi
trap "rm ${LOCKFILE}" EXIT
/usr/bin/spacewalk-repo-sync --channel centos5-base-i386 \
--url http://mirror.centos.org/centos/5/os/i386/ \
--type yum --label centos5-base-i386 > /dev/null
chmod 700 /etc/cron.daily/spacewalk_sync.cron
chown root:root /etc/cron.daily/spacewalk_sync.cron
提示:spacewalk-repo-sync 这个指令是用来替把频道的内容与相关的 yum 软件库进行同步。至当前为止,只有 yum 这个方法是被支持的。任何 yum 支持的软件库 URL 都可行(http://、 file://、 等)。整个 yum 软件库的内容将会被转移到 spacewalk 服务器上。

7.2.2.2. 供 i386 使用的 CentOS 5 Updates
以下是 CentOS 5 Updates i386 频道的设置样例:
Basic Channel Details
* Channel Name: CentOS 5 Updates - i386
* Channel Label: centos5-updates-i386
* Parent Channel: CentOS 5 Base - i386
* Parent Channel Architecture: IA-32
* Yum Repository Checksum Type: sha1
* Channel Summary: CentOS 5 Updates for i386 architecture
Associated yum repository
* Repository URL: http://mirror.centos.org/centos/5/updates/i386/
* Label: centos5-updates-i386
* Sync Repo: enabled
Security: GPG
* GPG key URL: http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
* GPG key ID: E8562897
* GPG key Fingerprint: 473D 66D5 2122 71FD 51CC 17B1 A8A4 47DC E856 2897
编辑 /etc/cron.daily/spacewalk_sync.cron 并加入以下内容:
/usr/bin/spacewalk-repo-sync --channel centos5-updates-i386 \
--url http://mirror.centos.org/centos/5/updates/i386/ \
--type yum --label centos5-updates-i386 > /dev/null
7.2.2.3. 供 i386 使用的 Spacewalk Client
以下是 Spacewalk Client i386 频道的设置样例:
Basic Channel Details
* Channel Name: Spacewalk Client - i386
* Channel Label: spacewalk-client-i386
* Parent Channel: CentOS 5 Base - i386
* Parent Channel Architecture: IA-32
* Yum Repository Checksum Type: sha1
* Channel Summary: Spacewalk Client for i386 architecture
Associated yum repository
* Repository URL: http://spacewalk.redhat.com/yum/1.0-client/RHEL/5/i386/
* Label: spacewalk-client-i386
* Sync Repo: enabled
Security: GPG
* GPG key URL: http://spacewalk.redhat.com/yum/RPM-GPG-KEY-spacewalk
* GPG key ID: 430A1C35
* GPG key Fingerprint:
编辑 /etc/cron.daily/spacewalk_sync.cron 并加入以下内容:
/usr/bin/spacewalk-repo-sync --channel spacewalk-client-i386 \
--url http://spacewalk.redhat.com/yum/1.0-client/RHEL/5/i386/ \
--type yum --label spacewalk-client-i386 > /dev/nul
7.2.2.4. 供 i386 使用的 Extra Packages Enterprise Linux 5
以下是 Extra Packages Enterprise Linux 5 i386 频道的设置样例:
Basic Channel Details
* Channel Name: EPEL5 - i386
* Channel Label: epel5-i386
* Parent Channel: CentOS 5 Base - i386
* Parent Channel Architecture: IA-32
* Yum Repository Checksum Type: sha1
* Channel Summary: Extra Packages Enterprise Linux 5 for i386 architecture
Associated yum repository
* Repository URL: http://download.fedora.redhat.com/pub/epel/5/i386/
* Label: epel5-i386
* Sync Repo: disabled
Security: GPG
* GPG key URL: http://download.fedora.redhat.com/pub/epel/RPM-GPG-KEY-EPEL
* GPG key ID: 217521F6
* GPG key Fingerprint:
就这个频道而言,我们不想访问整个 yum 软件库。我们反而只想访问它在 yum 配置文件内,于 includepkg 指令下所列出的组件。若是这样,我们必须采用 reposync 这个工具。通过 reposync 这个指令,我们会下载 EPEL 的组件并创建一个本地旳 yum 软件库。接着,spacewalk-repo-sync 这个指令便会从这个本地的 yum 软件库中取得组件。
yum install yum-utils createrepo
为本地的 yum 软件库预留一个地方:
mkdir -p /var/www/html/pub/CentOS5-i386
编辑 /etc/cron.daily/spacewalk_sync.cron 并加入以下内容:
reposync --repoid=epel32 -c /etc/reposync.conf -p /var/www/html/pub/CentOS5-i386 -d -l -g -n -q > /dev/null
cd /var/www/html/pub/CentOS5-i386/epel32
createrepo /var/www/html/pub/CentOS5-i386/epel32 > /dev/null
/usr/bin/spacewalk-repo-sync --channel epel5-i386 \
--url file:///var/www/html/pub/CentOS5-i386/epel32/ \
--type yum --label epel5-i386 > /dev/null
提示:reposync 这个指令将会从 /etc/reposync.conf 配置文件内所指定的软件库来访问 EPEL 的 i386 RPM。组件将会被下载到 /var/www/html/pub/CentOS5-i386/epel32/ 这个目录。我们没有采用 reposync 的 --arch 选项,因为在某些情况下它未必正确。要对这个指令进行侦错,请删除 -q 这个选项。
7.2.2.5. 供 i386 使用的 RPMforge Enterprise Linux 5
以下是 RPMforge Enterprise Linux 5 i386 频道的设置样例:
Basic Channel Details
* Channel Name: RPMforge EL5 - i386
* Channel Label: rpmforge-el5-i386
* Parent Channel: CentOS 5 Base - i386
* Parent Channel Architecture: IA-32
* Yum Repository Checksum Type: sha1
* Channel Summary: RPMforge Enterprise Linux 5 for i386 architecture
Associated yum repository
* Repository URL: http://apt.sw.be/redhat/el5/en/i386/dag/
* Label: rpmforge-el5-i386
* Sync Repo: disabled
Security: GPG
* GPG key URL: http://dag.wieers.com/packages/RPM-GPG-KEY.dag.txt
* GPG key ID: 6B8D79E6
* GPG key Fingerprint:
就这个频道而言,我们不想访问整个 yum 软件库。我们反而只想访问它在 yum 配置文件(/etc/reposync.conf)内,于 includepkg 指令下所列出的组件。
编辑 /etc/cron.daily/spacewalk_sync.cron 并加入以下内容:
reposync --repoid=rpmforge32 -c /etc/reposync.conf -p /var/www/html/pub/CentOS5-i386 -d -l -g -n -q > /dev/null
cd /var/www/html/pub/CentOS5-i386/rpmforge32
createrepo /var/www/html/pub/CentOS5-i386/rpmforge32 > /dev/null
/usr/bin/spacewalk-repo-sync --channel rpmforge-el5-i386 \
--url file:///var/www/html/pub/CentOS5-i386/rpmforge32/ \
--type yum --label rpmforge-el5-i386 > /dev/null
7.2.2.6. GPG 金钥
为了方便 Spacewalk 客户端,我们将所有受管理组件的公共 GPG 钥放在网页服务器上。这些金钥会收录在 http://spacewalk.example.com/pub 。
cp /etc/pki/rpm-gpg/RPM-GPG-KEY-* /var/www/html/pub/
7.3. 升级
若要升级旧版本的 Spacewalk ,你必须先将 /etc/yum.repos.d/spacewalk.repo 这个 yum 配置文件及 /etc/cron.daily/spacewalk_sync.cron 这个 cron 脚本升级。
提示:在执行 yum update 这个指令之先,请遵从 https://fedorahosted.org/spacewalk/wiki/HowToUpgrade 内的指引。

8. Spacewalk 客户端(基本设置)
每个客户端都必须被设置以 Spacewalk 服务器作为它们的 RPM 组件来源。我们会临时地在客户端机器上设置 EPEL 软件库来访问所需的组件。请编辑 /etc/yum.repos.d/epel.repo:
[epel]
name=Extra Packages for Enterprise Linux 5 - $basearch
#baseurl=http://download.fedora.redhat.com/pub/epel/5/$basearch
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basearch
failovermethod=priority
gpgkey=http://download.fedora.redhat.com/pub/epel/RPM-GPG-KEY-EPEL
gpgcheck=1
enabled=1
includepkgs=bea-stax* cobbler editarea gc gc-devel git* jabberd jabberpy* jakarta-commons-cli jcommon \
jfreechart libapreq2 libgsasl* libntlm* libyaml perl-Algorithm-Diff perl-Apache-DBI \
perl-BerkeleyDB perl-Cache-Cache perl-Class-MethodMaker perl-Class-Singleton \
perl-Convert-BinHex perl-Config-IniFiles perl-Crypt-DES perl-Crypt-GeneratePassword \
perl-DateTime perl-DateTime-Format-Mail perl-DateTime-Format-W3CDTF perl-Error \
perl-FreezeThaw perl-Frontier-RPC perl-GD perl-Git perl-Math-FFT perl-HTML-TableExtract \
perl-IO-Capture perl-IO-stringy perl-IPC-ShareLite perl-libapreq2 perl-MIME-Lite \
perl-MIME-tools perl-Net-IPv4Addr perl-Net-SNMP perl-Params-Validate perl-Proc-Daemon \
perl-SOAP-Lite perl-TermReadKey perl-Text-Diff perl-Unix-Syslog perl-XML-RSS perl-version \
perlAlgorithm-Diff python-cheetah python-dmidecode python-hashlib python-netaddr PyYAML \
python-simplejson rhino tzdata-java udns*
安装 Spacewalk repo:
rpm -Uhv http://spacewalk.redhat.com/yum/1.4/RHEL/5/x86_64/spacewalk-client-repo-1.4-1.el5.noarch.rpm

现在我们已经准备好下载所需的组件:
yum install rhn-setup yum-rhn-plugin python-dmidecode
此刻我们在 Spacewalk 服务器上注册这个客户端:
注意: 请记得总是为你的 Spacewalk 服务器使用 FQDN。
rhnreg_ks --serverUrl=http://spacewalk.example.com/XMLRPC --activationkey=<default-activation-key>
提示:请进到你的 Spacewalk 服务器网页界面里的 Systems -> Activation Keys,以便取得你的缺省引导金钥。
在 Spacewalk 的网页界面里,进到 Systems -> Overview。你的客户端系统现在应该在榜上有名。选择它并点击 System Info 下的 Alter Channel Subscriptions 连结。在 Base Software Channel 部份,请选择 CentOS 5 Base - i386 这个频道并点击 Confirm 按钮。当你返回 Software Channel 管理页面时,你便可以为你的系统订阅子频道。
当你设置好一个 Spacewalk 频道,你便可以安全地停用该计算机上相应的 yum 软件库。请编辑 /etc/yum.repos.d 内的 repo 档并确定相关的部份内含有这个符串:
enabled=0
9. 利用 Cobbler 来管理 Spacewalk 客户端
自 0.4 版起,Cobbler 已随 Spacewalk 一供附上。Cobbler 是一个安装服务,用来简化装备服务器的过程。我们会示范你可以如何通过 Spacewalk 内的 Cobbler,在你现有的网络里增设一台新的服务器。
在以上步骤,我们概述了如何创建一个 CentOS 5 - i386 的发行版本。现在我们会解释如何用 Cobbler 在一台新的服务器上装备 CentOS 5 - i386。
9.1. 填满发行目录树
Spacewalk 服务器必须藏有发行版本的整个 kickstart 目录树。这棵树包含内核、initrd 及软件库数据。这个目录应该容让 apache 及 tomcat 用户读入。
mkdir -p /var/iso-p_w_picpaths /var/distro-trees
下载发行版本的首个 ISO 映像档为 /var/iso-p_w_picpaths/CentOS-5-i386-bin-1.iso。这个映像内藏有所需的文件。
mount -o loop /var/iso-p_w_picpaths/CentOS-5-i386-bin-1.iso /var/distro-trees/CentOS-5-i386
我们亦会编辑 /etc/fstab 于开机时自动挂载这个 ISO 映像:
/var/iso-p_w_picpaths/CentOS-5-i386-bin-1.iso /var/distro-trees/CentOS-5-i386 iso9660 rw,loop=/dev/loop0 0 0
提示要保持你的发行目录树在最新状态,请定时下载最新版本 CentOS 5 的 ISO 映像。每当一个新的 CentOS 5 ISO 映像被发行时,你亦须要卸除及重新挂载它。
9.2. 创建一个新的发行版本
进到 Spacewalk 的界面并选择 Systems -> Kickstart -> Distributions。点击 create a new distribution 这个连结。
Distribution Label: CentOS-5-i386
Tree Path: /var/distro-trees/CentOS-5-i386
Base Channel: CentOS 5 Base - i386
Installer Generation: Red Hat Enterprise Linux 5
点击 Create Kickstart Distribution 这个按钮。
9.3. 创建一个新的 kickstart 配置文件
若然要成功地安装我们的发行版本,我们需要一个 kickstart 档。它是一个简单的文本,内里含有项目清单,每个项目均以关键字来辨认,为来自 anaconda 安装器的问题提供答案。
进到 Spacewalk 的界面并选择 Systems -> Kickstart。点击 create a new kickstart profile 这个连结。
Label: CentOS-5-i386
Channel Base: CentOS 5 Base - i386
Kickstartable Tree: CentOS-5-i386
Virtualization Type: None
点击 Next 这个按钮。
在下一个划面,跳过缺省的下载位置并为 root 用户挑选一个密码。
进到 Spacewalk 的界面并选择 Systems -> Kickstart -> Profiles。选择 CentOS-5-i386 这个配置文件。在 Operating System 这个页签,启用 centos-updates-i386 及 spacewalk-client-i386 这两个频道。其它子频道亦可以被引导。
9.4. TFTP 服务器
这个 kickstart 配置文件是通过 TFTP 公布在网络上。请编辑 TFTP 服务的配置文件(/etc/xinetd.d/tftp)并将 disabled 的值改为 no。接着,请确定 xinetd 服务已在运行中。
/etc/init.d/xinetd status
你的 Spacewalk 服务器上的 TFTP 端口(69)必须接受来自网络端的连接。
9.5. 网络设置
你需要一台正确地设置 filename 及 next-server 变量的 DHCP 服务器。如果你采用 dhcp 这个守护程序,请编辑 /etc/dhcpd.conf 并在你的配置文件内加入这些选项:
filename "pxelinux.0";
next-server <spacewalk server IP address>;
你须要重新引导 DHCP 服务来实施这些改动。
你要装备的服务器必须能够解析你的 Spacewalk 服务器名称。请确定在相关的 DNS 服务器中备有一个项目是针对你的 Spacewalk 服务器名称的。
9.6. 客户端服务器
虽然一台没有操作系统的服务器会尝试每一个可行的开机方法,才至它进入 PXE 开机模式,已安装了操作系统的服务器却未必能进入 PXE 开机模式。请在它的 BIOS 内将 PXE 放置在开机模式清单的最高位置,好让这台服务器有机会被 PXE 被控制。
当客户端服务器关机时,它会展示一个包含 CentOS-5-i386 选项的划面。选择它来开始自动化地安装客户端服务器。
注意:这台客户端服务器的硬盘将会被重新格式化,而 CentOS 5 - i386 将会被重新安装在客户端服务器上。
当客户端端服务器的安装完成后,请用你先前设置的 root 密码登录。借着编辑 /etc/yum.repos.d 内的 repo 档,停用本地设置的 yum 软件库。请确定相关的部份包含以下符串:
enabled=0
接着,请进到 Spacewalk 的界面并选择 Systems。请选择新安装的客户端服务器。在 Details -> Overview 这个划面,点击 Alter Channel Subscriptions 这个连结。请为你新管理的服务器设置合适的频道。
10. 利用 Spacewalk 来管理配置文件
你可以利用 Spacewalk 来管理配置文件。你只需一个设置频道,当中包含一个或以上的文件/目录。
10.1. 创建一个新的设置频道
你必须先创建一个设置频道。进到 Spacewalk 的界面并选择 Configuration -> Configuration Channels。点击 create new config channel 这个连结。
这里有一个样例:
Name*: SSH Keys
Label*: ssh-keys
Description*: Channel to manage ~/.ssh/authorized_keys
频道被创建后,你可以在其中加入一个或以上的文件/目录。进到 Configuration -> Configuration Channels 并选择你刚创建的频道。现在点击 Create new configuration file or directory 并适当地编辑各字段。
10.2. 允许 Spacewalk 管理系统上的文件
你已经创建了设置频道并加入了文件。现在你需要允许 Spacewalk 管理系统上的文件。进到 Configuration -> Systems -> Target Systems 后你便会看见所有登记在 Spacewalk 上的系统。
请选择你想启用设置管理的系统并点击 Enable Spacewalk Configuration Management。Spacewalk 会尝试加进装备的权限并在系统上安装所需的组件。
注: 假若你看见 Could not subscribe to the Spacewalk Tools channel 这个错误信息,你便需要以人手安装所需的组件。

登录客端系统并执行以下指令:

yum install rhncfg rhncfg-actions rhncfg-client

现在于系统上执行以下指令,容许安装来自中央数据库的配置文件:

rhn-actions-control --enable-deploy

你的系统现在已经准就绪当。你再返回 Spacewalk 的界面时,便会看见它出现在 Configuration -> Systems -> Managed Systems 之内
11. 设置 OSAD(即时执行更新)
通过 OSAD,在 Spacewalk 界面上所个的更新会近乎即时在客户端执行。它亦为 Spacewalk 的其它功能提供这服务。因此,你便不用等候 Spacewalk 编排时间。
11.1. 设置客户端
安装 osad 这个组件:
yum install osad
打开 /etc/sysconfig/rhn/osad.conf 并将以 osa_ssl_cert 起首的那一行改为:
osa_ssl_cert = /usr/share/rhn/RHN-ORG-TRUSTED-SSL-CERT
下载被信任的凭证:
cd /usr/share/rhn/
wget http://spacewalk.example.com/pub/RHN-ORG-TRUSTED-SSL-CERT
注意: 切记时常使用你的 Spacewalk 服务器的全局名。
要启用 osad 你很可能须要安装 python-hashlib:
yum install python-hashlib
现在你只须启用 osad 这个守护程序:
service osad start
提示: 你可以强迫 Spacewalk 承认某台客户端的 OSA 现况。要这样做,请在网页界面上进到该客户端的主机概览页。在该页的右边,你会看见一处用来显示客户端的 OSA 现况。传送一个 ping 到该客户端将会更新它的现况为 online。
由现在起,你的更新将会接近即时地被执行。
12. 把软件库同步的脚本
Davidson Paulo <davidsonpaulo AT gmail.com> 炮制了一个更好的脚本来管理软件库及将它们同步(谢谢你的杰作 )。它会寻找一个配置文件并将内里所列出的一切镜像进行同步。
要应用这个脚本,你需要:
• 一个配置文件(例如:/etc/sysconfig/spacewalk-repo-sync)
• 该脚本
12.1. 配置文件
配置文件(/etc/sysconfig/spacewalk-repo-sync)采用以下语法:
[频道名称] [软件库 URL] [方法]
以下是一个实例:
centos-5-updates-i386 http://mirror.centos.org/centos/5/updates/i386/ yum
centos-5-extras-i386 http://mirror.centos.org/centos/5/extras/i386/ yum
centos-5-base-i386 http://mirror.centos.org/centos/5/os/i386/ yum
epel-5-i386 http://download.fedora.redhat.com/pub/epel/5/i386/ yum
12.2. 脚本
而这里是为你代劳的脚本(我很快会用它取代旧的版本):
#!/bin/bash
#
# spacewalk-repo-sync
# Repository synchronization utility for Spacewalk
#
# Authors: Davidson Paulo <davidsonpaulo AT gmail.com>
#
# This is free software. You are free to use it and distribute it under
# the terms of the GNU General Public License v3+

## Variables
config=/etc/sysconfig/spacewalk-repo-sync
log=/var/log/spacewalk-repo-sync
lockfile=/var/run/spacewalk-repo-sync.lock

## Functions
syncrepo() {
echo "/usr/bin/spacewalk-repo-sync --channel $1 --url $2 --type $3"
/usr/bin/spacewalk-repo-sync --channel $1 --url $2 --type $3
}

## Main routine
# try to create the lock and check the outcome
lockfile -r 0 ${lockfile} 1>/dev/null 2>&1
status=$?

if [ ${status} -ne 0 ] ; then
echo "Another instance already running. Aborting."
exit 1
fi

# Remove $lockfile when Ctrl+C is pressed
trap "rm ${lockfile}" EXIT

# Read $config and execute /usr/bin/spacewalk-repo-sync for each repository
if [ -f $config ] ; then
while read line ; do
syncrepo $line
done < <(egrep -v '^([[:space:]#]+|$)' $config)
else
echo "Config file $config does not exist."
exit 1
fi | tee -a $log

exit 0
请存储它,譬如成为 /usr/bin/spacewalk-repo-sync,然后执行:
$ chmod +x /usr/bin/spacewalk-repo-sync
现在,每次你需要把的软件库同步,你只需执行这个脚本。你亦可以将它加进 cron 内。
注意:这个脚本可以正确运作,而且较本指引先前所描述的方法更易管理。我计划以该脚本取代将本指引的某些部份。不过我首先需要一些反馈。所以假若你遇到问题,请告诉我。

源链接:http://wiki.centos.org/zh/HowTos/PackageManagement/Spacewalk