Sybase Technical Library - Product Manuals Home
[Search Forms] [Previous Section with Hits] [Next Section with Hits] [Clear Search] Expand Search

Chapter 1: Introduction [Table of Contents] Chapter 3: Configuring the Operating System for Adaptive Server

Configuring Adaptive Server Enterprise for UNIX Platforms

[-] Chapter 2: Starting and Stopping Adaptive Server and Backup Server

Chapter 2

Starting and Stopping Adaptive Server and Backup Server

This chapter describes how to start and stop Adaptive Server and Backup Server.

Topics covered are:

Introduction

After you create or upgrade Adaptive Server (using srvbuild or sqlupgrade), Adaptive Server and Backup Server are running.

The methods described here are used to start Adaptive Server and Backup Server after a shutdown for database maintenance, because of an operating system crash, or for some other reason.

You can start Adaptive Server and Backup Server in three ways:

Starting and Stopping Servers Using Sybase Central

For information on how to use Sybase Central to start, stop, and manage Adaptive Server, see Managing and Monitoring Sybase Adaptive Server Enterprise.

Starting Servers at the UNIX Command Line

This section discusses how to use runserver files and the startserver command to start Adaptive Server or Backup Server from the UNIX command line. It also describes how to move the Adaptive Server shared memory files by adding a flag to the runserver file.

Note: Do not delete the runserver file that is created in $SYBASE/install. This file is used to restart servers when you customize your installation. If you need the runserver file in another location, make a copy of the original runserver file in the new location.

Using the Runserver File

Each time a new Adaptive Server or Backup Server is installed, the srvbuild program creates a runserver file that contains the information required to restart that server. Runserver files are created in the $SYBASE/install directory. The runserver file is named RUN_servername, where servername is the name of the server.

For example, the runserver file name for an Adaptive Server named TEST is RUN_TEST, and the runserver file name for an Adaptive Server named PRACTICE is RUN_PRACTICE.

Note: The runserver file for a server named SYBASE is named RUN_SYBASE.
If the runserver file for your current Adaptive Server is named RUNSERVER, sqlupgrade renames it to RUN_SYBASE during the upgrade process.

Using the startserver Command

Use the following command to start a server from the command line:

$SYBASE/install/startserver [ -f runserverfile ]

where $SYBASE/install/startserver is the full path name of the startserver utility, and runserverfile is the full path name of the runserver file (usually $SYBASE/install/RUN_servername).

If your Adaptive Server is named SYBASE, the runserver file specification is optional.

You must have read and write permissions on the master device for an Adaptive Server in order to start it with startserver. See Utility Programs for UNIX Platforms for more information about startserver.

Although startserver runs Adaptive Server in the background, it does not return to the operating system prompt after restarting. After Adaptive Server has been restarted, press Return to return to the operating system prompt.

Starting Servers When the Operating System Restarts

On production systems, Adaptive Server and Backup Server should restart automatically when the UNIX operating system starts. This section describes how to configure your operating system for automatic restart on the following platforms:

Digital UNIX

To enable automatic restart:

  1. Verify that all network resources are available before you start Adaptive Server or Backup Server. Your server cannot start if the network is down.

  2. Verify that the entry in the rc (run control) directory for restarting the server follows any commands for starting network operations.

  3. Designate a period of time for your server to wait before starting, by inserting a sleep command at the beginning of the linked runserver file you created. Slow start-up of network operations can prevent servers from starting, even when the commands are in the correct order in the rc directory.

