CentOS6.9を7.3にアップグレード

スポンサーリンク

CentOS6系から7系へのアップグレードはアップグレードツールが存在するのですが、このツールは6.7以上で実行すると問題があると書かれているます。
TipsAndTricks/CentOSUpgradeTool – CentOS Wiki

色々ググると6.5からならアップグレードできたという記事が多い反面、6.8からアップグレードしようとしてエラーが出たという記事もありました。
CentOS6.8 から CentOS7 へのアップグレード – demandosigno
↑の記事を読むと、openscapをバージョンダウンさせるといけそうという話があったのでその方法で試してみました。

注意:アップグレード後の起動時にsshdが止まっているのでコンソールアクセスができる状態が必要です。
また一時的にsudoが動かなくなったりする場合があるのでrootのパスワードを忘れないように。
あと他にも何が起こるかわからないので重要なファイルはバックアップを。

アップグレードツールを落とすためのリポジトリをyum.repos.dに追加。

# vim /etc/yum.repos.d/upgradetool.repo
[upg]
name=CentOS-$releasever - Upgrade Tool
baseurl=http://dev.centos.org/centos/6/upg/x86_64/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

ツールインストール。

# yum install redhat-upgrade-tool preupgrade-assistant-contents

アップグレード前診断的なコマンド実行。

# preupg -s CentOS6_7
OpenSCAP Error:: Could not parse XSLT file '/usr/share/preupgrade/xsl/preup.xsl' [oscapxml.c:416]
Unable to open file /root/preupgrade/result.html
Usage: preupg [options]

preupg: error: [Errno 2] No such file or directory: '/root/preupgrade/result.html'

エラーになりました。
CentOS6.8 から CentOS7 へのアップグレード – demandosignoのコメントを参考にopenscapをダウングレード。

# rpm -Uhv --oldpackage http://dev.centos.org/centos/6/upg/x86_64/Packages/openscap-1.0.8-1.0.1.el6.centos.x86_64.rpm
# preupg -s CentOS6_7

preupg通ったっぽい。

preupgrade/result.htmlを除いてみる。needs_actionの項目は要注意っぽい。
よくわからないのもあるけど一部対処。

Result for General
Result: needs_action

We have detected that you are using SELinux. There were changes in policies which require to apply custom command before upgrade process. In order to have working SELinux on CentOS 7, you HAVE TO run command prior to running redhat-upgrade-tool:
semodule -r sandbox

やれと書かれているのでやります。

# semodule -r sandbox
Result for Removed rpms
Result: needs_action

Remediation instructions

Some of the packages were removed between CentOS 6 and CentOS 7. This may break
the upgrade for some of your packages. We are not aware of any compatible
replacement for these packages.

Following packages are no longer available:
ConsoleKit-libs
MAKEDEV
atmel-firmware
b43-openfwwf
cloog-ppl
dash
ipw2100-firmware
ipw2200-firmware
lcms-libs
libgcj
libnih
mesa-dri1-drivers
perl-Cache-Memcached
perl-Email-Date-Format
perl-MIME-Lite
perl-MIME-Types
ppl
setools-libs-python
zd1211-firmware

INPLACERISK: HIGH: After upgrading to CentOS 7 there are still some el6 packages left. Add --cleanup-post option to redhat-upgrade-tool if you want to remove them automatically.

仮想環境で先に一度試した時、この中の一部のパッケージは確かにライブラリが無いよ状態みたいなのになってたので –cleanup-post(6から7で廃止されたパッケージを自動的に削除するオプション)を付けることにします。

アップグレード。

# redhat-upgrade-tool-cli --network 7.0 --cleanup-post --instrepo http://mirror.centos.org/centos/7/os/x86_64/

INPLACERISKとかいうのが沢山出てくるけどとりあえずy

Downloading failed: invalid data in .treeinfo: No option 'upgrade' in section: 'images-x86_64'

エラー。
sgrastar blogを参考にinstrepoを変更してみる。

# redhat-upgrade-tool-cli --network 7.0 --cleanup-post --instrepo=http://vault.centos.org/centos/7.2.1511/os/x86_64/
Downloading failed: failure: repodata/3a1b41925bb25892c1003b22979ea0705aa815fed57f992cf0229b76539a9ac4-filelists.sqlite.bz2 from cmdline-instrepo: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"

またエラー。
repodata/3a1b41925bb25892c1003b22979ea0705aa815fed57f992cf0229b76539a9ac4-filelists.sqlite.bz2はmirror.centos.orgにはある模様。

redhat-upgrade-tool-cli –helpを見たところ–addrepoという引数があるっぽいので試してみる。

# redhat-upgrade-tool-cli --network 7 --cleanup-post --instrepo=http://vault.centos.org/centos/7.2.1511/os/x86_64/ --addrepo=CentOS7=http://mirror.centos.org/centos/7/os/x86_64/
Finished. Reboot to start upgrade.

通ったっぽい。

# reboot

grep: error while loading shared libraries~とかいうのが大量に出ましたが待ってたら終わりました。

sshdが止まってるので7系からの新スタイルで起動と自動起動設定。

# systemctl start sshd.service # 起動
job for sshd.service failed because control process exited with error code. See "systemctl status sshd.service" and "journalctl -xe" for detauls

起動失敗しました。
色々ググったら解決してる方が。
CentOS 6.5からCentOS 7.0へのアップグレード(補足トラブル:対処) – Marlock Homes Diary

