Home Database Mysql Tutorial 自制mysql主从复制(实时)软件配置_MySQL

自制mysql主从复制(实时)软件配置_MySQL

Jun 01, 2016 pm 01:10 PM

mysql 5.5——my.ini—— innodb数据库引擎配置


我的机器配置也不是什么高端配置,就一般的笔记本电脑配置2G内存

PS:添出这个myini文件的原因有以下几点

    1. 作为我日后进一步学习的笔记

    2. 作为和大家交流的中介,希望有更多的朋友指出我的不足 

    3. 也是督促我学习的一个模式       

# MySQL Server Instance Configuration File

# ----------------------------------------------------------------------

[client]

port=3306
Copy after login
Copy after login

[mysql]

default-character-set=utf8
Copy after login

[mysqld]

port=3306
Copy after login
Copy after login

#错误日志

log-error=D:/MySQL/MySQL Server 5.5/logerror/mysql-error
Copy after login

#二进制更新日志

log-bin=D:/MySQL/MySQL Server 5.5/logbin/mysql-bin
Copy after login

#mysql 的安装路径

basedir="D:/MySQL/MySQL Server 5.5/"
Copy after login

#数据库存储位置

datadir="E:/MySQL/MySQL Server 5.5/DB/"
Copy after login


#*** INNODB Specific options ***

innodb_data_home_dir="D:/MySQL Datafiles/data5.5/"character-set-server=utf8default-storage-engine=INNODB
Copy after login

# Set the SQL mode to strict

#用来约束你的数据库中数据处理的模式

sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
Copy after login

# mysql并发会话数量,实际上一般的用户得到并发会话最大数量是max_connections-1,因为任何时候都需要给super用户留一个

max_connections=1024
Copy after login

#查询缓存 如果你的项目就几张表,那么打开这个参数,并设定一个比较大的值(如果你的内存允许的话),那你的查询性能将是一个质的提高;

#如果你的项目中有很多的表,而且查询经常是在不同的表之间,那么这个参数就越小越好,甚至可以关闭该参数,因为表的查询切换太频繁,

#过度的缓存将适得其反

query_cache_size=0Mquery_cache_limit = 1Mquery_cache_type=off
Copy after login

#所有线程打开表的总和,主要是查询打开,因为对于一般的使用而言数据的查询较多

table_cache=1520
Copy after login

#零时表的大小,这个参数说的是一张表的大小。如果一个表的实际大小(200M)大于该值,那该值自动变为表的实际大小(200M)

tmp_table_size=100M
Copy after login

#线程可以缓存的数量,从而重复使用

# 但是这个值的改动不会有太大的性能的提高,或者说改善的不明显

thread_cache_size=60
Copy after login

#*** MyISAM Specific options

#这些个参数是MyISAM 引擎参数设置,我不是很确定每个参数的实际改动效果

myisam_max_sort_file_size=100Gmyisam_sort_buffer_size=199Mkey_buffer_size=16Mread_buffer_size=8Mread_rnd_buffer_size=16Msort_buffer_size=32M
Copy after login

#*** INNODB Specific options ***

#每张表建立一个数据文件,这个参数可以直接写innodb_file_per_table 或者写innodb_file_per_table = on ,

#也就是意味着你的数据表的存放格式是frm+ibd,这些文件都放在你的数据存储位置,当然系统的一些配置数据还

#都放在ibdata1文件中,但是如果你不配置该参数,那么你的数据存储位置只有frm文件,而实际的数据是都放在

#ibdata1文件中,这样做到好处是你可以看到每个表的实际大小和应用情况,方便管理,而且如果你的数据崩溃的话,

#你可以用保留的日志文件替换,并且直接删除不需要的表或者出现了问题的表。

innodb_file_per_table
Copy after login

#InnoDB用来存储数据目录信息&其它内部数据结构的内存池的大小。你应用程序里的表越多,你需要在这里分

#配越多的内存。如果InnoDB用光了这个池内的内存,InnoDB开始从操作系统分配内存,并且往MySQL错误日

#志写警告信息。 默认值是1MB。

innodb_additional_mem_pool_size = 12M
Copy after login

# 当innodb_flush_log_at_trx_commit被 设置为0,日志缓冲每秒一次地被写到日志文件,并且对日志文件做到

# 磁盘操作的刷新,但是在一个事务提交不做任何操作。当这个值为1(默认值)之时,在每个事务提交时,日

# 志缓冲被写到日志文件,对日志文件做到磁盘操作的 刷新。当设置为2之时,在每个提交,日志缓冲被写到文

