Chinaunix首页 | 论坛 | 博客
  • 博客访问: 19741563
  • 博文数量: 679
  • 博客积分: 10495
  • 博客等级: 上将
  • 技术积分: 9308
  • 用 户 组: 普通用户
  • 注册时间: 2006-07-18 10:51
文章分类

全部博文(679)

文章存档

2012年(5)

2011年(38)

2010年(86)

2009年(145)

2008年(170)

2007年(165)

2006年(89)

分类: Mysql/postgreSQL

2008-02-01 12:25:12

优化MYSQL server 配置

       Server调节从某种意义上是一种黑色艺术。本章仅仅介绍server配置的基本概念,涉及如下内容:

       *编译和连接

       *服务器参数

       *其他参数的调节

       对于服务器的调节,经验很重要,尽量一次只修改一个地方,之前之后都对性能进行测试,来验证修改是否切实提高了性能。

§17.1 通过编译和连接加快速度

       如果linux运行于奔腾的机器之上,使用pgcc会提大大提升性能。使用合适的编译器和选项一般都能提高性能10% to 30%,具体请参考手册。

       编译时只添加你需要的字符集也会提高性能。12章中有讲字符集。

       参考资料主要有: mysql手册,

§17.2           调节服务器参数

查看当前配置:

show variables;

查看状态

show status;

 

mytop工具类似top,还以深入MYSQL进程,查看现在正在执行的查询。

下载地址:

 

       内存的分配很重要。内部buffers and caches,比如key_buffer_size and the table_cache.  

key buffer用于存储MyISAM indexes。要考虑索引数据有多大 (that is, how big your .MYI files are in total),一般设置为系统内存的20% and 50%,在只有mysql服务的情况下。这个值只针对MyISAM tables.其他表类型有各自单独的参数。比如:innodb_buffer_pool_size12章和mysql手册中有详细的描述。

table_cache限制可同时打开的表数。MyISAM中每个表和每个索引都是单独文件。打开和关闭文件是很慢的。所以这个值越大越好。不过要注意操作系统的限制。

除了这2个全局变量外,还有per-thread basis的内存,比如:the sort buffer and the read buffer. read_buffer_size扫描整个表的时候使用。sort buffer 用于排序。

 

§17.3           调节其他参数

Solaris 是推荐系统。支持多CPU,开发和初始测试也是基于它。硬盘建议使用RAID15。用SCSI代替IDE.日志文件系统,比如:Reiserfs or XFS。其他还有网络等。

§17.4           小结

 

There is an entire book's worth of material on MySQL optimization, so be sure to continue reading and researching for yourself.

·         You may obtain a performance gain by compiling the MySQL binary yourself, especially if you are running Linux on a Pentium machine.

·         Tune server parameters for a performance boost, particularly those relating to memory usage. More physical memory is always a good thing, but allocating it is more important. These are some particularly important parameters:

o        key_buffer_size: Amount of memory used for storing MyISAM indexes.

o        table_cache: Number of tables that can be open at once.

o        read_buffer_size: Amount of memory used to store data from full table scans.

o        sort_buffer: Amount of memory used to store table data to be sorted for ORDER BY.

·                     Tune hardware with more memory, use of RAID, use of a journaling file system, and a fast network between clients and servers and masters and slaves.

阅读(2881) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2008-02-01 12:26:00

§17.5 习题 Quiz 1: The parameter that controls how much memory is used to store indexes for InnoDB is key_buffer_size innodb_buffer_pool_size innodb_key_buffer_size read_buffer_size 2: The parameter that controls how much memory is used to cache table data for InnoDB is key_buffer_size innodb_buffer_pool_size innodb_key_buffer_size read_buffer_size 3: The parameter that controls how much memory is used to cache table data for MyISAM is key_buffer_size tab