- 论坛徽章:
- 0
|
The dbid 4 was the db for my testing purpose, you can find your dbid:
select db_id('your_db_name')
You better rebuild your db, please bcp out all your data and extract your db schema through DBArtisan before you shutdown your server!!!
There's problem after I reboot server in my test environment:
1> use testdb
2> go
Msg 921, Level 14, State 1:
Server 'HERO', Line 1:
Database 'testdb' has not been recovered yet - please wait and try again
Please see below the steps for reference, or seek help from Sybase.
1. Save old *.dat files and for raw devices save device file using dd command.
2. Create a new server.
3. Save master.dat.
4. Load old master.
5. bcp out syslogins, sysloginroles, sysservers.
6. Run select * from sysusages where dbid = <dbid> order by lstart. Execute sp_helpdevice and get the device name,physical name and size.
7. Create database ddl for this database.
8. shutdown server.
9. Replace master.dat file from step3
10. Restart server. This will start server with a fresh master device.
11. Create a new devices same as found in step 6.
12 Using ddl from step7 create database
13. Shutdown server.
14. Replace *.dat files for this database ( as Log.dat file is not available from old so keep this one as it is).
15. restart server.
16. If there is no error then goto step 24.
17. Else update sysdatabases set status = -32768 where name = "<dbname>"
18. execute sp_role "grant","sybase_ts_role",sa
19 . shutdown and restart server.
20. execute dbcc traceon(3604)
21. execute dbcc rebuild_log(dbid,1,1)
22. update sysdatabases set status = 0 where name = "<dbname>"
23. shutdown and restart server.
24. edit syslogins.bcp file and remove the first line and bcp into master..syslogins table.
25 edit sysloginroles.bcp file and remove all tile having first column = 1 and bcp into master..sysloginroles table.
26. If sysservers.bcp file has more server than select * from master..sysservers then add remaining server using sp_addserver command.
27. Shutdown and restart server.
28. For this database then run dbcc checkdb/checkalloc/checkcatalog and fix other error.
29. If your application still needs old dbid the you may need to update sysdatabases set dbid = <old_dbid> where name = "dbname" also update sysusages set dbid = <old_dbid> where dbid = <current_dbid> and then shutdown and recycle server. This is an optional step only required if necessary for the application otherwise ignore this step.
Procedure - 2
=============
If you have enough additional disk space and master device is fine and able to start server.
Start server in single user mode.
First bcp out sysdatabases and sysusages using -c option of bcp.
1. select name,dbid,status from sysdatabases. -- save this result.
2. Create a new database exactly same as the one having problem.
3. select name,dbid from sysdatabases where name = "newdb"
4. delete sysdatabases where name = "newdb"
5. delete sysusages where dbid = <dbid for newdb> and segmap != 4 -- Basically remove all entries for data and keep entries for logs from sysusages for this newdb.
6. delete sysusages where dbid = <dbid for bad_dbname> and segmap = 4 -- Remove entries for bad logs for bad_dbname
7. update sysusages set dbid = <dbid for bad_dbname> where dbid = <dbid for newdb> -- This would map to new good log device.
8. Shutdown and restart server.
9. If there is no error then goto step 17.
10. Else update sysdatabases set status = -32768 where name = "<bad_dbname>"
11. execute sp_role "grant","sybase_ts_role",sa
12. shutdown and restart server.
13. execute dbcc traceon(3604)
14. execute dbcc rebuild_log(dbid,1,1)
15. update sysdatabases set status = < old_status from step 1 > where name = "<bad_dbname>"
16. Shutdown and restart server.
17. For this database run dbcc checkdb/checkalloc/checkcatalog and fix other error.
18. You may remove unused devices using sp_dropdevice command. |
|