Lesson Four (2)--mysql configuration parameters Explained

Source: Internet
Author: User
Tags reverse dns

General*****************user
启动mysql domain的用户
Port
 数据库端口号
Socket
数据库socket文件的路径
Pid_file
数据库启动进程文件的路径
DataDir
数据文件路径
Tmpdir
临时文件路径
Log_bin
配置二进制文件名称、路径(不写绝对路径就在datadir下)
Relay-log
配置中继日志名称、路径(不写绝对路径就在datadir下)
Log_error
配置错误日志名称、路径(不写绝对路径就在datadir下)
Slow_query_log_file
配置慢查询日志名称、路径(不写绝对路径就在datadir下)
Long_query_time
是否开启慢查询
Sync_binlog
(1)sync_binlog=0时,当事务提交后,mysql不做fsync之类的磁盘同步指定刷新binlog_cache中的信息到磁盘,而是操作系统系统决定什么时候同步binlog_cache到磁盘,甚至是cache满了才会同步到磁盘。也就是不做任何强制性的磁盘刷新指令,sync_binlog=0的性能做好,风险也是最大的。(2)sync_binlog=N时,当每进行N次事务提交之后,MySQL将进行一次fsync之类的磁盘同步指令来将binlog_cache中的数据强制写入磁盘。(3)备注:如果启用了autocommit,那么每一个语句statement就会有一次写操作;否则每个事务对应一个写操作(4)sync_binlog=0的性能最好,风险也最大;因为一旦系统崩溃,在binlog_cache里的所有binlog信息将丢失;sync_binlog=1是最安全但是性能损坏最大;因为当设置为1时,即使系统crash,也最多丢失bunlog_cache中为完成的一个事务,对实际数据没有任何实质性影响。(5)sync_binlog参数的建议值:如果是在线交易和帐有关的数据建议设置成1, 其它数据保持为0即可。
Expire_logs_days
自动清理binlog的天数
Back_log
(1)back_log 值指出在MySQL暂时停止回答(TCP三次捂手)新请求之前的短时间内多少个请求可以被存在堆栈中;(2)在linux下这个参数的值不能大于系统参数tcp_max_syn_backlog的值(位于/proc/sys/net/ipv4/tcp_max_syn_backlog)(3)show variables like ‘back_log‘;查看back_log值,mysql5.5默认50,mysql5.6默认80
Skip-name-resolve

(1) Skip the domain name resolution forward, reverse DNS resolution, the default MySQL authentication remote client, not only to verify the user name, password also need to verify that the hostname on the DNS can be resolved.
(2) Show variables like ' skip_name_resolve '; to see if the host name is resolved, by default, you need to verify that the hostname is resolvable on DNS.