To start Adaptive Server or Backup Server automatically:

  1. Create a start-up script file like the following. The start-up file is a Bourne shell script. You must use Bourne shell conventions in this file, even if you use the C shell for other tasks.

    #!/sbin/sh
    # start a SYBASE Adaptive Server on system reboot
    # set SYBASE to the path of the sybase directory
    # set RUNSERVER to the name of the runserver file
    # for the Adaptive Server
    # set BSERVER to the name of the runserver file
    # for the backup server
    #
    SYBASE=/sybase/rel115
    RUNSERVER=RUN_REL115_XYZ
    BSERVER=RUN_REL115_XYZ_BACKUP
    PATH=/sbin:/usr/sbin:/usr/bin
    #
    export PATH SYBASE RUNSERVER BSERVER
    #
    case "$1" in
    'start')
    echo "Starting Sybase Adaptive Server"
    nohup su sybase -c \
    "$SYBASE/install/startserver -f
    $SYBASE/install/$RUNSERVER >/dev/null &"
    echo "Starting Sybase Backup Server"
    nohup su sybase -c \
    "$SYBASE/install/startserver -f $SYBASE/install/$BSERVER >/dev/null &"
    ;;
    *)
    echo "Usage: $0 {start}"
    ;;
    esac
  2. Copy the script to the /sbin/init.d directory, using syntax like the following:

    cp script_name /sbin/init.d/script_name
  3. Review the "initdefault" entry in the /etc/inittab file to determine the default run level for your operating system. The default run level is usually 2 or 3.

  4. Use the ln command to create a hard link from the runserver file to the appropriate run control (rc) directory, rc#, where # is the default run level obtained in step 3. Use syntax like the following:

    ln /sbin/init.d/script_name /sbin/rc#.d/S##script_name
    When you type the command to create the link, add an uppercase "S" and a 2-digit sequence number preceding the name of the script file. "S" indicates a start-up file. The sequence number is necessary because files in the rc directory are executed in numeric order. This file should be executed last, so use a number that comes after all existing numbers in ASCII sort order.

    You can perform an ls command on the rc directory to view existing numbers. For example:

    ls /sbin/rc3.d/S* 
    returns the following results:

    /sbin/rc3.d/S10syslog
    /sbin/rc3.d/S15nfs.server
    /sbin/rc3.d/S21rfs
    If your script is named sybstart, type a command like the following:

    ln /sbin/init.d/sybstart /sbin/rc3.d/S99sybstart
    In this example, you can use any number greater than 21 in place of 99.

HP-UX

With HP-UX versions 10 .0 and later, you cannot edit commands in the /etc/rc file so the System Administrator must create a script that executes when the operating system starts or shuts down.

Refer to the HP-UX UNIX manual page for rc (1M) for additional help. You can model your script after the HP-UX template file /sbin/init.d/template.

After creating the start-up and shutdown script, place it in the directory /sbin/init.d. Execution scripts placed in this directory have symbolic links to directories /sbin/rcn.d where n is the system runlevel. The linked scripts in /sbin/rcn.d are used to control the sequencing order of the execution scripts.

IBM RS/6000

On production systems, Adaptive Server can be restarted automatically whenever the UNIX operating system restarts. To have Adaptive Server restart automatically, place the startserver command in the /etc/inittab file.

Following is a suggested format for an Adaptive Server start-up command to add to /etc/inittab:

"sybase:2:wait:/release_directory/install/startserver -f \ RUN_servername /dev/console 2>&1"

Where release_directory is the full path to the Sybase installation directory (specified as the SYBASE environment variable), and RUN_servername is the runserver file for the server you are starting.

Make sure that the entry for starting Adaptive Server follows any entry for /etc/rc.tcpip and /etc/rc.nfs in the /etc/inittab file. All network resources must be available before you start Adaptive Server; otherwise Adaptive Server will not start. Your server will not start if the network is not up.

Slow start-up of network operations can also prevent Adaptive Server from starting, even when the commands in the /etc/rc.tcpip file are in the correct order. You can designate a period of time for Adaptive Server to wait before starting by inserting a sleep command before the server start-up command in the runserver file. The sleep command is in the form:

sleep seconds_of_rest
Note: To enable restart of a Backup Server at the operating system restart, add a Backup Server start-up command to /etc/inittab. Use the path of the Backup Server runserver file in this command.

Sun Solaris 2.x

Before you set Adaptive Server or Backup Server to start automatically, make sure that all network resources are available. Your server will not start if the network is not up. Be sure that the entry for restarting the server follows any commands in the rc directory for starting network operations. Slow start-up of network operations can prevent servers from starting, even if commands are in the correct order in the rc directory. You may want to designate a period of time for your server to wait before starting by inserting a sleep command at the beginning of the linked runserver file you created.

To have Adaptive Server or Backup Server start automatically:

  1. Create a start-up script file with contents like the following:

    $SYBASE/install/startserver -f $SYBASE/install/RUN_servername
    where $SYBASE/install/startserver is the full path name of the startserver utility, and $SYBASE/install/RUN_servername is the full path name of the runserver file for the server.

  2. Copy the script to the /etc/init.d directory, using syntax like the following:

    cp script_name /etc/init.d/script_name
  3. Review the contents of the /etc/inittab file to determine the default run level for your operating system. The initdefault entry specifies the default run level, which is usually 2 or 3.

  4. Use the ln command to create a hard link from the runserver file to the appropriate run control (rc) directory, rc#, where # is the default run level obtained in step 2. Use syntax like the following:

    ln /etc/init.d/script_name /etc/rc#.d/S##script_name
    When you type the command to create this link, add an uppercase "S" and a 2-digit sequence number preceding the name of the script file. "S" indicates a start-up file. The sequence number is necessary because files in the rc directory are executed in order of their numbers. This file should be executed last, so you should use a sequence number that follows all existing numbers in ASCII order.

    You can perform an ls command on the rc directory to view existing sequence numbers. For example:

    ls /etc/rc3.d/S* 
    returns the following results:

    /etc/rc3.d/S10syslog
    /etc/rc3.d/S15nfs.server
    /etc/rc3.d/S21rfs
    If your script is named sybstart, type the following:

    ln /etc/init.d/sybstart /etc/rc3.d/S77sybstart
    In this example, you could use any number greater than 21 in place of 77.

