- 浏览: 258856 次
- 性别:
- 来自: 未定
文章分类
最新评论
-
zl544434558:
最后一行</filter> 多余的
Springmvc 乱码问题 -
imknown:
方法有效,感谢博主!
Springmvc 乱码问题 -
notafreak:
方法有效,感谢博主
Springmvc 乱码问题 -
linvar:
ligangdufs 写道 what about resin ...
Springmvc 乱码问题 -
ligangdufs:
what about resin
Springmvc 乱码问题
from http://dev.mysql.com/doc/refman/5.5/en/innodb-storage-engine.html
1.InnoDB is a high-reliability and high-performance storage engine for MySQL. Starting with MySQL 5.5, it is the default MySQL storage engine.
2.Key advantages of InnoDB include:
a.Its design follows the ACID model, with transactions featuring commit, rollback, and crash-recovery capabilities to protect user data.
b.Row-level locking and Oracle-style consistent reads increase multi-user concurrency and performance.
c.InnoDB tables arrange your data on disk to optimize common queries based on primary keys. Each InnoDB table has a primary key index called the clustered index that organizes the data to minimize I/O for primary key lookups.
d.To maintain data integrity, InnoDB also supports FOREIGN KEY referential-integrity constraints.
e.You can freely mix InnoDB tables with tables from other MySQL storage engines, even within the same statement. For example, you can use a join operation to combine data from InnoDB and MEMORY tables in a single query.
f.The InnoDB storage engine maintains its own buffer pool for caching data and indexes in main memory. InnoDB stores its tables and indexes in a tablespace, which may consist of several files (or raw disk partitions). This is different from, for example, MyISAM tables where each table is stored using separate files. InnoDB tables can be very large even on operating systems where file size is limited to 2GB.
3.Best Practices for InnoDB Tables
a.Specify a primary key for every table using the most frequently queried column or columns, or an auto-increment value if there isn't an obvious primary key.
b.Embrace the idea of joins, For fast join performance, define foreign keys on the join columns, and declare those columns with the same datatype in each table.
c.Turn off autocommit. Bracket sets of related changes, logical units of work, with START TRANSACTION and COMMIT statements.
d.Stop using LOCK TABLE statements. InnoDB can handle multiple sessions all reading and writing to the same table at once, without sacrificing reliability or high performance.
e.Enable the innodb_file_per_table option to put the data and indexes for individual tables into separate files, instead of in a single giant system tablespace. (This setting is required to use some of the other features, such as table compression and fast truncation.)
f.Evaluate whether your data and access patterns benefit from the new InnoDB table compression feature (ROW_FORMAT=COMPRESSED on the CREATE TABLE statement. You can compress InnoDB tables without sacrificing read/write capability.
g.Run your server with the option --sql_mode=NO_ENGINE_SUBSTITUTION to prevent tables being created with a different storage engine if there is an issue with the one specified in the ENGINE= clause of CREATE TABLE.
4.Configuring InnoDB
a.Two important disk-based resources managed by the InnoDB storage engine are its tablespace data files and its log files.
b.Specifying the Location and Size for InnoDB Tablespace Files
[mysqld]
innodb_data_home_dir=/data/mysql/ibdata
innodb_data_file_path=ibdata1:50M;ibdata2:50M:autoextend
c.Determining the Maximum Memory Allocation for InnoDB
innodb_buffer_pool_size
+ key_buffer_size
+ max_connections* (sort_buffer_size+read_buffer_size+binlog_cache_size)
+ max_connections*2MB
< 2G in 32bit linux
5.Tuning other mysqld server parameters.
[mysqld]
skip-external-locking
max_connections=200
read_buffer_size=1M
sort_buffer_size=1M
#
# Set key_buffer to 5 - 50% of your RAM depending on how much
# you use MyISAM tables, but keep key_buffer_size + InnoDB
# buffer pool size < 80% of your RAM
key_buffer_size=value
6.Using Per-Table Tablespaces
a.By default, all InnoDB tables and indexes are stored in the system tablespace. As an alternative, you can store each InnoDB table and its indexes in its own file. This feature is called “multiple tablespaces” because each table that is created when this setting is in effect has its own tablespace.
b.Enabling and Disabling Multiple Tablespaces
[mysqld]
innodb_file_per_table
c.With multiple tablespaces enabled, InnoDB stores each newly created table in its own tbl_name.ibd file in the appropriate database directory. Unlike the MyISAM storage engine, with its separate tbl_name.MYD and tbl_name.MYI files for indexes and data, InnoDB stores the data and the indexes together in a single .ibd file. The tbl_name.frm file is still created as usual.
d.You can always access both tables in the system tablespace and tables in their own tablespaces, regardless of the file-per-table setting. To move a table from the system tablespace to its own tablespace, or vice versa, you can change the innodb_file_per_table setting and issue the command:
ALTER TABLE table_name ENGINE=InnoDB;
e.Portability Considerations for .ibd Files
You cannot freely move .ibd files between database directories as you can with MyISAM table files. The table definition stored in the InnoDB shared tablespace includes the database name. The transaction IDs and log sequence numbers stored in the tablespace files also differ between databases.
To move an .ibd file and the associated table from one database to another, use a RENAME TABLE statement:
RENAME TABLE db1.tbl_name TO db2.tbl_name;
7.Backing Up and Recovering an InnoDB Database
a.hot backup:
MySQL Enterprise Backup / Percona-xtrabackup
b.cold backup:
stop the server without errors,
copy innodb data files(ibdata*, .ibd),
innodb log files(ib_logfile file), all .frm files for innodb tables
c.mysqldump --single-transaction --opt -c -e --default-character-set=utf8
8.The InnoDB Transaction Model and Locking
In the InnoDB transaction model, the goal is to combine the best properties of a multi-versioning database with traditional two-phase locking. InnoDB does locking on the row level and runs queries as nonlocking consistent reads by default, in the style of Oracle.
In terms of the SQL:1992 transaction isolation levels, the default InnoDB level is REPEATABLE READ. InnoDB offers all four transaction isolation levels described by the SQL standard: READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ, and SERIALIZABLE.
9.InnoDB Lock Modes
a. InnoDB implements standard row-level locking where there are two types of locks:
(1).A shared (S) lock permits a transaction to read a row.
(2).An exclusive (X) lock permits a transaction to update or delete a row.
b.Additionally, InnoDB supports multiple granularity locking which permits coexistence of record locks and locks on entire tables. To make locking at multiple granularity levels practical, additional types of locks called intention locks are used. Intention locks are table locks in InnoDB.
(1).Intention shared (IS):
Transaction T intends to set S locks on individual rows in table t.
(2).Intention exclusive (IX):
Transaction T intends to set X locks on those rows.
c.The intention locking protocol is as follows:
(1).Before a transaction can acquire an S lock on a row in table t, it must first acquire an IS or stronger lock on t.
(2).Before a transaction can acquire an X lock on a row, it must first acquire an IX lock on t.
10.InnoDB Multi-Versioning
InnoDB is a multi-versioned storage engine: it keeps information about old versions of changed rows, to support transactional features such as concurrency and rollback.
11.Optimizing for InnoDB Tables
a.Once your data reaches a stable size, or a growing table has increased by tens or some hundreds of megabytes, consider using the OPTIMIZE TABLE statement to reorganize the table and compact any wasted space.
b.In InnoDB, having a long PRIMARY KEY,wastes a lot of disk space.
The primary key value for a row is duplicated in all the secondary index records that point to the same row.
c.Use the VARCHAR data type instead of CHAR to store variable-length strings or for columns with many NULL values.
d.For tables that are big, or contain lots of repetitive text or numeric data, consider using COMPRESSED row format.
COMPACT row format is the default InnoDB format in MySQL 5.5.
12.Optimizing InnoDB Transaction Management
a.The default MySQL setting AUTOCOMMIT=1 can impose performance limitations on a busy database server.
b.Avoid performing rollbacks after inserting, updating, or deleting huge numbers of rows.If a big transaction is slowing down server performance, rolling it back can make the problem worse
To minimize the chance of this issue occurring: increase the size of the buffer pool so that all the DML changes can be cached rather than immediately written to disk; set innodb_change_buffering=all so that update and delete operations are buffered in addition to inserts; and consider issuing COMMIT statements periodically during the big DML operation, possibly breaking a single delete or update into multiple statements that operate on smaller numbers of rows.
13.Optimizing InnoDB Logging
a.Make your log files big, even as big as the buffer pool. When InnoDB has written the log files full, it must write the modified contents of the buffer pool to disk in a checkpoint. Small log files cause many unnecessary disk writes. Although historically big log files caused lengthy recovery times, recovery is now much faster and you can confidently use large log files.
b.Make the log buffer quite large as well (on the order of 8MB).
14.Bulk Data Loading for InnoDB Tables
a.When importing data into InnoDB, turn off autocommit mode, because it performs a log flush to disk for every insert.
SET autocommit=0;
... SQL import statements ...
COMMIT;
b.SET unique_checks=0;
... SQL import statements ...
SET unique_checks=1;
c.SET foreign_key_checks=0;
... SQL import statements ...
SET foreign_key_checks=1;
d.Use the multiple-row INSERT syntax to reduce communication overhead
e.When doing bulk inserts into tables with auto-increment columns, set innodb_autoinc_lock_mode to 2 or 3 instead of the default value 1.
15.Optimizing InnoDB Queries
To tune queries for InnoDB tables, create an appropriate set of indexes on each table.
a.Because each InnoDB table has a primary key (whether you request one or not), specify a set of primary key columns for each table, columns that are used in the most important and time-critical queries.
b.Do not specify too many or too long columns in the primary key, because these column values are duplicated in each secondary index.
c.Do not create a separate secondary index for each column, because each query can only make use of one index.
d.If an indexed column cannot contain any NULL values, declare it as NOT NULL when you create the table. The optimizer can better determine which index is most effective to use for a query, when it knows whether each column contains NULL values or not.
e.If you often have recurring queries for tables that are not updated frequently, enable the query cache:
[mysqld]
query_cache_type = 1
query_cache_size = 10M
16.Optimizing InnoDB DDL Operations
a.For DDL operations on tables and indexes (CREATE, ALTER, and DROP statements), the most significant aspect for InnoDB tables is that creating and dropping secondary indexes is much faster in MySQL 5.5 and higher
b.“Fast index creation” makes it faster in some cases to drop an index before loading data into a table, then re-create the index after loading the data.
c.Use TRUNCATE TABLE to empty a table, not DELETE FROM tbl_name. Foreign key constraints can make a TRUNCATE statement work like a regular DELETE statement, in which case a sequence of commands like DROP TABLE and CREATE TABLE might be fastest.
d.Because the primary key is integral to the storage layout of each InnoDB table, and changing the definition of the primary key involves reorganizing the whole table, always set up the primary key as part of the CREATE TABLE statement, and plan ahead so that you do not need to ALTER or DROP the primary key afterward.
17.Optimizing InnoDB for Systems with Many Tables
InnoDB computes index cardinality values for a table the first time that table is accessed after startup, instead of storing such values in the table. This step can take significant time on systems that partition the data into many tables. Since this overhead only applies to the initial table open operation, to “warm up” a table for later use, access it immediately after startup by issuing a statement such as SELECT 1 FROM tbl_name LIMIT 1.
发表评论
-
Oracle 确实很难搞
2013-08-04 20:00 2213对Oracle的庞大而复杂早有耳闻, 也一直没有涉足Or ... -
pgsql note
2012-03-31 07:55 01.PGDATA pgsql数据存放地方叫做database ... -
[转]MySQL事务隔离级别
2011-11-07 16:31 1254[转自]http://www.ningoo.net/html/ ... -
[转]MySQL索引
2011-08-15 21:53 924转自:http://database.51cto.com/ar ... -
MySQL Server Administration
2011-04-16 16:34 12041.Server Option and Variable R ... -
Mysql Backup and Recovery
2011-04-16 12:01 14911.Backup and Recovery Types ... -
mysql replication note
2011-04-15 23:21 1207Replication enables data f ... -
Mysql Stored Programs
2011-04-12 17:44 10281.Stored programs include thes ... -
delete, truncate, drop
2011-02-24 11:14 1032转自:http://www.chinaunix.net/jh ... -
mysql 常用命令-coder
2011-02-24 11:12 0记录一些开发中用到的mysql sql 1.增(insert ... -
mysql 日期函数
2010-10-11 21:27 969转自:http://www.cnblogs.com/she27 ... -
常用的MySQL数据类型
2010-10-11 21:18 1329转自:http://roclinux.cn/?p= ... -
mysql 常用命令-admin
2010-04-04 19:59 1020还真需要有个mysql常用命令参考在手边,脑袋太小,信息太多 ... -
mysql5 trap and tip
2010-03-17 13:30 10631.mysql在linux下表名是区分大小写的,但是列又不区分 ... -
mysql5 备份与恢复
2010-03-15 23:41 1181.备份数据库使用mysqldump命令 #mysqldum ... -
oracle notes
2010-03-11 20:46 191.Oracle Database is composed o ... -
oraclexe tip
2010-03-11 20:45 201. Oracle Database Express Edit ... -
mysql源码安装
2010-03-03 09:42 1721安装路径是/home/opt/mysql(/home是独立分区 ...
相关推荐
前言mysql中有很多的引擎,不同的引擎存储数据的方式是不同的,本文以InnoDB为例进行讲解InnoDB页简介为了提高效率,InnoDB以页作为磁盘和内存之间
引用 090613 10:15:27 [ERROR] Default storage engine (InnoDB) is not available 090613 10:15:27 [ERROR] Aborting 090613 10:15:27 [Note] C:\www\mysql\bin\mysqld-nt: Shutdown complete 估计是上次加了参数...
MySQL支持多种数据库引擎,其中最常用的是InnoDB和MyISAM。InnoDB是默认引擎,它支持事务处理和行级锁定,适合需要数据一致性的应用。MyISAM则以读取速度快著称,但不支持事务,适用于读多写少的场景。此外,还有...
2016-03-03T00:02:30.483100Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files. 终端不断地重复打印上面的错误日志,从错误日志看起来似乎有...
读到未提交的数据违反了事务的隔离性加X锁不可重复读指在一个事务内多次读取同一数据,读取到的数据不一致。死锁的处理方式超时InnoDB采用的就是等待图的方式,等待
3. **InnoDB初始化信息**:接下来的一系列`[Note]`消息记录了InnoDB存储引擎在启动过程中的状态,如使用原子操作管理缓冲池页面、内存堆的禁用、使用Windows原生互斥函数等。 4. **非正常关机提示**:“Database ...
mysqld --defaults-file="C:\Program Files\MySQL\MySQL Server 5.1\my.ini" --console --skip-grant-tables ``` - 其中`--defaults-file`参数指定了MySQL的配置文件路径,通常是安装目录下的`my.ini`文件。 - `...
安装完成后,你可以访问提供的安装教程链接(https://note.youdao.com/s/1pW9U1H)获取详细步骤和注意事项,以确保正确安装和配置MySQL 5.7.13。 总之,MySQL 5.7.13是Windows平台上的一款强大数据库管理系统,它的...
2017-06-05T14:30:55.590590Z 0 [Warning] InnoDB: New log files created, LSN=457902017-06-05T14:30:56.000269Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2017-06-05T14:30:56....
日志文件`/disk/mysql/www.err`中显示了错误信息:“InnoDB: Unable to lock ./ibdata1, error: 11”。这个错误通常意味着MySQL无法获取对数据文件的锁,可能是由于另一个MySQL实例正在运行,或者数据文件损坏。 3...
例如,`create table Departments (DepartmentID char(3) NOT null, DepartmentName char(20) not null, Note text(16), primary key (DepartmentID))engine=innodb;` 创建了名为`Departments`的表,其中包含了字段`...
2018-07-08T02:58:03.718786Z5[Note][MY-010454] A temporary password is generated for root@localhost:J&:rqhMd/9>f ``` #### 六、MySQL服务启动与管理 - **启动MySQL服务**: ```bash ./support-files/...
MySQL数据库在运行过程中可能会遇到各种错误,其中"Got timeout reading communication packets"是一个常见的错误提示,意味着客户端在尝试读取服务器的通信数据包时超时。这个错误通常与连接的超时设置、网络延迟...
当MySQL在新的数据目录下无法启动,报出与InnoDB相关的错误时,这可能意味着InnoDB存储引擎无法初始化。InnoDB错误通常涉及到数据文件的读写权限、文件损坏或表空间的问题。例如,错误日志中提到的`ibdata1`文件无法...
- 在使用`mysqladmin shutdown`命令关闭MySQL服务时,需要注意InnoDB和MyISAM存储引擎的数据一致性问题。 - InnoDB支持事务处理,关闭时需要确保所有未提交的事务都已完成,否则可能导致数据不一致。 - MyISAM不...
MySQL数据库在运行过程中可能会遇到各种问题,其中一种是由于`Plugin 'FEDERATED' is disabled`导致的服务自动停止。FEDERATED存储引擎在MySQL中用于实现远程数据的联邦,当它被禁用时,可能会影响服务的稳定运行。...
首先停止mysql服务: 代码如下: root@webserver:/home/webmaster# service mysql stop 接着采用忽略密码认证模式重新创建一个mysql服务: 代码如下: root@webserver:/home/webmaster# mysqld –user=mysql –skip-...
装好wamp后在试图用phpMyAdmin链接... 而MySql报错如下: 091224 1:43:18 InnoDB: Starting shutdown… 091224 1:43:19 InnoDB: Shutdown completed; log sequence number 0 43655 091224 1:43:19 [Note] c:\wamp\mysql