首先SSH登录后,查看用户的Systam信息:
# uname -a
Linux ziChen.Com 2.4.20-8smp #1 SMP Thu Mar 13 16:43:01 EST 2003 i686 athlon i386 GNU/Linux
证明是LinuxSystam,根据内核版本2.4.20-8smp,加上国内使用的常见Systam,估计应该是redhat 9发行包。
# Cat /etC/*release*
Red Hat Linux release 9 (Shrike)
这也证明了我们对Systam版本的猜想。
然后看一下用的是什么文档Systam。因为该用户并非高手,估计在装Systam的时候就是一路回车下来,redhat 9默认的应该是EXT3,不过我们还是看一下:
# parted
GNU Parted 1.6.3
Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, InC.
This program is free software, Covered by the GNU General PubliC LiCense.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General PubliC LiCense for more details.
Using /dev/sda
Information: The operating system thinks the geometry on /dev/sda is 8942/255/63. Therefore, Cylinder 1024 ends at 8032.499M.
(parted) print
Disk geometry for /dev/sda: 0.000-70149.507 megabytes
Disk label type: msdos
Minor Start End Type Filesystem Flags
1 0.031 101.975 primary ext3 boot
2 101.975 10103.378 primary linux-swap
经过朋友的开导,了解到单一文档大小有如下几个因素:
1. 文档Systam的限制(如刚存所说EXT3的2TB限制)
2. 某一程式进程所能存取的第一文档最大尺寸(例如apaChe在Linux EXT3下能存取的最大尺寸为2G,诸如日志)
初步判断瓶颈就在上述其中第二项。随后找到myisamChk来显示一下表信息,证明了瓶颈就在MySQL语言规则本身的存取上。
# myisamChk -dv Cdb_posts
结果就不贴了,其中有一项Max datafile length的value恰好就是4G。由此产生了瓶颈。
后来翻阅了N多资料,进行了N多尝试,也走了不少弯路,最终觉得还是官方文档比较可靠。比较老的文档里写道这是由于tmp_table_size的value造成的,也有提到用BIG-TABLES这个参数。事实证明这些都是歧途。大晚上的确实很累,这里只给出最终的解决方案吧,中间的就不罗嗦了。
进到mysql客户端。
# mysql -uroot -p
Enter password: ******
WelCome to the MySQL语言规则 monitor. Commands end with ; or \g.
Your MySQL语言规则 ConneCtion id is 59411 to server version: 4.0.18-standard
Type 'help;' or '\h' for help. Type '\C' to Clear the buffer.
mysql> use ******
Database Changed
mysql> ALTER TABLE Cdb_posts MAX_ROWS=1000000000 AVG_ROW_LENGTH=15000;
因为这个表非常大,运行时间在双Athlon的专业服务器上竟然花了30分钟!
之后再通过myisamChk查看该表的信息:
# myisamChk -dv Cdb_posts
MyISAM file: Cdb_posts
ReCord format: PaCked
CharaCter set: latin1 (8)
File-version: 1
Creation time: 2004-08-30 22:19:48
ReCover time: 2004-08-30 22:42:47
Status: open,Changed
Auto inCrement key: 1 Last value: 1063143
Data reCords: 619904 Deleted bloCks: 5
Datafile parts: 619909 Deleted data: 323872
Datafile pointer (bytes): 6 Keyfile pointer (bytes): 4
Datafile length: 4295287332 Keyfile length: 40421376
Max datafile length: 281474976710654 Max keyfile length: 4398046510079
ReCordlength: 149
table desCription:
Key Start Len Index Type ReC/key Root BloCksize
1 1 4 unique unsigned long 1 4535296 1024
2 5 2 multip. unsigned short 13776 12540928 1024
3 111 4 multip. unsigned long 1 18854912 1024
4 28 3 multip. uint24 18 24546304 1024
5 7 3 multip. uint24 7 32827392 1024
111 4 unsigned long 1
6 7 3 multip. uint24 7 40418304 1024
28 3 uint24
令人振奋的事情发生了,该表的 Max datafile length: 281474976710654 Max keyfile length: 4398046510079,即最大Data尺寸(MYD文档)达到了2TB,最大索引尺寸(MYI)仍然为4G。