任务:
- 备份已安装的glibc为RPM包,还原。
准备:
- 下载rpmrebuild
- 上传至服务器
密码: wgy9
操作:
1.以root用户登录
2.解压rpmrebuild.rar
#cd/tmp #unrar x rpmrebuild.rar /usr/lib
3.修改/usr/lib/rpmrebuild目录下的文件权限。
#cd /usr/lib/rpmrebuild/ #chmod 755 *
4.创建/opt/ataebackup目录备份原glibc版本信息。
#mkdir -p /opt/ataebackup #rpm -qa |grep glibc > /opt/ataebackup/glibc_version.txt #rpm -qa |grep ^nscd > /opt/ataebackup/nscd_version.txt
5.依次执行以下命令备份原有的glibc。
# /usr/lib/rpmrebuild/rpmrebuild.sh -d /opt/ataebackup glibc # /usr/lib/rpmrebuild/rpmrebuild.sh -d /opt/ataebackup glibc-32bit # /usr/lib/rpmrebuild/rpmrebuild.sh -d /opt/ataebackup glibc-devel # /usr/lib/rpmrebuild/rpmrebuild.sh -d /opt/ataebackup glibc-devel-32bit # /usr/lib/rpmrebuild/rpmrebuild.sh -d /opt/ataebackup glibc-html # /usr/lib/rpmrebuild/rpmrebuild.sh -d /opt/ataebackup glibc-i18ndata # /usr/lib/rpmrebuild/rpmrebuild.sh -d /opt/ataebackup glibc-info # /usr/lib/rpmrebuild/rpmrebuild.sh -d /opt/ataebackup glibc-locale # /usr/lib/rpmrebuild/rpmrebuild.sh -d /opt/ataebackup glibc-locale-32bit # /usr/lib/rpmrebuild/rpmrebuild.sh -d /opt/ataebackup glibc-profile # /usr/lib/rpmrebuild/rpmrebuild.sh -d /opt/ataebackup glibc-profile-32bit # /usr/lib/rpmrebuild/rpmrebuild.sh -d /opt/ataebackup nscd
异常处理:
- 若提示是否继续及输入版本时,请依次输入y和N。例如,执行过程如下:
/usr/lib/rpmrebuild/rpmrebuild.sh: WARNING: some files have been modified: S.5....T c /etc/ld.so.conf Do you want to continue ? (y/N) y Do you want to change release number ? (y/N) N Processing files: glibc-2.4-31.77.88.4 warning: Could not canonicalize hostname: linux Wrote: /opt/ataebackup/x86_64/glibc-2.4-31.77.88.4.x86_64.rpm result: /opt/ataebackup/x86_64/glibc-2.4-31.77.88.4.x86_64.rpm
其中,result行表示备份文件的存放路径。
- 若系统中未安装相应的包,则不需要备份,系统会提示以下类似信息,请忽略该错误提示。
atae-mo-slot4:/usr/lib/rpmrebuild # /usr/lib/rpmrebuild/rpmrebuild.sh glibc-html /usr/lib/rpmrebuild/rpmrebuild.sh: ERROR: glibc-html package in not installed
- 备份原gblic包时,若提示以下类似信息,请忽略该错误提示。
linux02:/usr/lib/rpmrebuild # /usr/lib/rpmrebuild/rpmrebuild.sh -d /opt/ataebackup glibc-32bit Processing files: glibc-32bit-2.4-31.77.88.4.4491.2.PTF.772242 warning: Could not canonicalize hostname: linux02
- 备份nscd包时,若提示以下错误信息:
Processing files: nscd-2.4-31.63.7 error: File not found: /var/run/nscd/hosts RPM build errors: File not found: /var/run/nscd/hosts /usr/lib/rpmrebuild/rpmrebuild.sh: ERROR: package 'nscd' build failed
需要手工创建该文件,备份后删除该文件。执行以下命令重新备份nscd包:
# touch /var/run/nscd/hosts # /usr/lib/rpmrebuild/rpmrebuild.sh -d /opt/ataebackup nscd # rm /var/run/nscd/hosts
还原:
1.进入备份目录。
# cd /opt/ataebackup/x86_64
2.重新安装旧版本的补丁包。
部分补丁包原来没有安装,因此无备份文件,忽略错误提示即可。
查看/opt/ataebackup/glibc_version.txt和/opt/ataebackup/nscd_version.txt中备份的glibc和nscd包的版本信息。以2.4-31.77.88.4版本为例,执行如下命令回退版本:
# rpm -Uvh --force glibc-2.4-31.77.88.4.x86_64.rpm # rpm -Uvh --force glibc-32bit-2.4-31.77.88.4.x86_64.rpm # rpm -Uvh --force glibc-devel-2.4-31.77.88.4.x86_64.rpm # rpm -Uvh --force glibc-devel-32bit-2.4-31.77.88.4.x86_64.rpm # rpm -Uvh --force glibc-html-2.4-31.77.88.4.x86_64.rpm # rpm -Uvh --force glibc-i18ndata-2.4-31.77.88.4.x86_64.rpm # rpm -Uvh --force glibc-info-2.4-31.77.88.4.x86_64.rpm # rpm -Uvh --force glibc-locale-2.4-31.77.88.4.x86_64.rpm # rpm -Uvh --force glibc-locale-32bit-2.4-31.77.88.4.x86_64.rpm # rpm -Uvh --force glibc-profile-2.4-31.77.88.4.x86_64.rpm # rpm -Uvh --force glibc-profile-32bit-2.4-31.77.88.4.x86_64.rpm # rpm -Uvh --force nscd-2.4-31.77.88.4.x86_64.rpm
3.检查回退后的glibc库的版本信息。
# rpm -qa |grep glibc
如果系统没有安装相应的软件包,则不会被查询到。以版本2.4-31.77.88.4为例,显示结果如下:
glibc-2.4-31.77.88.4 glibc-locale-2.4-31.77.88.4 glibc-32bit-2.4-31.77.88.4 glibc-profile-32bit-2.4-31.77.88.4 glibc-devel-2.4-31.77.88.4 glibc-i18ndata-2.4-31.77.88.4 glibc-profile-2.4-31.77.88.4 glibc-html-2.4-31.77.88.4 glibc-locale-32bit-2.4-31.77.88.4 glibc-devel-32bit-2.4-31.77.88.4 glibc-info-2.4-31.77.88.4
4.检查nscd的版本是否回退。
# rpm -qa |grep ^nscd
例如,显示结果如下:
nscd-2.4-31.77.88.4
重启操作系统和应用。