Shutting Down Adaptive Server and Backup Server

The preferred method of stopping Adaptive Server or Backup Server is to use the Transact-SQL shutdown command. Only the System Administrator has permission to issue shutdown. Using the shutdown command minimizes the amount of work that automatic recovery needs to do when Adaptive Server or Backup Server is restarted.

Shutting Down Adaptive Server

To shut down Adaptive Server, specify the server name with the shutdown command:

  1. Use isql to log into an Adaptive Server account with System Administrator privileges:

    isql -Usa -Ppassword -Sserver_name
  2. Enter the following command to shut down the server:

    1> shutdown server_name
    2> go

The default for the shutdown command is with wait. The with wait option allows Adaptive Server to finish executing SQL statements or procedures, perform a checkpoint in each database, disable new logins, and other shutdown duties.

Issuing the shutdown command prints a message like this to sterr:

Adaptive Server SHUTDOWN by request.The Adaptive Server is terminating this process.
DB-Library: Unexpected EOF from Adaptive Server.

This is normal behavior. If the message indicates that Adaptive Server is waiting for processes to complete, and you need to stop Adaptive Server immediately, you can use the shutdown with nowait command. shutdown with nowait does not wait for currently executing statements to finish and does not perform checkpoints in every database.

Shutting Down Backup Server

To shut down a Backup Server, specify the Backup Server name with the Transact-SQL shutdown command:

  1. Use isql to log into a Sybase account with System Administrator privileges:

    % isql -Usa -Ppassword -Sserver_name
  2. Enter the following command to shut down the specified Backup Server:

    1> shutdown SYB_BACKUP
    2> go

When you use the shutdown command to stop a Backup Server, specify the srvname listed in sysservers for Backup Server. The default Backup Server srvname is SYB_BACKUP.

After you shut down a Backup Server, you must wait at least 30 seconds before restarting it.

Issuing the shutdown command prints a message similar to the following to the stderr file:

Adaptive Server SHUTDOWN by request.The Adaptive Server is terminating this process.
DB-Library: Unexpected EOF from Adaptive Server.

This is normal behavior. If a message indicates that Adaptive Server or Backup Server is waiting for processes to complete, and you need to stop Adaptive Server or Backup Server immediately, you can use the shutdown with nowait command. shutdown with nowait does not wait for currently executing statements to finish and does not perform checkpoints in every database.

Using shutdown with nowait for Backup Server can cause inconsistent or incomplete dumps and loads. Use this command only when necessary.

For more information on the shutdown command, see the Adaptive Server Reference Manual.

The kill Command

Use the kill command on Adaptive Server and Backup Server only as a last resort. When possible, use the Transact-SQL shutdown or shutdown with nowait command. Do not use kill with the -9 flag because it exits the server without running a checkpoint to assure that all database changes are written to the database device. Adaptive Server may also exit without removing associated shared memory files and network handlers.

Because Adaptive Server and Backup Server are background processes, they can be killed from the operating system by their owner or by "root" with the UNIX kill command. The syntax is:

kill pid

where pid is the process identification of any dataserver process, as determined by the showserver command. Killing one engine for a particular Adaptive Server kills all engines for that server.

If more than one Adaptive Server is running on the same system, you must be careful that the engine you kill is associated with the correct Adaptive Server. See "Monitoring Adaptive Server and Backup Server" in Chapter 11, "Administrative and Monitoring Tasks," for details on how to tell whether a dataserver process is associated with a particular Adaptive Server.

Shutdown and Shared Memory Files

When Adaptive Server starts, it creates the following files in $SYBASE to store information about the shared memory segments that it uses:

For Digital UNIX, HP-UX, and IBM RS/6000:

SERVER_NAME.krg
SERVER_NAME.srg0

For Sun Solaris:

SERVER_NAME.krg

When Adaptive Server is shut down in a normal manner, the shared memory files are automatically removed. If Adaptive Server crashes or is stopped with the kill -9 command, these files are not deleted. You need read and write permissions on these files to restart Adaptive Server after a crash or a kill -9 command, as Adaptive Server must be able to overwrite the previously created shared memory files.


Chapter 1: Introduction [Table of Contents] Chapter 3: Configuring the Operating System for Adaptive Server