Java Heap Size Options
You achieve best performance by individually tuning each of your applications. Configuring the JVM heap size options listed in Table 2-2 increases performance for most applications.
The options listed in Table 2-2 may differ depending on your architecture and operating system. See your vendor’s documentation for platform-specific JVM tuning options.
Table 2-2 Java Heap Size Options
Task |
Option |
Description |
|---|
Setting the New generation heap size |
-XX:NewSize |
Use this option to set the New generation Java heap size. Set this value to a multiple of 1024 that is greater than 1MB. As a general rule, set -XX:NewSize to be one-fourth the size of the maximum heap size. Increase the value of this option for larger numbers of short-lived objects.
Be sure to increase the New generation as you increase the number of processors. Memory allocation can be parallel, but garbage collection is not parallel. |
Setting the maximum New generation heap size |
-XX:MaxNewSize |
Use this option to set the maximum New generation Java heap size. Set this value to a multiple of 1024 that is greater than 1MB. |
Setting New heap size ratios |
-XX:SurvivorRatio |
The New generation area is divided into three sub-areas: Eden, and two survivor spaces that are equal in size.
Use the -XX:SurvivorRatio=X option to configure the ratio of the Eden/survivor space size. Try setting this value to 8 and then monitor your garbage collection. |
Setting minimum heap size |
-Xms |
Use this option to set the minimum size of the memory allocation pool. Set this value to a multiple of 1024 that is greater than 1MB. As a general rule, set minimum heap size (-Xms) equal to the maximum heap size (-Xmx). |
Setting maximum heap size |
-Xmx |
Use this option to set the maximum Java heap size. Set this value to a multiple of 1024 that is greater than 1MB. |
2台mysql server:
192.168.0.11 (master)
192.168.0.12 (slave)
如果要在master-slave之间复制bbs库,首先
在master上创建replication用户(赋予‘复制’权限):
mysql>GRANT REPLICATION SLAVE ON *.*
TO ‘repl’@'%’ IDENTIFIED BY ’slavepass’;
mysql>GRANT FILE ON *.* TO ‘repl’@'%’ IDENTIFIED BY ’slavepass’;
锁定只能操作读权限
mysql>FLUSH TABLES WITH READ LOCK;
在master上创建bbs库的快照(snapshot)
tar -cvf /tmp/bbs.tar ./bbs
在slave上还原快照:
tar -xvf /tmp/bbs.tar
mysql> UNLOCK TABLES;
修改slave上/etc/my.cnf
[mysqld]
master-host=192.168.0.11
master-user=repl
master-password=slavepass
master-port=3306
server-id=2
master-connect-retry=60
replicate-do-db=bbs
log-slave-updates
master服务器修改my.cnf文件,一般路径在/etc/my.cnf,添加如下内容:
[mysqld]
log-bin
server-id=1 #分配一个id
sql-bin-update-same
binlog-do-db=bbs #要同步的库名
master
mysql > SHOW MASTER STATUS;
slave
mysql > SHOW SLAVE STATUS;