# 件,但不对日志文件做到磁盘操作的刷新。尽管如此,在对日志文件的刷新在值为2的情况也每秒发生一次。

# 我们必须注意到,因为进程安排问题,每秒一次的 刷新不是100%保证每秒都发生。你可以通过设置这个值不

# 为1来获得较好的性能,但随之你会在一次崩溃中损失二分之一价值的事务。如果你设置这个值为0,那么任

# 何mysqld进程的崩溃会删除崩溃前最后一秒的事务,如果你设置这个值为2,那么只有操作系统崩溃或掉电才

# 会删除最后一秒的事务。尽管如此,InnoDB的崩溃恢复不受影响,而且因为这样崩溃恢复开始作用而不考虑这

# 个值。注意,许多操作系统和一些磁盘硬件会欺骗 刷新到磁盘操作。尽管刷新没有进行,你可以告

# 诉mysqld刷新已经进行。即使设置这个值为1,事务的持久程度不被保证,且在最坏情况下掉电甚至会破

# 坏InnoDB数据库。在SCSI磁盘控制器中,或在磁盘自身中,使用有后备电池的磁盘缓存会加速文件 刷新并且

# 使得操作更安全。你也可以试着使用Unix命令hdparm来在硬件缓存中禁止磁盘写缓存,或使用其它一些对硬

# 件提供商专用的命令。这个选项的 默认值是1。

innodb_flush_log_at_trx_commit=1
Copy after login

# InnoDB用来往磁盘上的日志文件写操作的缓冲区的大小。明智的值是从1MB到8MB。 默认的是1MB。一个大

# 的日志缓冲允许大型事务运行而不需要在事务提交之前往磁盘写日志。因此,如果你有大型事务,使日志缓冲

# 区更大以节约磁盘I/O。

innodb_log_buffer_size=5M
Copy after login

# InnoDB用来缓存它的数据和索引的内存缓冲区的大小。你把这个值设得越高,访问表中数据需要得磁盘I/O越

# 少。在一个专用的数据库服务器上,你可以设置这个参数达机器物理内存大小的80%。尽管如此,还是不要把

# 它设置得太大,因为对物理内存的竞争可能在操作系统上导致内存调度,其性能反而下降。

###innodb_buffer_pool_size=800M

innodb_buffer_pool_size=474M
Copy after login

# 在日志组里每个日志文件的大小。在32位计算机上日志文件的合并大小必须少于4GB。 默认是5MB。明智的值

# 从1MB到N分之一缓冲池大小,其中N是组里日志文件的数目。值越大,在缓冲池越少需要检查点刷新行为,以

# 节约磁盘I/O。但更大的日志文件也意味这在崩溃时恢复得更慢。

innodb_log_file_size=95M
Copy after login

# InnoDB试着在InnoDB内保持操作系统线程的数量少于或等于这个参数给出的限制。如果有性能问题,并

# 且SHOW INNODB STATUS显示许多线程在等待信号,可以让线程“thrashing” ,并且设置这个参数更小或更

# 大。如果你的计算机有多个处理器和磁盘,你可以试着这个值更大以更好地利用计算机的资源。一个推荐的值

# 是系统上处理器和磁盘的个数之和。值为500或比500大会禁止调用并发检查。默认值是20,并且如果设置大

# 于或等于20,并发检查将被禁止。

#(这段话是我在mysql5.5手册中复制过来的,这个8是我自己电脑的设置,而服务器的参数是30)

innodb_thread_concurrency=8
Copy after login

# 在InnoDB中,这个选项仅与你使用多表空间innodb_file_per_table 时有关。它指定InnoDB一次可以保持打开的.ibd文件的最大数目。

# 最小值是10。 默认值300

innodb_open_files=250
Copy after login

#Number of file I/O threads in InnoDB. Normally, this should be 4, but on Windows disk I/O may benefit from a larger number.

innodb_read_io_threads= 8innodb_write_io_threads =8
Copy after login

#设置自动提交为false 当然这个自动提交也可以在自己的外部程序中控制

autocommit = false
Copy after login

#该参数反应的是一次事务提交可以提交的最大包的大小

#max_allowed_packet  = 5Mmax_allowed_packet  = 25M
Copy after login

#由于操作失败导致数据库崩溃

#(这个参数是当数据库crash后为了能启动你的数据库设置的参数,默认值是0)

#1(SRV_FORCE_IGNORE_CORRUPT):忽略检查到的corrupt页。

#2(SRV_FORCE_NO_BACKGROUND):阻止主线程的运行,如主线程需要执行full purge操作,会导致crash。

#3(SRV_FORCE_NO_TRX_UNDO):不执行事务回滚操作。

#4(SRV_FORCE_NO_IBUF_MERGE):不执行插入缓冲的合并操作。

#5(SRV_FORCE_NO_UNDO_LOG_SCAN):不查看重做日志,InnoDB存储引擎会将未提交的事务视为已提交。

#6(SRV_FORCE_NO_LOG_REDO):不执行前滚的操作。

#innodb_force_recovery = 5
Copy after login

ps:这里的my.ini仅仅针对我们自己的项目和实际应用而设定的,除了最初的mysql安装时候给出的通用my.ini很多时候都需要我们自己设定里边的参数,从而提高mysql的性能。


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

When might a full table scan be faster than using an index in MySQL? When might a full table scan be faster than using an index in MySQL? Apr 09, 2025 am 12:05 AM

Full table scanning may be faster in MySQL than using indexes. Specific cases include: 1) the data volume is small; 2) when the query returns a large amount of data; 3) when the index column is not highly selective; 4) when the complex query. By analyzing query plans, optimizing indexes, avoiding over-index and regularly maintaining tables, you can make the best choices in practical applications.

Can I install mysql on Windows 7 Can I install mysql on Windows 7 Apr 08, 2025 pm 03:21 PM

Yes, MySQL can be installed on Windows 7, and although Microsoft has stopped supporting Windows 7, MySQL is still compatible with it. However, the following points should be noted during the installation process: Download the MySQL installer for Windows. Select the appropriate version of MySQL (community or enterprise). Select the appropriate installation directory and character set during the installation process. Set the root user password and keep it properly. Connect to the database for testing. Note the compatibility and security issues on Windows 7, and it is recommended to upgrade to a supported operating system.

Explain InnoDB Full-Text Search capabilities. Explain InnoDB Full-Text Search capabilities. Apr 02, 2025 pm 06:09 PM

InnoDB's full-text search capabilities are very powerful, which can significantly improve database query efficiency and ability to process large amounts of text data. 1) InnoDB implements full-text search through inverted indexing, supporting basic and advanced search queries. 2) Use MATCH and AGAINST keywords to search, support Boolean mode and phrase search. 3) Optimization methods include using word segmentation technology, periodic rebuilding of indexes and adjusting cache size to improve performance and accuracy.

Difference between clustered index and non-clustered index (secondary index) in InnoDB. Difference between clustered index and non-clustered index (secondary index) in InnoDB. Apr 02, 2025 pm 06:25 PM

The difference between clustered index and non-clustered index is: 1. Clustered index stores data rows in the index structure, which is suitable for querying by primary key and range. 2. The non-clustered index stores index key values ​​and pointers to data rows, and is suitable for non-primary key column queries.

MySQL: Simple Concepts for Easy Learning MySQL: Simple Concepts for Easy Learning Apr 10, 2025 am 09:29 AM

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

Can mysql and mariadb coexist Can mysql and mariadb coexist Apr 08, 2025 pm 02:27 PM

MySQL and MariaDB can coexist, but need to be configured with caution. The key is to allocate different port numbers and data directories to each database, and adjust parameters such as memory allocation and cache size. Connection pooling, application configuration, and version differences also need to be considered and need to be carefully tested and planned to avoid pitfalls. Running two databases simultaneously can cause performance problems in situations where resources are limited.

The relationship between mysql user and database The relationship between mysql user and database Apr 08, 2025 pm 07:15 PM

In MySQL database, the relationship between the user and the database is defined by permissions and tables. The user has a username and password to access the database. Permissions are granted through the GRANT command, while the table is created by the CREATE TABLE command. To establish a relationship between a user and a database, you need to create a database, create a user, and then grant permissions.

RDS MySQL integration with Redshift zero ETL RDS MySQL integration with Redshift zero ETL Apr 08, 2025 pm 07:06 PM

Data Integration Simplification: AmazonRDSMySQL and Redshift's zero ETL integration Efficient data integration is at the heart of a data-driven organization. Traditional ETL (extract, convert, load) processes are complex and time-consuming, especially when integrating databases (such as AmazonRDSMySQL) with data warehouses (such as Redshift). However, AWS provides zero ETL integration solutions that have completely changed this situation, providing a simplified, near-real-time solution for data migration from RDSMySQL to Redshift. This article will dive into RDSMySQL zero ETL integration with Redshift, explaining how it works and the advantages it brings to data engineers and developers.

See all articles