Home > Archives > August 2007 Archive
August 2007 Archive
レプリケーションでバイナリログのメンテナンス
- August 29, 2007 8:52 PM
一番簡単なのはexpire_logs_daysを設定しておく方法。
例えばログファイル類は一週間保存しておく、というポリシーの場合はexpire_logs_days=7;としておくと、バイナリログのローテートのタイミングで、古いファイルは自動削除される。
一週間以上レプリケーションが遅延することは、実質無いという前提。
もし、理論上も確実にやりたいのであれば、show slave status;のRELAY_MASTER_LOG_FILEまではスレーブ側で実行中なので、このファイル名を記録して、PURGE MASTER LOGS TO <ファイル名>;をマスターで発行する。
すると、ここで指定したファイル名以前のバイナリログが削除される。
- Comments (Close): 0
- TrackBack (Close): 0
サマータイムはtime_zone_transitionテーブルとtime_zone_transition_typeテーブルで管理している
- August 23, 2007 4:40 PM
-----
[mysql]> select * from time_zone_transition where time_zone_id='542';
+--------------+-----------------+--------------------+
| Time_zone_id | Transition_time | Transition_type_id |
+--------------+-----------------+--------------------+
| 542 | -1633269600 | 0 |
| 542 | -1615129200 | 1 |
| 542 | -1601820000 | 0 |
| 542 | -1583679600 | 1 |
| 542 | -880207200 | 2 |
| 542 | -769395600 | 3 |
| 542 | -765385200 | 1 |
| 542 | -687967200 | 0 |
| 542 | -662655600 | 1 |
| 542 | -620834400 | 0 |
| 542 | -608137200 | 1 |
| 542 | -589384800 | 0 |
| 542 | -576082800 | 1 |
| 542 | -557935200 | 0 |
| 542 | -544633200 | 1 |
| 542 | -526485600 | 0 |
| 542 | -513183600 | 1 |
| 542 | -495036000 | 0 |
| 542 | -481734000 | 1 |
| 542 | -463586400 | 0 |
| 542 | -450284400 | 1 |
| 542 | -431532000 | 0 |
| 542 | -418230000 | 1 |
| 542 | -400082400 | 0 |
| 542 | -386780400 | 1 |
| 542 | -368632800 | 0 |
| 542 | -355330800 | 1 |
| 542 | -337183200 | 0 |
| 542 | -323881200 | 1 |
| 542 | -305733600 | 0 |
| 542 | -292431600 | 1 |
| 542 | -273679200 | 0 |
| 542 | -260982000 | 1 |
| 542 | -242229600 | 0 |
| 542 | -226508400 | 1 |
| 542 | -210780000 | 0 |
| 542 | -195058800 | 1 |
| 542 | -179330400 | 0 |
| 542 | -163609200 | 1 |
| 542 | -147880800 | 0 |
| 542 | -131554800 | 1 |
| 542 | -116431200 | 0 |
| 542 | -100105200 | 1 |
| 542 | -84376800 | 0 |
| 542 | -68655600 | 1 |
| 542 | -52927200 | 0 |
| 542 | -37206000 | 1 |
| 542 | -21477600 | 0 |
| 542 | -5756400 | 1 |
| 542 | 9972000 | 0 |
| 542 | 25693200 | 1 |
| 542 | 41421600 | 0 |
| 542 | 57747600 | 1 |
| 542 | 73476000 | 0 |
| 542 | 89197200 | 1 |
| 542 | 104925600 | 0 |
| 542 | 120646800 | 1 |
| 542 | 126698400 | 0 |
| 542 | 152096400 | 1 |
| 542 | 162381600 | 0 |
| 542 | 183546000 | 1 |
| 542 | 199274400 | 0 |
| 542 | 215600400 | 1 |
| 542 | 230724000 | 0 |
| 542 | 247050000 | 1 |
| 542 | 262778400 | 0 |
| 542 | 278499600 | 1 |
| 542 | 294228000 | 0 |
| 542 | 309949200 | 1 |
| 542 | 325677600 | 0 |
| 542 | 341398800 | 1 |
| 542 | 357127200 | 0 |
| 542 | 372848400 | 1 |
| 542 | 388576800 | 0 |
| 542 | 404902800 | 1 |
| 542 | 420026400 | 0 |
| 542 | 436352400 | 1 |
| 542 | 452080800 | 0 |
| 542 | 467802000 | 1 |
| 542 | 483530400 | 0 |
| 542 | 499251600 | 1 |
| 542 | 514980000 | 0 |
| 542 | 530701200 | 1 |
| 542 | 544615200 | 0 |
| 542 | 562150800 | 1 |
| 542 | 576064800 | 0 |
| 542 | 594205200 | 1 |
| 542 | 607514400 | 0 |
| 542 | 625654800 | 1 |
| 542 | 638964000 | 0 |
| 542 | 657104400 | 1 |
| 542 | 671018400 | 0 |
| 542 | 688554000 | 1 |
| 542 | 702468000 | 0 |
| 542 | 720003600 | 1 |
| 542 | 733917600 | 0 |
| 542 | 752058000 | 1 |
| 542 | 765367200 | 0 |
| 542 | 783507600 | 1 |
| 542 | 796816800 | 0 |
| 542 | 814957200 | 1 |
| 542 | 828871200 | 0 |
| 542 | 846406800 | 1 |
| 542 | 860320800 | 0 |
| 542 | 877856400 | 1 |
| 542 | 891770400 | 0 |
| 542 | 909306000 | 1 |
| 542 | 923220000 | 0 |
| 542 | 941360400 | 1 |
| 542 | 954669600 | 0 |
| 542 | 972810000 | 1 |
| 542 | 986119200 | 0 |
| 542 | 1004259600 | 1 |
| 542 | 1018173600 | 0 |
| 542 | 1035709200 | 1 |
| 542 | 1049623200 | 0 |
| 542 | 1067158800 | 1 |
| 542 | 1081072800 | 0 |
| 542 | 1099213200 | 1 |
| 542 | 1112522400 | 0 |
| 542 | 1130662800 | 1 |
| 542 | 1143972000 | 0 |
| 542 | 1162112400 | 1 |
| 542 | 1173607200 | 0 |
| 542 | 1194166800 | 1 |
| 542 | 1205056800 | 0 |
| 542 | 1225616400 | 1 |
| 542 | 1236506400 | 0 |
| 542 | 1257066000 | 1 |
| 542 | 1268560800 | 0 |
| 542 | 1289120400 | 1 |
| 542 | 1300010400 | 0 |
| 542 | 1320570000 | 1 |
| 542 | 1331460000 | 0 |
| 542 | 1352019600 | 1 |
| 542 | 1362909600 | 0 |
| 542 | 1383469200 | 1 |
| 542 | 1394359200 | 0 |
| 542 | 1414918800 | 1 |
| 542 | 1425808800 | 0 |
| 542 | 1446368400 | 1 |
| 542 | 1457863200 | 0 |
| 542 | 1478422800 | 1 |
| 542 | 1489312800 | 0 |
| 542 | 1509872400 | 1 |
| 542 | 1520762400 | 0 |
| 542 | 1541322000 | 1 |
| 542 | 1552212000 | 0 |
| 542 | 1572771600 | 1 |
| 542 | 1583661600 | 0 |
| 542 | 1604221200 | 1 |
| 542 | 1615716000 | 0 |
| 542 | 1636275600 | 1 |
| 542 | 1647165600 | 0 |
| 542 | 1667725200 | 1 |
| 542 | 1678615200 | 0 |
| 542 | 1699174800 | 1 |
| 542 | 1710064800 | 0 |
| 542 | 1730624400 | 1 |
| 542 | 1741514400 | 0 |
| 542 | 1762074000 | 1 |
| 542 | 1772964000 | 0 |
| 542 | 1793523600 | 1 |
| 542 | 1805018400 | 0 |
| 542 | 1825578000 | 1 |
| 542 | 1836468000 | 0 |
| 542 | 1857027600 | 1 |
| 542 | 1867917600 | 0 |
| 542 | 1888477200 | 1 |
| 542 | 1899367200 | 0 |
| 542 | 1919926800 | 1 |
| 542 | 1930816800 | 0 |
| 542 | 1951376400 | 1 |
| 542 | 1962871200 | 0 |
| 542 | 1983430800 | 1 |
| 542 | 1994320800 | 0 |
| 542 | 2014880400 | 1 |
| 542 | 2025770400 | 0 |
| 542 | 2046330000 | 1 |
| 542 | 2057220000 | 0 |
| 542 | 2077779600 | 1 |
| 542 | 2088669600 | 0 |
| 542 | 2109229200 | 1 |
| 542 | 2120119200 | 0 |
| 542 | 2140678800 | 1 |
+--------------+-----------------+--------------------+
185 rows in set (0.00 sec)
[mysql]>
[mysql]> select * from time_zone_transition_type where time_zone_id='542';
+--------------+--------------------+--------+--------+--------------+
| Time_zone_id | Transition_type_id | Offset | Is_DST | Abbreviation |
+--------------+--------------------+--------+--------+--------------+
| 542 | 0 | -25200 | 1 | PDT |
| 542 | 1 | -28800 | 0 | PST |
| 542 | 2 | -25200 | 1 | PWT |
| 542 | 3 | -25200 | 1 | PPT |
+--------------+--------------------+--------+--------+--------------+
4 rows in set (0.28 sec)
[mysql]>
- Comments (Close): 0
- TrackBack (Close): 0
BakBoneが新しいMySQL APMを提供開始
- August 10, 2007 4:23 PM
http://www.bakbone.co.jp/about_us/press_releases_2007/0807.html
MySQL APM v3.0の主な特徴 (製品の詳細はこちらへ)
- MySQL APMは、MySQL Enterprise Gold認定ソリューションです。
- MySQL APM v3.0からMySQL 5.0をサポート、ひとつのジョブに、複数のストレージ・エンジンのバックアップを統合することが可能です。
- データをオンラインでアクセス可能な状態のまま、フルバックアップ、増分/差分バックアップが行えます。
- データベース単位、テーブル単位で、またはMySQLのインスタンス全体をリストアすることが可能です。
- MySQLのネイティブのポイント・イン・タイム機能に対応することで、データ破損が発生する前の時点へ、または発生した後の時点へのポイント・イン・タイム・リカバリが行えます。
- MySQLのレプリケーション機能に対応 - スレーブ・インスタンス側でバックアップを行うことで、マスター・インスタンスに影響を与えることなく、個々のデータベース/テーブルのコピーが行えるだけでなく、フルバックアップ、差分/増分バックアップも行えます。
- リストア時のデータベースの名前変更に対応
- MySQLの代替インスタンスへのリストアが可能
- Comments (Close): 0
- TrackBack (Close): 0
カーソルの3タイプ
- August 6, 2007 3:05 PM
メモ
There are 3 possible types, "SENSITIVE", "INSENSITIVE" and "ASENSITIVE"
SENSITIVE means is that the server runs the query and it gets back a list of rows matching the query. That is, they will have been filtered, ordered, etc. However, the server does not make a copy of the results at this time but instead points back to the rows on the server.
This means that if another MySQL thread changes a row in the table referenced by your results, you will in fact see those changes as you advance through the cursor. Following from that, when you actually read the data from the cursors, they may no longer be in the correct order, or match your WHERE condition as the data may have been changed from what it was originally when the query ran.
INSENSITIVE means that the server takes a copy of the data at the time the query was executed, and that any further updates do not affect the data in that cursor.
ASENSITIVE means that it may be one or the other, you can't rely on it being either way - which way the server goes depends on various things including how the server executed the query.
For example, if it is a very simple query, where the server can just read the data out directly - it would probably make the data SENSITIVE.
However if you had a more complex query, involving JOINs, SUBQUERIES, etc - it would most likely end up in a temporary table and thus behave an an INSENSITIVE manner.
Note that it is not as simple as this, it is just an example to give you an idea what might make the difference between the data happening to be SENSITIVE or INSENSITIVE in any one case.
- Comments (Close): 0
- TrackBack (Close): 0
CONVERT_TZ関数はUNIX時間以前の時刻に対して使えない
- August 6, 2007 2:50 PM
[test]> select convert_tz('1980-01-01 00:10:00','UTC','ASIA/Tokyo');マニュアルによると、仕様
+------------------------------------------------------+
| convert_tz('1980-01-01 00:10:00','UTC','ASIA/Tokyo') |
+------------------------------------------------------+
| 1980-01-01 09:10:00 |
+------------------------------------------------------+
1 row in set (0.31 sec)
[test]> select convert_tz('1970-01-01 00:10:00','UTC','ASIA/Tokyo');
+------------------------------------------------------+
| convert_tz('1970-01-01 00:10:00','UTC','ASIA/Tokyo') |
+------------------------------------------------------+
| 1970-01-01 09:10:00 |
+------------------------------------------------------+
1 row in set (0.00 sec)
[test]> select convert_tz('1960-01-01 00:10:00','UTC','ASIA/Tokyo');
+------------------------------------------------------+
| convert_tz('1960-01-01 00:10:00','UTC','ASIA/Tokyo') |
+------------------------------------------------------+
| 1960-01-01 00:10:00 |
+------------------------------------------------------+
1 row in set (0.00 sec)
MySQL AB :: MySQL 5.1 リファレンスマニュアル :: 11.5 日付時刻関数
値が、from_tz から UTC に変換される際に TIMESTAMP でサポートされている範囲から外れた場合、変換は行われません。
MySQL AB :: MySQL 5.1 リファレンスマニュアル :: 10.1.2 データと時刻タイプの概要
TIMESTAMP
タイムスタンプです。範囲は '1970-01-01 00:00:01' UTCから 2037 年の途中までです。TIMESTAMP 値は ('1970-01-01 00:00:00' UTC)からの秒数として格納されます。TIMESTAMP は、'1970-01-01 00:00:00' 値を表す事はできません。
- Comments (Close): 0
- TrackBack (Close): 0
TIME ZONEの使い方
- August 2, 2007 1:20 PM
TIME ZONEテーブルを設定後、TIME ZONE変数を設定することで、「簡単にタイムゾーンを変更できる」というメリットを享受することができるものなので、タイムゾーンを変更する必要が無い場合は、特に設定する必要はございません。
参考までに、TIME ZONEを設定した際の挙動を以下に記す。
[mysql]> select @@time_zone;
+-------------+
| @@time_zone |
+-------------+
| SYSTEM |
+-------------+
1 row in set (0.00 sec)
[mysql]> select now();
+---------------------+
| now() |
+---------------------+
| 2007-08-02 13:17:58 |
+---------------------+
1 row in set (0.00 sec)
[mysql]> set @@time_zone='Europe/London';
Query OK, 0 rows affected (0.37 sec)
[mysql]> select now();
+---------------------+
| now() |
+---------------------+
| 2007-08-02 05:18:20 |
+---------------------+
1 row in set (0.00 sec)
[mysql]> set @@time_zone='Asia/Tokyo';
Query OK, 0 rows affected (0.05 sec)
[mysql]> select now();
+---------------------+
| now() |
+---------------------+
| 2007-08-02 13:18:40 |
+---------------------+
1 row in set (0.00 sec)
[mysql]> set @@time_zone='SYSTEM';
Query OK, 0 rows affected (0.00 sec)
[mysql]> select now();
+---------------------+
| now() |
+---------------------+
| 2007-08-02 13:18:56 |
+---------------------+
1 row in set (0.00 sec)
- Comments (Close): 0
- TrackBack (Close): 0