Skip-external-locking
跳过MyISAM表级别的外部锁,用于多个线程访问同一个数据库目录的锁机制。默认是跳过MYISAM表级别的外部锁的
Skip-character-set-client-handshake
忽略客户端字符集,而是使用服务端字符集
Explicit_defaults_for_timestamp
(1) mysql5.6 new parameters, limit the creation of timestamp types of fields to specify the default behavior, (2) before the mysql5.6 version, define the first timestamp Type field: Add column t timestamp; the default T field property is not NULL default current_timestamp on UPDATE current_timestamp; defines the second and above TIMESTAMP type fields: Add column t TIMESTAMP; the Default TT field property is not NULL DEFAULT ' 0000-00-00 00:00:00 '. That is, the timestamp column is not explicitly defined as bull, and is set to NOT NULL by default. The first timestamp column in the table, if not defined as NULL, defines the default value, or on update, automatically assigns the default Current_timestamp and on Update current_timestamp properties All timestamp columns after the first timestamp column in the table are automatically assigned the default value ' 0000-00-00 00:00:00 ' if they are not defined as null. When inserting, if the values of these columns are not specified, they are automatically specified as ' 0000-00-00 00:00:00 ' and do not produce a warning. (3) After mysql5.6, the default setting method of the above timestamp type is discarded, when MySQL is started, the method of canceling alarm is setting explicit_defaults_for_timestamp=true parameter, after setting this parameter, The default handling of columns of type timestamp also varies: (3.1) timestamp column supports the Null property if it is not explicitly defined as NOT NULL. Setting the timestamp column value to NULL will not be set to current timestamp; (3.2) The default Current_timestamp and on Update Current_timestamp properties are no longer assigned automatically. These properties must be explicitly specified, (3.3) declared as NOT null and no default value is explicitly specified without a default value. The column is inserted in the table without assigning a value to the timestamp column, an error is thrown if it is in strict SQL mode, and if strict SQL mode is not enabled, it will be assigned a value of ' 0000-00-00 00:00:00′Now a warning. (This is the same as when MySQL handles other time-type data, such as DateTime)
Default_storage_engine
设置MySQL默认使用的引擎
Bind-address
用于MySQL允许TCP/IP连接的,0.0.0.0代表任意主机
Lower_case_table_names
设置为1时,表示存储表名是不区分大小写
Myisam_recover
自动恢复MyISAM表
Transaction-isolation
事务隔离级别:READ UNCOMMITTED、READ COMMITTED、 REPEATABLE READ、SERIALIZABLE
Table_definition_cache
存放表的定义信息。是frm文件在内存中的映射。MySQL需要打开frm文件,并将其内容初始化为Table Share 对象。这里存放与存储引擎无关的,独立的表定义相关信息。
Table_open_cache
为所有线程打开表的缓存,存放当前已经打开的表句柄,与表创建时指定的存储引擎相关。
Performance_schema
启动性能统计信息
Max_connections
最大允许的同时客户的数量
Max_user_connections
root权限意外用户最大连接数
Max_connect_errors
对于链接中断的次数进行计数,超过配置次数,要通过flush hosts;重置计数器
Timeout*****************wait_timeout
服务器在关闭它之前在一个连接上等待行动的秒数
Interactive_timeout
服务器在关闭它前在一个交互连接上等待行动的秒数
Lock_wait_timeout
事务获得资源超时时间
Connect_timeout
MySQL Server等待客户端TCP链接的时间
Slave-net-timeout
slave和master网络超时的时间,单位:秒
Character*****************character-set-server
 MySQL Server字符集
