配布用beginnerならきっと役立つmaster slave環境
Post on 10-Jun-2015
3.262 Views
Preview:
TRANSCRIPT
Beginnerならきっと役立つ
master-slave環境
MySQL Beginners Talk 2012年5月29日
@yut148
自己紹介
@yut148 ←ワイユーティーでお願いします。
他特にこだわりはありません。 鍵ユーザーですがフォロー歓迎です。
職業 ゲーム会社 (sap とか CPとかです。)
orエンターテイメント会社に勤めています。
現在は仕事でコードを書いてません。今の仕事はどちらかと言えば運用系多分インフラエンジニアに属します。
前職含め、ゲーム会社にてサーバ管理の仕事が多い。
さて、
皆さんの会社のある意味Beginner(新社会人)の方々は、、 研修期間終わりました?研修に付きもの、OJTとか言われてませんか? 「おい、うちの会社はOJTなんだ」 by 経営陣
OJTとは
言わずと知れた、On-the-Job Training
というのが本来の意味が実際。また企業によってはいきなり業務を行わせ、いざという時のフォローだけ行うことを
OJTと称することがある。指導する側の指導やチェックが確実に行われ指導される側
が報告義務を欠かさなければ成果を出せるが、指導する側・される側のどちらかに
問題があれば成果は期待できない。
wikipediaより
指導やチェックの時間がない。
Tryさせてそのままかよ。。orz otz
OJTのトレーニングと称して、、
MySQLインストールのお作法とありますが、実際会社で何度もインストールされてしまっては困りますよね、、 研修時間が設けられる企業ならいいのですが、教えたい事はいろいろある。 特にユーザ企業側に就職した場合は通販の事、GAMEの事、等々またはお客様の事業について等々
トレーニング環境を作るにしても
実際、トレーニング専用の予算とか無ければ、機材も無い。(クラウドにしても)
webアプリーションで使用する為の
グローバルIPアドレスなんかない。 といって拒んでしまってはビギナーな方に申し訳ない。
PaaS環境でmysqlを使えば、
インストールの手間がなくすぐ使える。
1回のサインインは必要となってしまいますが、
mysqlインストールよりかは敷居が低い。
無料枠でmysqlが使えるPaaS ※極々一部
サイト 特徴/仕様
http://dotcloud.com/ トータル800G程度無料枠だとマスタースレーブまで。もしくは1webAPPとDB
https://www.cloudcontrol.com/
SharedMulti-AZ RDSMax. 2 connectionsMax. 5 MB
http://xeround.com/ Throughput: up to 1MB/sConnections: up to 5Shared Environment 10Mまで
dotCloud
MySQL5.1.41-3ubuntu12
mysql@16shots-default-db-0:~$ mysqlWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 193Server version: 5.1.41-3ubuntu12.10-log (Ubuntu)
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
※説明の為、16shotsというアプリケーションを作成しています。
mysql> \s--------------mysql Ver 14.14 Distrib 5.1.61, for redhat-linux-gnu (x86_64) using readline 5.1 Connection id: 85Current database: Current user: root@ip-10-79-37-178.ec2.internal ←イーモバイルから接続しただけ
SSL: Not in useCurrent pager: stdoutUsing outfile: ''Using delimiter: ;Server version: 5.1.41-3ubuntu12.10-log (Ubuntu)Protocol version: 10Connection: ??????.dotcloud.com via TCP/IPServer characterset: latin1Db characterset: latin1Client characterset: latin1Conn. characterset: latin1TCP port: 18935Uptime: 16 days 9 hours 52 min 0 sec Threads: 1 Questions: 274 Slow queries: 0 Opens: 139 Flush tables: 1 Open tables: 33 Queries per second avg: 0.0
mysql> SHOW VARIABLES LIKE 'version%' \G*************************** 1. row ***************************Variable_name: version Value: 5.1.41-3ubuntu12.10-log*************************** 2. row ***************************Variable_name: version_comment Value: (Ubuntu)*************************** 3. row ***************************Variable_name: version_compile_machine Value: x86_64*************************** 4. row ***************************Variable_name: version_compile_os Value: debian-linux-gnu4 rows in set (0.00 sec)
cloudcontrol
MySQLversion 5.1.57
[root@localhost ~]# mysql -h mysqlsdb.?????.eu-west-1.rds.amazonaws.com -u username -P 3306 -p databasenameEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 45987481Server version: 5.1.57-log MySQL Community Server (GPL) Copyright (c) 2000, 2011, 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.
mysql> \s--------------mysql Ver 14.14 Distrib 5.1.61, for redhat-linux-gnu (x86_64) using readline 5.1 Connection id: 45987481Current database: databasenameCurrent user: databasename@EM114-48-20-237.pool.e-mobile.ne.jpSSL: Not in useCurrent pager: stdoutUsing outfile: ''Using delimiter: ;Server version: 5.1.57-log MySQL Community Server (GPL)Protocol version: 10Connection: mysqlsdb.???????.eu-west-1.rds.amazonaws.com via TCP/IPServer characterset: latin1Db characterset: latin1Client characterset: latin1Conn. characterset: latin1TCP port: 3306Uptime: 110 days 5 hours 55 min 5 sec Threads: 22 Questions: 879893254 Slow queries: 1672 Opens: 21887591 Flush tables: 1 Open tables: 64 Queries per second avg: 92.374--------------
mysql> SHOW VARIABLES LIKE 'version%' \G*************************** 1. row ***************************Variable_name: version Value: 5.1.57-log*************************** 2. row ***************************Variable_name: version_comment Value: MySQL Community Server (GPL)*************************** 3. row ***************************Variable_name: version_compile_machine Value: x86_64*************************** 4. row ***************************Variable_name: version_compile_os Value: unknown-linux-gnu4 rows in set (0.43 sec)
xeround
MySQLversion 5.1.42
[root@localhost ~]# mysql -u username -P 9782 -h instancename.db.xeround.com -pEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 176Server version: 5.1.42 Source distribution Copyright (c) 2000, 2011, 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. mysql>
mysql> \sConnection id: 23Current database: mysql --------------mysql Ver 14.14 Distrib 5.1.61, for redhat-linux-gnu (x86_64) using readline 5.1 Connection id: 23Current database: mysqlCurrent user: username@EM111-188-50-181.pool.e-mobile.ne.jpSSL: Not in useCurrent pager: stdoutUsing outfile: ''Using delimiter: ;Server version: 5.1.42 Source distributionProtocol version: 10Connection: ?????.db.xeround.com via TCP/IPServer characterset: utf8Db characterset: utf8Client characterset: latin1Conn. characterset: latin1TCP port: 9782Uptime: 55 min 19 sec Threads: 3 Questions: 778 Slow queries: 0 Opens: 33 Flush tables: 1 Open tables: 26 Queries per second avg: 0.234
mysql> SHOW VARIABLES LIKE 'version%' \G*************************** 1. row ***************************Variable_name: version Value: 5.1.42*************************** 2. row ***************************Variable_name: version_comment Value: Source distribution*************************** 3. row ***************************Variable_name: version_compile_machine Value: x86_64*************************** 4. row ***************************Variable_name: version_compile_os Value: unknown-linux-gnu4 rows in set (0.20 sec)
例えばdotcloudで使うなら、
mysqlを使う為の設定 ※mysqlシングルマスター構成
dotcloud.ymldata: type: mysql [root@localhost ~]# tree database/database/└── dotcloud.yml dotcloud create databasedotcloud push database ./database
dotcloudならmaster-slave構成が組めま
す。
mysqlを使う為の設定
[root@localhost ~]# cat dotcloud.ymlwww: approot: mediawiki type: phpdb: type: mysql-masterslave
instances: 2 ← ※重要
[root@localhost ~]# dotcloud info 16shots.dbconfig:
mysql_masterslave: truemysql_password: mysqlpassword
created_at: 1337501349.485523datacenter: Amazon-us-east-1bimage_version: 1120eda9aa82 (latest)instances:
16shots.db.0: role: master state: up
16shots.db.1: replication_lag: 0s role: slave state: upmemory: 40M/512M (7%)ports:- name: ssh
url: ssh://mysql@16shots.hostname.dotcloud.com:28612- name: mysql
url: mysql://root:mysqlpassword@16shots-hostname.dotcloud.com:27224state: runningtype: mysql-masterslave
mysql> SHOW PROCESSLIST \G*************************** 1. row *************************** Id: 47 User: root Host: ip-10-79-37-178.ec2.internal:33156 db: NULLCommand: Binlog Dump Time: 621 State: Has sent all binlog to slave; waiting for binlog to be updated Info: NULL*************************** 2. row *************************** Id: 48 User: root Host: localhost db: NULLCommand: Query Time: 0 State: NULL Info: SHOW PROCESSLIST2 rows in set (0.01 sec)
で肝心のslave側にログインしたいのだか。。
mysql@16shots-default-db-0:~$ mysqlWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 221Server version: 5.1.41-3ubuntu12.10-log (Ubuntu) Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> SHOW SLAVE HOSTS;Empty set (0.00 sec) mysql>
スレーブのマスター昇格は自動で行われる(未確認 ※壊れた経験がありません。)
説明オワタ\(^o^)/
念のため説明しますと、
[root@localhost ~]# dotcloud ssh 16shots.db# $SHELLmysql@16shots-default-db-0:~$ ifconfigWarning: cannot open /proc/net/dev (No such file or directory). Limited output. mysql@16shots-default-db-0:~$ ssState Recv-Q Send-Q Local Address:Port Peer Address:Port mysql@16shots-default-db-0:~$ netstat -anpActive Internet connections (servers and established)Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program nameActive UNIX domain sockets (servers and established)Proto RefCnt Flags Type State I-Node PID/Program name Path
これらのコマンドではIPアドレスに関する情報は得られません。( ´・ω・)
でもdotcloudを使うといいところmysqlをインストールし直すのも
dotcloud destroy hogehogedotcloud create hogehogedotcloud push hogehoge ./
#ワイルド に出来ます。
まとめ
mysqlを使うだけなら
自前でサーバを用意する必要は無い。
まとめ
mysqlを使うだけなら
自前でサーバを用意する必要は無い。
学習目的のインストールは
非常に大切
まとめ
mysqlを使うだけなら
自前でサーバを用意する必要は無い。
学習目的のインストールは
非常に大切
利用が簡単なPaaSもいいけど
資格を取るなら自前で用意
でもちょっと思い出して欲しい事
デブサミ 2011
【17-A-4】大規模Webサービスのためのデータベー
ス技術の現在・未来 松信嘉範 氏
http://togetter.com/li/102067運用メンバーはサーバほどスケールしない!もっと大きな声で言ってほしい!ww #devsumi
oranie 2011/02/17 15:00:16「運用メンバーはサーバほどスケールしない」まさに、サーバは買ってこれるけど人は買って来られないよなぁ #devsumi 17-A-4
ymkx_ 2011/02/17 15:00:18運用メンバー数はサーバ台数ほどスケールしないw。サーバ100台買うのと採用するの考えれば当然。サーバならボリューム
ディスカウントだってあるし。
#devsumi napooko 2011/02/17 15:01:42
Beginnerに学んで欲しい事
まずはバージョンを確認。現在の動作を確認。
次に
どの様な変更が加えられるか?デフォルトの設定は忘れずに。
↑設定変更後と変更前では
どの様な違いが出るのか?
Beginner以外の方に忘れないでいた
だきたい事いちいちサーバを用意する時間も予算も無い場合は
PaaSという選択肢もある事を忘れずに
※ただしセキュリティや職務上重要なデータが流失してしまわぬ様に注意
top related