月度存档: 十二月 2011

linux下生成随机密码

cat /dev/urandom | head -1 | md5sum | head -c 16

mysqlreport mysql性能分析脚本

安装:

wget hackmysql.com/scripts/mysqlreport

如果提示错误:

Can’t locate DBI.pm in @INC (@INC contains: /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 .) at ./mysqlreport line 24.

需要安装:perl dbd

yum -y install perl-DBD-MySQL

 

hibernate mysql autocommit

http://forum.springsource.org/showthread.php?12639-MySQL-set-autocommit-0-set-autocommit-1

以下设置避免每次事务都向db发送无用的commit请求

<bean id="dataSourceTarget">
  <property name="driverClassName"><value>com.mysql.jdbc.Driver</value></property>
  <property name="url"><value>jdbc&#58;mysql&#58;//localhost&#58;3306/imagedb</value></property>
  <property name="username"><value>admin</value></property>
  <property name="password"><value></value></property>
</bean>

<bean id="dataSource">
  <property name="targetDataSource"><ref local="dataSource"/></property>
</bean>

设置之前:

__ Questions ___________________________________________________________
Total           1.88M     5.3/s
Com_          1.32M     3.7/s  %Total:  69.98
DMS         512.62k     1.5/s           27.28
QC Hits      51.53k     0.1/s            2.74
COM_QUIT         36     0.0/s            0.00
-Unknown          7     0.0/s            0.00
Slow 2 s            2     0.0/s            0.00  %DMS:   0.00  Log:  ON
DMS           512.62k     1.5/s           27.28
SELECT      373.42k     1.1/s           19.87         72.85
INSERT       68.29k     0.2/s            3.63         13.32
UPDATE       61.07k     0.2/s            3.25         11.91
DELETE        9.84k     0.0/s            0.52          1.92
REPLACE           0       0/s            0.00          0.00
Com_            1.32M     3.7/s           69.98
set_option  875.44k     2.5/s           46.59
commit      436.17k     1.2/s           23.21
change_db       544     0.0/s            0.03

 

设置之后:

__ Questions ___________________________________________________________
Total          50.41M   197.8/s
DMS          32.99M   129.5/s  %Total:  65.45
Com_         16.53M    64.9/s           32.78
QC Hits     855.49k     3.4/s            1.70
COM_QUIT     34.27k     0.1/s            0.07
-Unknown         29     0.0/s            0.00
Slow 2 s            1     0.0/s            0.00  %DMS:   0.00  Log:  ON
DMS            32.99M   129.5/s           65.45
SELECT       17.61M    69.1/s           34.94         53.38
UPDATE       11.46M    45.0/s           22.74         34.74
INSERT        3.38M    13.3/s            6.70         10.24
DELETE      544.37k     2.1/s            1.08          1.65
REPLACE           0       0/s            0.00          0.00
Com_           16.53M    64.9/s           32.78
set_option   10.99M    43.1/s           21.81
commit        5.43M    21.3/s           10.76
change_db    34.37k     0.1/s            0.07
可以看到在设置之后

DMS语句从比例27%提升至65%.性能提升非常大.