スティーブジョブスに俺はなる!!

毎日全力を出し切り、自分史上最高を出し続けたい!

LinuxにMySQLをyumでインストールではまった・・・

yumリポジトリ取得

OS確認

$ uname -a

Linux fxch.jp 2.6.32-71.el6.x86_64 #1 SMP Fri May 20 03:51:51 BST 2011 x86_64 x86_64 x86_64 GNU/Linux

つまり、これだ→Hat Enterprise Linux 6 / Oracle Linux 6

以下のリンク先から該当のファイルをダウンロードする

MySQL :: Download MySQL Yum Repository

$ wget http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm

ダウンロードしたyumを適用

$ sudo yum localinstall mysql-community-release-el6-5.noarch.rpm

中略

インストール:
mysql-community-release.noarch 0:el6-5

完了しました!

 

確認してみる

$ yum repolist enabled | grep "mysql.*-community.*"

mysql-connectors-community MySQL Connectors Community 14
mysql-tools-community MySQL Tools Community 23
mysql56-community MySQL 5.6 Community Server 146

 

インストール可能なのは以下の通り

$ yum repolist all | grep mysql
mysql-connectors-community MySQL Connectors Community 有効: 14
mysql-connectors-community-source MySQL Connectors Community - Sourc 無効
mysql-tools-community MySQL Tools Community 有効: 23
mysql-tools-community-source MySQL Tools Community - Source 無効
mysql55-community MySQL 5.5 Community Server 無効
mysql55-community-source MySQL 5.5 Community Server - Sourc 無効
mysql56-community MySQL 5.6 Community Server 有効: 146
mysql56-community-source MySQL 5.6 Community Server - Sourc 無効
mysql57-community-dmr MySQL 5.7 Community Server Develop 無効
mysql57-community-dmr-source MySQL 5.7 Community Server Develop 無効


私のLinuxにはmysql 5.1がデフォルトで入ってるがいらないので、削除
$ sudo yum remove mysql
中略
削除しました:
mysql.x86_64 0:5.1.73-3.el6_5

依存性の削除をしました:
mysql-server.x86_64 0:5.1.73-3.el6_5

完了しました!

改めてインストール
$
sudo yum install mysql-community-server
インストール:
mysql-community-libs.x86_64 0:5.6.24-3.el6
mysql-community-libs-compat.x86_64 0:5.6.24-3.el6
mysql-community-server.x86_64 0:5.6.24-3.el6

依存性関連をインストールしました:
libaio.x86_64 0:0.3.107-10.el6
mysql-community-client.x86_64 0:5.6.24-3.el6
mysql-community-common.x86_64 0:5.6.24-3.el6

置換:
mysql-libs.x86_64 0:5.1.73-3.el6_5

完了しました!

さて、mysql起動してみますか!
% sudo service mysqld start
MySQL Daemon failed to start.
Starting mysqld: [FAILED]

あh???エラー発生・・・
% sudo tail -100f /var/log/mysqld.log
[ERROR] InnoDB: auto-extending data file ./ibdata1 is of a different size 640 pages (rounded down to MB) than specified in the .cnf file: initial 768 pages, max 0 (relevant if non-zero) pages!
2015-05-24 22:43:37 10323 [ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the system tablespace, and it failed here, you should now edit innodb_data_file_path in my.cnf back to what it was, and remove the new ibdata files InnoDB created in this failed attempt. InnoDB only wrote those files full of zeros, but did not yet use them in any way. But be careful: do not remove old data files which contain your precious data!
2015-05-24 22:43:37 10323 [ERROR] Plugin 'InnoDB' init function returned error.
2015-05-24 22:43:37 10323 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2015-05-24 22:43:37 10323 [ERROR] Unknown/unsupported storage engine: InnoDB
2015-05-24 22:43:37 10323 [ERROR] Aborting

よくわからないがファイルが悪いらしい
% cd /var/lib/mysql
% sudo mv ibdata1 ibdata1_bk

再度、mysql起動!おらーーーー!!!!
% sudo service mysqld start
MySQL Daemon failed to start.
Starting mysqld: [FAILED]

エラー発生・・・
% sudo tail -100f /var/log/mysqld.log
[ERROR] InnoDB: Cannot create ./ib_logfile1
2015-05-24 22:45:11 10588 [ERROR] Plugin 'InnoDB' init function returned error.
2015-05-24 22:45:11 10588 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2015-05-24 22:45:11 10588 [ERROR] Unknown/unsupported storage engine: InnoDB
2015-05-24 22:45:11 10588 [ERROR] Aborting

おっ、エラー変わった!
よくわからないが適当に
% cd /var/lib/mysql
% sudo mv ib_logfile1 ib_logfile_bk

おらーーーー!!!!
% sudo service mysqld start
MySQL Daemon failed to start.
Starting mysqld: [FAILED]

[Warning] InnoDB: Doublewrite does not have page_no=0 of space: 0
[ERROR] InnoDB: space header page consists of zero bytes in data file ./ibdata1
どうやらだめだったらしい、元に戻す
% cd /var/lib/mysql
% sudo cp -p ib_logfile_bk ib_logfile1

調査

osx - MySQL doesn't starts on AMPPS OS X - Stack Overflow


設定変更してみる。
% sudo vi /etc/my.cnf
[mysqld]の下に以下を挿入
innodb_force_recovery = 1

おらーーーー!!!!
% sudo service mysqld start
MySQL Daemon failed to start.
Starting mysqld: [FAILED]

動きませんが?
% sudo tail -100f /var/log/mysqld.log
InnoDB: Assertion failure in thread 140398945199904 in file fsp0fsp.cc line 1849
InnoDB: Failing assertion: inode
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.6/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
14:06:34 UTC - mysqld got signal 6 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed,
something is definitely wrong and this may fail.

エンドレスエラー突入っぽい。
俗に言うあれですね、「ハマった💦」

てか、innodb force recoveryなんてやっていいのかよ?w

MySQL Bugs: #74876: InnoDB: Failing assertion: inode in file fsp0fsp.cc line 1887 | fseg_inode_get

調べたらわけわからない事になってるので他の方法探す。

 

% sudo vi /etc/my.cnf
さっき追加したのを削除
削除→innodb_force_recovery = 1

またここに戻る
% cd /var/lib/mysql
先頭がibから始まるファイル全部退避
% sudo mv ibdata1 ibdata1_bk
% sudo mv ib_logfile0 ib_logfile0_bk
% sudo mv ib_logfile1 ib_logfile1_bk
% sudo mv ib_logfile101 ib_logfile101_bk

おらーーーーーーーー!!!!
% sudo service mysqld start
Starting mysqld: [  OK  ]

成功????

% sudo service mysqld status
mysqld (pid 12994) is running...

^^v

インスト終わったら、セキュリティ大事よ
% sudo mysql_secure_installation
rootのパスワード設定
Enter current password for root (enter for none):
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
またかよ・・・・

Control + C で脱出

そけっとくらいつくっとk−ーーーーーーー
% sudo touch /var/lib/mysql/mysql.sock 
% sudo chown mysql:mysql /var/lib/mysql/mysql.sock


% sudo mysql_secure_installation
Enter current password for root (enter for none):
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
ん??????

[Note] /usr/sbin/mysqld: ready for connections.
Version: '5.6.24' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server (GPL)
2015-05-24 23:49:11 13447 [Note] /usr/sbin/mysqld: Normal shutdown

ポート開いてない系?
まあ、開けた覚えないけどさ・・・・

一行追加
% sudo vi /etc/sysconfig/iptables
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
% sudo service iptables restart
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
iptables: Applying firewall rules: [ OK ]

% sudo mysql_secure_installation Enter current password for root (enter for none):
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
ん??????

% sudo service mysqld start
Starting mysqld: [ OK ]

% sudo mysql_secure_installation
入力なしでEnter
Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] Y

・・・・・・起動してないとダメなのかよ・・・・・・

New password:
Re-enter new password:
ERROR 1054 (42S22) at line 1: Unknown column 'plugin' in 'where clause'
old password update failed!
Cleaning up...


またエラー〜????

もう一回やってみる・・

% sudo mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

空でEnter
Enter current password for root (enter for none):
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

え?設定されてるの???
Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

You already have a root password set, so you can safely answer 'n'.

設定されてるのでn
Change the root password? [Y/n]n

エラーになって設定されているという怖いパターン。
後で破片が問題にならなければいいが・・・・

Remove anonymous users? [Y/n] Y
... Success!
Disallow root login remotely? [Y/n] Y
... Success!
Remove test database and access to it? [Y/n] Y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
eload privilege tables now? [Y/n] Y
... Success!
All done! If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

Cleaning up...


できたーーーー(涙)
俺に何時間掛けさせるつもりやねん!

全部GrailsがデフォルトDB使えずにMySQLを設定しなければいけないせいだ!!