- 论坛徽章:
- 0
|
能不能把设备转移到别的卷上?
12.0
http://manuals.sybase.com/onlinebooks/group-as/asg1200e/svrtsg/@Generic__BookView;lang=zh?DwebQuery=buildmaster
Manually Rebuilding Adaptive Server with bcp and buildmaster
Manually rebuilding Adaptive Server with bcp and buildmaster enables you to create a new master device/configuration block and preserve system tables.
Some of the most common uses for a manual rebuild are when:
The master device has no more available space. You can migrate the system table information to a new, larger master device while retaining all current data on the original devices.
Restoring the master device resulted in 605 errors due to an incorrect sysusages table. You can use trace flags, along with the bcp and buildmaster steps, to get the information needed for a rebuild.
No backup of the master database exists. The old master database is accessible, although it is not runnable. You can migrate the system information to a new master database.
You can also use manual rebuild steps for immediate recovery when:
Severe data corruption necessitates a speedy recovery. You can run the bcp and buildmaster commands, instead of using the sybinit utility, running the disk reinit/refit commands, or creating/loading from backups.
You need to perform a recovery from an inadvertent configuration change, such as memory set too high.
Major corruption problems on, or loss of, the master device requires creating a new server. In this case, you must use bcp on your system tables immediately.
Ensure that your backup procedures include bcp commands for all relevant tables, including the six system tables listed under "Steps for Rebuilding Adaptive Server". You can then more easily restore the master database if necessary.
Checklist
You can use the following checklist when you manually rebuild Adaptive Server with bcp and buildmaster. Details on each step follow.
Copy the system tables to files (bcp...out with the -c option).
Get configuration information and shut down the server.
Run the buildmaster command to create the new master device.
Bring up the server in single user mode.
Delete sysconfigures, and then copy the files into the system tables (bcp...in), including sysconfigures.
Reconfigure, shut down with nowait and then restart the server.
Run the install scripts for master and model.
Shut down/bring up the server in multi-user mode.
Test the results.
Considerations
Before performing Adaptive Server recovery, carefully evaluate the issues specific to your system, and then choose the best approach.
You may also find it helpful to review appropriate recovery and rebuild information in earlier sections of this chapter.
If using bcp version 11.1.1, ensure that you have applied the latest EBF for this version. As an alternative, you can use the -Q option in bcp 11.1.1 to revert to the version 10.0.4 behavior, which converts null data to spaces.
Steps for Rebuilding Adaptive Server
Let us say that your master device is full and is producing 1105 errors (system segment is full). As a last resort, you have run the dump transaction command with the truncate_only or no_log option, which did not free any database space. You cannot even run alter database to add rows to the sysusages system table, because the system segment is full. This section details how to manually rebuild Adaptive Server in this common situation, focusing on these six system tables:
sysdevices represents the available physical devices.
sysdatabases represents the databases known to Adaptive Server.
sysusages plots how individual databases use the device fragments, such as for data and transaction logging.
syslogins holds the login information about users allowed to work in the server.
sysconfigures contains the user-settable configuration parameters.
syscharsets contains the character sets and sort orders defined for Adaptive Server use.
Your Adaptive Server configuration may include other system tables of critical importance. If so, be sure to include them when recreating the original environment. For example:
sysservers holds the names of other remote servers.
sysremotelogins contains the login information for the remote hosts.
sysloginroles may be necessary for sites doing extensive group/security work.
The following procedures rely on the bcp command. If bcp is unavailable, see "If You Cannot Use bcp or a Dump".
Copy the System Tables to Files
Copy the system tables to data files as follows:
Execute the bcp...out command for each of the six main tables. At a Sybase bin directory prompt, enter:
bcp master..sysdevices out /directory.spec/devs -Usa -P -c
bcp master..sysdatabases out /directory.spec/dbs -Usa -P -c
bcp master..sysusages out /directory.spec/usages -Usa -P -c
bcp master..syslogins out /directory.spec/logins -Usa -P -c
bcp master..sysconfigures out /directory.spec/configures -Usa -P -c
bcp master..syscharsets out /directory.spec/charsets -Usa -P -c
If your site needs other system tables, such as sysservers, and sysremotelogins, run bcp...out for them now as well. The syntax is:
bcp master..<table_name>; out /directory.spec/<filename>; -Usa -P -c
Where:
table_name is the name of the table, for example sysservers.
filename is the name you want to give the bcp file, for example srvrs.
For details on using the bcp command, see the Adaptive Server utilities manual for your platform.
You cannot use bcp and buildmaster to recover user databases on the master device. You must manually drop and reload these user databases from backups.
Get Configuration Information and Shut Down the Server
Print current configuration values to an output file, and then shut down the Adaptive Server as follows:
At a Sybase bin directory prompt:
isql -Usa -P -S<server>; << EOF >; /directory.spec/sp_configure.out
For details on isql parameters, see the Adaptive Server utilities manual for your platform.
At the isql prompt, enter:
1>; sp_configure
2>; go
1>; shutdown
2>; go
EOF
Perform buildmaster Commands and Edit the run_server File
Consider these guidelines before running buildmaster:
Preserve the original. When doing a full buildmaster rebuild to create a new master device, preserve the original device in case you need information from it. First do all the work on a new device (a filesystem is adequate for this.) Once the server is running, you can either repeat the same work on the original master device or copy the new device with an operating system utility, such as dd (Unix).
Keep tempdb on master. If you previously moved tempdb off the master device, sysusages for master will be nonstandard if the master database was altered after moving tempdb.
Maintaining tempdb on the master device ensures a standard master device layout that you can restore conveniently if the device is lost. It is recommended that you take this opportunity to move tempdb back to the master device.
To create a new master device:
Create a new master device/configuration block. At the Sybase bin directory prompt, enter:
buildmaster -d<path_to_new_master_device>;
-s<new_master_device_size>;
where the <new_master_device_size>; is the size of the new master device in 2K pages.
To find where the current master device path is set, look in the "run_server" file under the Sybase install directory. The default name is RUN_SYBASE; if the server name is not SYBASE, the filename is RUN_servername.
Copy the "run_server" file under the Sybase install directory, and then edit the copy as follows:
Change the -d<path_to_old_master_device>; to reflect the <path_to_new_master_device>; that you created in step 1.
Change the comment, &num; Size of Master Device: <old_master_device_size>;", to reflect the <new_master_device_size>;.
Bring Up the Server in Single-User Mode
Copy the "run_server" file and name it with a "m_" prefix to indicate single user mode; for example, m_RUN_servername.
Edit the m_RUN_servername file to add the single-user mode flag (-m on Unix) in the dataserver command.
At a Sybase install directory prompt, enter:
startserver -f m_RUN_servername
For details refer to "How to Start Adaptive Server in Single-User Mode".
Copy the Files into the System Tables
Log into the Adaptive Server that contains the new master device. No password is needed.
Delete the sysconfigures table. You will replace the rows in step 4.
Remove the rows in the sysusages output file /directory.spec/usages for dbid 1 (master), 2 (tempdb), and 3 (model). dbid is the leftmost value in each row.
This step prevents incorrect sysusages errors. Otherwise, databases try to use uninitialized space from rows in the output file that are not in the new sysusages table.
Copy the files back into the system tables by entering the following commands at a Sybase bin directory prompt:
bcp master..sysdevices in /directory.spec/devs -Usa -P -b 1 -c
bcp master..sysdatabases in /directory.spec/dbs -Usa -P -b 1 -c
bcp master..sysusages in /directory.spec/usages -Usa -P -b 1 -c
bcp master..syslogins in /directory.spec/logins -Usa -P -b 1 -c
bcp master..sysconfigures in /directory.spec/configures -Usa -P -b 1 -c
bcp master..syscharsets in /directory.spec/charsets -Usa -P -b 1 -c
The -b 1 parameter allows processing to continue when bcp encounters duplicate records, such as the SA login created during the initial buildmaster process.
Remember to run bcp...in for any other tables that you included in the step "Copy the System Tables to Files".
Look at your error log prior to failure for the default sort order and character set ID. Then invoke isql and enter:
1>; update sysconfigures set value = <new-sort-id>;
2>; where comment like "%default sort%"
3>; go
1>; update sysconfigures set value = <new-charset>;
2>; where comment like "%default character%"
3>; go
Invoke isql and run checkpoint on the master database:
1>; checkpoint
2>; go
Shut Down/Bring Up Adaptive Server in Single-User Mode
At a Sybase bin directory prompt, invoke isql:
isql -Usa -P << EOF
Shut down the server. Use the with nowait option to avoid misleading error messages. At the isql prompt, enter:
1>; shutdown with nowait
2>; go
Start the server in single user mode. Refer to "How to Start Adaptive Server in Single-User Mode".
If the sort order is changing, the server rebuilds some indexes and shuts down again. In this case, simply repeat step 3.
Run the Install Scripts for master and model
At this point, Adaptive Server has recovered all of the user databases and sybsystemprocs. Assuming that both master and sybsystemprocs are available to the server, run the install scripts to install system procedures and grant permissions for using Adaptive Server. Run the install scripts from a Sybase bin directory prompt.
For example, on Unix platforms with ASE version 11.9.x or earlier, enter:
isql -Usa -P < $SYBASE/scripts/installmaster
isql -Usa -P < $SYBASE/scripts/installmodel
On Unix platforms with ASE version 12.0 and later, enter:
isql -Usa -P < $SYBASE/$SYBASE_ASE/scripts/installmaster
isql -Usa -P < $SYBASE/$SYBASE_ASE/scripts/installmodel
Shut Down/Bring Up the Server in Multi-User Mode
From the Sybase install directory prompt, enter:
startserver -f RUN_<server>;
Verify the Results and Test Applications
Recommendations for verifying and recording the manual rebuild results:
Perform dbcc commands on all databases.
Dump the master database.
Make and store hard copies of system tables, especially:
sysdevices
sysdatabases
sysusages
syslogins
sysconfigures
syscharsets
Test applications to ensure that they work as expected.
If You Cannot Use bcp or a Dump
If you cannot use bcp or a dump to restore master database information, refer to the information on using disk reinit and disk refit in "How to Restore System Table Information in master Database".
Also note that if you do not have disk reinit scripts, you can get device information from these sources:
Error log, which provides the physical and logical device names and vdevno
Operating system, which provides the size |
|