Upload
yokoninaritai-matsuo
View
4.406
Download
6
Embed Size (px)
DESCRIPTION
Mysql casual talks vol4
Citation preview
MySQL5.6プロダクション投入
2013/04/17Kenji Matsuo
1
13年4月17日水曜日
自己紹介
•Kenji Matsuo• @matsukena• FreakOutでインフラエンジニアをやってます。
•福岡から東京にきてまだ4ヶ月です。2
13年4月17日水曜日
アジェンダ•セットアップ•どうやって切り替えを行った?•はまったポイント•今後やりたい事
3
13年4月17日水曜日
セットアップ
4
13年4月17日水曜日
パッケージ•MySQL-shared-compat-5.6.10-1.el6.x86_64
• MySQL-server-5.6.10-1.el6.x86_64• MySQL-devel-5.6.10-1.el6.x86_64• MySQL-client-5.6.10-1.el6.x86_64
5
13年4月17日水曜日
素直に本家からrpmを持ってきてインストール
6
13年4月17日水曜日
7
class mysql { case $::operatingsystemrelease { /^5/: { $release = "rhel5" } /^6/: { $release = "el6" } } }
package { [ "MySQL-client", "MySQL-devel", "MySQL-shared-compat", ]: ensure => "5.6.10-1.$release", } package { "MySQL-server": ensure => "5.6.10-1.$release", require => [ File["/var/lib/mysql/ibdata"], File["/var/lib/mysql/iblog"], ], }
13年4月17日水曜日
my.cnf
8
13年4月17日水曜日
• performance_schema = off• table_cache → table_open_cache• explicit_defaults_for_timestamp • innodb_additional_mem_pool_sizeを削除
9
13年4月17日水曜日
どうやって切り替えを行った?
10
13年4月17日水曜日
変更前
11
13年4月17日水曜日
変更途中
12
13年4月17日水曜日
変更後
13
13年4月17日水曜日
はまったポイント
14
13年4月17日水曜日
15
mysqlデータベース内のInnoDBで作成されたtableが壊れる。
13年4月17日水曜日
•ibdata1やib_logfileを削除して、再起動するといきなり出た。
•エラーメッセージ
16
[Warning] InnoDB: Cannot open table mysql/slave_master_info from the internal data dictionary of InnoDB though the .frm file for the table exists. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html for how you can resolve the problem. [Warning] Info table is not ready to be used. Table 'mysql.slave_master_info' cannot be opened. [ERROR] Error in checking mysql.slave_master_info repository info type of TABLE. [ERROR] Error creating master info: Error checking repositories. [ERROR] Failed to create or recover replication info repository.
13年4月17日水曜日
17
use mysql;DROP TABLE IF EXISTS `innodb_index_stats`;DROP TABLE IF EXISTS `innodb_table_stats`;DROP TABLE IF EXISTS `slave_master_info`;DROP TABLE IF EXISTS `slave_relay_log_info`;DROP TABLE IF EXISTS `slave_worker_info`;
まず、該当のテーブルを消す!
でも、.ibdは残っているのでこれも消す!rm -rf /var/lib/mysql/mysql/innodb_index_stats.ibdrm -rf /var/lib/mysql/mysql/innodb_table_stats.ibdrm -rf /var/lib/mysql/mysql/slave_master_info.ibdrm -rf /var/lib/mysql/mysql/slave_relay_log_info.ibdrm -rf /var/lib/mysql/mysql/slave_worker_info.ibd
13年4月17日水曜日
18
mysql_system_tablesから再作成!!
use mysql;source /usr/share/mysql/mysql_system_tables.sql;
13年4月17日水曜日
19
Testが通らなくなる。
13年4月17日水曜日
詳細は、oranieさんのblogに書いてあります。
20
13年4月17日水曜日
21
Test::mysqlでmysql_install_dbしているところで、エラーになった。
エラーメッセージがなにもでない。
13年4月17日水曜日
22
427 # ----------------------------------------------------------------------428 # This will be the default config file429 # ----------------------------------------------------------------------430431 $config_file= "$basedir/my.cnf";432433 my $cfg_template= find_in_basedir($opt,"file","my-default.cnf",434 "share","share/mysql","support-files");435 -e $cfg_template or cannot_find_file("my-default.cnf");436437 $copy_cfg_file= $config_file;438 if (-e $copy_cfg_file)439 {440 $copy_cfg_file =~ s/my.cnf/my-new.cnf/;441 # Too early to print warning here, the user may not notice442 }443 open (TEMPL, $cfg_template) or error("Could not open config template");444 open (CFG, "> $copy_cfg_file") or error("Could not open config file");445 while (<TEMPL>)446 {447 # Remove lines beginning with # *** which are template comments448 print CFG $_ unless /^# \*\*\*/;449 }450 close CFG;451 close TEMPL;
13年4月17日水曜日
23
Testでいままでとおってた
insertがエラーになる。
13年4月17日水曜日
24
デフォルトのsql_modeの設定が5.5までは空だったのに5.6からは指定されていた。
/usr/my.cnfに明示的に書かれていた。
13年4月17日水曜日
25
mysql> SELECT @@GLOBAL.sql_mode;+-------------------+| @@GLOBAL.sql_mode |+-------------------+| |+-------------------+1 row in set (0.00 sec)
mysql> SELECT @@GLOBAL.sql_mode;+--------------------------------------------+| @@GLOBAL.sql_mode |+--------------------------------------------+| STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION |+--------------------------------------------+1 row in set (0.00 sec)
5.5系
5.6系
13年4月17日水曜日
26
GTIDがOnだと、レプリケーションが
組めない
13年4月17日水曜日
•環境 mysql5.5(Master) + mysql5.6(Slave)
•エラーメッセージ
27
root@localhost[(none)]> show slave status\G[...]Last_IO_Error: The slave IO thread stops because the master has GTID_MODE OFF and this server has GTID_MODE ON
13年4月17日水曜日
28
GTIDの設定log-binlog-slave-updatesgtid-mode=ONenforce-gtid-consistency
GTIDを使用するには、レプリケーションを組むサーバ全体でGTIDを有効にする必要がある。
13年4月17日水曜日
GTIDの利用を断念
29
root@localhost[(none)]> show global variables like '%gtid%';+--------------------------+----------------------------------------------+| Variable_name | Value |+--------------------------+----------------------------------------------+| enforce_gtid_consistency | OFF || gtid_executed | 9ee58062-864d-11e2-a94b-003048b3b452:1-64049 || gtid_mode | OFF || gtid_owned | || gtid_purged | |+--------------------------+----------------------------------------------+5 rows in set (0.00 sec)
13年4月17日水曜日
30
”-p”オプションをつけてるとwarningに
13年4月17日水曜日
•エラーメッセージ
31
Warning: Using a password on the command line interface can be insecure.Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 476849Server version: 5.6.10-log MySQL Community Server (GPL)
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
root@localhost[(none)]>
13年4月17日水曜日
mysql_config_editorが便利
32
13年4月17日水曜日
•暗号化されたパスワードが「.mylogin.cnf」に書かれるので、「.my.cnf」に平文のパスワード書かなくてもいいから安心。
33
$ mysql_config_editor set --user=admin --passwordEnter password: <パスワード手入力>
$ mysql_config_editor print --all[client]user = adminpassword = *****
13年4月17日水曜日
34
セクションも指定できる。 mysql_config_editor set --login-path=mysqldump --user=root --passwordEnter password: <パスワード手入力>
$ mysql_config_editor print --all[client]user = adminpassword = *****[mysql]user = adminpassword = *****[mysqladmin]user = rootpassword = *****
13年4月17日水曜日
35
mysqldumpでエラー
13年4月17日水曜日
•mysql5.6 から mysql5.5のdumpをとるときにerrorになる。
•エラーメッセージ
36
mysqldump: Couldn't execute 'SELECT @@GTID_MODE': Unknown system variable 'GTID_MODE' (1193)
13年4月17日水曜日
--set-gtid-purgedをoffにすればいい
37
あまり無いと思いますが、あえて5.5系とかのdumpをとる場合は、このオプションを付ける事でgtidを使用した環境からのダンプファイルに以下内容が出力されなくなります。
SET @@GLOBAL.GTID_PURGED='71803be2-7816-11e2-8c99-5254003e1cec:1-665';
13年4月17日水曜日
今後の予定
38
13年4月17日水曜日
•GTIDをON•MHAの導入
39
13年4月17日水曜日
ご清聴ありがとうございました。
40
13年4月17日水曜日