您的位置:首页 > 其它

sybase 优化总结

2015-08-12 15:39 363 查看
sybase 优化总结

===========================================================

一. SYBASE 系统参数调整

1.内存

/sbin/sysctl -w kernel.shmmax=3416386150
shmmax是最大共享内存段,假如服务器上没有别的应用并且使用raw device可以将此参数调整到物理内存的90%,如果使用file system device 的话相应调小,因为file system buffer需要开销内存!修改后重新启动系统。
sp_configure "max memory",1500000 重启生效(设置为共享内存的75%)

sp_configure "allocate max shared mem",1 启动的时候自动分配max memory指定的最大内存

sp_cacheconfig "default data cache","1500m" 设置数据缓存(设置为max memory的一半)

sp_cacheconfig "default data cache","cache_partition=2" 是CPU数量的倍数,对数据缓冲区分区

sp_poolconfig "default data cache","64m","16k" 设置16K 数据缓存

sp_poolconfig "default data cache","128m","8k" 设置8K 数据缓存

sp_configure "procedure cache size",90000 存储过程数据缓存

sp_cacheconfig 'tempdb_cache','200m','mixed' 创建命名高速缓存

sp_bindcache 'tempdb_cache',tempdb 捆绑临时数据库到

tempdb_cache高速缓存
2.cpu

sp_configure "max online engines",2 设置使用的CPU数量

sp_configure "number of engines at startup",2 启动时使用CPU数量
3. 网络

sp_configure "default network packet size",2048 设置网络传送包的大小(重启动生效)

sp_configure "max network packet size",2048
4. 其他资源使用

sp_configure "number of locks",100000 锁使用数量

sp_configure "number of open indexes",5000 打开索引

sp_configure "number of open objects",5000 打开对象

sp_configure "number of user connections",1000 用户连接数

sp_configure "number of device",100 新建设备最大数量

二. sybase 设备调整
数据设备与日志设备必须分开,添加临时数据库设备
1. 数据设备

sp_deviceattr devname,"dsync",true

2. 日志设备

sp_deviceattr devname,"dsync",false

3. 临时数据库设备

sp_deviceattr devname,"dsync",false

tempdb数据和日志分离:

USE master

Go
DISK INIT name = 'tempdbdev01', physname = '/opt/sybase/data/tempdbdev01.dat' , size = '1G',dsync = 'false'

Go
DISK INIT name = 'tempdblogdev01', physname = '/opt/sybase/data/tempdblogdev01.dat', size = '1G',dsync = 'false'

Go
ALTER DATABASE tempdb ON tempdbdev01 = '1G' LOG ON tempdblogdev01 = '1G'

Go
USE tempdb

Go
删除tempdb上使用的master段:

EXEC sp_dropsegment 'logsegment', 'tempdb', 'master'

go
EXEC sp_dropsegment 'system', 'tempdb', 'master'

go
EXEC sp_dropsegment 'default', 'tempdb', 'master'

Go
如果已针对 tempdb 建立了设备,则只需禁用 dsyncio,但需要重新启动 Adaptive Server:

EXEC sp_deviceattr 'tempdbdev01', 'dsync', 'false'

Go
EXEC sp_deviceattr 'tempdblogdev01', 'dsync','false'

Go
数据库设备最好设置Direct IO,获得的性能相信会让你满意

三. sybase 数据结构调整
1. 数据库对象表、索引。。

(1)对表新建合理的索引,定期分析表

update statistics tabname (不锁表)

(2)整理数据库空间 (锁表,剩余空间必须为最大表的1.2倍)

reorg rebuild tabname

recreate clustered index

(3)重新编译存储过程与触发器

sp_recompile usertable (与表相关联的存储过程和触发器)

四. sybase 数据库监控
1. 数据库死进程

select * from master.syslogshold

五. sybase 数据库启动参数
-T3607 master

-T3608 其他数据

-m 单

===========================================================

SYBASE 移动日志文件到其他的设备

===========================================================

Moving the transaction log to another device

1> alter database dbname log on device19 = 101> sp_logdevice dbname, device19The last-chance threshold for database dbname is now 1232 pages. ... sql inserts, to fill old log segment ...1> dump tran dbname with truncate_only1> sp_helplog dbname2> goIn database
'dbname', the log starts on device 'device19'.(return status = 0)1>

===========================================================

SYBASE 序列异常跳转解决方法

===========================================================

identity burning set factor的问题

每 次异常断电跳转的数目是:identity burning set factor*10的负7次方*表中identity列定义的长度,例如identity burning set factor=5000,identity列定义的长度numeric(10,0),则该数等于:5000*10的负7次方*1010的10次方,该数比 较大

另外可以在建表时设置跳转的值,语法是 create table (...) with identity_gap = value. 修改当前表步长
EXEC sp_chgattribute 't_61e_tolltype','identity_gap',50

===========================================================

SYBASE 如何创建代理表

===========================================================

如何创建代理表

在interfaces文件中加入远程服务器条目

sp_addserver dblocal,local

sp_addserver dbremote,null,dbremote

sp_configure "enable cis",1

sp_addexternlogin dbremote,sa,sa,password

创建代理表

create existing table zz_proxy (id int not null,name varchar(10) not null)

at "sybase.master..zz"

或者

create proxy_table zz1

at "sybase.master..zz"
建代理表时,远程表的结构数据已经存储在了本地,并且不会检测该表的结构是否发生改变,因此远程表的结构发生改变时,本地是不知道的,需要重新创建代理表,相当于重新刷新本地的存储的结构.

===========================================================

SYBASE 远程备份

===========================================================

在interfaces中加入远程备份服务器的条目(ip地址或者是远程服务器的物理名称)

要注意加入的名称与远程备份服务器的名称要一致!!!
dump database to ... at bs_server_name

六、配置参考
sp_configure "max memory",800000 ///共享内存1.6G

Sybase 能够用到的最大物理内存,单位2k,通常配置成主机物理内存的70%~80%

sp_configure “number of user connections”,180 ///180个用户连接数

通常根据实际并发呼叫来配,一般配置80~200

sp_configure “lock scheme”, allpages ///使用缺省:页锁

但有些并发操作多的表需使用行锁,如cc_telebill表等

sp_configure “number of locks”,50000 /锁的数目5万

可以根据实际应用,一般10000~50000

sp_configure “max online engines”,2 ///cpu个数为2

cpu使用缺省值,多cpu(4~8个)配成n-1个

number of engines at startup

sp_configure “number of worker processes”,2 //启用的工作进程数

单cpu使用缺省值,多cpu(4~8个)配成n-1个

sp_configure “number of open indexes ”,1000 ///打开的索引个数

sp_configure “number of open objects ”,1000 ///打开的事务个数

sp_configure "user log cache size",4096

日志缓存通常配成2048或4096

sp_configure "procedure cache size",50000 /// 100M

存储过程缓存(运行存储过程),单位2k,通常根据需要配置50~200M

sp_cacheconfig "default data cache","1.2G"

设置数据缓存1.2G(所有cache值累加不能超过max memory)

sp_cacheconfig "default data cache", "cache_partition=2"

数据缓存分区(减少锁竞争)

重启sybase服务令所有参数生效
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: