72GB内存生产环境中的my.cnf

参考贺老师书里的内容加上自己的注释

# MySQL configuration for 72G memory
[client]
port = 3306
socket = /tmp/mysql.sock

#The MySQL server
#########Basic###########
[mysqld]
server-id = 22
port = 3306
user = mysql
basedir = /usr/local/mysql
datadir = /mysqlData/data
tmpdir = /mysqlData/tmp
socket = /tmp/mysql.sock
skip-external-locking     --(This is OFF if mysqld uses external locking (system locking) External locking affects only MyISAM table access)
skip-name-resolve    --(Do not resolve host names when checking client connections. Use only IP addresses. If you use this option, all Host column values in the grant tables must be IP addresses or localhost)
default-storage-engine = INNODB
character-set-server = utf8
wait_timeout = 100    --(The number of seconds the server waits for activity on a noninteractive connection before closing it)
connect_timeout = 20    --(The number of seconds that the mysqld server waits for a connect packet before responding with Bad handshake. The default value is 10 seconds)
interactive_timeout = 100 --(The number of seconds the server waits for activity on an interactive connection before closing it.)
back_log = 500      --( The number of outstanding connection requests MySQL can have 指定MySQL可能的连接数量。当MySQL主线程在很短的时间内得到非常多的连接请求,该参数就起作用,之后主线程花些时间(尽管很短)检查连接并且启动一个新线程 )
myisam_recover    --(Set the MyISAM storage engine recovery mode)
event_scheduler = ON       --(This variable indicates the status of the Event Scheduler)

########binlog############
log-bin = /mysqlLog/logs/mysql-bin
binlog_format = row
max_binlog_size = 128M
binlog_cache_size = 2M
expire-logs-days = 5

########replication##########
slave-net-timeout = 10    --(The number of seconds to wait for more data from the master before the slave considers the connection broken, aborts the read, and tries to reconnect)
rpl_semi_sync_master_enabled = 1   --(Controls whether semisynchronous replication is enabled on the master.)
rpl_semi_sync_master_wait_no_slave = 1  --(With semisynchronous replication, for each transaction, the master waits until timeout for acknowledgment of receipt from some semisynchronous slave 默认打开,表示当备库起来后,并跟上主库时,自动切换到同步模式,如果关闭,即使备库起来并跟上了,也不会启用半同步)
rpl_semi_sync_master_timeout = 1000   --(A value in milliseconds that controls how long the master waits on a commit for acknowledgment from a slave before timing out and reverting to asynchronous replication)
rpl_semi_sync_slave_enabled = 1   --(Controls whether semisynchronous replication is enabled on the slave)
skip-slave-start   --(Tells the slave server not to start the slave threads when the server starts)
log_slave_updates = 1  --(Whether updates received by a slave server from a master server should be logged to the slave‘s own binary log. Binary logging must be enabled on the slave for this variable to have any effect.)
relay_log_recovery = 1   --(Enables automatic relay log recovery immediately following server startup)

########slow log############
slow_query_log = 1
slow_query_log_file = /mysqlLog/logs/mysql.slow
long_query_time = 2   --(If a query takes longer than this many seconds, the server increments the Slow_queries status variable)

########error log############
log-error = /mysqlLog/logs/error.log

