제목 | mysqladmin | ||||
이름 | 고재욱(3기) | 날짜 | 2005-02-04 | 조회 | 11994 |
데이터베이스 생성 및 삭제,승인 테이블 재로딩,디스크에 테이블 플러싱, 로그파일 재오픈등을 수행하는 관리자용 유틸리티 또한 서버에서 버전,프로세스,상태 정보를 확인할수 있다. 밑에 내용은 phpschool 이라는 사이트에서 따온건데여 한번 붙여넣기에서 천천이 읽어보세요. 영어는 다 읽을 수 있다고 생각하여 원문그대로 [mysqladmin] mysqladmin create [databasename] : Create a new database. mysqladmin drop [databasename] : Delete a database and all its tables. mysqladmin flush-hosts : Flush all cached hosts. mysqladmin flush-logs : Flush all logs. mysqladmin flush-tables : Flush all tables. mysqladmin flush-privileges : Reload grant tables (same as reload). mysqladmin kill [id(,id,...)]: Kill mysql threads. mysqladmin password : Set a new password. Change old password to new-password. mysqladmin reload : Reload grant tables. mysqladmin refresh : Flush all tables and close and open logfiles. mysqladmin shutdown : Take server down. mysqladmin slave-start : Start slave replication thread. mysqladmin slave-stop : Stop slave replication thread. mysqladmin version : Get version info from server. [그 외 ] ▷mysqladmin -u root -p proc stat(=processlist) --> 서버에 현재 활동중인 threads상태보기 Enter password: +------+------+-----------+----+---------+------+-------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +------+------+-----------+----+---------+------+-------+------------------+ | 3704 | root | localhost | | Query | 0 | | show processlist | +------+------+-----------+----+---------+------+-------+------------------+ Uptime: 281302 Threads: 1 Questions: 27330 Slow queries: 0 Opens: 1771 Flush tables: 1 Open tables: 64 Queries per second avg: 0.097 ▷mysqladmin status Uptime : the MySQL server 시작된 후 현재까지 시간 (초) Threads : 현재 디비서버에 연결된 유저수 Questions : 서버시작후 지금까지 요청된 쿼리수 Slow queries : --log-slow-queries[=file_name] option로 시작된 서버가 variables에 지정된 long_query_time seconds시간보다 큰 쿼리시간을 가진 요청수 Opens : 서버가 시작된 후 현재까지 열렸던 테이블 수 Flush tables : flush ..., refresh, and reload commands된 수 Open tables : 현재 열려 있는 테이블 수 Queries per second avg : 평균 초당 쿼리수 Memory in use :the mysqld code에 의해 직접 할당된 메모리 (only available when MySQL is compiled with --with-debug=full). Max memory used : the mysqld code에 의해 직접 할당된 최대메모리 (only available when MySQL is compiled with --with-debug=full). ▷mysqladmin -u root -p ping -->디비서버가 살아있는지 확인 Enter password: mysqld is alive ▷ mysqladmin -u root -p extended-status(※mysql>show stauts) ---------------------------------------------------------------------------------------- Aborted_clients 클라이언트가 연결을 적절히 닫지않아서 죽었기때문에 끊어진 연결수 Communication Errors / Aborted Connection를 참조 Aborted_connects 연결실패된 mysql서버에 연결시도 수 Communication Errors / Aborted Connection참조 Bytes_received 모든 클라이언트로 부터 받은 바이트 수 Bytes_sent 모든 클라이언트에게 보낸 바이트수 Connections mysql서버에 연결시도한 수 Created_tmp_disk_tables sql문을 실행하는 동안 생성된 디스크에 존재하는 임시테이블 수 Created_tmp_tables sql문을 실행하는 동안 생성된 메모리에 존재하는 임시테이블 수 Created_tmp_files 얼마나 많은 임시파일을 mysqld가 생성했는가 Delayed_insert_threads 사용중인 insert handler threads가 지연되고 있는 수 Delayed_writes INSERT DELAYED로 쓰여진 rows수 Delayed_errors 어떤 에러(duplicate key로인한 때문에 INSERT DELAYED로 쓰여진 rows수 Flush_commands 초과 flush명령수 Handler_delete 테이블로 부터 지워진 rows수 Handler_read_first 인덱스로 부터 읽혀진 처음 entry수 이것이 높으면 서버는 많은 full index scans를 하고 있다는 것을 의미한다 예를 들어 SELECT col1 FROM foo는 col1은 인덱스되었다는 것을 추정한다. Handler_read_key 키가 존재하는 row를 읽는 요청수 이것이 높으면 당신의 쿼리와 테이블이 적절히 인덱스화되었다는 좋은 지적이된다. Handler_read_next 키순서대로 다음 row를 읽는 요청수 이것은 만약 range constraint와 함께 인덱스컬럼을 쿼리할 경우 높아질 것이다. 이것은 또한 인덱스 스캔하면 높아질 것이다 Handler_read_rnd 고정된 위치에 존재하는 row를 읽는 요청수 이것은 결과를 정렬하기를 요하는 많은 쿼리를 한다면 높아질 것이다 Handler_read_rnd_next 데이타파일에서 다음 row를 읽기를 요청수 이것은 많은 테이블 스캔을 하면 높아질 것이다 일반적으로 이것은 당신의 테이블들이 적절하게 인덱스되지 않았거나 당신의 쿼리들이 당신이 가지고 있는 인덱스들의 이점을 활용하지 못하고 있다는 것을 의미한다 Handler_update Number of requests to update a row in a table. 한테이블에 한 row를 업데이트를 요청하는 수 Handler_write Number of requests to insert a row in a table. 한테이블에 한 row를 insert요청하는 수 Key_blocks_used The number of used blocks in the key cache. key케쉬에서 블럭을 사용하는 수 Key_read_requests 케쉬에서 키블럭을 읽기를 요청하는 수 Key_reads 디스크로부터 키블럭을 물리적으로 읽는 수 Key_write_requests The number of requests to write a key block to the cache. 케쉬에서 키블럭을 쓰기위해 요청하는 수 Key_writes The number of physical writes of a key block to disk. 디스크에 키블럭을 물리적으로 쓰는 수 Max_used_connections 동시사용 연결 최대수 Not_flushed_key_blocks 키케쉬에서 키블럭이 바뀌지만 디스크에는 아직 flush되지 않는다 Not_flushed_delayed_rows Number of rows waiting to be written in INSERT DELAY queues. INSERT DELAY queue에서 쓰여지기를 기다리는 row수 Open_tables 현재 오픈된 테이블수 Open_files 현재 오픈된 파일수 Open_streams 주로 logging에 사용되는 현재 오픈된 stream수 Opened_tables 지금까지 오픈된 테이블 수 Select_full_join 키없이 조인된 수(0이 되어야만 한다) Select_full_range_join reference table에서 range search를 사용한 조인수 Select_range 첫번째 테이블에 range를 사용했던 조인수 보통 이것이 크더라도 위험하진 않다 Select_scan 첫번째 테이블을 스캔했던 조인수 Select_range_check 각 row후에 key usage를 체크한 키없이 조인한 수(0이어야만 한다) Questions 서버에서 보낸 쿼리수 Slave_open_temp_tables 현재 slave thread에 의해 오픈된 임시 테이블 수 Slow_launch_threads 연결된 slow_launch_time보다 더 많은 수를 갖는 쓰레드수 Slow_queries long_query_time보다 더 많은 시간이 걸리는 쿼리 수 Slow Query Log참고 Sort_merge_passes 정렬해야만 하는 merge수 이 값이 크면 sort_buffer를 증가하는것에 대해 고려해야한다 Sort_range Number of sorts that where done with ranges. Sort_rows 정렬된 row수 Sort_scan 테이블 스캔에 의해 행해진 정렬수 Table_locks_immediate 즉시 획득된 테이블 lock 시간 (3.23.33부터 추가된 항목) Table_locks_waited 즉시 획득되지 않고 기다림이 필요한 테이블 lock 시간 이것이 높아지면 성능에 문제가 있으므로, 먼저 쿼리를 최적화 시키고, 테이블을 분산시키거나 복제를 사용해야한다 (3.23.33부터 추가된 항목) Threads_cached 스레드 캐쉬에서 쓰레드 수 Threads_connected 현재 오픈된 연결수 Threads_created 연결을 다루기위해 생성된 쓰레드 수 Threads_running sleeping하지 않는 쓰레드 수 Uptime 서버가 스타트된 후로 지금까지의 시간 [참고] 1. Opened_tables가 크면 table_cache variable의 값이 너무 작은것일지도 모른다 2. key_reads가 크면 key_cach의 값이 너무 작은것일지도 모른다 3. cache hit rate은 key_reads/key_read_requests이다 4. Handler_read_rnd가 크면 MySQL의 모든 테이블을 스캔하는 많은 쿼리가 있다거나 key를 적절히 사용하지 않는 조인들이 있을지 모른다 5. Threads_created가 크면 thread_cache_size값을 증가시키기를 바랄수도 있다 6. Created_tmp_disk_tables이 크면 디스크대신 임시테이블메모리를 얻기위해 tmp_table_size값을 증가시키기를 원할 수있다 --------------------------------------------------------------------------------------------- [튜닝참조 1] ※ 기본적으로 support-files밑에 `my-huge.cnf', `my-large.cnf', `my-medium.cnf', `my-small.출 를 기본으로 my.cnf 로 바꾸어 사용하면서 조정한다. 1. memory (>=256M)이고 많은 테이블이 있으며, 적당한 클라이언트수에서 최고 성능을 유지하기 위해 shell> safe_mysqld -O key_buffer=64M -O table_cache=256 -O sort_buffer=4M -O record_buffer=1M & 이러한 옵션으로 서버를 실행하는데, my-cnf에서 이를 수정하여 사용하면 될 것이다. 2. 128M메모리에 테이블이 적지만, 정렬이 많을 때 shell> safe_mysqld -O key_buffer=16M -O sort_buffer=1M 3. 메모리는 적지만 많은 연결이 있을 때 shell> safe_mysqld -O key_buffer=512k -O sort_buffer=100k -O record_buffer=100k & 또는 shell> safe_mysqld -O key_buffer=512k -O sort_buffer=16k -O table_cache=32 -O record_buffer=8k -O net_buffer=1K & [튜닝 참조2] ※group by와 order by작업이 가지고 있는 메모리보다 훨씬 클 경우, 정렬 후 row 읽는 것을 빠르게 하기위해 record_rnd_buffer값을 증가시켜라 ※많은 연결로 인한 swapping problems는 메모리를 올려야 되는 것은 당연하다 ※만약 튜닝을 위해 parameter를 바꾸고 그 효과에 대해 알아볼려면 shell> mysqld -O key_buffer=32m --help 를 사용하면된다. 주의할점은 --help를 나중에 붙여야 한다는 것이다. |