<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[运维进行时]]></title> 
<link>https://blog.liuts.com/index.php</link> 
<description><![CDATA[互联网运维与架构]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[运维进行时]]></copyright>
<item>
<link>https://blog.liuts.com/post/164/</link>
<title><![CDATA[非常不错的Mysql建模工具MySQL Workbench]]></title> 
<author>root &lt;admin@yourname.com&gt;</author>
<category><![CDATA[MYSQL]]></category>
<pubDate>Thu, 03 Sep 2009 16:03:58 +0000</pubDate> 
<guid>https://blog.liuts.com/post/164/</guid> 
<description>
<![CDATA[ 
	<strong>MySQL Workbench的主要功能包括：</strong><br/>基于Cairo 的图形渲染，可以将内容输出到OpenGL、Win32、X11、Quartz、PostScript、PDF等多种目标上<br/>可视化的表、视图、存储进程/函数和外键<br/>实现数据库到SQL脚本的逆向工程<br/>数据库/模型的同步<br/>导出SQL创建的脚本<br/>导入DBDesigner4的模型<br/>支持MySQL5的特性<br/>可选的图示记号<br/><a href="https://blog.liuts.com/attachment.php?fid=14" target="_blank"><img src="https://blog.liuts.com/attachment.php?fid=14" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a><br/>Tags - <a href="https://blog.liuts.com/tags/%25E5%25BB%25BA%25E6%25A8%25A1%25E5%25B7%25A5%25E5%2585%25B7/" rel="tag">建模工具</a>
]]>
</description>
</item><item>
<link>https://blog.liuts.com/post/160/</link>
<title><![CDATA[Mysql实现实时备份]]></title> 
<author>root &lt;admin@yourname.com&gt;</author>
<category><![CDATA[MYSQL]]></category>
<pubDate>Sun, 14 Jun 2009 15:56:49 +0000</pubDate> 
<guid>https://blog.liuts.com/post/160/</guid> 
<description>
<![CDATA[ 
	　　目前成熟的实时备份为双机(master/slave)，是基于同步日志事件来实现，那单机如何实现具有增量的备份呢？可以借用双机的原理，非常简单，实施步骤如下：<br/>Mysql版本：mysql4.0+<br/><br/><strong>1、vi my.cfg</strong><br/>[mysqld]<br/>log-update=/home/backup/update #添加该行<br/><br/><strong>2、service mysql restart</strong><br/>会在/home/backup/update00001文件，内容为数据库变化的所有SQL(没有select)<br/><br/><strong>3、每天的全备,mysql4.0+最简单就是备份data目录。</strong><br/>service mysql stop<br/>tar -czf data(日期).tar.gz mysql/data<br/>service mysql start<br/>当mysql启动时系统会自动在/home/backup/创建update0000*的文件，那我们可以用该文件作为当天全备的增量实时备份。<br/><br/><strong>4、数据还原</strong><br/>service mysql stop<br/>tar -zxvf data(日期).tar.gz mysql/<br/>service mysql start<br/>mysqladmin -u -p /home/backup/update0000*<br/><br/>如想还原昨天、前天的数据只需要找相应的update0000*来还原即可：）<br/>Tags - <a href="https://blog.liuts.com/tags/%25E5%25AE%259E%25E6%2597%25B6%25E5%25A4%2587%25E4%25BB%25BD/" rel="tag">实时备份</a>
]]>
</description>
</item><item>
<link>https://blog.liuts.com/post/140/</link>
<title><![CDATA[解决：Mysql exceeds the lock table size]]></title> 
<author>root &lt;admin@yourname.com&gt;</author>
<category><![CDATA[MYSQL]]></category>
<pubDate>Thu, 22 May 2008 14:10:56 +0000</pubDate> 
<guid>https://blog.liuts.com/post/140/</guid> 
<description>
<![CDATA[ 
	<strong>故障现象</strong><br/><textarea name="code" class="sql" rows="15" cols="100">
mysql> delete FROM `tablesname` WHERE datetime<'2009-03-06';
ERROR 1206 (HY000): The total number of locks exceeds the lock table size
</textarea><br/><strong>解决步骤</strong><br/>1、锁表写操作<br/><textarea name="code" class="sql" rows="15" cols="100">
mysql> lock tables tablesname write;
mysql> delete FROM `tablesname` WHERE datetime<'2009-03-06';
ERROR 1206 (HY000): The total number of locks exceeds the lock table size
</textarea><br/>没有解决。<br/>2、 innodb修改改innodb_buffer_pool_size值(一般配置为总内存的30%-40% ) myisam修改key_buffer(若是myisam应该没这个问题,因为myisam不是行级锁)<br/>重启Mysql，解决。 <br/>Tags - <a href="https://blog.liuts.com/tags/lock/" rel="tag">lock</a> , <a href="https://blog.liuts.com/tags/table/" rel="tag">table</a>
]]>
</description>
</item><item>
<link>https://blog.liuts.com/post/117/</link>
<title><![CDATA[Mysql写双机解决自增长问题]]></title> 
<author>root &lt;admin@yourname.com&gt;</author>
<category><![CDATA[MYSQL]]></category>
<pubDate>Thu, 22 May 2008 13:14:29 +0000</pubDate> 
<guid>https://blog.liuts.com/post/117/</guid> 
<description>
<![CDATA[ 
	通过修改两台Mysql服务器的自增长步长解决。<br/>其中一个步长为1<br/>另一台步长为2，初值设置成一样，这样就不会冲突了。<br/>详细说明：<a href="http://dev.mysql.com/tech-resources/articles/advanced-mysql-replication.html" target="_blank">http://dev.mysql.com/tech-resources/articles/advanced-mysql-replication.html</a><br/>Tags - <a href="https://blog.liuts.com/tags/%25E8%2587%25AA%25E5%25A2%259E%25E9%2595%25BF/" rel="tag">自增长</a>
]]>
</description>
</item><item>
<link>https://blog.liuts.com/post/116/</link>
<title><![CDATA[Mysql字段长度自动变短了:(]]></title> 
<author>root &lt;admin@yourname.com&gt;</author>
<category><![CDATA[MYSQL]]></category>
<pubDate>Thu, 22 May 2008 13:11:45 +0000</pubDate> 
<guid>https://blog.liuts.com/post/116/</guid> 
<description>
<![CDATA[ 
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;原服务器Mysql用的编码是latin1，结果更新了服务器，数据需要备份过来，新服务器数据库安装的时候选择了gbk编码，结果发现char、varchar类型的字段长度都有不同程度的变短。更换编码试试，先换成utf-8，结果还是一样。最后想想还是用原服务器数据库的编码，在my.cnf修改的[client]及[mysqld]处添加default-character-set=latin1，重启Mysql，数据恢复正常<br/>Tags - <a href="https://blog.liuts.com/tags/%25E5%258F%2598%25E7%259F%25AD/" rel="tag">变短</a>
]]>
</description>
</item><item>
<link>https://blog.liuts.com/post/98/</link>
<title><![CDATA[给Mysql表添加外键]]></title> 
<author>root &lt;admin@yourname.com&gt;</author>
<category><![CDATA[MYSQL]]></category>
<pubDate>Thu, 22 May 2008 08:32:03 +0000</pubDate> 
<guid>https://blog.liuts.com/post/98/</guid> 
<description>
<![CDATA[ 
	<strong>创建语法</strong><br/><textarea name="code" class="sql" rows="15" cols="100">
CREATE TABLE person (
id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
name CHAR(60) NOT NULL,
PRIMARY KEY (id)
)type=innoDB;

CREATE TABLE shirt (
id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
style ENUM('t-shirt', 'polo', 'dress') NOT NULL,
color ENUM('red', 'blue', 'orange', 'white', 'black') NOT NULL,
owner SMALLINT UNSIGNED NOT NULL,
FOREIGN KEY (owner) REFERENCES PERSON(id)
ON DELETE CASCADE
ON UPDATE CASCADE,
PRIMARY KEY (id)
)type=innoDB; 
</textarea><br/><strong>语法说明</strong><br/>RESTRICT : 只要本表格里面有指向主表的数据， 在主表里面就无法删除相关记录。一般来说，就选restrict最安全，当然也根据具体的业务而言了.cascade很cool,但是数据哗的一下就没了.<br/>CASCADE : 如果在foreign key 所指向的那个表里面删除一条记录，那么在此表里面的跟那个key一样的所有记录都会一同删掉。(常用)<br/><strong>问题原因</strong><br/>今天在Mysql中创建表时,提示错误:ERROR 1005: Can't create table (errno: 150) 在网上搜索,发现产生该错误有三种可能:<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>&nbsp;&nbsp; 1. 外键和被引用外键类型不一样，比如integer和double<br/>&nbsp;&nbsp; 2. 找不到要被引用的列<br/>&nbsp;&nbsp; 3. 表的字符编码不一样 <br/></div></div>
]]>
</description>
</item><item>
<link>https://blog.liuts.com/post/88/</link>
<title><![CDATA[解决：连接mysql服务器速度极慢]]></title> 
<author>root &lt;admin@yourname.com&gt;</author>
<category><![CDATA[MYSQL]]></category>
<pubDate>Sat, 22 Sep 2007 07:22:40 +0000</pubDate> 
<guid>https://blog.liuts.com/post/88/</guid> 
<description>
<![CDATA[ 
	PHP远程连接MYSQL速度慢,有时远程连接到MYSQL用时4-20秒不等,本地连接MYSQL正常,出现这种问题的主要原因是,默认安装的 MYSQL开启了DNS的反向解析,在MY.INI(WINDOWS系统下)或MY.CNF(UNIX或LINUX系统下)文件的[mysqld]下加入 skip-name-resolve这一句。<br/>在局域网内连接其他机器的MYSQL,发现速度慢的很,不知道什么原因,总有几秒的延迟.<br/>后来在网上发现解决方法,my.cnf里面添加<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>[mysqld]<br/>skip-name-resolve<br/>skip-grant-tables<br/></div></div><br/>这样速度就快了!<br/>skip-name-resolve<br/>选项就能禁用DNS解析，连接速度会快很多。不过，这样的话就不能在MySQL的授权表中使用主机名了而只能用ip格式。<br/>若使用–skip-grant-tables系统将对任何用户的访问不做任何访问控制，但可以用 mysqladmin flush-privileges或mysqladmin reload来开启访问控制;默认情况是show databases语句对所有用户开放，如果mysql服务器没有开远程帐户，就在my.ini里面加上skip-grant-tables<br/>Tags - <a href="https://blog.liuts.com/tags/mysql/" rel="tag">mysql</a> , <a href="https://blog.liuts.com/tags/%25E9%2580%259F%25E5%25BA%25A6%25E6%2585%25A2/" rel="tag">速度慢</a>
]]>
</description>
</item><item>
<link>https://blog.liuts.com/post/87/</link>
<title><![CDATA[mysqlhotcopy热备Mysql数据库]]></title> 
<author>root &lt;admin@yourname.com&gt;</author>
<category><![CDATA[MYSQL]]></category>
<pubDate>Sat, 22 Sep 2007 07:18:04 +0000</pubDate> 
<guid>https://blog.liuts.com/post/87/</guid> 
<description>
<![CDATA[ 
	一、配制两台服务器(主=>从)无密码SSH访问;<br/>二、添加热备用户权限： <br/><textarea name="code" class="sql" rows="15" cols="100">
grant select,reload,LOCK TABLES on *.* to backup@localhost identified by 'pass'
</textarea><br/>三、备份SHELL<br/><textarea name="code" class="shell" rows="15" cols="100">
#!/bin/bash
BACKUP_SERVER="192.168.100.2"
BACKUP_USER="mysql"

MYSQL_USER="backup"
MYSQL_USER_PASS="pass"
　　
MYSQLHOTCOPY=/usr/local/mysql/bin/mysqlhotcopy

# Change to MySQL data directory
cd /usr/local/mysql/data
　　
# Create an array with all directories in the MySQL data directory
# The directory name presents the database name in MySQL.
ARRAY=`find * -type d -prune`

for DATABASE in `echo $ARRAY`
do
&nbsp;&nbsp;&nbsp;&nbsp;# Create backup from database
&nbsp;&nbsp;&nbsp;&nbsp;$MYSQLHOTCOPY --method='scp -Bq -i /home/foo/.ssh/identity'&nbsp;&nbsp;--user=`echo $MYSQL_USER` --password=`echo $MYSQL_USER_PASS` &#92;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$DATABASE `echo $BACKUP_USER`@`echo $BACKUP_SERVER`:/usr/local/mysql/data/$DATABASE
done
</textarea><br/>Tags - <a href="https://blog.liuts.com/tags/mysql/" rel="tag">mysql</a> , <a href="https://blog.liuts.com/tags/%25E7%2583%25AD%25E5%25A4%2587/" rel="tag">热备</a>
]]>
</description>
</item><item>
<link>https://blog.liuts.com/post/74/</link>
<title><![CDATA[Mysql忘记密码后的解决办法(NT/Linux)]]></title> 
<author>root &lt;admin@yourname.com&gt;</author>
<category><![CDATA[MYSQL]]></category>
<pubDate>Sat, 22 Sep 2007 03:31:30 +0000</pubDate> 
<guid>https://blog.liuts.com/post/74/</guid> 
<description>
<![CDATA[ 
	[windows]<br/>1、停止mysql服务：打开命令行窗口CMD，Net stop mysql<br/>2、用另外一种方式启动Mysql：在命令行进入到mysql的安装路径下的bin目录下使用mysqld-nt.exe启动：mysqld-nt --skip-grant-tables<br/>&nbsp;&nbsp; 注意：此时CMD窗口不能关闭。<br/>3、进入Mysql：另外打开一个命入令行窗口，在bin目录下执行mysql，此时无需输入密码即可进入。<br/><textarea name="code" class="sql" rows="15" cols="100">
>use mysql
>update user set password=password("new_pass") where user="root";
>flush privileges;
>exit
</textarea><br/>&nbsp;&nbsp; 注意：1）如果对sql语句熟悉的话，update这句就不用解释了第一个User是表名、第二个User是表中的字段。第一个Password是表中的字段，第二个Password()是加密用的函数。new_pass是要更改的密码。<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2）flush privileges可以不用添加。但是如果添加了，一定要注意Host字段不能是Localhost。因为用了这个之后就不能用Localhost连接了。你可以把这个字段改成IP，或者通配符。<br/>>update user set host="192.168.0.1" where user="root"<br/>4、使用任务管理器，找到mysqld-nt的进程，结束进程！<br/>5、重新启动mysql服务，net start mysql 就可以用新密码登录了。<br/><br/>[linux]<br/>1、关闭Mysql： 如果 MySQL 正在运行，首先杀之 killall -TERM mysqld<br/>2、另外的方法启动 MySQL ：bin/safe_mysqld --skip-grant-tables &<br/>3、可以不需要密码就进入 MySQL 了。<br/>然后就是<br/><textarea name="code" class="sql" rows="15" cols="100">
>use mysql
>update user set password=password("new_pass") where user="root";
>flush privileges;
</textarea><br/>&nbsp;&nbsp; 注意点同上<br/>4、重新杀 MySQL ，用正常方法启动 MySQL 。 <br/>Tags - <a href="https://blog.liuts.com/tags/mysql/" rel="tag">mysql</a> , <a href="https://blog.liuts.com/tags/%25E5%25BF%2598%25E8%25AE%25B0%25E5%25AF%2586%25E7%25A0%2581/" rel="tag">忘记密码</a>
]]>
</description>
</item><item>
<link>https://blog.liuts.com/post/24/</link>
<title><![CDATA[linux高负载下mysql数据库彻底优化]]></title> 
<author> &lt;&gt;</author>
<category><![CDATA[MYSQL]]></category>
<pubDate>Tue, 14 Aug 2007 16:23:50 +0000</pubDate> 
<guid>https://blog.liuts.com/post/24/</guid> 
<description>
<![CDATA[ 
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;同时在线访问量继续增大 对于1G内存的服务器明显感觉到吃力严重时甚至每天都会死机 或者时不时的服务器卡一下 这个问题曾经困扰了我半个多月MySQL使用是很具伸缩性的算法，因此你通常能用很少的内存运行或给MySQL更多的被存以得到更好的性能。安装好mysql后，配制文件应该在/usr/local/mysql/share/mysql目录中，配制文件有几个，有my-huge.cnf my-medium.cnf my-large.cnf my-small.cnf,不同的流量的网站和不同配制的服务器环境，当然需要有不同的配制文件了。<br/>一般的情况下，my-medium.cnf这个配制文件就能满足我们的大多需要；一般我们会把配置文件拷贝到/etc/my.cnf 只需要修改这个配置文件就可以了，使用mysqladmin variables extended-status –u root –p 可以看到目前的参数，有３个配置参数是最重要的，即key_buffer_size,query_cache_size,table_cache。<br/><strong>一、key_buffer_size</strong><br/>key_buffer_size只对MyISAM表起作用，<br/>key_buffer_size指定索引缓冲区的大小，它决定索引处理的速度，尤其是索引读的速度。一般我们设为16M,实际上稍微大一点的站点　这个数字是远远不够的，通过检查状态值Key_read_requests和Key_reads,可以知道key_buffer_size设置是否合理。比例key_reads / key_read_requests应该尽可能的低，至少是1:100，1:1000更好（上述状态值可以使用SHOW STATUS LIKE ‘key_read%’获得）。 或者如果你装了phpmyadmin 可以通过服务器运行状态看到,笔者推荐用phpmyadmin管理mysql，以下的状态值都是本人通过phpmyadmin获得的实例分析: <br/>这个服务器已经运行了20天 <br/>key_buffer_size – 128M <br/>key_read_requests – 650759289 <br/>key_reads - 79112 <br/>比例接近1:8000 健康状况非常好 <br/>另外一个估计key_buffer_size的办法　把你网站数据库的每个表的索引所占空间大小加起来看看以此服务器为例:比较大的几个表索引加起来大概125M 这个数字会随着表变大而变大。<br/><strong>二、query_cache_size</strong><br/>从4.0.1开始，MySQL提供了查询缓冲机制。使用查询缓冲，MySQL将SELECT语句和查询结果存放在缓冲区中，今后对于同样的SELECT语句（区分大小写），将直接从缓冲区中读取结果。根据MySQL用户手册，使用查询缓冲最多可以达到238%的效率。<br/>通过调节以下几个参数可以知道query_cache_size设置得是否合理 <br/>Qcache inserts <br/>Qcache hits <br/>Qcache lowmem prunes <br/>Qcache free blocks <br/>Qcache total blocks <br/>Qcache_lowmem_prunes的值非常大，则表明经常出现缓冲不够的情况,同时Qcache_hits的值非常大，则表明查询缓冲使用非常频繁，此时需要增加缓冲大小Qcache_hits的值不大，则表明你的查询重复率很低，这种情况下使用查询缓冲反而会影响效率，那么可以考虑不用查询缓冲。此外，在SELECT语句中加入SQL_NO_CACHE可以明确表示不使用查询缓冲。<br/>Qcache_free_blocks，如果该值非常大，则表明缓冲区中碎片很多query_cache_type指定是否使用查询缓冲<br/>我设置: <br/>query_cache_size = 32M <br/>query_cache_type= 1 <br/>得到如下状态值: <br/>Qcache queries in cache 12737 表明目前缓存的条数 <br/>Qcache inserts 20649006 <br/>Qcache hits 79060095 　看来重复查询率还挺高的 <br/>Qcache lowmem prunes 617913　有这么多次出现缓存过低的情况 <br/>Qcache not cached 189896 　　 <br/>Qcache free memory 18573912　　目前剩余缓存空间 <br/>Qcache free blocks 5328 这个数字似乎有点大　碎片不少 <br/>Qcache total blocks 30953 <br/>如果内存允许32M应该要往上加点<br/><strong>三、table_cache</strong><br/>table_cache指定表高速缓存的大小。每当MySQL访问一个表时，如果在表缓冲区中还有空间，该表就被打开并放入其中，这样可以更快地访问表内容。通过检查峰值时间的状态值Open_tables和Opened_tables，可以决定是否需要增加table_cache的值。如果你发现open_tables等于table_cache，并且opened_tables在不断增长，那么你就需要增加table_cache的值了（上述状态值可以使用SHOW STATUS LIKE ‘Open%tables’获得）。注意，不能盲目地把table_cache设置成很大的值。如果设置得太高，可能会造成文件描述符不足，从而造成性能不稳定或者连接失败。<br/>对于有1G内存的机器，推荐值是128－256。 <br/>笔者设置table_cache = 256 <br/>得到以下状态: <br/>Open tables 256 <br/>Opened tables 9046 <br/>虽然open_tables已经等于table_cache，但是相对于服务器运行时间来说,已经运行了20天，opened_tables的值也非常低。因此，增加table_cache的值应该用处不大。如果运行了6个小时就出现上述值 那就要考虑增大table_cache。<br/><strong>四、Log-bin</strong><br/>如果你不需要记录2进制log 就把这个功能关掉，注意关掉以后就不能恢复出问题前的数据了，需要您手动备份，二进制日志包含所有更新数据的语句，其目的是在恢复数据库时用它来把数据尽可能恢复到最后的状态。另外，如果做同步复制( Replication )的话，也需要使用二进制日志传送修改情况。<br/>log_bin指定日志文件，如果不提供文件名，MySQL将自己产生缺省文件名。MySQL会在文件名后面自动添加数字引，每次启动服务时，都会重新生成一个新的二进制文件。此外，使用log-bin-index可以指定索引文件；使用binlog-do-db可以指定记录的数据库；使用binlog-ignore-db可以指定不记录的数据库。注意的是：binlog-do-db和binlog-ignore-db一次只指定一个数据库，指定多个数据库需要多个语句。而且，MySQL会将所有的数据库名称改成小写，在指定数据库时必须全部使用小写名字，否则不会起作用。 <br/>关掉这个功能只需要在他前面加上#号 <br/>#log-bin<br/><strong>五、开启慢查询日志</strong><br/>开启慢查询日志( slow query log ) <br/>慢查询日志对于跟踪有问题的查询非常有用。它记录所有查过long_query_time的查询，如果需要，还可以记录不使用索引的记录。下面是一个慢查询日志的例子：<br/>开启慢查询日志，需要设置参数log_slow_queries、long_query_times、log-queries-not-using-indexes。<br/>log_slow_queries指定日志文件，如果不提供文件名，MySQL将自己产生缺省文件名。long_query_times指定慢查询的阈值，缺省是10秒。log-queries-not-using-indexes是4.1.0以后引入的参数，它指示记录不使用索引的查询。笔者设置long_query_time=10 <br/><strong>六、其他一些重要参数</strong><br/>笔者设置: <br/>sort_buffer_size = 1M <br/>max_connections=120 <br/>wait_timeout =120 <br/>back_log=100 <br/>read_buffer_size = 1M <br/>thread_cache=32 <br/>interactive_timeout=120 <br/>thread_concurrency = 4 <br/>参数说明: <br/>back_log <br/>要求MySQL能有的连接数量。当主要MySQL线程在一个很短时间内得到非常多的连接请求，这就起作用，然后主线程花些时间(尽管很短)检查连接并且启动一个新线程。back_log值指出在MySQL暂时停止回答新请求之前的短时间内多少个请求可以被存在堆栈中。只有如果期望在一个短时间内有很多连接，你需要增加它，换句话说，这值对到来的TCP/IP连接的侦听队列的大小。你的操作系统在这个队列大小上有它自己的限制。 Unix listen(2)系统调用的手册页应该有更多的细节。检查你的OS文档找出这个变量的最大值。试图设定back_log高于你的操作系统的限制将是无效的。<br/>max_connections <br/>并发连接数目最大，120 超过这个值就会自动恢复，出了问题能自动解决<br/>thread_cache <br/>没找到具体说明，不过设置为32后 20天才创建了400多个线程 而以前一天就创建了上千个线程 所以还是有用的 <br/>thread_concurrency<br/>#设置为你的cpu数目x2,例如，只有一个cpu,那么thread_concurrency=2 <br/>#有2个cpu,那么thread_concurrency=4 <br/>skip-innodb <br/>#去掉innodb支持<br/><strong>七、附my.cnf全部文件</strong><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">[client] <br/>#password = your_password <br/>port = 3306 <br/>socket = /tmp/mysql.sock <br/>#socket = /var/lib/mysql/mysql.sock <br/># Here follows entries for some specific programs <br/># The MySQL server <br/>[mysqld] <br/>port = 3306 <br/>socket = /tmp/mysql.sock <br/>#socket = /var/lib/mysql/mysql.sock <br/>skip-locking <br/>key_buffer = 128M <br/>max_allowed_packet = 1M <br/>table_cache = 256 <br/>sort_buffer_size = 1M <br/>net_buffer_length = 16K <br/>myisam_sort_buffer_size = 1M <br/>max_connections=120 <br/>#addnew config <br/>wait_timeout =120 <br/>back_log=100 <br/>read_buffer_size = 1M <br/>thread_cache=32 <br/>skip-innodb <br/>skip-bdb <br/>skip-name-resolve <br/>join_buffer_size=512k <br/>query_cache_size = 32M <br/>interactive_timeout=120 <br/>long_query_time=10 <br/>log_slow_queries= /usr/local/mysql4/logs/slow_query.log <br/>query_cache_type= 1 <br/># Try number of CPU's*2 for thread_concurrency <br/>thread_concurrency = 4 <br/># binary logging is required for replication <br/>#log-bin <br/>server-id = 1 <br/>[mysqldump] <br/>quick <br/>max_allowed_packet = 16M <br/>[mysql] <br/>no-auto-rehash <br/># Remove the next comment character if you are not familiar with SQL <br/>#safe-updates <br/>[isamchk] <br/>key_buffer = 20M <br/>sort_buffer_size = 20M <br/>read_buffer = 2M <br/>write_buffer = 2M <br/>[myisamchk] <br/>key_buffer = 20M <br/>sort_buffer_size = 20M <br/>read_buffer = 2M <br/>write_buffer = 2M <br/>[mysqlhotcopy] <br/>interactive-timeout</div></div><br/>Tags - <a href="https://blog.liuts.com/tags/mysql/" rel="tag">mysql</a> , <a href="https://blog.liuts.com/tags/%25E4%25BC%2598%25E5%258C%2596/" rel="tag">优化</a>
]]>
</description>
</item>
</channel>
</rss>