# ln -s /lib64/libsasl2.so.3 /lib64/libsasl2.so.2
# systemctl start sshd.service

起動しました。

# systemctl enable sshd.servic # 自動起動設定

これでSSHが繋がりました。

# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
# uname -r
3.10.0-514.el7.x86_64

アップグレード成功っぽい。

grepしようとしたらエラー。

# grep
grep: error while loading shared libraries: libpcre.so.0: cannot open shared object file: No such file or directory

CentOS7へのアップデートでハマった – Qiitaを参考に

# ln -s /lib64/libpcre.so /lib64/libpcre.so.0

したら直しました。

yumを使おうとしたらエラー。

# yum update
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

   No module named yum

Please install a package which provides this module, or
verify that the module is installed correctly.

It's possible that the above module doesn't match the
current version of Python, which is:
2.7.8 (default, Oct 25 2014, 22:35:37)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)]

If you cannot solve this problem yourself, please go to
the yum faq at:
  http://yum.baseurl.org/wiki/Faq

rpm -ql yumを見るとyumモジュールは/usr/lib/python2.7/site-packages/yumにインストールされているのに対して

# python
Python 2.7.8 (default, Oct 25 2014, 22:35:37)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/local/lib/python27.zip', '/usr/local/lib/python2.7', '/usr/local/lib/python2.7/plat-linux2', '/usr/local/lib/python2.7/lib-tk', '/usr/local/lib/python2.7/lib-old', '/usr/local/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/site-packages']

/usr/libがありません。
CentOSリポジトリのpythonバージョンは2.7.5だけど過去に手動で2.7.8をビルドしてaltinstallしたせいな気がする。
というかリポジトリから2.7.5も入れたはずなのにどの実行ファイルをpython -Vしても2.7.8って出て謎…。
/usr/local/のパスしか見てないようなのでPythonでデフォルトパスを追加する方法 | 凡人のブログを参考に既存のパスに無理やりyumに必要なパスを追加しました。

# cd /usr/local/lib/python2.7/site-packages # 検索パスが通ってるディレクトリならどこでも
# vim custom.pth

以下2ディレクトリを追加

/usr/lib/python2.7/site-packages/
/usr/lib64/python2.7/site-packages/

したらyumが動くようになりました。
2.7.8のsite-packagesと2.7.5のsite-packagesが混ざっちゃってる気もするけど同じ2.7だし大丈夫でしょたぶん…。

httpdの起動エラー。
モジュール云々はCentOS7にアップグレードしたらApacheのバージョンが2.4になった! – My Happinessを参考にしつつエラー出るモジュールををひたすらコメントアウト。
あとsystemctlの出力が…で省略されて読めない時は-lオプションを付けるといいみたいです。
モジュール色々コメントアウトしたら次はphpのエラー。

httpd: Syntax error on line 222 of /etc/httpd/conf/httpd.conf: Syntax error on line 6 of /etc/httpd/conf.d/php.conf: Cannot load modules/libphp5.so into server: /etc/httpd/modules/libphp5.so: undefined symbol: unixd_config

たぶん以前php5.5をremiから入れたせいだと思うので消して公式リポジトリから再インストールしてみたら直りました。

# yum remove php-*
# yum install php php-devel php-mbstring php-mysql

MySQLから置き換わったMariaDBを起動しようとしたところ

mysqld_safe[2146]: /usr/bin/mysqld_safe: line 183: /var/log/mysqld.log: Permission denied
ysqld_safe[2146]: touch: cannot touch ‘/var/log/mysqld.log’: Permission denied
mysqld_safe[2146]: chown: cannot access ‘/var/log/mysqld.log’: No such file or directory
mysqld_safe[2146]: chmod: cannot access ‘/var/log/mysqld.log’: No such file or directory

/var/log/を見たところmysqld.log.rpmsaveというバックアップファイルができていてるのでこれを戻してみます。

# cd /var/log/
# cp mysqld.log.rpmsave mysqld.log
# chown mysql:mysql mysqld.log

そしたらまた起動失敗したので/var/log/mysqld.logをみると

[ERROR] mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 2)
[ERROR] Can't start server: can't create PID file: No such file

というエラー。

# mkdir /var/run/mysqld
# chown mysql:mysql /var/run/mysqld/
# systemctl start mariadb.service

これで起動しました。(参考:mysql5.7が急に起動しなくなった – Qiita

MariaDBに置き換わってもMySQL時代に入れたデータは引き継がれてるみたいです。

あとepelとremiがCentOS6用のままなのでアップデートします。

# yum update epel-release

こうするとyumの気遣いでepel.repoは更新されずepel.repo.rpmnewとして配置されるので入れ替えます。

# cd /etc/yum.repos.d/
# mv epel.repo epel.repo.bak # 一応
# cp epel.repo.rpmnew epel.repo
# yum remove remi-release
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

epelとremi-safeがデフォルトでenabled=1になっていたので一応0にしておきました。

こんな感じでだいたい動くようになった気がします。

スポンサーリンク
スポンサーリンク
Linux
フォローする
Akashic Records

コメント

  1. 通りすがり より:

    素晴らしい記事をありがとうございます。
    バージョンアップができなく色々なサイトをめぐっておりましたが最終的にこの記事のおかげでアップデートできました。

  2. joel diort より:

    thanks!, you so much !
    you save the day, the .treeinfo checksum error in redhat-upgrade-tool-cli was annoying

タイトルとURLをコピーしました