日期:2014-05-16  浏览次数:20484 次

sybase数据库夸平台恢复
演示一次sybase ASE15.0.3跨平台备份恢复的过程。

源数据库版本为:

1> select @@version
2> go
 -----------------------------------------------------
------------------------------------------------------
----------------------------------------
 Adaptive Server Enterprise/15.0.3/EBF 16738 ESD#2/P/NT (IX86)/Windows 2003/ase1
         503/2708/32-bit/OPT/Mon Jul 27 20:19:56 2009



目的数据库版本为:

1> select @@version
2> go
 -----------------------------------------------------
------------------------------------------------------
----------------------------------------
 Adaptive Server Enterprise/15.0.3/EBF 16548 ESD#1/P/Sun_svr4/OS 5.8/ase1503/268
         0/64-bit/FBO/Thu Mar  5 09:39:28 2009
 


跨平台恢复的详细过程如下:

(1). 检查欲备份的数据库testdb的完整性,利用checkdb和checkalloc

1> dbcc traceon(3604)
2> go
1> dbcc checkdb(testdb)
2> go
1> dbcc checkalloc(testdb)
2> go


(2). 将数据库testdb设置为单用户模式

1> use master
2> go
1> sp_dboption testdb,"single",true
2> go

(3). 清空testdb的日志,并设置检查点

1> dump tran testdb with no_log
2> go
1> checkpoint
2> go

(4). 将属于数据库testdb的脏页写到磁盘上面去,并发出检查点命令。 在发出sp_flushstats系统过程后要等待一段时间,保证数据库有足够的时间把页面信息刷新到磁盘上。

1> sp_flushstats
2> go
1> checkpoint
2> go


(5). 备份数据库testdb

1> dump database testdb to "d:\testdb-20100409.dmp"
2> go


(6). 利用ftp服务器将备份出来的testdb-20100409.dmp文件拷贝到solaris服务器上。

(7).用isql连接到目的数据库服务器上面,执行恢复命令

1> load database testdb from "/app/sybdata/testdb-20100409.dmp"
2> go


(8). 将目的数据库服务器中的testdb调整成在线。

1> online database testdb
2> go


(9). 进入testdb,执行sp_post_xpload系统存储过程来重建用户表的索引。

1> use testdb
2> go  
1> sp_post_xpload
2> go 

至此,跨平台备份恢复过程完成!

补充:以下为load database过程显示的所有的反馈信息。

1> sp_helpdb  testdb
2> go
 name   db_size       owner dbid created      status
 ------ ------------- ----- ---- ------------ -------------
 testdb     1300.0 MB sa       4 Apr 09, 2010 don't recover
(1 row affected)
 device_fragments               size          usage
         created                   free kbytes
 ------------------------------ ------------- --------------------
         ------------------------- ----------------
 testdb_dat                         1000.0 MB data only
         Apr  9 2010  7:05PM                1016720
 testdb_log                          300.0 MB log only
         Apr  9 2010  7:05PM       not applicable
Msg 921, Level 14, State 2:
Server 'SYB_NFJD_TEST', Procedure 'sp_helpdb', Line 588:
Database 'testdb' has not been recovered yet - please wait and try again.
 --------------------------
 log only free kbytes = 0
(return status = 0)
1> load database testdb from "/app/sybdata/testdb-20100409.dmp"
2> go
Backup Server session id is:  19.  Use this value when executing the
'sp_volchanged' system stored procedure after fulfilling any volume change
request from the Backup Server.
Backup Server: 6.28.1.1: Dumpfile name 'scourt5100990F2E6' section number 1
mounted on disk file '/app/sybdata/testdb-20100409.dmp'
Backup Server: 4.188.1.1: Database testdb: 23940 kilobytes (1%) LOADED.
Backup Server: 4.188.1.1: Database testdb: 58630 kilobytes (4%) LOADED.
Backup Server: 4.188.1.1: Database testdb: 93320 kilobytes (7%) LOADED.
Backup Server: 4.188.1.1: Database testdb: 127118 kilobytes (9%) LOADED.
Backup Server: 4.188.1.1: Database testdb: 151180 kilobytes (11%) LOADED.
Backup Server: 4.188.1.1: Database testdb: 1728