|
|
This chapter contains information that the Database Management System (DBMS) system administrator will use to perform basic database maintenance. The tasks described require a detailed working knowledge of UNIX, network communications, and the Abstract Syntax Notation One (ASN.1) language.
This chapter includes the following sections:
All of the tasks in this chapter are performed using root or sa privileges, unless otherwise noted. You can tell when a task requires these privileges by the use of the pound sign (#) in the examples or steps.
![]() | Caution Remember to shut down the Sybase data server using the $NMSROOT/etc/shutdown_nms script before performing a system shutdown. |
CiscoWorks provides a fully integrated relational database based on Sybase. Sybase stores network data, including device and polling information. CiscoWorks aids database administration tasks with a suite of scripts that allow you to perform required maintenance activities on your database. For a comprehensive review of Sybase administration, refer to the Sybase Database Administration Guide.
The Sybase daemon (dataserver) stores formatted log messages in the database. You can view the status of the Sybase server with Process Manager. To stop or start the Sybase server, refer to "Administering the Sybase Server" later in this chapter.
For detailed information on CiscoWorks database tables, refer to the chapter "CiscoWorks Database Tables" in the CiscoWorks Reference Guide.
As part of CiscoWorks, there are two server processes that require administration.
For a detailed explanation of the relationship between SQL Server and Backup Server, refer to the Sybase System Administration Guide.
The task of administering the backup server depends on how CiscoWorks was installed. If the SQL server provided by Cisco is used, CiscoWorks manages the backup server. However, if you chose to install CiscoWorks onto a non-Cisco-licensed SQL server, the administration of the backup server is optional and might not be reached by CiscoWorks.
To check server status, refer to "Checking the Status of the Sybase Servers" later in this chapter.
The system administrator uses two accounts:
You can log into the Sybase SA account using the SA Password or entering the following command:
# $SYBASE/bin/isql -Usa -Pcurrent_password -Sserver name
If you do lose the Sybase system administrator password, edit the RUN_CW_SYBASE file, where RUN_CW_SYBASE is the name of the Sybase server, in the $SYBASE/install directory. Add the -p option to the line with the dataserver command.
Then, run the following script:
# startserver -f RUN_CW_SYBASE
The Sybase server now starts without your using the password.
This chapter describes the tasks to perform while using these accounts. The Sybase sa account is the equivalent of the UNIX root account, because the Sybase database server does not check permissions while you are logged into the sa account.
If you forget your Sybase system administrator password, you cannot get system administrator access to the Sybase database unless you reinstall Sybase. During the reinstall, you reestablish a password as part of the installation.
This section includes information on how to start, query, shut down, and troubleshoot the server.
For information on how to disable the CiscoWorks default of automatically clearing the database, thereby customizing your backup procedures, refer to the section "Disabling the Automatic Clear Function" later in this chapter.
Use the following command to perform system administration tasks such as viewing or adding user accounts to the Sybase database:
hostname# user_nms
The Sybase SQL server must be running in order for your CiscoWorks applications to collect and display data. The SQL server enables CiscoWorks applications to collect and display data. The backup server enables system backup and recovery.
To start the Sybase server, use the nmstartup command. Typically, you run nmstartup when you boot your system. The nmstartup command also starts other background processes required by CiscoWorks. You set this functionality during the installation and configuration process as described in the CiscoWorks installation guide for your platform.
After you use the shutdown_nms script, perform the following steps to restart the Sybase SQL server:
Step 1 Enter the following command to start all CiscoWorks processes that are not currently active:
After startup, Sybase reads the interfaces file to get TCP port numbers.
Step 2 Enter the ps -ax command to list all these processes.
Step 3 Verify that the $SYBASE/interfaces file is similar to the following example:
cat $SYBASE/interfaces
In this example, lol-ss2 is the name of the workstation running the database, and 8100 and 8101 are the workstation ports.
Step 4 Enter the following command to access the sa account:
$SYBASE/bin/isql -Usa -P passwordquit
This command confirms that the database is up and can communicate with processes. A message may indicate that the network is unavailable or that Sybase is not currently running.
The isalive command is used to query the server to determine if it is connected and operational. Use it to quickly find out if your database functions are available. The query uses the same arguments as in any SQL server client application. If the query succeeds in connecting to the server, it returns a successful status code (zero) to the command line. If the query fails to make a server connection, a message identifying the reason appears and returns a nonzero status code.
To query the Sybase server, make a server connection query by entering the following command syntax:
$NMSROOT/etc/isalive [username] password [server_name]where
username specifies a username to the server. The default is the environmental variable USER.
password specifies the password. If you do not enter the password, the system will prompt you for it.
server name is the name of the server. The server names are located in the interfaces file in the home directory of the user sybase. (The home directory is defined by the $SYBASE environment variable, which is normally set to $NMSROOT/sybase.) The default server name is CW_SYBASE.
Following are examples of the isalive command:
% isalive -Ulloyd -SSYBASE % isalive -Psecret
If there is a problem with the server, an error message appears.
There are two methods to check the Sybase server status:
At any time a user can check to see if the CiscoWorks servers are running by entering the following command:
# $SYBASE/install/showserverThe results of this command differ depending on which operating system you are running, but two distinct lines are returned. One line details the SQL Server and the second details the backup server.
Use the shutdown_nms script to shut down the SQL server. The script sequentially shuts down the database to prevent corruption that might otherwise occur if power were simply cut off.
![]() | Caution Remember to shut down the Sybase dataserver using the $NMSROOT/etc/shutdown_nms script before performing a system shutdown. |
To use the shutdown_nms script, perform the following steps:
Step 1 Enter the following command:
$NMSROOT/etc/shutdown_nms
The shutdown_nms script is in the $NMSROOT/etc directory.
Step 2 Enter your DBMS system administrator (SA) password if requested.
The following message appears:
As the shutdown completes, the following message appears:
For details, see your system administrator for instructions or your Sun System Administration Guide.
If the server does not appear to be running, perform the following steps:
Step 1 Enter the following command to check for the server process:
ps -vax |grep dataserver
Step 2 If the server process is not listed, log in as a superuser and enter the following command:
$NMSROOT/etc/nmstartup
Step 3 If the server process is not listed, enter the following command:
cat $SYBASE/interfaces
The system name where your server is located appears. Ensure that this system is listed in your domain name server (DNS) or other name server.
For detailed information on Sybase error messages, refer to the Sybase System Administration Guide.
As shipped, the DBMS SA password to access the database is null. Press Return at the password prompt to accept the null password. You can change the password initially, or at any time by performing the following steps:
Step 1 To change the password at first usage, enter the following commands to log in as a superuser and change your password:
# $SYBASE/bin/isql -Usa -Ppassword
sp_password NULL,newpassword
Or
To change an established password, enter the following commands:
# $SYBASE/bin/isql -Usa -P current_password
sp_password current_password, newpassword
The following system message appears:
newpassword is the password you want to establish.
Step 2 Enter the following command to continue:
go
The following system message appears:
Step 3 Enter the following command to exit the command mode:
quit
Every Sybase database has its own transaction log. These transaction logs, which are part of the system catalog tables, track all activities performed on the database in which they reside. As a result, the logs become full and cannot hold additional transactions until action is taken to recover space.
To effectively manage a transaction log, you must truncate it. This program writes all committed transactions from the log to disk, then deletes them from the log. Once deleted, the transaction data is lost forever. You can use this method to store important polling transaction log data to disk.
The polling transaction log does not require storage of transactions (since they are dynamic and useful for only a short time). Therefore, whenever the polling transaction log reaches 70 percent full (or your polldb threshold), the data is automatically deleted, and the space is recovered for future polling transactions.
When CiscoWorks is shipped, the disk space allocated to database functions leaves about 10 megabytes (MB) of free space to record table information and polling. Polling can consume an enormous amount of space for retention of the data being acquired by the queries. The faster a poll rate (shorter interval), the faster disk space is consumed. For this reason, adjust the disk space allocation before polling with Device Polling. This means that when you create tables, be certain to save them with a no poll interval entry, so they do not start polling and fill the database.
To determine transaction log utilization, you must first determine the transaction log space used. Use the following to access data on how much space the transaction log is using and how much is available in the transaction log only.
To monitor your transaction log utilization data, perform the following steps:
Step 1 Log in as the system administrator and access the database by entering the following commands:
$SYBASE/bin/isql -Usa -P password
use nms
go
dbcc checktable(syslogs)
2> go
The system displays the percentage of transaction log currently in use similar to the following:
Step 2 Enter the following to exit the command mode:
quit
Sybase requires at least 1 MB of free space for reliable operation. When allocating your disk space, make sure you include this free space.
CiscoWorks database files are preallocated, so they will not visibly grow as you fill the database. As data is added, the access times on the files $NMSROOT/sybase/data/*.dat will change.
To determine the amount of available space in the database, perform the following steps:
Step 1 Enter the following commands:
$SYBASE/bin/isql -Usa -P password
dbcc checkalloc(nms)
go
Output similar to the following appears:
The line of output containing the word "Total" indicates how many pages are used. In this example, the used pages equal 431. In other words, 431 pages are in use. Each page is 2 KB, so the total usage is 862 KB.
Step 2 To check for allocated data and log space in the nms database, enter the following commands:
$SYBASE/bin/isql -Uuser -P
sp_helpdb nms
go
Output similar to the following appears:
size usage
-------------- ---------- -------------------
4.000000 MB log only
In this example, the size of the total database (nms + nms+ nms_data) is 26 MB. Thus, 862 KB out of 26 MB is in use, indicating approximately 3.2 percent utilization.
Step 3 Enter the following command to quit:
quit
To calculate disk space utilization, subtract the transaction log size and the used data space from the total disk space.
This is the free memory available. To calculate available transaction log space, refer to the previous section "Verifying Available Database Space."
The following example calculates the free memory available based on the previous example.
Take the total size of the database and subtract the transaction log size and the data space used for the amount of free disk space available.
Using the estimates in the previous examples, the size of the database is 26 MB (or 26,624 KB), minus the transaction log size of 4 MB (or 4096 KB), minus the used data space of 862 KB, which equals available disk space of 21,666 KB or 81.4 percent available.
Data collected during device polling is stored in the polling table. For example, if you have a table containing 20 MIB objects, the data collected from those 20 objects is stored in the polling table. You should periodically review your need to retain much of this data because its value diminishes rather rapidly, while its consumption of space keeps increasing.
This data can be purged without disturbing the configuration table structure, thereby eliminating the need to destroy the complete table and reconstruct table parameters to reestablish a viable poll base.
There are two methods to purge data: a total purge of the table poll data or a partial erasure. The following procedure uses the SQL delete command through the ISQL interface.
![]() | Warning The preferred method is to use Polling Summary. Do not use the following commands unless you are very familiar with Sybase. |
To purge all data in a table, perform the following steps:
Step 1 To select the database table, enter the following commands:
$SYBASE/bin/isql -Uuser -P password -Sservername
truncate table mytable
go
Mytable is the table name containing the data to be deleted.
Step 2 Enter the following command to exit:
quit
To partially purge table data, perform the following steps:
Step 1 Enter the following commands:
$SYBASE/bin/isql -U user -P password -Sservername
delete mytable
Step 2 Enter the following commands to indicate what data to erase:
where timestamp < "month day year"
go
The timestamp date tells the delete command to erase all data in the file prior to the date entered.
Step 3 Enter the following command to exit SQL:
quit
In most cases, it is unnecessary to alter the transaction log size with the new database setup. You may want to enlarge the transaction log for the following reasons:
There are two ways to increase disk space allocated to the database.
You can display the amount of space currently being used by each table using the dbcc command in isql to verify the tables. For information on how to use the dbcc command, refer to the section "Monitoring Transaction Log Utilization," earlier in this chapter. Do not use the sp_spaceused command because it will not provide accurate information.
To enlarge any CiscoWorks database or transaction log, use the cw_enlarge script.
To enlarge a database or transaction log:
Step 1 Make certain your NMSROOT environment variable is set and enter the following:
The cwconfigure.defs file is used to establish default values.
Step 2 Enter the name of the directory where the Sybase 10 server is installed. Press Return if the default is correct.
Step 3 Enter the name of the Sybase server, for example, CW_SYBASE. Press Return if the default is correct.
A confirmation notice appears stating whether the Sybase server is running. The server is started if it is not currently running.
Step 4 Become the Sybase system administrator and enter the SA password.
Step 5 Select one of the enlarge options:
If you are uncertain which option to use, contact your technical support representative for help on diagnosing your situation.
To enlarge the polldb database (recommended, since the storage requirements for polling data can be quite high), select option 3. If you select this option, you are asked if polldb is the actual name of the database.
To enlarge the polldb transaction log, select option 5. If you select this option, you are asked if polldb is the actual name of the transaction log.
There is no harm in increasing the size of a database or transaction log accidentally. However, an enlarged database or transaction log can never be shrunk, and the disk space required to hold new Sybase device cannot be deleted.
Step 6 Press Return to accept the default enlargement size, or enter a larger number if more space is desired. At least 10 MB must be added.
Step 7 Press Return to accept the default location of the new Sybase device, or enter a new location.
It is recommended that you accept the default (provided space is available on the file system to hold the new device).
Step 8 Press Return to enlarge the selected device. Note the confirmation notices that appear.
Step 9 To start CiscoWorks applications, enter the following command:
To expand the database space allocation using the command sequence method, perform the following steps:
Step 1 Enter the following commands to enlarge your disk space:
$SYBASE/bin/isql -Usa -Ppassword
disk init
name = "nms2",
physname = "../data/nms2.dat"
The name must be a unique name each time the enlarge script is run. Replace
../data/nms2.dat with any filename.
Step 2 To continue, enter the following command:
vdevno = n,
Enter any unique number greater than one. This number must be incremented by one each time the enlarge script is run.
Step 3 To continue, enter the following command:
size = n
Enter the size of disk space wanted in 2-kilobyte (KB) increment blocks. For example, 2 x 4096 = 8 MB.
Step 4 Start the sequence by entering the following command:
go
Step 5 Alter the database by entering the following command:
alter database nms
Substitute your database name for nms.
Step 6 Enter the following command:
on database_name = n
Enter size in megabytes. This number cannot exceed the size specified in the enlarge script. For example, nms2 is a database name and it might be an 8 MB file.
Step 7 Enter the following command to start the sequence:
go
Step 8 Enter the following command to exit:
quit
You can run the alter database portion of the enlarge sequence at any time after the database has been initialized. You do not need to initialize the disk again, unless you want more expansion space allocated than you defined the first time. For example, you run disk init with an expansion setting of 2048 (4 MB) and later attempt to run alter database with a setting of 5 MB. This would not be accepted because the value used in the alter database sequence exceeded the limit established in the disk init sequence.
The transaction log is automatically cleared periodically by the system. You can turn off the automatic clear function and clear the log manually, as well as increase the transaction log space.
If you do not want the log to be cleared automatically, disable the clear function by entering the following commands:
# $SYBASE/bin/isql -Usa -P
1> sp_dboption nms,"trunc.", false
2> go
1> use database_name go
1> checkpoint
2> go
1> quit
![]() | Caution If you plan to use your transaction log as a backup, be certain you do not run the script nmlogreset, or the existing log will be destroyed. |
If the automatic clear function is off, you can turn it on by using the same command sequence, substituting the word true for the word false as the last word in the first line (1>) of the command sequence.
To manually clear the transaction log, enter the following command:
$NMSROOT/etc/nmlogreset
There are two ways to enlarge the transaction log space on your CiscoWorks workstation:
To add space to the transaction log with the sp_extendsegment command, enter the following commands:
$SYBASE/bin/isql -Usa -Ppassword
1> use nms
go
sp_extendsegment logsegment, nmslog
go
A message appears confirming that the transaction log was enlarged.
To add space to the transaction log with the sp_logdevice command, perform the following steps:
Step 1 Enter the following commands to choose a virtual device number:
$SYBASE/bin/isql -Usa -Ppassword
1> sp_helpdevice
2> go
This virtual device number (vdevno) will be used in Step 2. Output similar to the following appears:
In this example, the vdevno is 2.
Step 2 Select a number other than 0, 1, or any other number already used by your database. Record the number.
Step 3 Enter the following commands to create a transaction log file named nmslog:
disk init
2> name = "nmslog",
3> physname = "../data/nmslog.dat",
4> vdevno = n,
5> size = 1024
6> go
Substitute the number you recorded in step 1 for the vdevno option. Size equals the transaction log size in 2-kilobyte (KB) blocks. (The recommended size is
2 MB = 1024 2-KB blocks.)
Step 4 To add more database space, enter the following commands:
alter database nms
2> on nmslog = 2
3> go
The 2 defines the transaction log size in megabytes. The recommended size is 2 MB.
The following message appears:
Step 5 To take the space added in Step 4 and use it as transaction log space, enter the following commands:
sp_logdevice nms,nmslog
2> go
Step 6 To verify that you have created a separate space for the transaction log, enter the command:
sp_helpdb nms
Output similar to the following appears:
Step 7 Enter the following command to exit:
quit
For further details, refer to the Sybase System Administration Guide.
There are two database backup procedures. The first is used to back up CiscoWorks software and database information. Use this method when you first receive your software. The second method is used to back up only data in the database on a regular maintenance schedule by using the backup_nms script.
Follow the backup recommendations and processes described in your network management platform documentation. For detailed information on the UNIX dump, cpio, and tar commands, refer to the appropriate UNIX manual pages.
Because network maps can change frequently, and there could be several different maps, save at least one copy of each map in a separate directory for quick access.
The default name for the Sybase SQL server is CW_SYBASE, and the default name for the backup server is CW_BACKUP_SERVER. Both names are set during the installation of CiscoWorks and are customizable. These names were chosen to guarantee uniqueness in multiserver environments. Once a SQL server name is set, it cannot be changed (unless you reinstall CiscoWorks). It is not possible to change the name of the backup server. However, it is possible to direct the SQL server to use a different backup server. Refer to the Sybase documentation for more information.
The following process describes how cw_backup performs transaction and database backup and verifies that the backup server is running. These processes are invisible to the user. They are provided in order to help you understand the backup process.
The backup server name Backup Server is running on hostname.
If the server fails to reboot, the following confirmation notice appears.
Failed to boot the backup server name Backup Server. Note messages printed to screen and contact your system administrator. Exiting.
If this happens, cw_backup is unable to run and exits.
Perform backups of the CiscoWorks databases frequently to allow recovery from data loss or file damage. Maintain the following minimum backup strategy:
Step 1 Make certain your $NMSROOT environment variable is set and enter the following:
The cwconfigure.defs file is used to establish default values.
Step 2 Enter the name of the directory where the Sybase 10 server is installed. Press Return if the default is correct.
Step 3 Enter the name of the Sybase server, for example, CW_SYBASE. Press Return if the default is correct.
A confirmation notice appears stating whether the Sybase server is running. The server is started if it is not currently running.
Step 4 Become the Sybase system administrator and enter the SA password.
The backup server must be running for cw_backup to work. cw_backup will attempt to locate the Backup Server and start it if it is not running.
Step 5 Enter the name of the directory where the Sybase Backup Server is installed. Press Return if the default is correct.
Step 6 Enter the name of the Sybase Backup Server. Press Return if the default is correct.
Step 7 Select from the following backup options:
Step 8 Select the destination of the dump file (disk or tape drive).
We recommend using the disk dump file option.
Step 9 Press Return to accept the default, or specify a new directory path to store the dump file.
If you have to recreate your database, run the CiscoWorks $NMSROOT/etc/cw_recover script to perform the recovery. Refer to the section "Backing Up the Database" before continuing.
To recover a database:
Step 1 Log in as superuser.
Step 2 Make certain your $NMSROOT environment variable is set and enter the following.
The cwconfigure.defs file is used to establish default values.
Step 3 Enter the name of the Sybase home directory.
You can accept the default choice for each question by pressing Return.
Step 4 Enter the Sybase server name.
Step 5 Become the SA and enter the SA Password.
Step 6 Enter the name of the backup server home directory.
There is no backup server the first time you run this script. The backup server is created automatically when you choose the default name, CW_BACKUP_SERVER.
Step 7 Select from the following recovery options:
Step 8 Enter the actual name of the database for the database option you have selected.
Step 9 Tell any users who are currently logged into the database to log off.
The script provides a list of currently logged in users.
Step 10 Select the device where the dump file is located (disk or tape drive).
Step 11 Select the path where the dump file currently resides.
If you used cw_backup to store your files to a disk, enter the path and file name. For example:
If you used cw_backup to write your files to tape, enter the device name. For example:
cw_recover uses this information to locate the database or transaction log dump files and begins the recovery process. Confirmation notices appear informing you of the recovery process status and completion.
Step 12 To start CiscoWorks applications, enter the following command:
This section describes how to move the database from one server to another. The servers can be in the same physical workstation or in different workstations. This procedure is for installations that have a preexisting Sybase database.
Use the $NMSROOT/etc/cw_move_db script to copy a database from one location to another location. You can move your database from one server to another server/host on the network or you can move the database to another Sybase server on the same host. Migrating a database from one Sybase server to another on the same host is called a local migration. You can also use this script to move a database running on UNIX files to a database running on raw partitions.
The script must be run by root from the machine where the destination Sybase server is running. The $SYBASE environment variable should be set to the destination SQL server root directory. The interface file in the $SYBASE directory should contain entries for both the source and destination SQL servers and their backup servers. The destination backup server must be contained in both the source and destination interfaces files and must be the name contained within the -s switch within the destination $SYBASE/install/RUNSERVER_BACKUP file. Each SQL server must have an entry in its syssswervers table for its local backup server. The name in the srvnetname column must match the name in the interfaces file.
The Sybase SQL server versions must be compatible. See the Sybase SQL server release notes for more information.
The utility will create a corresponding device on the destination SQL server for every device on the source SQL server that is in use by the source database. You must make sure that your destination SQL server is configured to be able to create the necessary devices.
If you are creating devices on raw partitions, see the appropriate section in the Sybase system administration manual regarding raw partitions.
To move a database:
Step 1 Become root on the system with the database you want to move.
Step 2 Enter the following command:
If the $SYBASE environment variable is not set, the script notifies you and terminates.
Step 3 Enter the correct response when the script asks you whether this is a local migration (staying on the same server) or a migration to a different server.
Step 4 Provide the name of the destination server.
Step 5 Provide the SA password for the destination server.
Step 6 Provide the name of the source server.
Step 7 Provide the SA password for the source server.
Step 8 Provide the name of the source database.
Step 9 Provide the name of the destination database.
A database must not already exist on the destination server with the name of the database that the user provided.
Step 10 Confirm that the displayed values are correct.
Step 11 Indicate whether you want to continue after the source device name appears.
Step 12 Provide the destination device name.
Raw devices and files are permitted. A raw device must not already be in use. A size check is performed for the selected device (both for raw and file). An existence check is performed on files, and if a file is found, you may delete it. If there are not enough device numbers available on the Sybase SQL server, you will be asked to contact the Sybase system administrator, and the script will terminate.
Step 13 Provide the name of a working directory to temporarily store the database dump from the source machine.
This directory must have the appropriate write permissions. (/tmp is the default directory.)
Several CiscoWorks applications use the example polling tables named sample. If you write over the sample tables or accidentally delete them, you can recreate them using the makesample script. The makesample script recreates the following tables: sample_mix, sample_traffic, and sample_error.
You can choose which variables to poll in the sample tables by selecting the pick menus located in the Device Polling fields. For more information on the sample tables, refer to the section "Creating a New Polling Table" in Chapter 3.
To recreate your sample tables, perform the following steps:
Step 1 Enter the following command:
$NMSROOT/etc/makesample -Unmsuper -Ppassword
A message confirming the recreation of the sample tables appears.
Step 2 Verify that the sample tables were copied into Sybase by restarting the Polling Summary application.
The sample tables will appear in the Poll Groups scroll window.
|
|