LoginSignup
10
13

More than 5 years have passed since last update.

CentOS7へのアップデートでハマった

Last updated at Posted at 2016-03-08

今後のサーバーパフォーマンス向上のためCent0S6.8からCentOS7にアップデートしました。アップデート前の設定が終わり、rebootをかけてからが阿鼻叫喚でしたので、teratailでご支援もいただきましたが、
qiitaで備忘録も兼ねて共有しようと思います。
ポイントは
・libpcre.so.0のエラーが出たら、シンボリックリンクを変更する
・Mysqlのmy.confの設定で、default-character-set=utf8という表記は最新版ではご法度
というところでしょうか。

rebootをかける前に、前回rebootかけた際に、httpd(apache)が起動してしまい、nginxとポートが衝突し、nginxが起動しなかったので

ランレベルのコマンド
# chkconfig --level 2 httpd off
# chkconfig --level 3 httpd off
# chkconfig --level 4 httpd off
# chkconfig --level 5 httpd off

を実施し、再起動しても起動しないようにしました。

リブート
# reboot
Broadcast message from ユーザー名@***.sakura.ne.jp
    (/dev/pts/1) at 10:49 ...

The system is going down for reboot NOW!

少し待ってログインを試みると

リブート
$ ssh -p ポート番号 ユーザー名@IPアドレス
ssh: connect to host IPアドレス port ポート番号: Connection refused

ログイン拒否?!と慌てて、別PCからもログイン出来ず「やばい」
と思い、さくらのVPSのコントロールパネルからシリアルコンソールへ。
画面を見ると、まだアップデートが走っていることが判明し、終わるのを
待ったところ、再度ログイン。今度は成功しました。

Mysqlのバックアップを直前に取り忘れたので、Mysqlの復旧を第1優先にと思い、以下のコマンドを打ちました。

MysqlとNGINX起動
# service mysql start
egrep: error while loading shared libraries: libpcre.so.0: cannot open shared object file: No such file or directory
The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.
# systemctl is-enabled mysqld.service
Failed to get unit file state for mysqld.service: No such file or directory
# service httpd status
egrep: error while loading shared libraries: libpcre.so.0: cannot open shared object file: No such file or directory
The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.
#  /etc/init.d/nginx start
grep: error while loading shared libraries: libpcre.so.0: cannot open shared object file: No such file or directory
Starting nginx (via systemctl):  Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
 [失敗]

ここまでやった段階で、libpcre.so.0へのアクセスができてないことが
判明し、libpcreのインストールを試みます。

pcreのインストール
# yum install pcre-devel
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: mirrors.hustunique.com
 * extras: ftp.iij.ad.jp
 * remi-php56: mirror.innosol.asia
 * remi-safe: mirror.innosol.asia
 * updates: ftp.iij.ad.jp
パッケージ pcre-devel-8.32-15.el7.x86_64 はインストール済みか最新バージョンです
何もしません

うーん困った。どうしようとなる。

再度pcreをインストール
# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.37.tar.gz
# tar zxvf pcre-8.37.tar.gz
# cd pcre-8.37
# ./configure --prefix=/opt/pcre-8.37
(...省略...)
grep: error while loading shared libraries: libpcre.so.0: cannot open shared object file: No such file or directory
checking for grep that handles long lines and -e... configure: error: no acceptable grep could be found in /usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/nanokko/bin:/usr/xpg4/bin

pcreが無いのでmakeファイルが作れない...
ここで、考え付く万策は尽きてしまったので、Teratailに質問を...
回答を待つ間、自己流でいろいろ的外れな対策を打って、上手くいかず心折れかけていましたが、その後いろいろアドバイスを頂くことができ、

リンクを修復
# find / libpcre.so.0
・・・ファイルは見つからず...
# ldd /usr/sbin/nginx
    linux-vdso.so.1 =>  (0x00007ffd42296000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f248cd64000)
    libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007f248cb2d000)
    libpcre.so.0 => not found
# ln -s /lib64/libpcre.so /lib64/libpcre.so.0

シンボリックリンクを貼る。
もう1度nginxを起動

Nginx起動
#systemctl restart nginx
Job for nginx.service failed because the control process exited with error code.
# systemctl status nginx.service
3月 08 13:09:43 www***.sakura.ne.jp nginx[12027]: nginx: [emerg] SSL_CTX_use_PrivateKey_file("/etc/nginx/***/****.key") failed (SSL: error:0906...:PEM lib)

SSL用のプライベートキーが開けないとのこと。

SSL用キーの再生成とnginxの起動
# cp ***.key ***.key.backup
# openssl rsa -in ***.key -out ***.key
# systemctl restart nginx

無事起動!。

Mysqlの起動
# systemctl restart mysqld

このコマンドを投げてもレスポンスが帰ってこなく、起動もできておらず、
タイムアウトが帰ってきた。
エラーも出ず途方にくれつつ、

Mysqlの起動時のログ
 3月 08 14:06:25 ***.sakura.ne.jp systemd[1]: Starting MySQL Community Server...
 3月 08 14:06:25 ****.sakura.ne.jp mysqld_safe[18808]: 160308 14:06:25 mysqld_safe Logging to '/var/log/mysqld.log'.
 3月 08 14:06:25 ****.sakura.ne.jp mysqld_safe[18808]: 160308 14:06:25 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

起動時のログを確認したところ、ここで止まっていることが判明。

Mysqlの起動時のログ
# vi /var/log/mysqld.log

[ERROR] /usr/libexec/mysqld: unknown variable 'default-character-set=utf8'

見てみると、原因は、mysqlもバージョンアップされていて、my.cnfの設定が

誤っていたmy.cnf
[mysqld]
default-character-set=utf8
[mysql]
default-character-set=utf8

になっていたのがNGで、

正しいmy.cnf
[mysqld]
character-set-server=utf8
[mysql]
default-character-set=utf8

にしなくてはいけないことが判明。
参考

my.cnfを編集
# vi /etc/my.cnf

で編集し

Mysqlを再起動
# systemctl start mysql.service

で立ち上がりを確認し、復旧までこぎつけたのでした。
他の人が同じ罠にはまらないように備忘録となりますが、
なお、MySQLはCentOS7に入っていないので、別途インストールを実施してます。。。

10
13
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
13