[转] 修改Sybase数据库最大连接数

1、查看最大连接数
sp_configure 'number of user connections'
结果如下:
Parameter Name                 Default     Memory Used Config Value Run Value   Unit                 Type     
--------------                 -------     ----------- ------------ ---------   ----                  ----     
number of user connections              25        2372          25           25 number               dynamic
Sybase的数据库默认最大连接数为25,当连接数不够用的情况下,需要修改数据库配置。
2、修改为200
sp_configure 'number of user connections',200
报如下错误:
Server Message: Number 7415, Severity 10
Procedure 'sp_configure', Line 606:
The transaction log in database master is almost full. Your transaction is being suspended until space is made available in the log.
看来是由于日志空间将满导致,需清除日志。
清除Log有两种方法:
1>自动清除法
开放数据库选项 Trunc Log on Chkpt,使数据库系统每隔一段时间自动清除Log。此方法的优点是无须人工干预,由SQL Server自动执行,并且一般不会出现Log溢满的情况;缺点是只清除Log而不做备份。
2>手动清除法
执行命令“dump transaction”来清除Log。以下两条命令都可以清除日志:
dump transaction with truncate_only
dump transaction with no_log
通常删除事务日志中不活跃的部分可使用“dump transaction with trancate_only”命令,这条命令写进事务日志时,还要做必要的并发性检查。SYBASE提供“dump transaction with no_log”来处理某些非常紧迫的情况,使用这条命令有很大的危险性,SQL Server会弹出一条警告信息。为了尽量确保数据库的一致性,你应将它作为“最后一招”。
以上两种方法只清除日志,而不做日志备份,若想备份日志,应执行“dump transaction database_name to dumpdevice”命令。
3、清除日志,选用第一种方法
dump transaction melinets with truncate_only
清除后执行sp_configure 'number of user connections',200
发现依然存在该错误
Server Message: Number 7415, Severity 10
Procedure 'sp_configure', Line 606:
The transaction log in database master is almost full. Your transaction is being suspended until space is made available in the log.
4、看来还需要清除一下master的日志文件
dump transaction master with truncate_only
再次执行sp_configure 'number of user connections',200
结果报如下错误,提示'max memory'值不够大
Server Message: Number 5861, Severity 16
Procedure 'sp_configure', Line 606:
The current 'max memory' value '23552', is not sufficient to change the parameter 'number of user connections' to '200'. 'max memory' should be greater than 'total logical memory' '26606' required for the configuration.
(1 row affected)
(return status = 1)
5、根据失败提示信息,修改'max memory'为需要的值
sp_configure 'max memory',26606
执行结果
Parameter Name                 Default     Memory Used Config Value Run Value   Unit                 Type     
--------------                 -------     ----------- ------------ ---------   ----                 ----     
max memory                           23552       53212       26606        26606 memory pages(2k)     dynamic  
Configuration option changed. The SQL Server need not be rebooted since the option is dynamic.
Changing the value of 'max memory' to '26606' increases the amount of memory ASE uses by 10 K.
(1 row affected)
(return status = 0)
6、重新修改连接数,终于成功
sp_configure 'number of user connections',200
结果如下:
Parameter Name                 Default     Memory Used Config Value Run Value   Unit                 Type     
-------------                 -------     ----------- ------------ ---------   ----                 ----     
number of user connections              25       17347         200          200 number               dynamic
Configuration option changed. The SQL Server need not be rebooted since the option is dynamic.
Changing the value of 'number of user connections' to '200' increases the amount of memory ASE uses by 19534 K.
(1 row affected)
(return status = 0)
7、重启数据库服务。
刚发表这篇日志,那个客户就来找我,说中午人少的时候把数据库服务期重启了,然后所有的系统都不能用了。晕哦,有点严重,马上远程连接看了下,ping也ping不通,看了一下服务也没有启,请教了一下老员工,说可能是由于内存比较小,承受不了200个连接,要改小一点。于是在sybase根目录下找到sybase.cfg,将number of user connections的值由200改为100,然后就可以启动数据库服务了。所以,改连接数的时候还要充分考虑内存的问题。

猜你喜欢

转载自tearguang.iteye.com/blog/1726046
今日推荐