Your SlideShare is downloading. ×
오픈강의 2014 mysql튜닝
오픈강의 2014 mysql튜닝
오픈강의 2014 mysql튜닝
오픈강의 2014 mysql튜닝
오픈강의 2014 mysql튜닝
오픈강의 2014 mysql튜닝
오픈강의 2014 mysql튜닝
오픈강의 2014 mysql튜닝
오픈강의 2014 mysql튜닝
오픈강의 2014 mysql튜닝
오픈강의 2014 mysql튜닝
오픈강의 2014 mysql튜닝
오픈강의 2014 mysql튜닝
오픈강의 2014 mysql튜닝
오픈강의 2014 mysql튜닝
오픈강의 2014 mysql튜닝
오픈강의 2014 mysql튜닝
오픈강의 2014 mysql튜닝
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

오픈강의 2014 mysql튜닝

139

Published on

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
139
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. 오픈강의 Mysql 설치 및 튜닝 류지만 ryu.jiman@gmail.com
  • 2. [mysql@imdisdbs ~]$ cat my.cnf* [client] #password = your_password port = 3371 socket = /tmp/mysql.sock #default-character-set=utf8 # Here follows entries for some specific programs # The MySQL server [mysqld] port = 3371 socket = /tmp/mysql.sock tmpdir=/mysql_tmp01:/mysql_tmp02 basedir=/usr/local/mysql datadir=/mysql_data default-storage-engine = innodb #default-character-set=utf8 character-set-server = utf8 #innodb_force_recover=5 ## Innodb Plugin ## #ignore-builtin-innodb #plugin-load=innodb=ha_innodb_plugin.so #plugin_dir=/usr/local/mysql/lib/plugin skip-external-locking #skip-networking # Disable Federated by default skip-federated skip-name-resolve skip-innodb_doublewrite # Connection option max_connections = 600 max_connect_errors = 100 back_log = 50 thread_cache_size = 5
  • 3. sort_buffer_size = 8M join_buffer_size = 8M max_allowed_packet = 32M table_cache = 2000 #open-files-limit = 1000 tmp_table_size=64M max_heap_table_size=64M max_tmp_tables=128 wait_timeout=3600 interactive_timeout=3600 ################# # MyISAM option # ################# key_buffer_size = 30M read_buffer_size = 4M read_rnd_buffer_size = 6M #bulk_insert_buffer_size = 64M #myisam_sort_buffer_size = 128M #myisam_max_sort_file_size = 256G # Try number of CPU's*2 for thread_concurrency thread_concurrency = 16 innodb_thread_concurrency = 16 slow_query_log = 1 slow_query_log_file = /mysql_log/imdisdbs-slow.log long_query_time = 3 ###################################### # Replication Master Server (default) server-id = 11 #####################################
  • 4. # binary logging is required for replication log-bin=/dumplog/mysql-bin #log-bin=/mysql_log/mysql-bin binlog_format=mixed expire_logs_days=5 ############### # Query Cache # ############### #query_cache_size=100M query_cache_type=0 ################# # innodb option # ################# #default-storage-engine = innodb innodb_data_home_dir = /mysql_data innodb_data_file_path = ibdata1:10G;ibdata2:10G;ibdata3:10G;ibdata4:10G;ibdata5:1 0G innodb_log_group_home_dir = /mysql_data innodb_log_files_in_group = 3 # You can set .._buffer_pool_size up to 50 - 80 % # of RAM but beware of setting memory usage too high ##################################################### innodb_buffer_pool_size = 18G innodb_additional_mem_pool_size = 100M #####################################################
  • 5. # Set .._log_file_size to 25 % of buffer pool size innodb_log_file_size = 500M ##################################################### innodb_log_buffer_size = 100M innodb_lock_wait_timeout = 10 innodb_max_dirty_pages_pct = 90 ##################################################### innodb_flush_log_at_trx_commit = 2 innodb_flush_method=O_DIRECT innodb_doublewrite = 0 [mysqldump] quick max_allowed_packet = 32M [mysql] no-auto-rehash # Remove the next comment character if you are not familiar with SQL #safe-updates #[myisamchk] #key_buffer_size = 512M #sort_buffer_size = 256M #read_buffer = 8M #write_buffer = 8M [mysqlhotcopy] interactive-timeout [mysql@imdisdbs ~]$
  • 6. Master ( /etc/my.cnf) [client] #password = your_password port = 3306 socket = /tmp/mysql.sock default-character-set=utf8 # Here follows entries for some specific programs # The MySQL server [mysqld] port = 3306 socket = /tmp/mysql.sock tmpdir=/mysql_tmp01:/mysql_tmp02 basedir=/usr/local/mysql datadir=/mysql_data
  • 7. default-storage-engine = innodb #default-character-set=utf8 character-set-server = utf8 #innodb_force_recover=5 ## Innodb Plugin ## ignore-builtin-innodb plugin-load=innodb=ha_innodb_plugin.so plugin_dir=/usr/local/mysql/lib/plugin skip-external-locking #skip-networking # Disable Federated by default skip-federated skip-name-resolve skip-innodb_doublewrite # Connection option max_connections = 500 max_connect_errors = 100 sort_buffer_size = 4M join_buffer_size = 4M max_allowed_packet = 32M table_cache = 2000 #open-files-limit = 1000 tmp_table_size=32M max_heap_table_size=32M max_tmp_tables=128 wait_timeout=1200 interactive_timeout=1200 ################# # MyISAM option # #################
  • 8. key_buffer_size = 30M read_buffer_size = 4M read_rnd_buffer_size = 6M #bulk_insert_buffer_size = 64M #myisam_sort_buffer_size = 128M #myisam_max_sort_file_size = 256G # Try number of CPU's*2 for thread_concurrency thread_concurrency = 12 innodb_thread_concurrency = 12 #slow_query_log = 1 #slow_query_log_file = /mysql_log/HOSTNAME-slow.log #long_query_time = 5 ###################################### # Replication Master Server (default) server-id = 11 ##################################### # binary logging is required for replication log-bin=/mysql_log/mysql-bin binlog_format=mixed expire_logs_days=7 ################# # innodb option # ################# #default-storage-engine = innodb innodb_data_home_dir = /mysql_data innodb_data_file_path
  • 9. ibdata1:10G;ibdata2:10G;ibdata3:10G;ibdata4:10G;ibdata5:10G innodb_log_group_home_dir = /mysql_data innodb_log_files_in_group = 3 # You can set .._buffer_pool_size up to 50 - 80 % # of RAM but beware of setting memory usage too high innodb_buffer_pool_size = 13000M innodb_additional_mem_pool_size = 30M # Set .._log_file_size to 25 % of buffer pool size innodb_log_file_size = 500M innodb_log_buffer_size = 10M innodb_flush_log_at_trx_commit = 1 innodb_lock_wait_timeout = 50 innodb_flush_method=O_DIRECT [mysqldump] quick max_allowed_packet = 32M [mysql] no-auto-rehash # Remove the next comment character if you are not familiar with SQL #safe-updates #[myisamchk] #key_buffer_size = 512M #sort_buffer_size = 256M #read_buffer = 8M #write_buffer = 8M [mysqlhotcopy] interactive-timeout
  • 10. Slave ( /etc/my.cnf) [client] #password = your_password port = 3306 socket = /tmp/mysql.sock default-character-set=utf8 # Here follows entries for some specific programs # The MySQL server [mysqld] port = 3306 socket = /tmp/mysql.sock tmpdir=/mysql_tmp01:/mysql_tmp02 basedir=/usr/local/mysql datadir=/mysql_data default-storage-engine = innodb #default-character-set=utf8 character-set-server = utf8 #innodb_force_recover=5 ## Innodb Plugin ## ignore-builtin-innodb plugin-load=innodb=ha_innodb_plugin.so plugin_dir=/usr/local/mysql/lib/plugin skip-external-locking #skip-networking # Disable Federated by default skip-federated skip-name-resolve
  • 11. skip-innodb_doublewrite # Connection option max_connections = 500 max_connect_errors = 100 back_log = 50 thread_cache_size = 5 sort_buffer_size = 4M join_buffer_size = 4M max_allowed_packet = 32M table_cache = 2000 max_heap_table_size=32M max_tmp_tables=128 wait_timeout=1200 interactive_timeout=1200 ################# # MyISAM option # ################# key_buffer_size = 30M read_buffer_size = 4M read_rnd_buffer_size = 6M #bulk_insert_buffer_size = 64M #myisam_sort_buffer_size = 128M #myisam_max_sort_file_size = 256G # Try number of CPU's*2 for thread_concurrency thread_concurrency = 12 innodb_thread_concurrency = 12 #slow_query_log = 1 #slow_query_log_file = /mysql_log/HOSTNAME-slow.log #long_query_time = 5
  • 12. ###################################### # Replication Master Server (default) server-id = 21 master-host= 1.1.1.1 master-port = 3306 master-user =jmryu master-password = 1234 master-connect-retry = 10 ##################################### slave-skip-errors=all relay-log=/mysql_log/relaylog-bin # binary logging is required for replication #log-bin=/mysql_log/mysql-bin #binlog_format=mixed #expire_logs_days=7 relay-log=/mysql_log/relaylog-bin ################# # innodb option # ################# #default-storage-engine = innodb innodb_data_home_dir = /mysql_data innodb_data_file_path = ibdata1:1G;ibdata2:1G;ibdata3:1G;ibdata4:1G;ibdata5:1G innodb_log_group_home_dir = /mysql_data innodb_log_files_in_group = 3 # You can set .._buffer_pool_size up to 50 - 80 % # of RAM but beware of setting memory usage too high
  • 13. innodb_buffer_pool_size = 13000M innodb_additional_mem_pool_size = 30M # Set .._log_file_size to 25 % of buffer pool size innodb_log_file_size = 500M innodb_log_buffer_size = 10M innodb_flush_log_at_trx_commit = 1 innodb_lock_wait_timeout = 50 innodb_flush_method=O_DIRECT [mysqldump] quick max_allowed_packet = 32M [mysql] no-auto-rehash # Remove the next comment character if you are not familiar with SQL #safe-updates #[myisamchk] #key_buffer_size = 512M #sort_buffer_size = 256M #read_buffer = 8M #write_buffer = 8M [mysqlhotcopy] interactive-timeout
  • 14. 1) 보안설정 mysql> drop database test; mysql> delete from mysql.user where user=’’; mysql> update mysql.user set password=password(‘패스워드’) where user = ‘root’; # root 계정 패스워드 ( 1234 ) (MySQL 관리자 패스워드 변경시 update 문 활용하시기 바랍니다.) mysql> grant all privileges on *.* to ‘root’@’%’ identified by ‘변경 패스워드’; mysql> flush privileges; 2 ) Replication 계정 생성 mysql> create user jmryu identified by ‘1234'; mysql> grant replication slave, replication client on *.* to jmryu@’1.1.1.1' identified by ‘1234'; mysql> grant replication slave, replication client on *.* to jmryu@’1.1.1.2' identified by ’1234'; mysql> grant replication slave, replication client on *.* to jmryu@'1.1.1.3' identified by ’1234'; 3) 일반 계정 생성 mysql> grant all privileges on *.* to jmryu@localhost identified by ”1234"; mysql> grant all privileges on *.* to jmryu@'%' identified by ”1234"; mysql> grant select,execute,show view,event,trigger,usage on *.* to ‘was01'@’1.1.1.1' identified by “1234"; mysql> grant select,execute,show view,event,trigger,usage on *.* to ‘was02'@’1.1.1.2' identified by "1234"; mysql> grant select,execute,show view,event,trigger,usage on *.* to ‘was03'@’1.1.1.3' identified by ”1234"; mysql> grant select,execute,show view,event,trigger,usage on *.* to ‘was04'@’1.1.1.4' identified by ”1234"; mysql> grant select,execute,show view,event,trigger,usage on *.* to ‘was05'@’1.1.1.5' identified by ”1234";
  • 15. mysql> grant select,execute,show view,event,trigger,usage on *.* to 'imecwas06'@’1.1.1.1' identified by “1234”; mysql> grant select,execute,show view,event,trigger,usage on *.* to 'imecwas06'@’1.1.1.2' identified by “1234”;
  • 16. < MySQL 접속 방법 > Shell> /usr/local/mysql/bin/mysql –uroot –p Enter password: 패스워드 입력 # root 계정 패스워드 ( 비밀번호 ) DataBase 접속 Mysql> use DBNAME; < MySQL 서버 START > Shell> /data/mysql/bin/mysqld_safe –user=mysql & < MySQL 서버 STOP > Shell> /data/mysql/bin/mysqladmin –uroot –p shutdown Enter password: 패스워드 입력
  • 17. < Replication Master Postion 확인 > Mysql> show master status; Ex> File = mysql-bin.000001 Position = 123; < Replication 설정 방법 (Slave) > Ex> change master to master_host='10.10.10.100', master_user=’사용자아이디', master_password=’비밀번호', master_log_file='mysql-bin.000001', master_log_pos= 123; < Replicaion Slave Postion 확인 > Mysql> show slave statusG; < Replication Slave 서버 START > Mysql> start slave; < Replication Slave 서버 STOP > Mysql> stop slave;

×