【CentOS7】実は古いバージョンのままのMariaDBでハマる

CREATE TABLE IF NOT EXISTS `enum` (
`id` mediumint(9) NOT NULL COMMENT ‘主キー’,
`name` varchar(16) DEFAULT NULL COMMENT ‘enum名’,
`version` varchar(16) DEFAULT NULL COMMENT ‘バージョン’,
`list` text COMMENT ‘キーとバリューのリスト 書式はJSON’,
`cre_ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ‘作成日時’,
`up_ts` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT ‘更新日時’,
`del` tinyint(1) NOT NULL DEFAULT ‘0’ COMMENT ‘削除フラグ’
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COMMENT=’列挙型宣言’;
な感じのテーブルを作ろうとしたら、MariaDBのVer5.5ではCURRENT_TIMESTAMPが使えるのは1カラム限定だった。
作成日時と更新日時の両方を気にせずに済むようにしたかったダケなんだが・・・
本家を見てみる。画面で、CentOSで、7で、x86_64で、Ver 10.1 と順に選択していくと、yumが使えるらしい。
まず、新たなMariaDBのリポジトリィの追加が必要で、先の画面の云う通りに /etc/yum.repos.d/MariaDB.repoを追加。
新規サーバーなら
# sudo yum install MariaDB-server MariaDB-client
でいいらしいけど、そうは行かないので、
公開中のブログ鯖なら・・・
ここでルータから80ポートを飛ばさない様にしないと、
アップグレード中はあの文字化け画面(echoコマンドで16進数ダンプをUTF-8に変換すると、「データベースの接続に失敗しました。」とかになるハズ)を送信してるはずだし、アップグレード自体、失敗するかもしれない。
さて、https://mariadb.com/kb/en/library/yum/ を見ながら・・・
# systemctl stop MariaDB
# systemctl status MariaDB
でちゃんと止まっているのを確認する。

Active: inactive (dead)

# yum update MariaDB-server MariaDB-client
# systemctl start MariaDB
ここでやっとphpMyAdminやWordPressが使えるようになる。
とりあえず、支障はない様だ。先のCREATE TABLEもOK。
メデタシメデタシ。
******************************
と思ったら、10.2というのがあったのでコレにアップグレードしようと思ったら、ならないので
本家を見てみる。画面で、CentOSで、7で、x86_64で、Ver 10.2 と順に選択して
先の画面の云う通りに /etc/yum.repos.d/MariaDB.repoを改ざん。
# systemctl stop MariaDB
# yum update MariaDB-server MariaDB-client
してみると、失敗。
先のページを読むと、一旦5.5にダウングレードして10.2にアップグレードした方が良かったらしい。
では、今はどうなっているのだろうか?????
# yum list MariaDB-server MariaDB-client
どうやら、10.1と10.2が混在。
10.2の方が黄色い文字で表示された。
一旦、両方を削除。
# yum remove MariaDB-server MariaDB-client
そして、やりなおし。
# yum install MariaDB-server MariaDB-client
# systemctl start MariaDB
で、phpMyAdminにも「サーバのバージョン: 10.2.14-MariaDB – MariaDB Server」と表示された。
多分データベースだからremoveしても設定やデータ関連のファイルは消さないのだろう。
普通のパッケージでもremove時に設定ファイルの名前をバックアップっぽい名前に変えていて install時に再利用することもあるけど、「設定がゴッソリ消えることもある」と思った方がいいだろう。
 
以上、自宅鯖のお話。
あ、ここ(lolipop)のサーバーのデータベースのバージョンは変えられないと思うよ。
 
メデタシメデタシ。
ps.
後で見つけた
https://mariadb.com/kb/en/library/upgrading-from-mariadb-101-to-mariadb-102/
を見ると、
10.1から10.2にアップデートするには
 

の手順になるらしいが、CentOSには

は無いそうなので、やらない。
しかし、
systemctl stop mariadb
systemctl start mariadb
の直後のvar/log/messagesではエラっていた。

systemd: Starting MariaDB 10.2.14 database server…
mysqld: 2018-04-27 20:14:25 140130462066816 [Note] /usr/sbin/mysqld (mysqld 10.2.14-MariaDB) starting as process 32327 …
mysqld: 2018-04-27 20:14:25 140130462066816 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
mysqld: 2018-04-27 20:14:25 140130462066816 [Note] InnoDB: Uses event mutexes
mysqld: 2018-04-27 20:14:25 140130462066816 [Note] InnoDB: Compressed tables use zlib 1.2.7
mysqld: 2018-04-27 20:14:25 140130462066816 [Note] InnoDB: Using Linux native AIO
mysqld: 2018-04-27 20:14:25 140130462066816 [Note] InnoDB: Number of pools: 1
mysqld: 2018-04-27 20:14:25 140130462066816 [Note] InnoDB: Using SSE2 crc32 instructions
mysqld: 2018-04-27 20:14:25 140130462066816 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
mysqld: 2018-04-27 20:14:25 140130462066816 [Note] InnoDB: Completed initialization of buffer pool
mysqld: 2018-04-27 20:14:25 140129696761600 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
mysqld: 2018-04-27 20:14:25 140130462066816 [Note] InnoDB: Highest supported file format is Barracuda.
mysqld: 2018-04-27 20:14:25 140130462066816 [Note] InnoDB: 128 out of 128 rollback segments are active.
mysqld: 2018-04-27 20:14:25 140130462066816 [Note] InnoDB: Creating shared tablespace for temporary tables
mysqld: 2018-04-27 20:14:25 140130462066816 [Note] InnoDB: Setting file ‘./ibtmp1’ size to 12 MB. Physically writing the file full; Please wait …
mysqld: 2018-04-27 20:14:25 140130462066816 [Note] InnoDB: File ‘./ibtmp1’ size is now 12 MB.
mysqld: 2018-04-27 20:14:25 140130462066816 [Note] InnoDB: Waiting for purge to start
mysqld: 2018-04-27 20:14:25 140130462066816 [Note] InnoDB: 5.7.21 started; log sequence number 3990152243
mysqld: 2018-04-27 20:14:25 140130462066816 [Note] Plugin ‘FEEDBACK’ is disabled.
mysqld: 2018-04-27 20:14:25 140129322649344 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
mysqld: 2018-04-27 20:14:25 140130462066816 [Note] Server socket created on IP: ‘::’.
mysqld: 2018-04-27 20:14:25 140129322649344 [Note] InnoDB: Buffer pool(s) load completed at 180427 20:14:25
mysqld: 2018-04-27 20:14:25 140130462066816 [ERROR] Missing system table mysql.roles_mapping; please run mysql_upgrade to create it
mysqld: 2018-04-27 20:14:25 140130354976512 [Warning] Failed to load slave replication state from table mysql.gtid_slave_pos: 1146: Table ‘mysql.gtid_slave_pos’ doesn’t exist
mysqld: 2018-04-27 20:14:25 140130462066816 [Note] Reading of all Master_info entries succeded
mysqld: 2018-04-27 20:14:25 140130462066816 [Note] Added new Master_info ” to hash table
mysqld: 2018-04-27 20:14:25 140130462066816 [Note] /usr/sbin/mysqld: ready for connections.
mysqld: Version: ‘10.2.14-MariaDB’ socket: ‘/var/lib/mysql/mysql.sock’ port: 3306 MariaDB Server
systemd: Started MariaDB 10.2.14 database server.

なので
# mysql_upgrade -u root -p
してみた。
systemd: Starting MariaDB 10.2.14 database server…
mysqld: 2018-04-27 20:26:45 140386232084608 [Note] /usr/sbin/mysqld (mysqld 10.2.14-MariaDB) starting as process 32483 …
mysqld: 2018-04-27 20:26:45 140386232084608 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
mysqld: 2018-04-27 20:26:45 140386232084608 [Note] InnoDB: Uses event mutexes
mysqld: 2018-04-27 20:26:45 140386232084608 [Note] InnoDB: Compressed tables use zlib 1.2.7
mysqld: 2018-04-27 20:26:45 140386232084608 [Note] InnoDB: Using Linux native AIO
mysqld: 2018-04-27 20:26:45 140386232084608 [Note] InnoDB: Number of pools: 1
mysqld: 2018-04-27 20:26:45 140386232084608 [Note] InnoDB: Using SSE2 crc32 instructions
mysqld: 2018-04-27 20:26:45 140386232084608 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
mysqld: 2018-04-27 20:26:46 140386232084608 [Note] InnoDB: Completed initialization of buffer pool
mysqld: 2018-04-27 20:26:46 140385465427712 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
mysqld: 2018-04-27 20:26:46 140386232084608 [Note] InnoDB: Highest supported file format is Barracuda.
mysqld: 2018-04-27 20:26:46 140386232084608 [Note] InnoDB: 128 out of 128 rollback segments are active.
mysqld: 2018-04-27 20:26:46 140386232084608 [Note] InnoDB: Creating shared tablespace for temporary tables
mysqld: 2018-04-27 20:26:46 140386232084608 [Note] InnoDB: Setting file ‘./ibtmp1’ size to 12 MB. Physically writing the file full; Please wait …
mysqld: 2018-04-27 20:26:46 140386232084608 [Note] InnoDB: File ‘./ibtmp1’ size is now 12 MB.
mysqld: 2018-04-27 20:26:46 140386232084608 [Note] InnoDB: Waiting for purge to start
mysqld: 2018-04-27 20:26:46 140386232084608 [Note] InnoDB: 5.7.21 started; log sequence number 3990183005
mysqld: 2018-04-27 20:26:46 140384957097728 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
mysqld: 2018-04-27 20:26:46 140386232084608 [Note] Plugin ‘FEEDBACK’ is disabled.
mysqld: 2018-04-27 20:26:46 140386232084608 [Note] Server socket created on IP: ‘::’.
mysqld: 2018-04-27 20:26:46 140384957097728 [Note] InnoDB: Buffer pool(s) load completed at 180427 20:26:46
mysqld: 2018-04-27 20:26:46 140386232084608 [Note] Reading of all Master_info entries succeded
mysqld: 2018-04-27 20:26:46 140386232084608 [Note] Added new Master_info ” to hash table
mysqld: 2018-04-27 20:26:46 140386232084608 [Note] /usr/sbin/mysqld: ready for connections.
mysqld: Version: ‘10.2.14-MariaDB’ socket: ‘/var/lib/mysql/mysql.sock’ port: 3306 MariaDB Server
systemd: Started MariaDB 10.2.14 database server.
多分、これでいいのだろう。
 
 




コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA