古いRedhatでyumを使う方法
古いバージョンのLinuxサーバをメンテすることが多くなったので、いつも試行錯誤するyumのリポジトリの設定をメモっておきました。---------------------------古いバージョンのRedHatで、yum コマンドを実行すると、次のようなエラーになります。 例:RedHat 5.4(64bit)の場合yum update Loaded plugins: security YumRepo Error: All mirror URLs are not using ftp, http[s] or file. Eg. 5Server is not a valid release or hasnt been released yet/ removing mirrorlist with no valid mirrors: /var/cache/yum/local/mirrorlist.txt Error: Cannot retrieve repository metadata (repomd.xml) for repository: local. Please verify its path and try againEOSLになっている古いバージョンは、ミラーから削除されるため、yumコマンドはエラーになります。RedHatのリポジトリには、古いバージョンはないので、CentOSのリポジトリを使います。下記で、古いリポジトリを参照できます。(2019年4月時点)http://vault.centos.org/そこで、以下のようなrepoファイルを作成すれば、参照できるようになります。/etc/yum.repos.d/CentOS-Base.repo[root yum.repos.d]# cat CentOS-Base.repo[base]name=CentOS-$releasever - Base#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/baseurl=http://vault.centos.org/5.4/os/$basearch/gpgcheck=1#gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-$releasevergpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-5[updates]name=CentOS-$releasever - Updates#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/baseurl=http://vault.centos.org/5.4/os/$basearch/gpgcheck=1gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-5[extras]name=CentOS-$releasever - Extras#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/baseurl=http://vault.centos.org/5.4/os/$basearch/gpgcheck=1gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-5このファイルを作成したあとで、リポジトリのlistを確認すると、ちゃんと認識してくれました。[root yum.repos.d]# yum repolistLoaded plugins: securityrepo id repo name statusbase CentOS-5Server - Base enabled: 2,535extras CentOS-5Server - Extras enabled: 2,535updates CentOS-5Server - Updates enabled: 2,535zabbix Zabbix Official Repository - x86_64 enabled: 401zabbix-non-supported Zabbix Official Repository non-supported - x86_64 enabled: 13repolist: 8,019コメントアウトした行は、参考のために残してありますが、変数のままだと、必要な環境を指してくれないので、明示的に変更します。$releaseverの変数のままだと、この環境では、"5Server"になってしまうので、明示的に指定しました。上記の設定では、バージョンを5.4と固定しています。$basearchの変数は、環境のアーキテクチャに合わせて決まるので、この5.4(64bit)の場合だと、x86_64と、i386 を探してくれます。環境にあわせて、i686も探すので、この変数は書き換える必要はないはずです。