########per_thread_buffers######
max_connections = 1024      --(The maximum permitted number of simultaneous client connections 是指整个mysql服务器的最大连接数)
max_user_connections = 1000   --(The maximum number of simultaneous connections permitted to any given MySQL user account. A value of 0 (the default) means “no limit.” 是指每个数据库用户的最大连接数)
max_connect_errors = 10000   --(If more than this many successive connection requests from a host are interrupted without a successful connection, the server blocks that host from further connections.是一个MySQL中与安全有关的计数器值,它负责阻止过多尝试失败的客户端以防止暴力破解密码的情况)
key_buffer_size = 64M   --(Index blocks for MyISAM tables are buffered and are shared by all threads. key_buffer_size is the size of the buffer used for index blocks. The key buffer is also known as the key cache.)
max_allowed_packet = 128M    --(The maximum size of one packet or any generated/intermediate string, or any parameter sent by the mysql_stmt_send_long_data() C API function Server接受的数据包大小,避免大数据写入或者更新失败)
table_cache = 3096   --(5.1.13之前的版本)
table_open_cache = 6144    --(The number of open tables for all threads.)
table_definition_cache= 4096  --(The number of table definitions (from .frm files) that can be stored in the definition cache)
sort_buffer_size = 512K
read_buffer_size - 512K
read_rnd_buffer_size = 512K   --(This variable is used for reads from MyISAM tables, and, for any storage engine, for Multi-Range Read optimization.)
join_buffer_size = 512K  --(The minimum size of the buffer that is used for plain index scans, range index scans, and joins that do not use indexes and thus perform full table scans)
tmp_table_size = 64M    --(The maximum size of internal in-memory temporary tables. This variable does not apply to user-created MEMORY tables.)
max_heap_table_size = 64M     --(This variable sets the maximum size to which user-created MEMORY tables are permitted to grow 它规定了内部内存临时表的最大值,每个线程都要分配。(实际起限制作用的是tmp_table_size和max_heap_table_size的最小值。)如果内存临时表超出了限制,MySQL就会自动地把它转化为基于磁盘的MyISAM表,存储在指定的tmpdir目录下)
query_cache_type = 0  --(Set the query cache type. Setting the GLOBAL value sets the type for all clients that connect thereafter.不缓存查询结果)
query_cache_size = 0  --(The amount of memory allocated for caching query results)
bulk_insert_buffer_size = 32M   --(MyISAM uses a special tree-like cache to make bulk inserts faster for INSERT ... SELECT, INSERT ... VALUES (...), (...), ..., and LOAD DATA INFILE when adding data to nonempty tables.)
thread_cache_size = 64    --(How many threads the server should cache for reuse.)
#thread_concurrency = 32   --(This variable is specific to Solaris 8 and earlier systems, for which mysqld invokes the thr_setconcurrency() function with the variable value, This variable is deprecated as of MySQL 5.6.1 and is removed in MySQL 5.7)
thread_stack = 256K  (The stack size for each thread.)

