标签:频率 code 自动提交 应用 appears 完成 5.5 bsp 重要
MyISAM存储引擎
mysql系统表很多都用myisam引擎
生产场景:
引擎调优精要:
query_cache_size=256M
query_cache_limit=1M
query_cache_min_res_unit=2K
Innodb引擎:
生产场景:
innodb_additional_mem_pool_size=16M
innodb_buffer_pool_size=2048M
innodb_data_file_path=ibdata1:1024M:autoextend
innodb_file_io_threads = 4
innodb_thread_concurrency = 8
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 16M
innodb_log_file_size=128M
innodb_log_files_in_group=3
innodb_max_dirty_pages_pct=90
innodb_lock_wait_timeout=120
innodb_file_per_table=0
innodb_file_per_table #每张表一个文件
innodb_data_home_dir=/data/xxx
innodb_log_group_home_dir=/data/xxx
innodb引擎调优精要:
mysql> show engines; +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+ | Engine | Support | Comment | Transactions | XA | Savepoints | +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+ | MyISAM | YES | MyISAM storage engine | NO | NO | NO | | CSV | YES | CSV storage engine | NO | NO | NO | | PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO | | BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO | | MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO | | InnoDB | DEFAULT | Supports transactions, row-level locking, and foreign keys | YES | YES | YES | | ARCHIVE | YES | Archive storage engine | NO | NO | NO | | MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO | | FEDERATED | NO | Federated MySQL storage engine | NULL | NULL | NULL | +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+ 9 rows in set (0.00 sec)
生产环境中如何批量修改MySQL引擎
1、alter table account ENGINE=MyISAM;
mysql> show create table account; +---------+-----------------------------------+ | Table | Create Table | +---------+-----------------------------------+ | account | CREATE TABLE `account` ( `id` int(11) DEFAULT NULL, `name` varchar(10) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 | +---------+-----------------------------------+ 1 row in set (0.00 sec) mysql> alter table account ENGINE=MyISAM; Query OK, 2 rows affected (0.06 sec) Records: 2 Duplicates: 0 Warnings: 0 mysql> show create table account; +---------+-----------------------------------+ | Table | Create Table | +---------+-----------------------------------+ | account | CREATE TABLE `account` ( `id` int(11) DEFAULT NULL, `name` varchar(10) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 | +---------+-----------------------------------+ 1 row in set (0.00 sec)
2、使用sed对备份内容进行引擎转换(适合小数据量)
mysqldump > abbott.sql nohup sed -e ‘s/MyISAM/InnoDB/g‘ abbott2.sql > abbott.sql & mysql < abbott.sql
3、如下脚本
SET @DATABASE_NAME = ‘abbott‘; SELECT CONCAT(‘ALTER TABLE `‘, table_name, ‘` ENGINE=InnoDB;‘) AS sql_statements FROM information_schema.tables AS tb WHERE table_schema = @DATABASE_NAME AND `ENGINE` = ‘MyISAM‘ AND `TABLE_TYPE` = ‘BASE TABLE‘ ORDER BY table_name DESC;
标签:频率 code 自动提交 应用 appears 完成 5.5 bsp 重要
原文地址:http://www.cnblogs.com/zx3212/p/7143733.html