Init-connect
指定每个客户端在链接MySQL后,执行的strings
Query Cachequery_cache_type
是否启用查询缓存QC
Query_cache_size
查询缓存QC大小
replication*****************server_id
server_id要求尽量唯一
Gtid_mode
(1)是否开启GTID,如果是ON,则必须是log-bin,log-slave-updates,enforce-gtid-consistency也必须启动(2)TID:Transaction ID,事务的ID号:也就是说在mysql复制中每一个事务都有自己的ID号(随机数);(3)GTID:Global Transaction ID,全局事务ID,在整个事务架构中每一个事务ID号是全局唯一的,不止是在一个节点上而是整个主从复制架构中每任何两个事务的ID号都不会相同;(4)在mysql5.6以后每一个mysql服务器都有一个全局唯一的ID号叫做uuid,通用唯一识别码 (Universally Unique Identifier),而GTID就是由当前节点的UUID(一个128位的随机数)和为当前节点生成的随机数(TID)组成的,因此只要UUID不同再在此基础上保证事务ID不同就保证全局不一样了。(5)GTID复制的工作原理:        ——master更新数据时,会在事务前产生GTID,一同记录到binlog日志中;        ——slave端的i/o 线程将变更的binlog,写入到本地的relay log中;        ——sql线程从relay log中获取GTID,然后对比slave端的binlog是否有记录;        ——如果有记录,说明该GTID的事务已经执行,slave会忽略        ——如果没有记录,slave就会从relay log中执行该GTID的事务,并记录到binlog;        ——在解析过程中会判断是否有主键,如果没有就用二级索引,如果没有就用全部扫描。
Enforce-gtid-consistency
gtid-mode=ON,该参数必须开启,用于控制事务安全的记录到binlog中
Log-slave-updates
slave会把复制的binlog也到binarylog中记录,在级联复制中,用于记录元数据都被哪些数据库应用过.
Binlog-format=row
binlog日志格式:statement、row、mixed可动态修改,建议row
Slave-parallel-workers
MySQL5.6并行复制参数(库级别并行复制)
Master-info-repository
服务器写master log info的存储方式是table还是file
Relay-log-info-repository
服务器写relay log info的存储方式是table还是file
Sync_master_info
和sync_binlog是一种参数,控制N次之后刷新master.info
Slave_sql_verify_checksum
SQL thread使用校验和验证数据从中继日志读取
Skip-slave-start
跳过MySQL自动启动slave
Myiasm*****************key_buffer_size
(MyISAM)索引块是缓冲的并且被所有的线程共享。keybuffersize是用于索引块的缓冲区大小
Sessionread_buffer_size
每个进行一个顺序扫描的线程为其扫描的每张表分配这个大小的一个缓冲区
Read_rnd_buffer_size
每个进行一个离散扫描的线程为其扫描的每张表分配这个大小的一个缓冲区
Tmp_table_size
临时HEAP数据表的最大长度
Max_heap_table_size
此变量设置允许用户创建的内存表的最大大小
Max_allowed_packet
允许最大发送、接收数据包的大小
Bulk_insert_buffer_size
insert、load data infile子句所需要的插入缓冲区大小
Sort_buffer_size
每个需要进行排序的线程分配该大小的一个缓冲区
Join_buffer_size
每个需要及进行表连接分配改大小的缓冲区
Myisam_sort_buffer_size
该缓冲区分配指标排序时MyISAM修表期间的大小
Thread_cache_size
可以复用的保存在中的线程的数量。如果有,新的线程从缓存中取得,当断开连接的时候如果有空间,客户的线置在缓存中。一般来讲首先要确认一下“Threads_connected”的最大最小的值,一般来讲设置256就已经很大了,因为保持大量等待连接的空闲线程并没有什么作用
Thread_concurrency
运行的应用程序在同一时间并发的线程数
Thread_stack
每个线程的堆栈大小
Innodb*****************innodb_flush_method
O_DIRECT设置时,依然使用sync()来刷新文件到磁盘,但是会通知操作系统不要缓存数据,也不要预读,这个选项完全的关闭操作系统缓存,避免了缓存双重写的问题, 使用O_DIRECT选项时,通常需要带有写缓存的RAID卡,并设置为write-back(写缓冲,需要RAID电源备份单元才可以启动该状态)策略,因为这是唯一能保持性能的方法。
Iinnodb_data_home_dir
innodb数据文件家目录(也即是idbdata文件的路径)
Innodb_data_file_path
innodb共享表空间及大小(也即是idbdata文件定义和大小)
Redo Loginnodb_log_group_home_dir
innodb redo log家目录(也即是idb_logfile*文件路径)
Innodb_log_files_in_group
innodb redo log group数量(也即是idb_logfile文件的个数,一般是2个,顺序循环写入日志)
Innodb_log_file_size
innodb redo log大小(也即是idb_logfile文件的大小)
InnoDB Performanceinnodb_flush_log_at_trx_commit
(1)如果innodb_flush_log_at_trx_commit=0,log buffer将每秒一次地写入log file中,并且log file的flush(刷到磁盘)操作同时进行;该模式下,在事务提交的时候,不会主动触发写入磁盘的操作。(2)如果innodb_flush_log_at_trx_commit=1,每次事务提交时MySQL都会把log buffer的数据写入log file,并且flush(刷到磁盘)中去,默认值是1;(3)如果innodb_flush_log_at_trx_commit=2,每次事务提交时MySQL都会把log buffer的数据写入log file.但是flush(刷到磁盘)操作并不会同时进行。该模式下,MySQL会每秒执行一次 flush(刷到磁盘)操作。
Innodb_file_per_table
是否启用独立表空间(启用innodb独立表空间后,每个表都会生成一个.idb文件,用了存放数据和索引)
Innodb_buffer_pool_instances
innodb buffer pool 实例数量,innodb在管理大内存的buffer pool时,效率总不是能够利用充分,因为内存大会造成遍历buffer pool内的page时间会长,更重要的原因是mutex只有一个
Innodb_io_capacity
innodb曾经在代码里写死了,每秒100个IO操作的单硬盘上,现在通过innodb_io_capacity参数指定innodb服务器有多大的IO能力
Innodb_lock_wait_timeout
innodb事务等待row lock超时时间
Binlog_error_action
控制服务器无法写入到二进制日志时发生的动作
Innodb_buffer_pool_size
innodb引擎最大的缓冲区大小
Innodb_additional_mem_pool_size
InnoDB用来存储数据字典和其他内部数据结构的内存池大小
innodb_max_dirty_pages_pct
innodb最大脏页的百分比,超过该参数值,就会触发check point
Innodb_file_format