########InnoDB###############
innodb_data_home_dir = /mysqlData/data
innodb_log_group_home_dir = /mysqlLog/logs
innodb_data_file_path = ibdata1:2G:autoextend
innodb_buffer_pool_size = 50G
innodb_buffer_pool_instances = 8
innodb_additional_mem_pool_size = 16M   --(The size in bytes of a memory pool InnoDB uses to store data dictionary information and other internal data structures.As of MySQL 5.6.3, innodb_additional_mem_pool_size is deprecated and will be removed in a future MySQL release.)
innodb_log_file_size = 1024M
innodb_log_buffer_size = 64M
innodb_log_files_in_group = 3
innodb_flush_log_at_trx_commit = 2    --(Controls the balance between strict ACID compliance for commit operations, and higher performance that is possible when commit-related I/O operations are rearranged and done in batches.)
innodb_lock_wait_timeout = 10   --(The length of time in seconds an InnoDB transaction waits for a row lock before giving up)
innodb_sync_spin_loops = 40   --(The number of times a thread waits for an InnoDB mutex to be freed before the thread is suspended.)
innodb_max_dirty_pages_pct = 90   --(InnoDB tries to flush data from the buffer pool so that the percentage of dirty pages does not exceed this value.)
innodb_support_xa = 1    --(Enables InnoDB support for two-phase commit in XA transactions, causing an extra disk flush for transaction preparation.)
innodb_thread_concurrency = 0   --(InnoDB tries to keep the number of operating system threads concurrently inside InnoDB less than or equal to the limit given by this variable (InnoDB uses operating system threads to process user transactions).跟cpu有关)
innodb_thread_sleep_delay = 500    --(How long InnoDB threads sleep before joining the InnoDB queue, in microseconds.)
innodb_file_io_threads = 4    --(在innodb plugin中,不在使用innodb_file_io_threads参数,而使用innodb_read_io_threads and innodb_write_io_threads 两个值代替)
innodb_concurrency_tickets = 1000    --(Determines the number of threads that can enter InnoDB concurrently)
c = 1   --(跟创建函数相关的操作)
innodb_flush_method = O_DIRECT   --(Defines the method used to flush data to the InnoDB data files and log files, which can affect I/O throughput,O_DIRECT: InnoDB uses O_DIRECT (or directio() on Solaris) to open the data files, and uses fsync() to flush both the data and log files. This option is available on some GNU/Linux versions, FreeBSD, and Solaris.)
innodb_file_per_table
innodb_read_io_threads = 16  --(The number of I/O threads for read operations in InnoDB.)
innodb_write_io_threads = 16  --(The number of I/O threads for write operations in InnoDB.)
innodb_io_capacity = 2000   --(The innodb_io_capacity parameter sets an upper limit on the I/O activity performed by the InnoDB background tasks, such as flushing pages from the buffer pool and merging data from the change buffer.在MySQL中一次刷新的脏页的数量有一个 innodb_io_capacity的参数进行控制, innodb_io_capacity越大,一次刷新的脏页的数量也就越大)
innodb_file_format = Barracuda   --(The file format to use for new InnoDB tables. Currently, Antelope and Barracuda are supported.)
innodb_purge_threads = 1    --(The number of background threads devoted to the InnoDB purge operation)
innodb_purge_batch_size = 32     --(The granularity of changes, expressed in units of redo log records, that trigger a purge operation, flushing the changed buffer pool blocks to disk. 表示一次完成多少个undolog page 但这个值有一个有趣的副作用是会影响到undolog的释放,因为总是在128轮purge后释放undolog page,在5.5及之后版本,开始支持128个回滚段)
innodb_old_blocks_pct = 75    --(Specifies the approximate percentage of the InnoDB buffer pool used for the old block sublist.)
innodb_change_buffering = all    --(Whether InnoDB performs change buffering, an optimization that delays write operations to secondary indexes so that the I/O operations can be performed sequentially. 当更新/插入的非聚集索引的数据所对应的页不在内存中时(对非聚集索引的更新操作通常会带来随机IO),会将其放到一个insert buffer中,当随后页面被读到内存中时,会将这些变化的记录merge到页中。当服务器比较空闲时,后台线程也会做merge操作)
transaction_isolation = READ-COMMITTED

[mysqldump]
quick
max_allowed_packet = 128M
myisam_max_sort_file_size = 10G

[mysql]
no-auto-rehash

[myisamchk]
key_buffer_size = 64M
sort_buffer_size = 256K
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout

[mysqld_safe]
open-files-limit = 28192
时间: 2024-10-15 18:13:26

72GB内存生产环境中的my.cnf的相关文章

生产环境中tomcat的配置

生产环境中要以daemon方式运行tomcat 通常在开发环境中,我们使用$CATALINA_HOME/bin/startup.sh来启动tomcat, 使用$CATALINA_HOME/bin/shutdown.sh来关闭tomcat. 而在生产环境中,我们要配置tomcat使其以daemon方式运行,这是因为: 以daemon运行不受终端影响,不会因为退出终端而停止运行 可以让tomcat以普通用户身份运行,可以让tomcat随linux启动而启动 如何将tomcat配置成守护进程 将tom

明白生产环境中的jvm参数

明白生产环境中的jvm参数 写代码的时候,程序写完了,发到线上去运行,跑一段时间后,程序变慢了,cpu负载高了--一堆问题出来了,所以了解一下生产环境的机器上的jvm配置是有必要的.比如说: JDK版本是多少?采用何种垃圾回收器? 程序启动的时候默认分配堆内存空间是多少?随着程序的运行,程序最多能使用多大的内存空间? 程序中使用了多少个线程?目前的java进程又处于何种状态? 了解了这些,会对程序的运行有一个更好的了解.本文结合生产实践,记录一下我常用的一些操作. 注意:如果没有特殊说明,下面所

Dubbo Mesh 在闲鱼生产环境中的落地实践

