- Apacheの各フェーズの実行順
- imgタグでbase64表現を用いてイメージを表示する方法
- ネットマスクとは
- Class::DBIのhas_manyはどうつかう?
- Class::DBIのinflate deflateはどうつかう?
- CSEのlibmysql.dllは
- mysqlのユニークインデックスは、インデックスとしても働く
- shの出力制御
- Debianでinit.dを登録するには
- ランレベル
- PHPで「Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to 8388608 allocate bytes)」というエラーがでたら?
- postgresqlの現在走っているクエリを見るためには
- mysqlのテンポラリテーブル
- mysqlのレプリケーション
- P900iのflv作成方法
- mysqlのシステム変数の動的変更について
- mysqlのmax_connectionsの算出方法
- postgresのmysqlでいうところのdesc
- postgresのポート番号
- mysqlのメモリ設定方法
- mysqlで外部キーの制約を一時的に外す
- mysqlをcvsに吐き出す
- HTTPのステータスコード
- MySQLのチューニング
main() { ap_RUN_pre_config(); // RUN_ALL ap_RUN_test_config(); // VOID ap_RUN_open_logs(); // RUN_ALL ap_RUN_post_config(); // RUN_ALL for (;;) { ap_RUN_pre_config(); // RUN_ALL ap_RUN_open_logs(); // RUN_ALL ap_RUN_post_config(); // RUN_ALL ap_RUN_optional_fn_retrieve(); // VOID ap_mpm_run() { startup_children() { make_child(child_main); } ap_RUN_pre_mpm(); ap_wait_or_timeout() { ap_RUN_monitor(); // RUN_ALL } make_child(child_main); } } } child_main() { ap_RUN_child_init(); // VOID ap_RUN_create_connection(); // RUN_FIRST ap_process_connection() { ap_RUN_pre_connection(); // RUN_ALL ap_RUN_process_connection(); // RUN_FIRST { ap_process_http_connection() { ap_read_request() { ap_RUN_create_request(); // RUN_ALL ap_RUN_post_read_request(); // RUN_ALL } ap_process_request() { ap_RUN_quick_handler(); // RUN_FIRST ap_process_request_internal() { ap_RUN_translate_name(); // RUN_FIRST ap_RUN_map_to_storage(); // RUN_FIRST ap_RUN_header_parser(); // RUN_ALL ap_RUN_access_checker(); // RUN_ALL ap_RUN_check_user_id(); // RUN_FIRST ap_RUN_auth_checker(); // RUN_FIRST ap_RUN_type_checker(); // RUN_FIRST ap_RUN_fixups(); // RUN_ALL } ap_invoke_handler() { ap_RUN_insert_filter(); // VOID ap_RUN_handler(); // RUN_FIRST } } ap_RUN_log_transaction(); // RUN_ALL } } } }
192.168.0.7/29 ネットマスク(つまり255.255.255.248 = 11111111.11111111.11111111.11111000)
ネットワークアドレス ホストアドレス --------------------------------+-------------- 11000000 10101000 00000000 00000 111
取り得るIPアドレス
192.168.0.0
192.168.0.1
192.168.0.2
192.168.0.3
192.168.0.4
192.168.0.5
192.168.0.6
192.168.0.7
192.168.0.8/29 ネットマスク(つまり255.255.255.248 = 11111111.11111111.11111111.11111000)
ネットワークアドレス ホストアドレス --------------------------------+-------------- 11000000 10101000 00000000 00001 000
取り得るIPアドレス
192.168.0.8
192.168.0.9
192.168.0.10
192.168.0.11
192.168.0.12
192.168.0.13
192.168.0.14
192.168.0.15
package Team;
PACKAGE->table('team'); PACKAGE->has_many(players => 'Team' => team_id) package Player; PACKAGE->table('player'); package main; # すべてのプレイヤを取得 my @players = Team->players; # playerテーブルのteam_idが1のプレイヤを取得 my $team1 = Team->retrieve(1); my @players = $team1->players;
ちなみに、has_manyの最後要素に{ order_by => 'foo' }とやると、上記の処理の取得時にfooカラムでソートされた値が渡ってくる。
下記のように使う。inflateは引いてきたカラムの値をモジュールにマッピングするためのもので、deflateはcreateする際に呼ばれるメソッドを指定するもので、これが指定されたカラムにオプジェクトを渡すと、このメソッドの返り値でレコードがcreateされる。
PACKAGE->has_a( created_datetime => 'Time::Piece', inflate => sub { my $t = shift; return Time::Piece->strptime($t, '%Y-%m-%d %T'); }, deflate => 'datetime', );
http://www.softagency.co.jp/products/mysql/win_win... の winclients-3_22_28_euc.zip に。
・標準出力は1
・標準エラー出力は2
・command 1> stdout.txt 2> stderr.txt とすると標準出力はstdout.txt、標準エラー出力はstderr.txtに出力される
・command >stdout_err.txt 2>&1 とするとまとめて1つのファイルに出せる
・command 2>&1 | less とするとstdout, stderr両方をコマンドに渡せる
・標準エラー出力のみをページャなどで見たい場合は、% command 2>&1 1>/dev/null | less である。これも % command 1>/dev/null 2>&1 | less (誤り!) と順番を逆にするとうまくいかない。
・参考:http://x68000.q-e-d.net/~68user/unix/pickup?%A5%EA...
・標準エラー出力は2
・command 1> stdout.txt 2> stderr.txt とすると標準出力はstdout.txt、標準エラー出力はstderr.txtに出力される
・command >stdout_err.txt 2>&1 とするとまとめて1つのファイルに出せる
・command 2>&1 | less とするとstdout, stderr両方をコマンドに渡せる
・標準エラー出力のみをページャなどで見たい場合は、% command 2>&1 1>/dev/null | less である。これも % command 1>/dev/null 2>&1 | less (誤り!) と順番を逆にするとうまくいかない。
・参考:http://x68000.q-e-d.net/~68user/unix/pickup?%A5%EA...
RedHat系Linuxでは、以下のようなRunLevelの割当をしてあります。
init0 = 停止
init1 = シングルユーザーモード
init2 = NFSを使用しないテキストログインモード(マルチユーザーモード)
init3 = テキストログインモード(マルチユーザーモード)
init4 = 未使用
init5 = GUIログインモード(マルチユーザーモード)
init6 = 再起動
Debianでは、
init0 = 停止
init1 = シングルユーザーモード
init2 = マルチユーザーモード
init3 = init2に同じ
init4 = init2に同じ
init5 = init2に同じ
init6 = 再起動
init0 = 停止
init1 = シングルユーザーモード
init2 = NFSを使用しないテキストログインモード(マルチユーザーモード)
init3 = テキストログインモード(マルチユーザーモード)
init4 = 未使用
init5 = GUIログインモード(マルチユーザーモード)
init6 = 再起動
Debianでは、
init0 = 停止
init1 = シングルユーザーモード
init2 = マルチユーザーモード
init3 = init2に同じ
init4 = init2に同じ
init5 = init2に同じ
init6 = 再起動
PHPで「Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to 8388608 allocate bytes)」というエラーがでたら?
php.iniの
memory_limit = 8M
をもうちょっと上げてみましょう。
memory_limit = 8M
をもうちょっと上げてみましょう。
db=# set stats_command_string = true; SET VARIABLE db=# select * from pg_stat_activity; datid | datname | procpid | usesysid | usename | current_query --------+---------------------+---------+----------+----------+--------------- 175041 | reserve_system_0408 | 14592 | 1 | postgres | <IDLE> (1 row)
こんな感じ、<IDLE>の部分に表示されるはず。
1 サーバのmy.cnfの設定
3 マスターにレプリケーション用のユーザを作る
5 テーブルをアンロックする
mysql> START SLAVE;
- slaveの設定
/etc/my.cnf: [mysqld] # レプリケーションするならば指定する必要あり log-bin # 1以外 server-id=2 # max_allowed_packetはマスタとスレーブ同じにする max_allowed_packet=16M
- masterの設定
/etc/my.cnf: log-bin server-id=1 max_allowed_packet=16M2 マスターを起動
3 マスターにレプリケーション用のユーザを作る
% mysql -u root -p mysql> GRANT REPLICATION SLAVE ON *.* TO repl@'%' IDENTIFIED BY 'ABCD'; mysql> FLUSH TABLES WITH READ LOCK;4 マスターからスレーブへデータをコピー
5 テーブルをアンロックする
mysql> UNLOCK TABLES;6 スレーブを起動する
CHANGE MASTER TO MASTER_HOST='マスターのホスト名', MASTER_USER='slave_user', MASTER_PASSWORD='マスター側のパスワード', MASTER_LOG_FILE='ログ名(Fileの値)', MASTER_LOG_POS=4 (Positionの値);7 スレーブスレッドの開始
mysql> START SLAVE;
innodb_buffer_pool_size + key_buffer_size + max_connections * (sort_buffer_size + read_buffer_size) + max_connections * 2 MB <= 2G
93 key_buffer_size=536870912 94 read_buffer_size=4190208 95 max_used_connections=279 96 max_connections=512 97 threads_connected=268 98 It is possible that mysqld could use up to 99 key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = 2619388 K 100 bytes of memory 101 Hope that's ok; if not, decrease some variables in the equation.
% mysql -uroot Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 32156 to server version: 4.0.15-log Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> SET FOREIGN_KEY_CHECKS = 0; Query OK, 0 rows affected (0.03 sec) mysql> \. dump.sql
select * into outfile '/tmp/data.csv' fields terminated by ',' enclosed by '"' lines terminated by '\n' from table where ...
<HTTP 1.0>
2xx: Success (成功)
200 OK
201 Created
202 Accepted
204 No Content
3xx: Redirection (転送)
301 Moved Permanently
302 Moved Temporarily
304 Not Modified
4xx: Client Error (クライアントエラー)
400 Bad Request
401 Unauthorized
403 Forbidden
404 Not Found
5xx: Server Error (サーバエラー)
500 Internal Server Error
501 Not Implemented
502 Bad Gateway
503 Service Unavailable
※ HTTP 1.0では100番代は「Informational」と定義されていますが、将来のために予約されているだけで実際のコードは割り当てられていません。
<HTTP 1.1>
1xx: Informational (情報)
100 Continue
101 Switching Protocols
2xx: Success (成功)
200 OK
201 Created
202 Accepted
203 Non-Authoritative Information
204 No Content
205 Reset Content
206 Partial Content
3xx: Redirection (転送)
300 Multiple Choices
301 Moved Permanently
302 Moved Temporarily
303 See Other
304 Not Modified
305 Use Proxy
4xx: Client Error (クライアントエラー)
400 Bad Request
401 Unauthorized
402 Payment Required
403 Forbidden
404 Not Found
405 Method Not Allowed
406 Not Acceptable
407 Proxy Authentication Required
408 Request Time-out
409 Conflict
410 Gone
411 Length Required
412 Precondition Failed
413 Request Entity Too Large
414 Request-URI Too Large
415 Unsupported Media Type
5xx: Server Error (サーバエラー)
500 Internal Server Error
501 Not Implemented
502 Bad Gateway
503 Service Unavailable
504 Gateway Time-out
505 HTTP Version not supported
2xx: Success (成功)
200 OK
201 Created
202 Accepted
204 No Content
3xx: Redirection (転送)
301 Moved Permanently
302 Moved Temporarily
304 Not Modified
4xx: Client Error (クライアントエラー)
400 Bad Request
401 Unauthorized
403 Forbidden
404 Not Found
5xx: Server Error (サーバエラー)
500 Internal Server Error
501 Not Implemented
502 Bad Gateway
503 Service Unavailable
※ HTTP 1.0では100番代は「Informational」と定義されていますが、将来のために予約されているだけで実際のコードは割り当てられていません。
<HTTP 1.1>
1xx: Informational (情報)
100 Continue
101 Switching Protocols
2xx: Success (成功)
200 OK
201 Created
202 Accepted
203 Non-Authoritative Information
204 No Content
205 Reset Content
206 Partial Content
3xx: Redirection (転送)
300 Multiple Choices
301 Moved Permanently
302 Moved Temporarily
303 See Other
304 Not Modified
305 Use Proxy
4xx: Client Error (クライアントエラー)
400 Bad Request
401 Unauthorized
402 Payment Required
403 Forbidden
404 Not Found
405 Method Not Allowed
406 Not Acceptable
407 Proxy Authentication Required
408 Request Time-out
409 Conflict
410 Gone
411 Length Required
412 Precondition Failed
413 Request Entity Too Large
414 Request-URI Too Large
415 Unsupported Media Type
5xx: Server Error (サーバエラー)
500 Internal Server Error
501 Not Implemented
502 Bad Gateway
503 Service Unavailable
504 Gateway Time-out
505 HTTP Version not supported
key_buffer + (sort_buffer + record_buffer) * max_connections
が搭載メモリ(2G)を超えないように。→これが正しいかは微妙?
だけど、上記にそう形で以下のように設定。
key_buffer=512M
sort_buffer=16M
record_buffer=4M
table_cache=1024
max_connections=512
table_cache=max_connections * n(joinで使用する最大のテーブル数)
OSが制限するファイルを同時に開くことができる制限数:
csh系のシェルコマンドでlimitというのがあるのでその結果の
「descriptors」を確認。
例)
descriptors 1024
# limit
cputime unlimited
filesize unlimited
datasize 1310720 kbytes
stacksize 65536 kbytes
coredumpsize unlimited
memoryuse unlimited
descriptors 16424
memorylocked unlimited
maxproc 8211
key_buffer + (sort_buffer + record_buffer) * max_connections
を確認しもっとmax_connectionあげれれば、再度設定を見直す。
同時にdescriptorsの値をいじって、table_cashの値も変更予定。
が搭載メモリ(2G)を超えないように。→これが正しいかは微妙?
だけど、上記にそう形で以下のように設定。
key_buffer=512M
sort_buffer=16M
record_buffer=4M
table_cache=1024
max_connections=512
table_cache=max_connections * n(joinで使用する最大のテーブル数)
OSが制限するファイルを同時に開くことができる制限数:
csh系のシェルコマンドでlimitというのがあるのでその結果の
「descriptors」を確認。
例)
descriptors 1024
# limit
cputime unlimited
filesize unlimited
datasize 1310720 kbytes
stacksize 65536 kbytes
coredumpsize unlimited
memoryuse unlimited
descriptors 16424
memorylocked unlimited
maxproc 8211
key_buffer + (sort_buffer + record_buffer) * max_connections
を確認しもっとmax_connectionあげれれば、再度設定を見直す。
同時にdescriptorsの値をいじって、table_cashの値も変更予定。
コメントをかく