· Antelope is the original InnoDB file format, which previously do not has a name. It supports COMPACT and redundant row formats for InnoDB tables and are the default file format in MySQL 5.5 to ensure maxi Mum compatibility with earlier MySQL versions, the Barracuda file format.
· Barracuda is the newest file format. It supports all InnoDB row formats including the newer compressed and DYNAMIC row formats. The features associated with compressed and DYNAMIC row formats include compressed tables and Off-page storage for long Co Lumn data. See section 14.14, "InnoDB row Storage and Row Formats".

Innodb_support_xa
默认为true,如果关闭则binlog记录事务的顺序可能与实际不符1. prepare ,然后将redo log持久化到磁盘2. 如果前面prepare成功,那么再继续将事务日志持久化到binlog3. 如果前面成功,那么在redo log里面写上一个commit记录 那么假如在进行着三步时又任何一步失败,crash recovery是怎么进行的呢? 此时会先从redo log将最近一个检查点开始的事务读出来,然后参考binlog里面的事务进行恢复。 如果是在1 crash,那么自然整个事务都回滚; 如果是在2 crash,那么也会整个事务回滚; 如果是在3 crash(仅仅是commit记录没写成功),那么没有关系因为2中已经记录了此次事务的binlog,所以将这个进行commit。所以总结起来就是redo log里凡是prepare成功,但commit失败的事务都会先去binlog查找判断其是否存在(通过XID进行判断,是不是经常在binlog里面看到Xid=xxxx?这就是xa事务id),如果有则将这个事务commit,否则rollback。
Innodb_buffer_pool_dump_at_shutdown
(1)5.6新特性:数据库启动或关闭时自动dump buffer pool 数据(2)问题:如果内存100G,关闭MySQL的时候需要dump出100G数据吗?
Innodb_buffer_pool_load_at_startup
5.6新特性:快速预热buffer pool热数据
Innodb_sync_spin_loops
thread 等待innodb metux的时间
Innodb_thread_concurrency
线程调度器的最大并行度,0表示没有限制
Innodb_thread_sleep_delay
如果已经进入内核的线程超过了允许的数量,新的线程就无法进入内核,innodb使用两阶段处理来尝试尽可能高效快速的进入内核,(两阶段策略减少了因操作系统调度引起的上下文切换)
Innodb_concurrency_tickets
线程一旦进入内核就会得到一定数量的tickets(票据,由innodbconcurrencytickets参数决定),该参数限制了一个线程回答其他等待线程之间可以做多少事,tickets的单位是查询的数量,而不是事务数量,一旦tickets用完就作废。
innodb_old_blocks_pct
数据库通过LRU算法来进行管理,LRU列表中加入的midpoint位置。新读取到的页,并不是直接放到lru列表的首部,而是midpoint位置。默认情况下,在lru列表长度的5/8处。由参数innodboldblocks_pct控制。
Innodb_read_io_threads
read thread的数量默认4
Innodb_write_io_threads
write thread的数量默认4
Innodb_purge_threads
purge thread数量默认1
Innodb_purge_batch_size
The granularity of changes, expressed in units of redo log records, that trigger a purge operation, flushing the changed buffer pool blocks to disk. This option is intended for tuning performance in combination with the setting innodbpurgethreads=n, and typical users do not need to modify it.
Innodb_change_buffering
该参数控制insert/change buffer将insert update delete合并到insert buffer thread中
Innodb_stats_on_metadata
该参数控制当使用 SHOW INDEX, SHOW TABLE STATUS and SHOW [FULL] TABLES时,或者对应的从 INFORMATIONSCHEMA.TABLES和INFORMATIONSCHEMA.STATISTICS 表中查询时会自动更新统计信息。


From for notes (Wiz)

Lesson Four (2)--mysql configuration parameters Explained

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.