本文作者至简曾在 2018 QCon 上海站以<Service Mesh 的本质.价值和应用探索>为题做了一次分享,其中谈到了 Dubbo Mesh 的整体发展思路是"借力开源.反哺开源",也讲到了 Service Mesh 在阿里巴巴的发路径将经历以下三大阶段: 撬动做透价值***实现技术换代Dubbo Mesh 在闲鱼生产环境的落地,分享的是以多语言为撬动点的阶段性总结. 文章首发于「QCon」,阿里巴巴中间件授权转载. 闲鱼场景的特点闲鱼采用的编程语言是 Dart,思

Liu Junqiao:生产环境中shell脚本实例

在生产环境中,我们时常要注意主机的各种硬件状态,如果是规模较大的服务集群zabbix等健康工具当然好用,如果只是一些小规模的服务主机,shell就会表现的更灵活,也更适用,今天就和大家分享一个系统巡检脚本! 1 #!/bin/bash 2 3 function system(){ 4 echo "#########################系统信息#########################" 5 OS_TYPE=`uname` 6 OS_VER=`cat /etc/red

Kubernetes 在生产环境中常用架构

Kubernetes 在生产环境中常用架构 首先,我们来梳理下Kubernetes生产架构,其设计适用于绝大多数环境.如下图所示 在该架构中,我们可以将其分为四层,如下: Client层:即Kubernetes集群外部用户.客户端等: 服务访问层:即由Traefik ingress实现服务发现.负载均衡和路由规则定义等: 业务应用层:即基于Kubernetes平台构建和运行企业业务应用,如CI/CD持续集成.微服务项目.监控告警和日志管理.私有镜像仓库等服务: 基础设施层:即由Kubernete

13.生产环境中的 redis 是怎么部署的?

作者:中华石杉 面试题 生产环境中的 redis 是怎么部署的? 面试官心理分析 看看你了解不了解你们公司的 redis 生产集群的部署架构,如果你不了解,那么确实你就很失职了,你的 redis 是主从架构?集群架构?用了哪种集群方案?有没有做高可用保证?有没有开启持久化机制确保可以进行数据恢复?线上 redis 给几个 G 的内存?设置了哪些参数?压测后你们 redis 集群承载多少 QPS? 兄弟,这些你必须是门儿清的,否则你确实是没好好思考过. 面试题剖析 redis cluster,10

生产环境中的PHP WEB 简单架构

使用三台虚拟机器, Ubuntu1(nginx) 192.168.226.128 Ubuntu2(php-fpm+memcached)192.168.226.132 CentOS(MySQL)192.169.226.130 PHP 框架使用CakePHP,这个是很常用的MVC 框架,基于事件的分发模型 当然需要注意的是框架代码要部署在php-fpm机器上,需要在nginx 中配置的配置如下 余下的内容: 1. CakePHP 框架代码 2. PHP 内核 3. Nginx内核 4. 数据库设计模

[virtualenv]生产环境中使用virtualenv

virtualenv 对于python开发和部署都是好工具,可以隔离多个python版本和第三方库的版本,这里作者总结了几个常用python服务怎么样结合virtual部署 原文链接 Python 中我最喜欢的东西之一就是可以使用 virtualenv 去创建隔离的环境.非常简单的就可以在不同的项目中部署不同的python类库. 有一个比较棘手的问题就是在生产环境中使用virtualenv 部署几个不同的服务有一些配置上的不同. 于是我就从我的项目中收集了几种不同的服务的不同配置方式. 可以肯定

生产环境中CentOS7部署NET Core应用程序

NET Core应用程序部署至生产环境中(CentOS7) 阅读目录 环境说明 准备你的ASP.NET Core应用程序 安装CentOS7 安装.NET Core SDK for CentOS7. 部署ASP.NET Core应用程序 配置Nginx 配置守护服务(Supervisor) 这段时间在使用Rabbit RPC重构公司的一套系统(微信相关),而最近相关检验(逻辑测试.压力测试)已经完成,接近部署至线上生产环境从而捣鼓了ASP.NET Core应用程序在CentOS上的部署方案,今天