Sybase ASE System and Database Administration, Unix Lab Workbook - Sybase - Sybase, 2006
Sybase ASE System and Database Administration, Unix Lab Workbook - Sybase - Sybase, 2006
Module 6: Initializing and Using Devices Module 6: Initializing and Using Devices
Lab 6: Initializing and Using Devices ..........................................................................................Lab 6-1 Lab 6: Initializing and Using Devices ..........................................................................................Lab 6-1
Detailed Instructions ....................................................................................................................Lab 6-2 Detailed Instructions ....................................................................................................................Lab 6-2
Module 7: Creating and Using Databases Module 7: Creating and Using Databases
Lab 7: Creating and Using Databases...........................................................................................Lab 7-1 Lab 7: Creating and Using Databases...........................................................................................Lab 7-1
Detailed Instructions ....................................................................................................................Lab 7-2 Detailed Instructions ....................................................................................................................Lab 7-2
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 TOC - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 TOC - 1
Module 8: Suggested Disk Resource Strategies Module 8: Suggested Disk Resource Strategies
Lab 8: Using Free Space Thresholds............................................................................................Lab 8-1 Lab 8: Using Free Space Thresholds............................................................................................Lab 8-1
Detailed Instructions ....................................................................................................................Lab 8-2 Detailed Instructions ....................................................................................................................Lab 8-2
Module 11: Administering System Roles and Logins Module 11: Administering System Roles and Logins
Lab 11: Administering System Roles and Logins.........................................................................Lab 11-1 Lab 11: Administering System Roles and Logins.........................................................................Lab 11-1
Detailed Instructions ....................................................................................................................Lab 11-2 Detailed Instructions ....................................................................................................................Lab 11-2
Module 12: Managing Database Users and Groups Module 12: Managing Database Users and Groups
Lab 12: Managing Database Users and Groups ...........................................................................Lab 12-1 Lab 12: Managing Database Users and Groups ...........................................................................Lab 12-1
Detailed Instructions ....................................................................................................................Lab 12-2 Detailed Instructions ....................................................................................................................Lab 12-2
Module 13: Implementing Roles, Object Permissions, and Groups Module 13: Implementing Roles, Object Permissions, and Groups
Lab 13: Implementing Roles, Object Permissions, and Groups ...................................................Lab 13-1 Lab 13: Implementing Roles, Object Permissions, and Groups ...................................................Lab 13-1
Detailed Instructions ....................................................................................................................Lab 13-2 Detailed Instructions ....................................................................................................................Lab 13-2
Module 14: Using Bulk Copy Utility Module 14: Using Bulk Copy Utility
Lab 14: Using Bulk Copy Utility .................................................................................................Lab 14-1 Lab 14: Using Bulk Copy Utility .................................................................................................Lab 14-1
Detailed Instructions ....................................................................................................................Lab 14-2 Detailed Instructions ....................................................................................................................Lab 14-2
Module 15: Overview of Automatic Recovery Module 15: Overview of Automatic Recovery
Lab 15: Overview of Automatic Recovery...................................................................................Lab 15-1 Lab 15: Overview of Automatic Recovery...................................................................................Lab 15-1
Detailed Instructions ....................................................................................................................Lab 15-2 Detailed Instructions ....................................................................................................................Lab 15-2
Module 16: Checking and Fixing Database Consistency Module 16: Checking and Fixing Database Consistency
Lab 16: Checking and Fixing Database Consistency....................................................................Lab 16-1 Lab 16: Checking and Fixing Database Consistency....................................................................Lab 16-1
Detailed Instructions ....................................................................................................................Lab 16-2 Detailed Instructions ....................................................................................................................Lab 16-2
TOC - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. TOC - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
System and Database Administration: Adaptive Server Enterprise System and Database Administration: Adaptive Server Enterprise
Module 17: Planning for Backups Module 17: Planning for Backups
Lab 17: Planning for Backups ......................................................................................................Lab 17-1 Lab 17: Planning for Backups ......................................................................................................Lab 17-1
Detailed Instructions ....................................................................................................................Lab 17-2 Detailed Instructions ....................................................................................................................Lab 17-2
Module 19: Practicing Advanced Backup Techniques Module 19: Practicing Advanced Backup Techniques
Lab 19: Practicing Advanced Backup Techniques.......................................................................Lab 19-1 Lab 19: Practicing Advanced Backup Techniques.......................................................................Lab 19-1
Detailed Instructions ....................................................................................................................Lab 19-2 Detailed Instructions ....................................................................................................................Lab 19-2
Module 21: Monitoring the System Module 21: Monitoring the System
There are no labs in this module...................................................................................................Lab 21-1 There are no labs in this module...................................................................................................Lab 21-1
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 TOC-3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 TOC-3
Module 6: Initializing and Using Devices Module 6: Initializing and Using Devices
Lab 6: Initializing and Using Devices ..........................................................................................Lab Solution 6-1 Lab 6: Initializing and Using Devices ..........................................................................................Lab Solution 6-1
Detailed Instructions and Solutions..............................................................................................Lab Solution 6-2 Detailed Instructions and Solutions..............................................................................................Lab Solution 6-2
Module 7: Creating and Using Databases Module 7: Creating and Using Databases
Lab 7: Creating and Using Databases...........................................................................................Lab Solution 7-1 Lab 7: Creating and Using Databases...........................................................................................Lab Solution 7-1
Detailed Instructions and Solutions..............................................................................................Lab Solution 7-2 Detailed Instructions and Solutions..............................................................................................Lab Solution 7-2
Module 8: Suggested Disk Resource Strategies Module 8: Suggested Disk Resource Strategies
Lab 8: Using Free Space Thresholds............................................................................................Lab Solution 8-1 Lab 8: Using Free Space Thresholds............................................................................................Lab Solution 8-1
Detailed Instructions and Solutions..............................................................................................Lab Solution 8-2 Detailed Instructions and Solutions..............................................................................................Lab Solution 8-2
Module 11: Administering System Roles and Logins Module 11: Administering System Roles and Logins
Lab 11: Administering System Roles and Logins.........................................................................Lab Solution 11-1 Lab 11: Administering System Roles and Logins.........................................................................Lab Solution 11-1
Detailed Instructions and Solutions..............................................................................................Lab Solution 11-2 Detailed Instructions and Solutions..............................................................................................Lab Solution 11-2
Module 12: Managing Database Users and Groups Module 12: Managing Database Users and Groups
Lab 12: Managing Database Users and Groups ...........................................................................Lab Solution 12-1 Lab 12: Managing Database Users and Groups ...........................................................................Lab Solution 12-1
Detailed Instructions and Solutions..............................................................................................Lab Solution 12-2 Detailed Instructions and Solutions..............................................................................................Lab Solution 12-2
TOC - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. TOC - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
System and Database Administration: Adaptive Server Enterprise System and Database Administration: Adaptive Server Enterprise
Module 13: Implementing Roles, Object Permissions, and Groups Module 13: Implementing Roles, Object Permissions, and Groups
Lab 13: Implementing Roles, Object Permissions, and Groups ...................................................Lab Solution 13-1 Lab 13: Implementing Roles, Object Permissions, and Groups ...................................................Lab Solution 13-1
Detailed Instructions and Solutions..............................................................................................Lab Solution 13-2 Detailed Instructions and Solutions..............................................................................................Lab Solution 13-2
Module 14: Using Bulk Copy Utility Module 14: Using Bulk Copy Utility
Lab 14: Using Bulk Copy Utility .................................................................................................Lab Solution 14-1 Lab 14: Using Bulk Copy Utility .................................................................................................Lab Solution 14-1
Detailed Instructions and Solutions..............................................................................................Lab Solution 14-2 Detailed Instructions and Solutions..............................................................................................Lab Solution 14-2
Module 15: Overview of Automatic Recovery Module 15: Overview of Automatic Recovery
Lab 15: Overview of Automatic Recovery...................................................................................Lab Solution 15-1 Lab 15: Overview of Automatic Recovery...................................................................................Lab Solution 15-1
Detailed Instructions and Solutions..............................................................................................Lab Solution 15-2 Detailed Instructions and Solutions..............................................................................................Lab Solution 15-2
Module 16: Checking and Fixing Database Consistency Module 16: Checking and Fixing Database Consistency
Lab 16: Checking and Fixing Database Consistency....................................................................Lab Solution 16-1 Lab 16: Checking and Fixing Database Consistency....................................................................Lab Solution 16-1
Detailed Instructions and Solutions..............................................................................................Lab Solution 16-2 Detailed Instructions and Solutions..............................................................................................Lab Solution 16-2
Module 17: Planning for Backups Module 17: Planning for Backups
Lab 17: Planning for Backups ......................................................................................................Lab Solution 17-1 Lab 17: Planning for Backups ......................................................................................................Lab Solution 17-1
Detailed Instructions and Solutions..............................................................................................Lab Solution 17-2 Detailed Instructions and Solutions..............................................................................................Lab Solution 17-2
Module 19: Practicing Advanced Backup Techniques Module 19: Practicing Advanced Backup Techniques
Lab 19: Practicing Advanced Backup Techniques.......................................................................Lab Solution 19-1 Lab 19: Practicing Advanced Backup Techniques.......................................................................Lab Solution 19-1
Detailed Instructions and Solutions..............................................................................................Lab Solution 19-2 Detailed Instructions and Solutions..............................................................................................Lab Solution 19-2
Module 21: Monitoring the System Module 21: Monitoring the System
There are no labs in this module...................................................................................................Lab Solution 21-1 There are no labs in this module...................................................................................................Lab Solution 21-1
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 TOC-5 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 TOC-5
TOC - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. TOC - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 1: Introducing Adaptive Server Module 1: Introducing Adaptive Server
There are no labs in this module There are no labs in this module
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 1 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 1 - 1
Lab 1 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 1 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 2: Installing Servers Module 2: Installing Servers
Lab setup This is a pencil-and-paper activity. Lab setup This is a pencil-and-paper activity.
Objectives Answer questions about the ASE operating environment. Objectives Answer questions about the ASE operating environment.
Description In this lab, you will learn ASE operating environment. Description In this lab, you will learn ASE operating environment.
Task Outline 1. Answering the questions regarding file locations, RUNSERVER file and how to start Task Outline 1. Answering the questions regarding file locations, RUNSERVER file and how to start
and stop servers. and stop servers.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 2 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 2 - 1
Task 1: Answering the questions regarding file locations, Task 1: Answering the questions regarding file locations,
RUNSERVER file and how to start and stop servers RUNSERVER file and how to start and stop servers
Description In this task, you will answer the questions regarding file locations, RUNSERVER file and Description In this task, you will answer the questions regarding file locations, RUNSERVER file and
how to start and stop servers. how to start and stop servers.
Procedure 1. For each type of ASE file listed below, identify its default location. Procedure 1. For each type of ASE file listed below, identify its default location.
a. The interfaces file: a. The interfaces file:
b. The RUNSERVER file: b. The RUNSERVER file:
c. The ASE errorlog: c. The ASE errorlog:
d. The ASE configuration (.cfg) file: d. The ASE configuration (.cfg) file:
2. Given the following contents of a RUNSERVER file, answer the following questions. 2. Given the following contents of a RUNSERVER file, answer the following questions.
#!/bin/sh #!/bin/sh
# #
# ASE page size (KB): 2K # ASE page size (KB): 2K
# Master device path: /home/usr/u/bur301/ASE- # Master device path: /home/usr/u/bur301/ASE-
12_5/devices/2Kmaster.dat 12_5/devices/2Kmaster.dat
# Error log path: /deltadisk/home/bur301/ASE- # Error log path: /deltadisk/home/bur301/ASE-
12_5/install/BUR301_2K.log 12_5/install/BUR301_2K.log
# Configuration file path: /deltadisk/home/bur301/ASE- # Configuration file path: /deltadisk/home/bur301/ASE-
12_5/BUR301_2K.cfg 12_5/BUR301_2K.cfg
# Directory for shared memory files: /deltadisk/home/bur301/ASE- # Directory for shared memory files: /deltadisk/home/bur301/ASE-
12_5 12_5
# Adaptive Server name: BUR301_2K # Adaptive Server name: BUR301_2K
# #
/deltadisk/home/bur301/ASE-12_5/bin/dataserver \ /deltadisk/home/bur301/ASE-12_5/bin/dataserver \
-d/home/usr/u/bur301/ASE-12_5/devices/2Kmaster.dat \ -d/home/usr/u/bur301/ASE-12_5/devices/2Kmaster.dat \
-e/deltadisk/home/bur301/ASE-12_5/install/BUR301_2K.log \ -e/deltadisk/home/bur301/ASE-12_5/install/BUR301_2K.log \
-c/deltadisk/home/bur301/ASE-12_5/BUR301_2K.cfg \ -c/deltadisk/home/bur301/ASE-12_5/BUR301_2K.cfg \
-M/deltadisk/home/bur301/ASE-12_5 \ -M/deltadisk/home/bur301/ASE-12_5 \
-sBUR301_2K \ -sBUR301_2K \
a. What is the name of the Adaptive Server associated with this RUNSERVER file? a. What is the name of the Adaptive Server associated with this RUNSERVER file?
b. What is the physical path to the master device? b. What is the physical path to the master device?
c. What is the name of the master device file for this server? c. What is the name of the master device file for this server?
d. What is the path and file name for the ASE errorlog? d. What is the path and file name for the ASE errorlog?
e. What is the path and file name for the ASE configuration file? e. What is the path and file name for the ASE configuration file?
3. How can you determine if Adaptive Server is running? 3. How can you determine if Adaptive Server is running?
4. How can you start and stop Adaptive Server? 4. How can you start and stop Adaptive Server?
Lab 2 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 2 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 3: Establishing Connectivity Module 3: Establishing Connectivity
Lab setup The first section is a pencil-and-paper activity. Lab setup The first section is a pencil-and-paper activity.
The second section has hands-on activities to perform. The second section has hands-on activities to perform.
You will be using your 2K-page size Adaptive Server for this lab. You will be using your 2K-page size Adaptive Server for this lab.
Objectives After completing this lab, you should be able to: Objectives After completing this lab, you should be able to:
Analyze the content and format of sample interfaces files Analyze the content and format of sample interfaces files
Establish a client connection to Adaptive Server Establish a client connection to Adaptive Server
Description In this lab, you will learn how to analyze the content and format of interfaces file. You will Description In this lab, you will learn how to analyze the content and format of interfaces file. You will
also learn to establish a client connection to Adaptive Server. also learn to establish a client connection to Adaptive Server.
Task outline 1. Comparing two interfaces file to debug a connectivity problem Task outline 1. Comparing two interfaces file to debug a connectivity problem
2. Starting up Adaptive Server and establishing a client connection 2. Starting up Adaptive Server and establishing a client connection
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 3 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 3 - 1
Task 1: Compare Two Interfaces File to Debug a Connectivity Task 1: Compare Two Interfaces File to Debug a Connectivity
Problem Problem
Description In this task, you will analyze the content and format of sample interfaces files. Description In this task, you will analyze the content and format of sample interfaces files.
Procedure Scenario: You have just assumed responsibility for administering an Adaptive Server Procedure Scenario: You have just assumed responsibility for administering an Adaptive Server
named GALILEO. The server resides on a Unix host named jupiter2 using TCP/IP and named GALILEO. The server resides on a Unix host named jupiter2 using TCP/IP and
Unix sockets. The previous System Administrator installed the server on one machine, and Unix sockets. The previous System Administrator installed the server on one machine, and
completed two client installations on two other machines. The previous administrator had completed two client installations on two other machines. The previous administrator had
done some editing of the interfaces files, and now neither client is able to connect to the done some editing of the interfaces files, and now neither client is able to connect to the
server. Study the interfaces files that appear below. server. Study the interfaces files that appear below.
interfaces on machine #1 (server): interfaces on machine #1 (server):
GALILEO GALILEO
master tcp ether jupiter2 4697 master tcp ether jupiter2 4697
query tcp ether jupiter2 4697 query tcp ether jupiter2 4697
interfaces on machine #2 (client): interfaces on machine #2 (client):
GALILEO GALILEO
master tcp ether jupiter2 4697 master tcp ether jupiter2 4697
interfaces on machine #3 (client): interfaces on machine #3 (client):
GALILEO GALILEO
query tcp ether jupiter2 4967 query tcp ether jupiter2 4967
1. Describe the changes you need to make to establish connectivity for both clients on 1. Describe the changes you need to make to establish connectivity for both clients on
machine #2 and machine #3. machine #2 and machine #3.
Lab 3 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 3 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 3: Establishing Connectivity Module 3: Establishing Connectivity
Task 2: Start up Adaptive Server and Establish a Client Task 2: Start up Adaptive Server and Establish a Client
Connection Connection
Description In this task, you first determine whether Adaptive Server is up and running and then start Description In this task, you first determine whether Adaptive Server is up and running and then start
up Adaptive Server and establish a client connection. up Adaptive Server and establish a client connection.
In this section, you will establish connectivity from your Windows workstation to In this section, you will establish connectivity from your Windows workstation to
Procedure Procedure
your 2K page size Adaptive Server running on the classroom Unix machine. your 2K page size Adaptive Server running on the classroom Unix machine.
Your instructor will provide the following information: Your instructor will provide the following information:
For all labs, you should open two windows (“A” and “B”). Unless For all labs, you should open two windows (“A” and “B”). Unless
instructed otherwise, perform all lab exercises in Window A. instructed otherwise, perform all lab exercises in Window A.
You use Window B primarily as a console for starting up Adaptive You use Window B primarily as a console for starting up Adaptive
Server and executing OS commands. All Adaptive Server system Server and executing OS commands. All Adaptive Server system
messages are displayed there instead of in your active ASE client messages are displayed there instead of in your active ASE client
window. window.
1. Open the “Select a UNIX Host” icon on the PC desktop. 1. Open the “Select a UNIX Host” icon on the PC desktop.
The Instructor will provide the name of the Unix host system to The Instructor will provide the name of the Unix host system to
which you should connect and the User ID and password that you which you should connect and the User ID and password that you
will use for the class. will use for the class.
Fill in the Host name, your User ID, and Password to open an xterm Fill in the Host name, your User ID, and Password to open an xterm
window from the Unix server. window from the Unix server.
Click “OK” to open Window A. Click “OK” to open Window A.
Repeat the process to open Window B. Repeat the process to open Window B.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 3 - 3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 3 - 3
2. In Window B, examine the Unix environment. 2. In Window B, examine the Unix environment.
a. Verify that you have logged into the Unix server with the correct login name by a. Verify that you have logged into the Unix server with the correct login name by
examining the setting for the $LOGNAME environment variable. (The solutions examining the setting for the $LOGNAME environment variable. (The solutions
are for student dub101.) are for student dub101.)
b. What is the $HOME variable set to? b. What is the $HOME variable set to?
c. What is the $SYBASE variable set to? c. What is the $SYBASE variable set to?
What is the relationship between your $HOME and $SYBASE What is the relationship between your $HOME and $SYBASE
directories? directories?
d. Confirm which directory you are currently in. d. Confirm which directory you are currently in.
pwd pwd
Examine your results carefully! Due to system variations, you Examine your results carefully! Due to system variations, you
may see slightly different output than the solutions show. Sybase may see slightly different output than the solutions show. Sybase
Learning Centers use a symbolic link between your $HOME and Learning Centers use a symbolic link between your $HOME and
$SYBASE directories. $SYBASE directories.
For example, the $HOME and $SYBASE environment variable For example, the $HOME and $SYBASE environment variable
may both display as /home/usr/u/dub101; but when you change may both display as /home/usr/u/dub101; but when you change
to either directory and use the Unix command “pwd”, the to either directory and use the Unix command “pwd”, the
directory name appears as /deltadisk/home/dub101. Functionally, directory name appears as /deltadisk/home/dub101. Functionally,
the two directories are identical. the two directories are identical.
Your results when using “pwd” may be different than shown. Your results when using “pwd” may be different than shown.
The key point is that your $HOME directory is also your The key point is that your $HOME directory is also your
$SYBASE directory. $SYBASE directory.
e. What is the $SYBASE_ASE variable set to? e. What is the $SYBASE_ASE variable set to?
Lab 3 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 3 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 3: Establishing Connectivity Module 3: Establishing Connectivity
f. What is the $DSQUERY variable set to? f. What is the $DSQUERY variable set to?
The Unix machines in Sybase Learning Centers have two ASE 15.0 The Unix machines in Sybase Learning Centers have two ASE 15.0
servers already installed for each student. The names of the servers servers already installed for each student. The names of the servers
for each student correspond to the respective Unix login name. For for each student correspond to the respective Unix login name. For
example if your Unix login is dub101, then your servers are named: example if your Unix login is dub101, then your servers are named:
DUB101_2K and DUB101_2K and
DUB101_8K. DUB101_8K.
The difference between the two servers is the page size used. The difference between the two servers is the page size used.
DUB101_2K will use a 2K page size while DUB101_8K uses an 8K DUB101_2K will use a 2K page size while DUB101_8K uses an 8K
page size. page size.
You will be performing lab exercises primarily on the 2K server. You will be performing lab exercises primarily on the 2K server.
Feel free to explore the differences between the 2K and the 8K page Feel free to explore the differences between the 2K and the 8K page
server for any comparisons that you would like to make. server for any comparisons that you would like to make.
Each student also has a Backup Server whose name is associated Each student also has a Backup Server whose name is associated
with the 2K Adaptive Server, for example: with the 2K Adaptive Server, for example:
DUB101_2K_BS DUB101_2K_BS
3. Examine the Unix interfaces file. 3. Examine the Unix interfaces file.
a. Display the contents of your interfaces file by using the Unix cat or more a. Display the contents of your interfaces file by using the Unix cat or more
command. command.
cd $SYBASE cd $SYBASE
b. Record the host name and port number for the 2K page size server in the following b. Record the host name and port number for the 2K page size server in the following
chart. chart.
• Recall, in this lab environment, the 2K server name is in the form: • Recall, in this lab environment, the 2K server name is in the form:
<YOUR_UNIX_LOGIN_ALL CAPS>_2K. <YOUR_UNIX_LOGIN_ALL CAPS>_2K.
In this example, the interfaces file shows the 2K server named DUB101_2K is In this example, the interfaces file shows the 2K server named DUB101_2K is
on the host named corona and uses port number 11020. on the host named corona and uses port number 11020.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 3 - 5 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 3 - 5
4. Use the Sybase Directory Services Editor utility, dsedit, to add an entry for your Unix 4. Use the Sybase Directory Services Editor utility, dsedit, to add an entry for your Unix
2K page size Adaptive Server on the PC client. 2K page size Adaptive Server on the PC client.
dsedit is a Sybase Windows utility that can be used to make a Unix- dsedit is a Sybase Windows utility that can be used to make a Unix-
based Adaptive Server available to PC client applications such as based Adaptive Server available to PC client applications such as
isql or Interactive SQL without having to open a Unix command isql or Interactive SQL without having to open a Unix command
prompt window. prompt window.
a. From the taskbar on the Windows Desktop, select: a. From the taskbar on the Windows Desktop, select:
Start->Programs->Sybase->Connectivity ->Open Client Directory Service Start->Programs->Sybase->Connectivity ->Open Client Directory Service
Editor Editor
b. In the Select Directory Service window, click Interfaces Driver and then click b. In the Select Directory Service window, click Interfaces Driver and then click
OK. OK.
c. From the menubar of the DSEDIT1 window, click Server Object and select Add. c. From the menubar of the DSEDIT1 window, click Server Object and select Add.
d. In the Server Name text field of the Input Server Name window, enter the name d. In the Server Name text field of the Input Server Name window, enter the name
of your 2K page size Adaptive Server that resides on the Unix host and then click of your 2K page size Adaptive Server that resides on the Unix host and then click
OK. OK.
e. In the left panel of the DSEDIT1 window, click the name of the new server entry e. In the left panel of the DSEDIT1 window, click the name of the new server entry
that has been added. that has been added.
f. In the right panel of the DSEDIT1 window, click the Server Address attribute. f. In the right panel of the DSEDIT1 window, click the Server Address attribute.
g. Continuing in the right panel of the DSEDIT1 window, right-click the Server g. Continuing in the right panel of the DSEDIT1 window, right-click the Server
Address attribute and select Modify Attribute. Address attribute and select Modify Attribute.
h. In the Network Address Attribute window, click Add. h. In the Network Address Attribute window, click Add.
i. In the Input Network Address For Protocol window, enter the Unix host name i. In the Input Network Address For Protocol window, enter the Unix host name
and port number as recorded in step 3b of this section. and port number as recorded in step 3b of this section.
The Unix host name and port number must be separated by a The Unix host name and port number must be separated by a
comma, for example: comma, for example:
corona.education,11020 corona.education,11020
j. In the Network Address Attribute window, verify the entry and then click OK. j. In the Network Address Attribute window, verify the entry and then click OK.
k. In the right panel of the DSEDIT1 window, verify that the Server Address for the k. In the right panel of the DSEDIT1 window, verify that the Server Address for the
Lab 3 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 3 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 3: Establishing Connectivity Module 3: Establishing Connectivity
5. Determine whether the Unix 2K ASE is up and running. 5. Determine whether the Unix 2K ASE is up and running.
List four ways to determine whether Adaptive Server is running on List four ways to determine whether Adaptive Server is running on
Unix. Unix.
a. Method 1: Use a client application as follows: a. Method 1: Use a client application as follows:
b. In Window A, try to connect to your Unix 2K page size ASE by using isql and the b. In Window A, try to connect to your Unix 2K page size ASE by using isql and the
sa login with a NULL password. sa login with a NULL password.
You can certainly use isql from a Unix command prompt window. You can certainly use isql from a Unix command prompt window.
Additionally, you can use isql from a Windows command prompt if Additionally, you can use isql from a Windows command prompt if
you used the Sybase Windows utility dsedit to make your Unix- you used the Sybase Windows utility dsedit to make your Unix-
based 2K page size Adaptive Server available to PC client based 2K page size Adaptive Server available to PC client
applications. applications.
6. In Window B, start your Unix 2K page size Adaptive Server by using the Sybase 6. In Window B, start your Unix 2K page size Adaptive Server by using the Sybase
startserver utility with the appropriate RUNSERVER file. startserver utility with the appropriate RUNSERVER file.
The startserver command must be issued from a Unix command The startserver command must be issued from a Unix command
prompt, not a Windows command prompt. prompt, not a Windows command prompt.
cd $SYBASE/$SYBASE_ASE/install cd $SYBASE/$SYBASE_ASE/install
7. Determine whether the Unix 2K ASE is up and running by using a client application as 7. Determine whether the Unix 2K ASE is up and running by using a client application as
follows: follows:
a. In Window A, try to connect to your Unix 2K page size ASE by using isql and the a. In Window A, try to connect to your Unix 2K page size ASE by using isql and the
sa login with a NULL password. sa login with a NULL password.
b. Verify that you have connected to the desired Adaptive Server by using the T-SQL b. Verify that you have connected to the desired Adaptive Server by using the T-SQL
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 3 - 7 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 3 - 7
command select to view the global variable @@servername as follows: command select to view the global variable @@servername as follows:
c. Determine the ASE version by using the T-SQL command select to view the c. Determine the ASE version by using the T-SQL command select to view the
global variable @@version. global variable @@version.
8. Determine whether the Unix 2K ASE is up and running by using the Ping capability of 8. Determine whether the Unix 2K ASE is up and running by using the Ping capability of
dsedit. dsedit.
a. Launch the Sybase dsedit Utility as in steps 4a and 4b of this section. a. Launch the Sybase dsedit Utility as in steps 4a and 4b of this section.
b. In the left panel of the DSEDIT1 window, click the Unix 2K server name. b. In the left panel of the DSEDIT1 window, click the Unix 2K server name.
c. Continuing in the left panel of the DSEDIT1 window, right-click the Unix 2K c. Continuing in the left panel of the DSEDIT1 window, right-click the Unix 2K
server name and select Ping Server. server name and select Ping Server.
d. In the Ping window, click Ping. d. In the Ping window, click Ping.
9. Exit all client sessions with Adaptive Server. 9. Exit all client sessions with Adaptive Server.
Lab 3 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 3 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 4: Configuring Server Behavior Module 4: Configuring Server Behavior
Lab setup You will be using your 2K page size Adaptive Server for this lab. Lab setup You will be using your 2K page size Adaptive Server for this lab.
Objectives After completing this lab, you should be able to configure Adaptive Server for varying Objectives After completing this lab, you should be able to configure Adaptive Server for varying
processing needs processing needs
Description In this lab, you will how to configure Adaptive Server for varying processing needs and Description In this lab, you will how to configure Adaptive Server for varying processing needs and
restart the server using different configurations. restart the server using different configurations.
Task outline 1. Creating a customized configuration file and using it to start the server Task outline 1. Creating a customized configuration file and using it to start the server
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 4 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 4 - 1
Task 1: Create a Customized Configuration File Task 1: Create a Customized Configuration File
Description In this task, you will create a customized configuration file for specific processing needs Description In this task, you will create a customized configuration file for specific processing needs
and you will restart the server using different configuration files. and you will restart the server using different configuration files.
Procedure Procedure
Scenario: You are responsible for an Adaptive Server that has differing processing Scenario: You are responsible for an Adaptive Server that has differing processing
requirements during different times of the day. During business hours, there are many requirements during different times of the day. During business hours, there are many
users doing online transaction processing. During nonbusiness hours, there is little or no users doing online transaction processing. During nonbusiness hours, there is little or no
user activity, and batch processes are run. You need to create configuration files for each user activity, and batch processes are run. You need to create configuration files for each
processing requirement, and then put those files into use. processing requirement, and then put those files into use.
Note: The configuration settings used in this lab are being used for demonstration purposes Note: The configuration settings used in this lab are being used for demonstration purposes
only and are not meant to suggest appropriate values for a real-world production server. only and are not meant to suggest appropriate values for a real-world production server.
For all labs, you should open two windows (“A” and “B”). Unless For all labs, you should open two windows (“A” and “B”). Unless
instructed otherwise, perform all lab exercises in Window A. instructed otherwise, perform all lab exercises in Window A.
You use Window B primarily as a console for starting up Adaptive You use Window B primarily as a console for starting up Adaptive
Server and executing OS commands. All Adaptive Server system Server and executing OS commands. All Adaptive Server system
messages are displayed there instead of in your active ASE client messages are displayed there instead of in your active ASE client
window. window.
1. Describe two ways to make a backup copy of the active Adaptive Server configuration 1. Describe two ways to make a backup copy of the active Adaptive Server configuration
file. (Hint: one way is to use T-SQL commands.) file. (Hint: one way is to use T-SQL commands.)
2. Create a backup copy of the current configuration file. 2. Create a backup copy of the current configuration file.
a. By default, where are ASE configuration files located? a. By default, where are ASE configuration files located?
b. In Window B, perform a directory listing of your ASE configuration files. (Recall b. In Window B, perform a directory listing of your ASE configuration files. (Recall
that the classroom setup provides you with a 2K and an 8K page size server.) that the classroom setup provides you with a 2K and an 8K page size server.)
cd $SYBASE/$SYBASE_ASE cd $SYBASE/$SYBASE_ASE
ls -l *.cfg ls -l *.cfg
Lab 4 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 4 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 4: Configuring Server Behavior Module 4: Configuring Server Behavior
c. Make a backup copy of the 2K configuration file and name it 2K_backup.cfg by c. Make a backup copy of the 2K configuration file and name it 2K_backup.cfg by
using the method of your choosing (OS commands or sp_configure). using the method of your choosing (OS commands or sp_configure).
Method 1: using OS commands Method 1: using OS commands
Method 2: Use the T-SQL command sp_configure. Method 2: Use the T-SQL command sp_configure.
d. Verify that the backup configuration file was created by performing a directory d. Verify that the backup configuration file was created by performing a directory
listing of your ASE configuration files. listing of your ASE configuration files.
cd $SYBASE/$SYBASE_ASE cd $SYBASE/$SYBASE_ASE
ls -l *.cfg ls -l *.cfg
3. Describe two ways to modify Adaptive Server configuration parameters. 3. Describe two ways to modify Adaptive Server configuration parameters.
4. Create a custom configuration file for batch processing requirements. 4. Create a custom configuration file for batch processing requirements.
(Method 1 - sp_configure) (Method 1 - sp_configure)
To create a custom configuration file, use either: To create a custom configuration file, use either:
Method 1 (sp_configure - use this step 4) Method 1 (sp_configure - use this step 4)
or or
Method 2 (manually create and edit a new file - proceed Method 2 (manually create and edit a new file - proceed
to step 5) to step 5)
a. For batch processing requirements, create a configuration file named batch.cfg that a. For batch processing requirements, create a configuration file named batch.cfg that
has the following differences from the current (default values) configuration file: has the following differences from the current (default values) configuration file:
user log cache size = 4096 user log cache size = 4096
allow remote access = 0 allow remote access = 0
b. In Window A, connect to the 2K server using the sa login with a NULL password. b. In Window A, connect to the 2K server using the sa login with a NULL password.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 4 - 3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 4 - 3
c. Issue the appropriate sp_configure commands to make the required configuration c. Issue the appropriate sp_configure commands to make the required configuration
changes. changes.
exec sp_configure "user log cache size", 4096 exec sp_configure "user log cache size", 4096
exec sp_configure "allow remote access", 0 exec sp_configure "allow remote access", 0
go go
Note that the configuration parameter user log cache size is static. Note that the configuration parameter user log cache size is static.
Changes to this value require a server reboot. Changes to this value require a server reboot.
The configuration parameter allow remote access is dynamic. The configuration parameter allow remote access is dynamic.
Changes to this value do not require a server reboot. Changes to this value do not require a server reboot.
d. In Window B, locate the active 2K server configuration file and make a copy of it d. In Window B, locate the active 2K server configuration file and make a copy of it
named batch.cfg. named batch.cfg.
cd $SYBASE/$SYBASE_ASE cd $SYBASE/$SYBASE_ASE
e. Verify that the customized configuration file was created by performing a e. Verify that the customized configuration file was created by performing a
directory listing of your ASE configuration files. directory listing of your ASE configuration files.
ls -l *.cfg ls -l *.cfg
5. Create a custom configuration file for batch processing requirements. 5. Create a custom configuration file for batch processing requirements.
(Method 2 - manually create and edit a new configuration file) (Method 2 - manually create and edit a new configuration file)
Skip this step if you used Method 1 (sp_configure) in the last step. Skip this step if you used Method 1 (sp_configure) in the last step.
a. In Window B, locate the backup configuration file, 2K_backup.cfg, which you a. In Window B, locate the backup configuration file, 2K_backup.cfg, which you
created in step 2 for the 2K server and make a copy of it named batch.cfg. created in step 2 for the 2K server and make a copy of it named batch.cfg.
cd $SYBASE/$SYBASE_ASE cd $SYBASE/$SYBASE_ASE
b. Edit batch.cfg by using a text editor such as vi to make the following changes b. Edit batch.cfg by using a text editor such as vi to make the following changes
shown in bold: shown in bold:
Lab 4 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 4 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 4: Configuring Server Behavior Module 4: Configuring Server Behavior
user log cache size = 4096 user log cache size = 4096
allow remote access = 0 allow remote access = 0
c. Verify that the customized configuration file was created by performing a c. Verify that the customized configuration file was created by performing a
directory listing of your ASE configuration files. directory listing of your ASE configuration files.
ls -l *.cfg ls -l *.cfg
d. Although not required, it is recommended that you perform a simple verification of d. Although not required, it is recommended that you perform a simple verification of
manual changes to a configuration file by issuing the following T-SQL command manual changes to a configuration file by issuing the following T-SQL command
in Window A: (make the appropriate substitution for bur301.) in Window A: (make the appropriate substitution for bur301.)
You can expect an error message from this command because the You can expect an error message from this command because the
configuration parameter user log cache size is static. The error configuration parameter user log cache size is static. The error
message is simply for informational purposes to warn that changes to message is simply for informational purposes to warn that changes to
this value cannot be imported ("read") from a configuration file. this value cannot be imported ("read") from a configuration file.
Changes to this value require a server reboot. Changes to this value require a server reboot.
No error message is displayed for the configuration parameter allow No error message is displayed for the configuration parameter allow
remote access because it is dynamic. Changes to this value do not remote access because it is dynamic. Changes to this value do not
require a server reboot. require a server reboot.
6. If the only value changes in batch.cfg were for dynamic configuration parameters, 6. If the only value changes in batch.cfg were for dynamic configuration parameters,
would it be necessary to reboot ASE to activate the changes? Explain. would it be necessary to reboot ASE to activate the changes? Explain.
7. Activate the configuration parameter changes from the customized configuration file 7. Activate the configuration parameter changes from the customized configuration file
named batch.cfg. named batch.cfg.
a. In Window A, as the sa connected to Adaptive Server, shut down your 2K a. In Window A, as the sa connected to Adaptive Server, shut down your 2K
Adaptive Server. (A reboot is required because there are static parameter changes.) Adaptive Server. (A reboot is required because there are static parameter changes.)
shutdown shutdown
go go
b. In Window B, change the directory to $SYBASE/$SYBASE_ASE/install. b. In Window B, change the directory to $SYBASE/$SYBASE_ASE/install.
c. Make a copy of the 2K RUNSERVER file (for example RUN_BUR301_2K) and c. Make a copy of the 2K RUNSERVER file (for example RUN_BUR301_2K) and
name it RUN_2K_batch. name it RUN_2K_batch.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 4 - 5 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 4 - 5
d. Edit the new RUNSERVER file, RUN_2K_batch, so that it starts the 2K server d. Edit the new RUNSERVER file, RUN_2K_batch, so that it starts the 2K server
using the customized configuration file batch.cfg. using the customized configuration file batch.cfg.
It is a good practice to make a change such as this on a backup copy It is a good practice to make a change such as this on a backup copy
of the original RUNSERVER file. Edit the comment as well as the of the original RUNSERVER file. Edit the comment as well as the
dataserver executable argument. dataserver executable argument.
#!/bin/sh #!/bin/sh
# #
# ASE page size (KB): 2K # ASE page size (KB): 2K
# Master device path: /home/usr/u/dub101/devices/2Kmaster.dat # Master device path: /home/usr/u/dub101/devices/2Kmaster.dat
# Error log path: /home/usr/u/dub101/ASE-15_0/install/DUB101_2K.log # Error log path: /home/usr/u/dub101/ASE-15_0/install/DUB101_2K.log
# Configuration file path: /home/usr/u/dub101/ASE-15_0/batch.cfg # Configuration file path: /home/usr/u/dub101/ASE-15_0/batch.cfg
# Directory for shared memory files: /home/usr/u/dub101/ASE-15_0 # Directory for shared memory files: /home/usr/u/dub101/ASE-15_0
# Adaptive Server name: DUB101_2K # Adaptive Server name: DUB101_2K
# #
/home/usr/u/dub101/ASE-15_0/bin/dataserver \ /home/usr/u/dub101/ASE-15_0/bin/dataserver \
-d/home/usr/u/dub101/devices/2Kmaster.dat \ -d/home/usr/u/dub101/devices/2Kmaster.dat \
-e/home/usr/u/dub101/ASE-15_0/install/DUB101_2K.log \ -e/home/usr/u/dub101/ASE-15_0/install/DUB101_2K.log \
-c/home/usr/u/dub101/ASE-15_0/batch.cfg \ -c/home/usr/u/dub101/ASE-15_0/batch.cfg \
-M/home/usr/u/dub101/ASE-15_0 \ -M/home/usr/u/dub101/ASE-15_0 \
-sDUB101_2K \ -sDUB101_2K \
e. Start the 2K page size Adaptive Server by using the Sybase startserver utility e. Start the 2K page size Adaptive Server by using the Sybase startserver utility
with the RUN_2K_batch file. with the RUN_2K_batch file.
8. Verify that the customized configuration file, batch.cfg, was used to start up the server. 8. Verify that the customized configuration file, batch.cfg, was used to start up the server.
a. In Window A, connect to the 2K server using the sa login with a NULL password. a. In Window A, connect to the 2K server using the sa login with a NULL password.
b. Examine the configuration settings for "allow remote access" and "user log cache b. Examine the configuration settings for "allow remote access" and "user log cache
size". size".
exec sp_configure "user log cache size" exec sp_configure "user log cache size"
exec sp_configure "allow remote access" exec sp_configure "allow remote access"
go go
Lab 4 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 4 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 4: Configuring Server Behavior Module 4: Configuring Server Behavior
Proof that the customized configuration file was used is that the run Proof that the customized configuration file was used is that the run
value for the static parameter, “user log cache size”, is different from value for the static parameter, “user log cache size”, is different from
its default value. its default value.
9. Restart the server using the original configuration file. 9. Restart the server using the original configuration file.
a. In Window A, as the sa connected to Adaptive Server, shut down your 2K a. In Window A, as the sa connected to Adaptive Server, shut down your 2K
Adaptive Server. Adaptive Server.
b. In Window B, change the directory to $SYBASE/$SYBASE_ASE. b. In Window B, change the directory to $SYBASE/$SYBASE_ASE.
c. Restore the backup copy of the 2K configuration file, 2K_backup.cfg to the c. Restore the backup copy of the 2K configuration file, 2K_backup.cfg to the
original configuration file which was named in the form $DSQUERY.cfg. original configuration file which was named in the form $DSQUERY.cfg.
e. Start your 2K page size Adaptive Server by using the Sybase startserver utility e. Start your 2K page size Adaptive Server by using the Sybase startserver utility
with the original RUNSERVER file, RUN_$DSQUERY, which uses the original with the original RUNSERVER file, RUN_$DSQUERY, which uses the original
configuration file. configuration file.
10. Verify that the original configuration file, $DSQUERY.cfg, was used to start up the 10. Verify that the original configuration file, $DSQUERY.cfg, was used to start up the
server. server.
a. In Window A, connect to the 2K server using the sa login with a NULL password. a. In Window A, connect to the 2K server using the sa login with a NULL password.
b. Examine the configuration settings for "allow remote access" and "user log cache b. Examine the configuration settings for "allow remote access" and "user log cache
size". size".
Proof that the original configuration file was used is that the run Proof that the original configuration file was used is that the run
values for these parameters are at their default values. values for these parameters are at their default values.
11. Exit all client sessions with Adaptive Server. 11. Exit all client sessions with Adaptive Server.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 4 - 7 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 4 - 7
Lab 4 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 4 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 5: Configuring Memory Module 5: Configuring Memory
Lab setup You will be using your 2K page size Adaptive Server for this lab. There is no additional Lab setup You will be using your 2K page size Adaptive Server for this lab. There is no additional
setup for this lab. setup for this lab.
Objectives After completing this lab, you should be able to: Objectives After completing this lab, you should be able to:
Calculate the appropriate configuration value for the procedure cache Calculate the appropriate configuration value for the procedure cache
Description In this lab, you will learn how to calculate the appropriate configuration value for the Description In this lab, you will learn how to calculate the appropriate configuration value for the
procedure cache. procedure cache.
Task outline 1. Analyzing the impact of changing configuration parameters on the procedure cache Task outline 1. Analyzing the impact of changing configuration parameters on the procedure cache
2. Estimating the amount of memory needed for procedure cache 2. Estimating the amount of memory needed for procedure cache
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 5 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 5 - 1
Task 1: Analyzing the Impact of Changing Configuration Task 1: Analyzing the Impact of Changing Configuration
Parameters on the Procedure Cache Parameters on the Procedure Cache
Description In this task, you will analyze the impact of changing configuration parameters on the Description In this task, you will analyze the impact of changing configuration parameters on the
procedure cache. procedure cache.
Procedure Procedure
For all labs, you should open two windows (“A” and “B”). Unless For all labs, you should open two windows (“A” and “B”). Unless
instructed otherwise, perform all lab exercises in Window A. instructed otherwise, perform all lab exercises in Window A.
You use Window B primarily as a console for starting up Adaptive You use Window B primarily as a console for starting up Adaptive
Server and executing OS commands. All Adaptive Server system Server and executing OS commands. All Adaptive Server system
messages are displayed there instead of in your active ASE client messages are displayed there instead of in your active ASE client
window. window.
1. Examine the default status of the ASE memory model. 1. Examine the default status of the ASE memory model.
a. In Window A, connect to Adaptive Server as the sa login using the NULL a. In Window A, connect to Adaptive Server as the sa login using the NULL
password. password.
b. Examine the following ASE configuration parameters by using sp_configure and b. Examine the following ASE configuration parameters by using sp_configure and
fill in the following chart. (Your values may be slightly different). fill in the following chart. (Your values may be slightly different).
max memory total logical procedure cache max memory total logical procedure cache
memory size memory size
Memory Used (KB) Memory Used (KB)
Pages Used (2 KB) Pages Used (2 KB)
Lab 5 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 5 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 5: Configuring Memory Module 5: Configuring Memory
Based on the current memory used for “max memory” and “total Based on the current memory used for “max memory” and “total
logical memory”, is there room to increase configuration parameters logical memory”, is there room to increase configuration parameters
that use memory without increasing “max memory”? that use memory without increasing “max memory”?
2. Analyze the impact of changing memory-related ASE configuration parameters on the 2. Analyze the impact of changing memory-related ASE configuration parameters on the
sizes of the data and procedure caches. sizes of the data and procedure caches.
a. Verify that the configuration parameter “number of user connections” is running a. Verify that the configuration parameter “number of user connections” is running
with its default value of 25. with its default value of 25.
b. Increase the “number of user connections” to 50. b. Increase the “number of user connections” to 50.
sp_configure "number of user connections", 50 sp_configure "number of user connections", 50
Changing the value of the “number of user connections” to 50 Changing the value of the “number of user connections” to 50
increases the amount of memory ASE uses by how much? increases the amount of memory ASE uses by how much?
Does the server need to be rebooted for a change to this memory- Does the server need to be rebooted for a change to this memory-
related parameter to take effect? Explain. related parameter to take effect? Explain.
c. Examine the following ASE configuration parameters again by using c. Examine the following ASE configuration parameters again by using
sp_configure and fill in the following chart: sp_configure and fill in the following chart:
"max memory" "max memory"
"logical memory" "logical memory"
"procedure cache" "procedure cache"
max memory total logical procedure cache max memory total logical procedure cache
memory size memory size
Memory Used (KB) Memory Used (KB)
Has the memory model changed from the values you recorded in Has the memory model changed from the values you recorded in
step 1b? step 1b?
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 5 - 3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 5 - 3
Task 2: Estimating the Amount of Memory Needed for Task 2: Estimating the Amount of Memory Needed for
Procedure Cache Procedure Cache
Description In this task, you will estimate the amount of memory needed for procedure cache and you Description In this task, you will estimate the amount of memory needed for procedure cache and you
will determine whether the procedure cache is currently under- or over sized according to will determine whether the procedure cache is currently under- or over sized according to
your calculation. your calculation.
Procedure 1. Estimate the amount of memory needed for procedure cache by obtaining the average Procedure 1. Estimate the amount of memory needed for procedure cache by obtaining the average
plan size for the largest database in the system. plan size for the largest database in the system.
Make the assumption that the largest number of concurrent users is Make the assumption that the largest number of concurrent users is
125. 125.
Because we do not have any large production databases we will use Because we do not have any large production databases we will use
the sybsystemprocs database to perform the calculation. the sybsystemprocs database to perform the calculation.
In a productive system you will have databases that are more In a productive system you will have databases that are more
appropriate for these calculations. appropriate for these calculations.
Calculate the average plan size for the largest database. Calculate the average plan size for the largest database.
The required procedure cache size will be estimated as (the largest The required procedure cache size will be estimated as (the largest
number of concurrent users) times (the average plan size) times a number of concurrent users) times (the average plan size) times a
factor of 1.25. factor of 1.25.
a. Determine the average plan size of the sybsystemprocs database. a. Determine the average plan size of the sybsystemprocs database.
b. Calculate the required procedure cache size as the number of concurrent users b. Calculate the required procedure cache size as the number of concurrent users
times the total of the average plan sizes times a factor of 1.25: times the total of the average plan sizes times a factor of 1.25:
Estimated procedure cache size (in 2KB pages) Estimated procedure cache size (in 2KB pages)
= (number of concurrent users) * (average plan size) * 1.25 = (number of concurrent users) * (average plan size) * 1.25
= ( 125 ) * ( ) * 1.25 = ( 125 ) * ( ) * 1.25
= =
= (Round up) = (Round up)
Is the procedure cache currently under- or oversized according to Is the procedure cache currently under- or oversized according to
your calculation? (Hint: refer to the values you recorded in step 1b.) your calculation? (Hint: refer to the values you recorded in step 1b.)
Lab 5 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 5 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 5: Configuring Memory Module 5: Configuring Memory
2. The procedure cache size is running at the default and minimum for the server and so 2. The procedure cache size is running at the default and minimum for the server and so
does not need to be changed based on our calculation,. The command to re-configure does not need to be changed based on our calculation,. The command to re-configure
Adaptive Server for the required procedure cache size, if necessary, is given here. Adaptive Server for the required procedure cache size, if necessary, is given here.
sp_configure "procedure cache size", <required number of pages> sp_configure "procedure cache size", <required number of pages>
3. You can now exit all client sessions with Adaptive Server. 3. You can now exit all client sessions with Adaptive Server.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 5 - 5 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 5 - 5
Lab 5 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 5 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 6: Initializing and Using Devices Module 6: Initializing and Using Devices
Module 6: Initializing and Using Devices Module 6: Initializing and Using Devices
Lab 6: Initializing and Using Devices Lab 6: Initializing and Using Devices
Lab setup You will be using your 2K page size Adaptive Server for this lab. There is no additional Lab setup You will be using your 2K page size Adaptive Server for this lab. There is no additional
setup for this lab. setup for this lab.
Objectives After completing this lab, you should be able to: Objectives After completing this lab, you should be able to:
Create data devices Create data devices
Implement device mirroring Implement device mirroring
Move a database device from one physical file to another by using disk mirroring Move a database device from one physical file to another by using disk mirroring
commands commands
Description In this lab, you will learn how to create data devices and how to implement device Description In this lab, you will learn how to create data devices and how to implement device
mirroring and you will also learn how to Move a database device from one physical file to mirroring and you will also learn how to Move a database device from one physical file to
another by using disk mirroring commands. another by using disk mirroring commands.
Task outline 1. Creating New Database Devices Task outline 1. Creating New Database Devices
2. Implementing Mirroring for a Database Device 2. Implementing Mirroring for a Database Device
3. Analyzing Mirroring Requirements 3. Analyzing Mirroring Requirements
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 6 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 6 - 1
Task 1: Creating New Database Devices Task 1: Creating New Database Devices
Description In this task, you will create new database devices. Description In this task, you will create new database devices.
Procedure Procedure
For all labs, you should open two windows (“A” and “B”). Unless For all labs, you should open two windows (“A” and “B”). Unless
instructed otherwise, perform all lab exercises in Window A. instructed otherwise, perform all lab exercises in Window A.
You use Window B primarily as a console for starting up Adaptive You use Window B primarily as a console for starting up Adaptive
Server and executing OS commands. All Adaptive Server system Server and executing OS commands. All Adaptive Server system
messages are displayed there instead of in your active ASE client messages are displayed there instead of in your active ASE client
window. window.
1. Given the following specifications for initializing a new database device, fill in the 1. Given the following specifications for initializing a new database device, fill in the
following diagram. following diagram.
• The device is for your 2K page size ASE, $DSQUERY • The device is for your 2K page size ASE, $DSQUERY
• The logical name of the database device is data_dev • The logical name of the database device is data_dev
• The physical path and file name associated with the new device • The physical path and file name associated with the new device
is in the form: is in the form:
$SYBASE/devices/data_dev.dat $SYBASE/devices/data_dev.dat
• The device size is to be 4 MB • The device size is to be 4 MB
Lab 6 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 6 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 6: Initializing and Using Devices Module 6: Initializing and Using Devices
2. Initialize a new database device for your 2K page size Adaptive Server. 2. Initialize a new database device for your 2K page size Adaptive Server.
a. In Window B, change the directory to $HOME/sa. a. In Window B, change the directory to $HOME/sa.
b. Write a T-SQL script file named data_dev.sql that contains the command to b. Write a T-SQL script file named data_dev.sql that contains the command to
initialize a database device named data_dev according to the specifications initialize a database device named data_dev according to the specifications
outlined in step 1. Specify the device size in MB. Remember to substitute your outlined in step 1. Specify the device size in MB. Remember to substitute your
specific path in place of the one given here. specific path in place of the one given here.
/* create the data_dev device */ /* create the data_dev device */
use master use master
go go
c. Create the new database device by executing the commands in the newly created c. Create the new database device by executing the commands in the newly created
T-SQL script data_dev.sql. T-SQL script data_dev.sql.
3. Examine the characteristics of the devices available in your Adaptive Server. 3. Examine the characteristics of the devices available in your Adaptive Server.
a. In Window A, connect to Adaptive Server as the sa. a. In Window A, connect to Adaptive Server as the sa.
b. Verify that the new device, data_dev, was created by using sp_helpdevice. b. Verify that the new device, data_dev, was created by using sp_helpdevice.
c. Examine the contents of the sysdevices table, by using a select statement. c. Examine the contents of the sysdevices table, by using a select statement.
use master use master
go go
select name, status, phyname from sysdevices select name, status, phyname from sysdevices
go go
The master device default device status is on when a server is built The master device default device status is on when a server is built
and should be turned off if the server is to be used as a production and should be turned off if the server is to be used as a production
server. server.
The master device likely shows a status of 3 indicating that it is a The master device likely shows a status of 3 indicating that it is a
default device. Turn off the default status with following command: default device. Turn off the default status with following command:
Now look again at the status of each device by Now look again at the status of each device by
running the previous select statement to look at the running the previous select statement to look at the
status codes for the devices. status codes for the devices.
d. Use the following reference table, which explains each bit in the status column, to d. Use the following reference table, which explains each bit in the status column, to
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 6 - 3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 6 - 3
answer the questions that follow: answer the questions that follow:
Based on the status column output of the previous query, which Based on the status column output of the previous query, which
devices, if any, are default devices? devices, if any, are default devices?
What are the characteristics of the master device? What are the characteristics of the master device?
What are the characteristics of the data_dev device? What are the characteristics of the data_dev device?
4. Make a new database device a default device. 4. Make a new database device a default device.
a. In Window A, as the sa connected to Adaptive Server, drop the new device a. In Window A, as the sa connected to Adaptive Server, drop the new device
data_dev by using the sp_dropdevice command. data_dev by using the sp_dropdevice command.
Lab 6 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 6 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 6: Initializing and Using Devices Module 6: Initializing and Using Devices
Strictly speaking, you do not have to drop a device to change its Strictly speaking, you do not have to drop a device to change its
default status. You are dropping the device for two demonstration default status. You are dropping the device for two demonstration
purposes: purposes:
1. Understand the mechanics of dropping a device at both the ASE 1. Understand the mechanics of dropping a device at both the ASE
and the OS levels. and the OS levels.
2. Ultimately, you want to modify the T-SQL script used to initialize 2. Ultimately, you want to modify the T-SQL script used to initialize
the device to also turn the default status on right after the disk init the device to also turn the default status on right after the disk init
command. command.
b. In Window B, change the directory to $SYBASE/devices and remove the physical b. In Window B, change the directory to $SYBASE/devices and remove the physical
device file. device file.
cd $SYBASE/devices cd $SYBASE/devices
rm data_dev.dat rm data_dev.dat
c. Continuing in Window B, change the directory back to $HOME/sa and modify the c. Continuing in Window B, change the directory back to $HOME/sa and modify the
T-SQL script file named data_dev.sql to initialize a database device named T-SQL script file named data_dev.sql to initialize a database device named
data_dev, making it a default device. data_dev, making it a default device.
/* create the data_dev device */ /* create the data_dev device */
use master use master
go go
d. Create the new, default database device by executing the commands in the newly d. Create the new, default database device by executing the commands in the newly
created T-SQL script data_dev.sql. created T-SQL script data_dev.sql.
e. In Window A, as the sa connected to Adaptive Server, verify that the new device, e. In Window A, as the sa connected to Adaptive Server, verify that the new device,
data_dev, was created as a default device by using sp_helpdevice. data_dev, was created as a default device by using sp_helpdevice.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 6 - 5 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 6 - 5
5. Given the following specifications for initializing a new database device, fill in the 5. Given the following specifications for initializing a new database device, fill in the
following diagram. following diagram.
• The device is for your 2K page size ASE, $DSQUERY • The device is for your 2K page size ASE, $DSQUERY
• The logical name of the database device is log_dev • The logical name of the database device is log_dev
• The physical path and file name associated with the new device • The physical path and file name associated with the new device
is in the form: is in the form:
$SYBASE/devices/log_dev.dat $SYBASE/devices/log_dev.dat
• The device size is to be 2 MB • The device size is to be 2 MB
• Do not make the device a default device • Do not make the device a default device
6. Initialize a new database device for your 2K page size Adaptive Server. 6. Initialize a new database device for your 2K page size Adaptive Server.
a. In Window B, write a new T-SQL script file named log_dev.sql that contains the a. In Window B, write a new T-SQL script file named log_dev.sql that contains the
command to initialize a database device named log_dev according to the command to initialize a database device named log_dev according to the
specifications outlined in step 5. Specify the device size in 2K pages. Remember specifications outlined in step 5. Specify the device size in 2K pages. Remember
to substitute your specific path in place of the one given here. to substitute your specific path in place of the one given here.
/* create the log_dev device */ /* create the log_dev device */
use master use master
go go
Lab 6 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 6 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 6: Initializing and Using Devices Module 6: Initializing and Using Devices
b. Create the new database device by executing the commands in the newly created b. Create the new database device by executing the commands in the newly created
T-SQL script log_dev.sql. T-SQL script log_dev.sql.
c. In Window A, verify the successful creation of the device named log_dev by using c. In Window A, verify the successful creation of the device named log_dev by using
sp_helpdevice. sp_helpdevice.
7. (Optional) Write queries to examine all the logical and physical device names for the 7. (Optional) Write queries to examine all the logical and physical device names for the
server. server.
a. In Window A, as the sa connected to Adaptive Server, retrieve all the logical and a. In Window A, as the sa connected to Adaptive Server, retrieve all the logical and
physical device names by running sp_helpdevice. physical device names by running sp_helpdevice.
b. Write a query against sysdevices that retrieves only the logical and physical device b. Write a query against sysdevices that retrieves only the logical and physical device
names for the server. names for the server.
c. Write a query against sysdevices that retrieves only logical and physical database c. Write a query against sysdevices that retrieves only logical and physical database
device names (exclude tape dump devices) for the server. device names (exclude tape dump devices) for the server.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 6 - 7 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 6 - 7
Task 2: Implementing Mirroring for a Database Device Task 2: Implementing Mirroring for a Database Device
Description In this task, you will implement mirroring for a database device. Description In this task, you will implement mirroring for a database device.
Procedure Procedure
In this section of the lab, you gain experience setting up, mirroring, In this section of the lab, you gain experience setting up, mirroring,
and interpreting the output from system stored procedures as well as and interpreting the output from system stored procedures as well as
from direct queries of system tables. With this experience, you will from direct queries of system tables. With this experience, you will
be able to quickly set up a database device mirror if needed, and to be able to quickly set up a database device mirror if needed, and to
assess the status of all devices in your environment. assess the status of all devices in your environment.
With ASE 15.0, the configuration parameter “disable disk mirroring” With ASE 15.0, the configuration parameter “disable disk mirroring”
is a static parameter and the default is “disabled” Therefore, the is a static parameter and the default is “disabled” Therefore, the
parameter will need to be changed and the server must be re-booted parameter will need to be changed and the server must be re-booted
to have the configuration set to allow disk mirroring. to have the configuration set to allow disk mirroring.
1. In Window A, as the sa connected to ASE, configure the server to allow disk mirroring 1. In Window A, as the sa connected to ASE, configure the server to allow disk mirroring
by changing the default value of “disable disk mirroring” from 1 to 0. by changing the default value of “disable disk mirroring” from 1 to 0.
a. Shutdown the Adaptive Server with a T-SQL command. a. Shutdown the Adaptive Server with a T-SQL command.
b. In Window B, cd to $SYBASE/$SYBASE_ASE/install and re-start the server b. In Window B, cd to $SYBASE/$SYBASE_ASE/install and re-start the server
with the following command with the following command
2. In Window A, as the sa connected to Adaptive Server, display the details about the 2. In Window A, as the sa connected to Adaptive Server, display the details about the
newly created device, log_dev, by using sp_helpdevice. newly created device, log_dev, by using sp_helpdevice.
3. Review the mirroring requirements for the device log_dev from the following 3. Review the mirroring requirements for the device log_dev from the following
specifications and then complete the following diagram: specifications and then complete the following diagram:
Lab 6 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 6 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 6: Initializing and Using Devices Module 6: Initializing and Using Devices
• The physical path and file name associated with the mirror • The physical path and file name associated with the mirror
device is in the form: device is in the form:
$SYBASE/devices/log_dev.mir $SYBASE/devices/log_dev.mir
Note: For this lab environment you are placing the device mirror file Note: For this lab environment you are placing the device mirror file
on the same physical disk as the device file itself. In a production on the same physical disk as the device file itself. In a production
system you would normally place the mirror file on a separate disk. system you would normally place the mirror file on a separate disk.
4. Mirror the log device log_dev. 4. Mirror the log device log_dev.
a. In Window A, as the sa connected to Adaptive Server, mirror the log device a. In Window A, as the sa connected to Adaptive Server, mirror the log device
log_dev by following the requirements outlined in step 2 and issuing the disk log_dev by following the requirements outlined in step 2 and issuing the disk
mirror command. Be sure to change the path to your home directory path. mirror command. Be sure to change the path to your home directory path.
disk mirror disk mirror
name = "log_dev", name = "log_dev",
mirror = "/home/usr/u/dub101/devices/log_dev.mir" mirror = "/home/usr/u/dub101/devices/log_dev.mir"
b. Verify that mirroring was successful by using sp_helpdevice. b. Verify that mirroring was successful by using sp_helpdevice.
sp_helpdevice log_dev sp_helpdevice log_dev
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 6 - 9 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 6 - 9
c. Use the following reference table, which explains each bit in the status column, to c. Use the following reference table, which explains each bit in the status column, to
answer the questions that follow: answer the questions that follow:
Describe the attributes of the device based on the status value. Describe the attributes of the device based on the status value.
Lab 6 - 10 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 6 - 10 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 6: Initializing and Using Devices Module 6: Initializing and Using Devices
At this point, you have experience with setting up a device mirror At this point, you have experience with setting up a device mirror
and assessing the status of devices in your environment. In this and assessing the status of devices in your environment. In this
part of the lab, you will turn mirroring on and off for the part of the lab, you will turn mirroring on and off for the
secondary side of the mirrored device. For a live system, if the secondary side of the mirrored device. For a live system, if the
secondary side of the mirror fails, you can take it offline, replace it, secondary side of the mirror fails, you can take it offline, replace it,
and then remirror it to turn mirroring back on. and then remirror it to turn mirroring back on.
5. Temporarily deactivate mirroring for a device. 5. Temporarily deactivate mirroring for a device.
a. In Window A, as the sa connected to Adaptive Server, deactivate the secondary a. In Window A, as the sa connected to Adaptive Server, deactivate the secondary
side of the mirror for the log_dev device by using the disk unmirror command. side of the mirror for the log_dev device by using the disk unmirror command.
b. Query the sysdevices table for the log_dev entry. b. Query the sysdevices table for the log_dev entry.
Describe the attributes of the device based on the status value. Describe the attributes of the device based on the status value.
c. Reactivate the secondary side of the mirror for log_dev by issuing the disk c. Reactivate the secondary side of the mirror for log_dev by issuing the disk
remirror command. remirror command.
d. Query the sysdevices table, again, for the log_dev entry only this time just get the d. Query the sysdevices table, again, for the log_dev entry only this time just get the
status.. status..
Describe the attributes of the device based on the status value. Describe the attributes of the device based on the status value.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 6 - 11 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 6 - 11
Now turn mirroring on and off for the primary side of the mirror. Now turn mirroring on and off for the primary side of the mirror.
For a live system, if the primary side has failed over to the For a live system, if the primary side has failed over to the
secondary side of the mirror, it will need to be taken offline, secondary side of the mirror, it will need to be taken offline,
replaced, and then re-mirrored to turn mirroring back on. replaced, and then re-mirrored to turn mirroring back on.
6. Temporarily deactivate mirroring for the primary side of a device. 6. Temporarily deactivate mirroring for the primary side of a device.
a. Deactivate mirroring for the primary side of device log_dev by issuing the disk a. Deactivate mirroring for the primary side of device log_dev by issuing the disk
unmirror command. unmirror command.
disk unmirror name = "log_dev", side = "primary" disk unmirror name = "log_dev", side = "primary"
b. Query the sysdevices table for the log_dev status entry again. b. Query the sysdevices table for the log_dev status entry again.
Describe the attributes of the device based on the status value. Describe the attributes of the device based on the status value.
c. Reactivate the primary side of the mirror for log_dev by issuing the disk remirror c. Reactivate the primary side of the mirror for log_dev by issuing the disk remirror
command. command.
Describe the attributes of the device based on the status value. Describe the attributes of the device based on the status value.
So far you have temporarily turned mirroring on and off for both the primary and So far you have temporarily turned mirroring on and off for both the primary and
secondary sides of the mirror. Now permanently disable the primary side of the mirror. secondary sides of the mirror. Now permanently disable the primary side of the mirror.
7. Permanently disable the primary side of a device mirror. 7. Permanently disable the primary side of a device mirror.
a. Permanently disable the primary side of the mirror for the log_dev device. a. Permanently disable the primary side of the mirror for the log_dev device.
b. Query the sysdevices table for the log_dev entry. b. Query the sysdevices table for the log_dev entry.
Lab 6 - 12 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 6 - 12 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 6: Initializing and Using Devices Module 6: Initializing and Using Devices
Describe the attributes of the device based on the status value. Describe the attributes of the device based on the status value.
The device log_dev is now unmirrored. What is the name of the The device log_dev is now unmirrored. What is the name of the
physical device file, log_dev.dat or log_dev.mir? physical device file, log_dev.dat or log_dev.mir?
In effect, what have you actually done to the original device that was In effect, what have you actually done to the original device that was
initialized in Section A, step 2 ? initialized in Section A, step 2 ?
. In Window B, remove the physical device (primary side) file. . In Window B, remove the physical device (primary side) file.
Remember, the .mir file is now the active physical device file so Remember, the .mir file is now the active physical device file so
make sure you remove the .dat file !!!!! make sure you remove the .dat file !!!!!
cd $SYBASE/devices cd $SYBASE/devices
rm log_dev.dat rm log_dev.dat
8. Exit all client sessions with Adaptive Server. 8. Exit all client sessions with Adaptive Server.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 6 - 13 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 6 - 13
Description In this task, you will analyze mirroring requirements as a paper and pencil activity. Description In this task, you will analyze mirroring requirements as a paper and pencil activity.
Procedure Now that you have experience turning mirroring on and off and moving devices by using Procedure Now that you have experience turning mirroring on and off and moving devices by using
disk mirroring commands, take a few minutes to consider what devices should or should disk mirroring commands, take a few minutes to consider what devices should or should
not be mirrored. not be mirrored.
1. Given that your production environment has limited disk resource constraints, you can 1. Given that your production environment has limited disk resource constraints, you can
mirror only three of the devices listed below. Which would you choose to mirror? mirror only three of the devices listed below. Which would you choose to mirror?
A_dev The master device A_dev The master device
B_dev Contains tempdb B_dev Contains tempdb
C_dev Contains data from frequently updated database1 C_dev Contains data from frequently updated database1
D_dev Contains log from frequently updated database1 D_dev Contains log from frequently updated database1
E_dev Contains data from frequently updated database2 E_dev Contains data from frequently updated database2
F_dev Contains log from frequently updated database2 F_dev Contains log from frequently updated database2
2. In the previous example, what if C_dev and D_dev were used for a “read-only” 2. In the previous example, what if C_dev and D_dev were used for a “read-only”
database? Would your answer change? database? Would your answer change?
3. Consider your own production environment. Which devices will you choose to mirror? 3. Consider your own production environment. Which devices will you choose to mirror?
Lab 6 - 14 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 6 - 14 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 7: Creating and Using Databases Module 7: Creating and Using Databases
Module 7: Creating and Using Databases Module 7: Creating and Using Databases
Lab 7: Creating and Using Databases Lab 7: Creating and Using Databases
Lab setup You will be using your 2K and 8K page size Adaptive Servers for this lab. Lab setup You will be using your 2K and 8K page size Adaptive Servers for this lab.
Note: You need to have completed Lab 6: Devices in which you created two database Note: You need to have completed Lab 6: Devices in which you created two database
devices, data_dev and log_dev on the 2K server. If you did not finish that lab or did not devices, data_dev and log_dev on the 2K server. If you did not finish that lab or did not
create the two devices, then create the devices now on your 2K page size Adaptive Server create the two devices, then create the devices now on your 2K page size Adaptive Server
by using the following two commands(substituting $SYBASE/ appropriately): NOTE: The by using the following two commands(substituting $SYBASE/ appropriately): NOTE: The
extension of the log_dev is mir and it needs to be that due to actions in lab 6.: extension of the log_dev is mir and it needs to be that due to actions in lab 6.:
Objectives After completing this lab, you should be able to: Objectives After completing this lab, you should be able to:
Create a database Create a database
Turn database options on and off Turn database options on and off
Understand table space requirements between Adaptive Servers that use different Understand table space requirements between Adaptive Servers that use different
logical page sizes logical page sizes
Write queries that return useful database diagnostics Write queries that return useful database diagnostics
Description In this lab, you will learn how to create a database, turn database options on and off, and Description In this lab, you will learn how to create a database, turn database options on and off, and
also how to write queries that return useful database diagnostics. also how to write queries that return useful database diagnostics.
Task outline 1. Creating a 6MB database, separating the data from the log, verifying, and also turning Task outline 1. Creating a 6MB database, separating the data from the log, verifying, and also turning
the dbo use only option on/off for the database the dbo use only option on/off for the database
2. Analyzing table space requirements between a 2K and 8K AS 2. Analyzing table space requirements between a 2K and 8K AS
3. Writing queries that use sysdevices, sysusages and sysdatabases 3. Writing queries that use sysdevices, sysusages and sysdatabases
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 7 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 7 - 1
Description In this task, you will create a 6MB database, separating the data from the log, verifying and Description In this task, you will create a 6MB database, separating the data from the log, verifying and
also turning the dbo use only option on/off for the database. also turning the dbo use only option on/off for the database.
Procedure In a previous lab you created two database devices named data_dev and log_dev. The Procedure In a previous lab you created two database devices named data_dev and log_dev. The
device sizes are 4 MB and 2 MB, respectively. If you did not create the two devices, please device sizes are 4 MB and 2 MB, respectively. If you did not create the two devices, please
refer to the Lab Setup in the Exercise Overview for this lab for instructions about creating refer to the Lab Setup in the Exercise Overview for this lab for instructions about creating
the devices. the devices.
In this lab you create a 6 MB database named my_db striped across these two devices. The In this lab you create a 6 MB database named my_db striped across these two devices. The
data portion (4 MB) of the database will be separated from the log (2 MB) as the following data portion (4 MB) of the database will be separated from the log (2 MB) as the following
diagram demonstrates: diagram demonstrates:
For all labs, you should open two windows (“A” and “B”). Unless For all labs, you should open two windows (“A” and “B”). Unless
instructed otherwise, perform all lab exercises in Window A. instructed otherwise, perform all lab exercises in Window A.
You use Window B primarily as a console for starting up Adaptive You use Window B primarily as a console for starting up Adaptive
Server and executing OS commands. All Adaptive Server system Server and executing OS commands. All Adaptive Server system
messages are displayed there instead of in your active ASE client messages are displayed there instead of in your active ASE client
window. window.
Lab 7 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 7 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 7: Creating and Using Databases Module 7: Creating and Using Databases
b. Write a T-SQL script file named create_db.sql that contains the command to b. Write a T-SQL script file named create_db.sql that contains the command to
create the database with the following specifications: create the database with the following specifications:
c. Create the new database my_db on the 2K page size Adaptive Server by executing c. Create the new database my_db on the 2K page size Adaptive Server by executing
the command in the newly created T-SQL script create_db.sql. the command in the newly created T-SQL script create_db.sql.
isql -Usa -P -S $DSQUERY -i create_db.sql isql -Usa -P -S $DSQUERY -i create_db.sql
2. Examine the characteristics of the new database my_db. 2. Examine the characteristics of the new database my_db.
a. In Window A, connect to the 2K Adaptive Server as the sa. a. In Window A, connect to the 2K Adaptive Server as the sa.
b. Verify that the new database was created by using sp_helpdb. b. Verify that the new database was created by using sp_helpdb.
Was the database created according to the specifications in step 1b? Was the database created according to the specifications in step 1b?
Explain. Explain.
Are any database options set? (Hint: examine the status column of Are any database options set? (Hint: examine the status column of
the sp_helpdb output.) the sp_helpdb output.)
c. Query all columns from the sysdatabases table for the my_db entry. c. Query all columns from the sysdatabases table for the my_db entry.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 7 - 3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 7 - 3
b. Display all the database objects by using sp_help. b. Display all the database objects by using sp_help.
c. Based on the output from sp_help, what objects other than system tables does the c. Based on the output from sp_help, what objects other than system tables does the
database contain? database contain?
d. How can you control which user objects a newly created database has? (Do not d. How can you control which user objects a newly created database has? (Do not
make any changes to your server!) make any changes to your server!)
4. Activate and then deactivate database options. 4. Activate and then deactivate database options.
a. Set context to the master database and set the database option dbo use only for the a. Set context to the master database and set the database option dbo use only for the
my_db database. my_db database.
b. Verify that the database option was turned on by using sp_helpdb. b. Verify that the database option was turned on by using sp_helpdb.
c. Turn off dbo use only for the my_db database. c. Turn off dbo use only for the my_db database.
d. Verify that the database option was turned off by using sp_helpdb. d. Verify that the database option was turned off by using sp_helpdb.
Lab 7 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 7 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 7: Creating and Using Databases Module 7: Creating and Using Databases
Task 2: Analyzing table space requirements between a 2K and Task 2: Analyzing table space requirements between a 2K and
8K ASE 8K ASE
Description In this task, you will analyze table space requirements between a 2K and 8K ASE. Description In this task, you will analyze table space requirements between a 2K and 8K ASE.
Procedure Procedure
As of version 12.5 of ASE, you have to choose a page size for the As of version 12.5 of ASE, you have to choose a page size for the
server during installation. The choices are 2K, 4K 8K and 16K. 16K server during installation. The choices are 2K, 4K 8K and 16K. 16K
is usually too large a size to choose for the logical page size, as this is usually too large a size to choose for the logical page size, as this
entails a lot of additional overhead. Each table takes up at least 16K entails a lot of additional overhead. Each table takes up at least 16K
of disk space, even if it holds little information. When the last page of disk space, even if it holds little information. When the last page
of a table contains little information, close to 16K of space is unused of a table contains little information, close to 16K of space is unused
on that page. The initial size of the system tables for a newly created on that page. The initial size of the system tables for a newly created
database on a 16K server is also quite large: 9.4Mb. 16K can be the database on a 16K server is also quite large: 9.4Mb. 16K can be the
appropriate logical page size for the server, but only when very large appropriate logical page size for the server, but only when very large
rows and query results will be the norm. rows and query results will be the norm.
In this lab we will compare a 2K logical page size server and an 8K In this lab we will compare a 2K logical page size server and an 8K
logical page size server. An 8K choice will demonstrate the logical page size server. An 8K choice will demonstrate the
differences more readily than a choice of 4K. differences more readily than a choice of 4K.
1. Explore some of the characteristics of a 2K page size Adaptive Server. 1. Explore some of the characteristics of a 2K page size Adaptive Server.
a. Continuing in Window A as the sa connected to the 2K Adaptive Server, verify a. Continuing in Window A as the sa connected to the 2K Adaptive Server, verify
that this is indeed a 2K page size server by examining the Adaptive Server global that this is indeed a 2K page size server by examining the Adaptive Server global
variable @@maxpagesize. variable @@maxpagesize.
c. Execute sp_spaceused on the following tables in the model database and fill in the c. Execute sp_spaceused on the following tables in the model database and fill in the
chart that follows: chart that follows:
For the entire database For the entire database
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 7 - 5 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 7 - 5
2K Server model database sysobjects sysprocedures 2K Server model database sysobjects sysprocedures
reserved (KB) reserved (KB)
data (KB) data (KB)
index_size (KB) index_size (KB)
2. End your client session with the 2K Adaptive Server. 2. End your client session with the 2K Adaptive Server.
3. Explore similar characteristics of an 8K page size Adaptive Server. 3. Explore similar characteristics of an 8K page size Adaptive Server.
a. In Window B, start your 8K page size Adaptive Server by using the Sybase a. In Window B, start your 8K page size Adaptive Server by using the Sybase
startserver utility with the appropriate RUNSERVER file. startserver utility with the appropriate RUNSERVER file.
The Unix machines in Sybase Learning Centers have two ASE 15.0 The Unix machines in Sybase Learning Centers have two ASE 15.0
servers already installed for each student. The names of the servers servers already installed for each student. The names of the servers
for each student correspond to the respective Unix login name. For for each student correspond to the respective Unix login name. For
example if your Unix login is dub101, then your servers are named: example if your Unix login is dub101, then your servers are named:
DUB101_2K and DUB101_2K and
DUB101_8K. DUB101_8K.
The difference between the two servers is the page size used. The difference between the two servers is the page size used.
DUB101_2K uses a 2K page size while DUB101_8K uses an 8K DUB101_2K uses a 2K page size while DUB101_8K uses an 8K
page size. page size.
In Sybase Learning Centers, the Unix environment variable In Sybase Learning Centers, the Unix environment variable
DSQUERY8 has been set up as a convenience to point to your 8K DSQUERY8 has been set up as a convenience to point to your 8K
Adaptive Server. Note that this is not a standard Sybase environment Adaptive Server. Note that this is not a standard Sybase environment
variable like DSQUERY. variable like DSQUERY.
cd $SYBASE/$SYBASE_ASE/install cd $SYBASE/$SYBASE_ASE/install
startserver -f RUN_$DSQUERY8 startserver -f RUN_$DSQUERY8
b. In Window A, connect to the 8K Adaptive Server as the sa using the NULL b. In Window A, connect to the 8K Adaptive Server as the sa using the NULL
password. password.
isql -Usa -P -S $DSQUERY8 isql -Usa -P -S $DSQUERY8
c. Verify that this is indeed an 8K page size server by examining the Adaptive Server c. Verify that this is indeed an 8K page size server by examining the Adaptive Server
global variable @@maxpagesize. global variable @@maxpagesize.
Lab 7 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 7 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 7: Creating and Using Databases Module 7: Creating and Using Databases
e. Execute sp_spaceused on the following tables in the model database and fill in the e. Execute sp_spaceused on the following tables in the model database and fill in the
chart that follows: chart that follows:
For the entire database For the entire database
8K Server model database sysobjects sysprocedures 8K Server model database sysobjects sysprocedures
reserved (KB) reserved (KB)
data (KB) data (KB)
index_size (KB) index_size (KB)
Both the 2K and 8K Adaptive Servers have their model database in Both the 2K and 8K Adaptive Servers have their model database in
its default condition with no added user objects. its default condition with no added user objects.
Explain why databases and tables with similar content take up Explain why databases and tables with similar content take up
significantly more space on an 8K server than on a 2K server. significantly more space on an 8K server than on a 2K server.
4. End your client session with the 8K Adaptive Server. 4. End your client session with the 8K Adaptive Server.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 7 - 7 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 7 - 7
Task 3: Writing Queries that Use sysdevices, sysusages, and Task 3: Writing Queries that Use sysdevices, sysusages, and
sysdatabases sysdatabases
Description In this task, you will write queries that use sysdevices, sysusages and sysdatabases. Description In this task, you will write queries that use sysdevices, sysusages and sysdatabases.
Procedure 1. Write queries against system tables that return useful device and database diagnostics. Procedure 1. Write queries against system tables that return useful device and database diagnostics.
a. In Window A, connect to your 2K Adaptive Server as the sa. a. In Window A, connect to your 2K Adaptive Server as the sa.
b. Write a query to show which databases are on database device data_dev. (Hint: b. Write a query to show which databases are on database device data_dev. (Hint:
Comparing sysusages.vdevno with sysdevices.vdevno will tell you which device Comparing sysusages.vdevno with sysdevices.vdevno will tell you which device
each database fragment is on.) each database fragment is on.)
c. Execute the query again for only the master device. c. Execute the query again for only the master device.
d. Write another query to determine how much free space there is on the device d. Write another query to determine how much free space there is on the device
data_dev. (Hint: The relevant rows in sysusages can be found using the same data_dev. (Hint: The relevant rows in sysusages can be found using the same
comparison as in the previous query.) comparison as in the previous query.)
e. Perform a similar query to determine how much free space there is on the master e. Perform a similar query to determine how much free space there is on the master
device. device.
f. End your client session with the 2K Adaptive Server. f. End your client session with the 2K Adaptive Server.
2. Given the following output from sysusages for a hypothetical database named sales, 2. Given the following output from sysusages for a hypothetical database named sales,
write down the command sequence that was used to create the database. (Assume that write down the command sequence that was used to create the database. (Assume that
the device names associated with vdevno values 5, 6, and 7 are dev1, dev2, and dev3, the device names associated with vdevno values 5, 6, and 7 are dev1, dev2, and dev3,
respectively.) respectively.)
select * from sysusages where dbid = db_id('sales') select * from sysusages where dbid = db_id('sales')
go go
dbid segmap lstart size vstart pad unreservedpgs crdate vdevno dbid segmap lstart size vstart pad unreservedpgs crdate vdevno
------ ------ ------ ----- ------ ---- ------------- ------------ ------ ------ ------ ------ ----- ------ ---- ------------- ------------ ------
6 3 0 1024 0 NULL 168 Oct 4 2005 5 6 3 0 1024 0 NULL 168 Oct 4 2005 5
6 4 1024 512 0 NULL 510 Oct 4 2005 6 6 4 1024 512 0 NULL 510 Oct 4 2005 6
6 3 1536 512 0 NULL 510 Oct 4 2005 7 6 3 1536 512 0 NULL 510 Oct 4 2005 7
3. Exit all client sessions with Adaptive Server. 3. Exit all client sessions with Adaptive Server.
Lab 7 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 7 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 8: Suggested Disk Resource Strategies Module 8: Suggested Disk Resource Strategies
Module 8: Suggested Disk Resource Strategies Module 8: Suggested Disk Resource Strategies
Lab 8: Using Free Space Thresholds Lab 8: Using Free Space Thresholds
Lab setup You will be using your 2K page size Adaptive Server for this lab. Lab setup You will be using your 2K page size Adaptive Server for this lab.
Note: If you have not completed lab 7 in which you should have Note: If you have not completed lab 7 in which you should have
created two database devices, data_dev, and log_dev and a database created two database devices, data_dev, and log_dev and a database
named my_db, then issue the following commands now (see script named my_db, then issue the following commands now (see script
lab08_setup.sql) (substituting $SYBASE appropriately): lab08_setup.sql) (substituting $SYBASE appropriately):
disk init disk init
name = "data_dev", name = "data_dev",
physname = "$SYBASE/devices/data_dev.dat", physname = "$SYBASE/devices/data_dev.dat",
size = "4M" size = "4M"
go go
Objectives After completing this lab, you should be able to: Objectives After completing this lab, you should be able to:
Create a free space threshold procedure Create a free space threshold procedure
Establish a threshold on a database segment to report when the free space drops below Establish a threshold on a database segment to report when the free space drops below
a specified level. a specified level.
Verify that the free space threshold delivers messages to the server log. Verify that the free space threshold delivers messages to the server log.
Description In this lab, you will learn how to construct a free space threshold procedure and set it in Description In this lab, you will learn how to construct a free space threshold procedure and set it in
use in a database to report a shortage of space. use in a database to report a shortage of space.
Task outline 1. Creating and verifying a free space threshold Task outline 1. Creating and verifying a free space threshold
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 8 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 8 - 1
Task 1: Creating a free space threshold procedure Task 1: Creating a free space threshold procedure
Description In this task, you will create a free space threshold procedure for the my_db database. Description In this task, you will create a free space threshold procedure for the my_db database.
Procedure Procedure
For all labs, you should open two windows (“A” and “B”). Unless For all labs, you should open two windows (“A” and “B”). Unless
instructed otherwise, perform all lab exercises in Window A. instructed otherwise, perform all lab exercises in Window A.
You use Window B primarily as a console for starting up Adaptive You use Window B primarily as a console for starting up Adaptive
Server and executing OS commands. All Adaptive Server system Server and executing OS commands. All Adaptive Server system
messages are displayed there instead of in your active ASE client messages are displayed there instead of in your active ASE client
window. window.
1. Examine the current state of the my_db database. 1. Examine the current state of the my_db database.
a. In Window A, connect to the 2K Adaptive Server as the sa and use the my_db a. In Window A, connect to the 2K Adaptive Server as the sa and use the my_db
database database
b. Examine the layout of my_db by using sp_helpdb to determine the free space in b. Examine the layout of my_db by using sp_helpdb to determine the free space in
the default data segment. the default data segment.
sp_helpdb my_db sp_helpdb my_db
What is the number of free Kbytes for the data_only portion of my_db ? What is the number of free Kbytes for the data_only portion of my_db ?
The database that we will be using is small, however, the principle The database that we will be using is small, however, the principle
is the same for any database. It is important to have time to react to is the same for any database. It is important to have time to react to
a shortage of space within a database. To do so it is necessary to a shortage of space within a database. To do so it is necessary to
establish a threshold and keep track of the messages in the log file. establish a threshold and keep track of the messages in the log file.
For this exercise, we wish to know when the database is down to For this exercise, we wish to know when the database is down to
only 400 pages left as free space so there is time to increase the size only 400 pages left as free space so there is time to increase the size
or other action. or other action.
2. Create a procedure called first_alert.. 2. Create a procedure called first_alert..
Lab 8 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 8 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 8: Suggested Disk Resource Strategies Module 8: Suggested Disk Resource Strategies
a. Write and create a T-SQL stored procedure as follows: a. Write and create a T-SQL stored procedure as follows:
b. Verify the stored procedure was created by using sp_helptext: b. Verify the stored procedure was created by using sp_helptext:
3. Continuing in Window A and still using the my_db database, use sp_helpthreshold 3. Continuing in Window A and still using the my_db database, use sp_helpthreshold
stored procedure to determine what thresholds are currently defined for the my_db stored procedure to determine what thresholds are currently defined for the my_db
database. database.
sp_helpthreshold sp_helpthreshold
The database is created with a threshold for the logsegment that The database is created with a threshold for the logsegment that
records an entry in the error log when the transaction log reaches 88 records an entry in the error log when the transaction log reaches 88
free pages and the transaction log will need to be trunctated to free free pages and the transaction log will need to be trunctated to free
up additional space. You may see the results of this threshold when up additional space. You may see the results of this threshold when
testing for correct operation of the threshold that we will be creating. testing for correct operation of the threshold that we will be creating.
4. Create a free space threshold within the my_db database that will use the first_alert 4. Create a free space threshold within the my_db database that will use the first_alert
threshold procedure when the free space in the default (data) segment reaches 400 threshold procedure when the free space in the default (data) segment reaches 400
pages. Use the sp_addthreshold stored procedure. pages. Use the sp_addthreshold stored procedure.
sp_addthreshold my_db, “default”, 400, first_alert sp_addthreshold my_db, “default”, 400, first_alert
5. Recheck the currently defined thresholds with sp_helpthreshold 5. Recheck the currently defined thresholds with sp_helpthreshold
sp_helpthreshold sp_helpthreshold
6. Change the dboption for my_db database to allow for "select into" capability to help 6. Change the dboption for my_db database to allow for "select into" capability to help
build up a table to use space in the data segment. Use the following set of commands: build up a table to use space in the data segment. Use the following set of commands:
use master use master
sp_dboption my_db, 'select into', true sp_dboption my_db, 'select into', true
7. Create a table within my_db where data can be added to test the threshold that was 7. Create a table within my_db where data can be added to test the threshold that was
added. Use the following select statement: added. Use the following select statement:
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 8 - 3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 8 - 3
select * into titles from pubs2..titles select * into titles from pubs2..titles
8. Check the current status of free space within the default segment using 8. Check the current status of free space within the default segment using
sp_helpsegment. sp_helpsegment.
sp_helpsegment 'default' sp_helpsegment 'default'
9. Insert data into the titles table to fill the default segment using the following statement: 9. Insert data into the titles table to fill the default segment using the following statement:
[The use of the number 250 after the go (a space after the go is required also) will have [The use of the number 250 after the go (a space after the go is required also) will have
the effect of issuing the command 250 times We will issue this command twice with the effect of issuing the command 250 times We will issue this command twice with
the truncating of the transaction log in between] the truncating of the transaction log in between]
a. Insert data into the titles table using the following command: a. Insert data into the titles table using the following command:
insert into titles select * from pubs2..titles insert into titles select * from pubs2..titles
go 250 go 250
b. Truncate the my_db database transaction log with the following command: b. Truncate the my_db database transaction log with the following command:
dump tran my_db with truncate_only dump tran my_db with truncate_only
c. Again, insert data into the titles table using the following command c. Again, insert data into the titles table using the following command
insert into titles select * from pubs2..titles insert into titles select * from pubs2..titles
go 250 go 250
Conduct a search of the error log by any method that will show the Conduct a search of the error log by any method that will show the
entry that contains information about pages left in the default entry that contains information about pages left in the default
segment. Use Notepad or the find command at a command prompt. segment. Use Notepad or the find command at a command prompt.
10. In Window B at a command prompt, search the error log for the string "pages left in" 10. In Window B at a command prompt, search the error log for the string "pages left in"
using the following command: using the following command:
grep "pages left in" $SYBASE/$SYBASE_ASE/install/$DSQUERY.log grep "pages left in" $SYBASE/$SYBASE_ASE/install/$DSQUERY.log
11. Perform a final check of the segment with sp_helpsegment 11. Perform a final check of the segment with sp_helpsegment
sp_helpsegment 'default' sp_helpsegment 'default'
Did the threshold work as you expected? Did the threshold work as you expected?
Yes. a report was sent to the error log to identify that the Yes. a report was sent to the error log to identify that the
threshold was reached. threshold was reached.
12. Drop table titles from the database. 12. Drop table titles from the database.
Lab 8 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 8 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 9: Auto Expansion Module 9: Auto Expansion
Lab setup You will be using your 2K page size Adaptive Server for this lab. There is no additional Lab setup You will be using your 2K page size Adaptive Server for this lab. There is no additional
setup for this lab. setup for this lab.
Objectives After completing this lab, you should be able to: Objectives After completing this lab, you should be able to:
Install and configure Adaptive Server for Auto Expansion Install and configure Adaptive Server for Auto Expansion
Understand the administrative limitations when not employing Auto Expansion Understand the administrative limitations when not employing Auto Expansion
Define the database and device level policies for triggering Auto Expansion Define the database and device level policies for triggering Auto Expansion
Realize the benefits provided by Auto Expansion. Realize the benefits provided by Auto Expansion.
Understand the process in removing the functionality. Understand the process in removing the functionality.
Description In this lab, you will learn how to setup your Adaptive Server to support Auto Expansion of Description In this lab, you will learn how to setup your Adaptive Server to support Auto Expansion of
database and devices. You will define the threshold needed to fire the expansion process. database and devices. You will define the threshold needed to fire the expansion process.
You will learn the advantages of using Auto Expansion feature sets as compared to having You will learn the advantages of using Auto Expansion feature sets as compared to having
the default database functionality. the default database functionality.
Task outline 1. Installing Auto Expansion scripts Task outline 1. Installing Auto Expansion scripts
2. Verifying default database behavior 2. Verifying default database behavior
3. Setup Auto Database and Device Expansion Policy 3. Setup Auto Database and Device Expansion Policy
4. Validating and simulating effects of Auto Expansion 4. Validating and simulating effects of Auto Expansion
5. Removing Auto Expansion 5. Removing Auto Expansion
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 9 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 9 - 1
Task 1: Installing Auto Expansion scripts Task 1: Installing Auto Expansion scripts
Description In this task, you will create new database devices for auto expansion and create the test Description In this task, you will create new database devices for auto expansion and create the test
databases. databases.
Procedure Procedure
For most of the labs, you should open two windows (“A” and “B”). For most of the labs, you should open two windows (“A” and “B”).
• Window A is your ISQL session connected to your server • Window A is your ISQL session connected to your server
primarily using the ‘sa’ account. This is where you enter the lab primarily using the ‘sa’ account. This is where you enter the lab
commands and SQL statements. commands and SQL statements.
• You use Window B for monitoring the Adaptive Server errorlog • You use Window B for monitoring the Adaptive Server errorlog
file. file.
Where there is no mention of Window name, use Window A. Where there is no mention of Window name, use Window A.
1. Connect to the host machine and run the auto expansion install script using the 1. Connect to the host machine and run the auto expansion install script using the
following command. following command.
cd $SYBASE/$SYBASE_ASE/scripts/ cd $SYBASE/$SYBASE_ASE/scripts/
isql -Usa -P -iinstalldbextend -o$HOME/sa/output.txt isql -Usa -P -iinstalldbextend -o$HOME/sa/output.txt
2. Verify from the output file that the script ran successfully. If the output file contains 2. Verify from the output file that the script ran successfully. If the output file contains
errors, resolve the problem and re-run the script before proceeding. Consult your errors, resolve the problem and re-run the script before proceeding. Consult your
instructor if you need assistance. instructor if you need assistance.
3. In your Window B, start monitoring your Adaptive Server errorlog file with the Linux 3. In your Window B, start monitoring your Adaptive Server errorlog file with the Linux
utility ‘tail’. The errorlog file name is in the form <ServerName>.log. utility ‘tail’. The errorlog file name is in the form <ServerName>.log.
cd $SYBASE/$SYBASE_ASE/install/ cd $SYBASE/$SYBASE_ASE/install/
tail -f $DSQUERY.log tail -f $DSQUERY.log
Lab 9 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 9 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 9: Auto Expansion Module 9: Auto Expansion
4. Login to your server as 'sa' and create the devices needed for this lab. Replace the file 4. Login to your server as 'sa' and create the devices needed for this lab. Replace the file
path appropriately. Run the commands from master database. path appropriately. Run the commands from master database.
5. Create the ‘auto_db’ database as follows. 5. Create the ‘auto_db’ database as follows.
create database auto_db on auto_dat=3 log on auto_log=3 create database auto_db on auto_dat=3 log on auto_log=3
go go
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 9 - 3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 9 - 3
Task 2: Verifying default database behavior Task 2: Verifying default database behavior
Description In this task, you will simulate data change that will saturate the default segment of the Description In this task, you will simulate data change that will saturate the default segment of the
auto_db database. In the process, you will acquire an understanding of Adaptive Servers auto_db database. In the process, you will acquire an understanding of Adaptive Servers
behavior when database segments run out of space. behavior when database segments run out of space.
Procedure 1. In order to minimize needed administrative actions when device and segments are Procedure 1. In order to minimize needed administrative actions when device and segments are
saturated, we will enable the database option "abort tran on log full". This command saturated, we will enable the database option "abort tran on log full". This command
is executed from the master database. is executed from the master database.
2. Enable the "select into bulkcopy" option so we can transfer data from pubs2 database 2. Enable the "select into bulkcopy" option so we can transfer data from pubs2 database
to simulate OLTP transactions. to simulate OLTP transactions.
3. Capture the database space information for auto_db as a baseline, prior to any data 3. Capture the database space information for auto_db as a baseline, prior to any data
change. Take note of the value for the "log only free kbytes" as well as the "free change. Take note of the value for the "log only free kbytes" as well as the "free
kbytes" for auto_dat device. Capture a summary report, as shown below, by kbytes" for auto_dat device. Capture a summary report, as shown below, by
executing the command from the master database. executing the command from the master database.
Enter Value for "free kbytes" for auto_dat _____________ Enter Value for "free kbytes" for auto_dat _____________
Enter Value for "log only free kbytes" __________________ Enter Value for "log only free kbytes" __________________
4. Capture the device space utilization for auto_dat as a baseline before any size 4. Capture the device space utilization for auto_dat as a baseline before any size
changes. Take note of the original device size. changes. Take note of the original device size.
5. Simulate an OLTP transaction that can fill up the database default segment. The first 5. Simulate an OLTP transaction that can fill up the database default segment. The first
statement creates an empty auto_db..blurbs table using the pubs2..blurbs table statement creates an empty auto_db..blurbs table using the pubs2..blurbs table
definition. Next you will execute an INSERT from the pubs2..blurbs table for 110 definition. Next you will execute an INSERT from the pubs2..blurbs table for 110
iterations. Run the following commands within the context of auto_db database. iterations. Run the following commands within the context of auto_db database.
use auto_db use auto_db
go go
select * into blurbs from pubs2..blurbs where 1=2 select * into blurbs from pubs2..blurbs where 1=2
go go
insert into blurbs select * from pubs2..blurbs insert into blurbs select * from pubs2..blurbs
go 110 go 110
Lab 9 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 9 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 9: Auto Expansion Module 9: Auto Expansion
6. The pubs2..blurbs table contains 6 rows. Running the INSERT statement 110 times 6. The pubs2..blurbs table contains 6 rows. Running the INSERT statement 110 times
successfully should have resulted in 660 rows being inserted into auto_db..blurbs successfully should have resulted in 660 rows being inserted into auto_db..blurbs
table. Each individual INSERT is a transaction. Check to see how many rows actually table. Each individual INSERT is a transaction. Check to see how many rows actually
exist by selecting the count of all rows from the table. exist by selecting the count of all rows from the table.
How many rows were inserted ? Explain. How many rows were inserted ? Explain.
7. Re-run sp_helpdb on the database to gather space utilization statistics after saturating 7. Re-run sp_helpdb on the database to gather space utilization statistics after saturating
the 'default' segment. the 'default' segment.
What is the value for auto_dat free kbytes? . What is the value for auto_dat free kbytes? .
What is the value for “log only free kbytes” . What is the value for “log only free kbytes” .
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 9 - 5 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 9 - 5
Task 3: Setup Auto Database and Device Expansion Policy Task 3: Setup Auto Database and Device Expansion Policy
Description In this task, you will define auto expansion policies for database and devices as well as Description In this task, you will define auto expansion policies for database and devices as well as
create the threshold that will trigger the process. create the threshold that will trigger the process.
Procedure 1. Cleanup the changes made by the initial testing. Truncate the blurbs table in the Procedure 1. Cleanup the changes made by the initial testing. Truncate the blurbs table in the
auto_db database. auto_db database.
2. Purge the auto_db transaction log to free up space for additional testing by dumping 2. Purge the auto_db transaction log to free up space for additional testing by dumping
the transaction file using the option ‘with truncate only’. the transaction file using the option ‘with truncate only’.
3. Verify that space is available with sp_helpdb and that free kbytes have returned to 3. Verify that space is available with sp_helpdb and that free kbytes have returned to
near baseline. near baseline.
4. Using sp_dbextend, setup auto expansion functionality for the auto_db database by 4. Using sp_dbextend, setup auto expansion functionality for the auto_db database by
establishing a policy that will expand the database default segment by the “growby” establishing a policy that will expand the database default segment by the “growby”
value of 1 MB each time the expansion is fired and set the maximum size policy to 10 value of 1 MB each time the expansion is fired and set the maximum size policy to 10
MB. Be sure your context is in the auto_db database in order to run the procedure. MB. Be sure your context is in the auto_db database in order to run the procedure.
use auto_db use auto_db
go go
sp_dbextend 'set', 'database', auto_db, 'default', '1M', '10MB' sp_dbextend 'set', 'database', auto_db, 'default', '1M', '10MB'
go go
5. Define the device expansion policy for the auto_dat device to increase size by 5 MB 5. Define the device expansion policy for the auto_dat device to increase size by 5 MB
each time the expansion is fired and set the maximum size policy to 50 MB. each time the expansion is fired and set the maximum size policy to 50 MB.
sp_dbextend 'set', 'device', 'auto_dat', '5m', '50m' sp_dbextend 'set', 'device', 'auto_dat', '5m', '50m'
go go
6. Once the database and device expansion policies are set, the next step is to define the 6. Once the database and device expansion policies are set, the next step is to define the
threshold policy. The threshold policy is the triggering mechanism of the auto threshold policy. The threshold policy is the triggering mechanism of the auto
expansion feature. Using the following command, auto expansion will fire when the expansion feature. Using the following command, auto expansion will fire when the
default segment has only 1 MB of free space left. default segment has only 1 MB of free space left.
sp_dbextend 'set', 'threshold', auto_db, 'default', '1m' sp_dbextend 'set', 'threshold', auto_db, 'default', '1m'
go go
Lab 9 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 9 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 9: Auto Expansion Module 9: Auto Expansion
7. View the auto database expansion policy currently configured for auto_db database. 7. View the auto database expansion policy currently configured for auto_db database.
sp_dbextend listfull, 'database', 'auto_db' sp_dbextend listfull, 'database', 'auto_db'
go go
8. View the auto device expansion policy currently configured for auto_dat device. 8. View the auto device expansion policy currently configured for auto_dat device.
sp_dbextend listfull, 'device', 'auto_dat' sp_dbextend listfull, 'device', 'auto_dat'
go go
9. View the threshold policy for the auto_db database. 9. View the threshold policy for the auto_db database.
sp_dbextend list, 'threshold', 'auto_db' sp_dbextend list, 'threshold', 'auto_db'
go go
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 9 - 7 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 9 - 7
Task 4: Validating and simulating effects of Auto Expansion Task 4: Validating and simulating effects of Auto Expansion
Description This task will demonstrate the capabilities of auto expansion. Description This task will demonstrate the capabilities of auto expansion.
Procedure 1. Execute the insert command once again for 110 times to simulate data changes. Procedure 1. Execute the insert command once again for 110 times to simulate data changes.
insert into blurbs select * from pubs2..blurbs insert into blurbs select * from pubs2..blurbs
go 110 go 110
2. In your Window B, the Adaptive Server errorlog will display the following message 2. In your Window B, the Adaptive Server errorlog will display the following message
confirming the use of auto expansion feature. confirming the use of auto expansion feature.
3. Verify the result for the auto_dat device using sp_helpdevice procedure. 3. Verify the result for the auto_dat device using sp_helpdevice procedure.
What has happened to the device size ? What has happened to the device size ?
4. Check the space allocation for the auto_db database after auto expansion with 4. Check the space allocation for the auto_db database after auto expansion with
sp_helpdb. sp_helpdb.
What has changed with device fragments ? Is this what is expected What has changed with device fragments ? Is this what is expected
after the settings that were made for Auto Expansion ? after the settings that were made for Auto Expansion ?
There are now two additional data device fragments of 1 Mb There are now two additional data device fragments of 1 Mb
size. The two slices corresponds to the event of the last two size. The two slices corresponds to the event of the last two
transactions that failed due to full default segment. YES – This is transactions that failed due to full default segment. YES – This is
what was expected to happen. what was expected to happen.
5. Check that the current policy for auto_db database is consistent against its segments 5. Check that the current policy for auto_db database is consistent against its segments
and the device layouts. Particularly for the default segment. A return status of 0 and the device layouts. Particularly for the default segment. A return status of 0
indicates no error. indicates no error.
sp_dbextend 'check', 'database', 'auto_db', 'default' sp_dbextend 'check', 'database', 'auto_db', 'default'
go go
Lab 9 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 9 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 9: Auto Expansion Module 9: Auto Expansion
6. Auto expansion feature can also be tested through a simulation exercise. Run the 6. Auto expansion feature can also be tested through a simulation exercise. Run the
following command to simulate expansion. The 4th parameter defines the number of following command to simulate expansion. The 4th parameter defines the number of
iterations and defaults to ‘1’ if not specified. iterations and defaults to ‘1’ if not specified.
use auto_db use auto_db
go go
sp_dbextend 'simulate', auto_db, 'default', '1' sp_dbextend 'simulate', auto_db, 'default', '1'
go go
It is possible to apply the expansion immediately, bypassing the It is possible to apply the expansion immediately, bypassing the
threshold, by using the command parameter “execute” of the threshold, by using the command parameter “execute” of the
sp_dbextend procedure. sp_dbextend procedure.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 9 - 9 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 9 - 9
Description The procedures discussed in this task will remove the auto expansion feature and bring Description The procedures discussed in this task will remove the auto expansion feature and bring
back the environment to its default setting. It is a good exercise to see how you can back the environment to its default setting. It is a good exercise to see how you can
remove the features that you have just installed. remove the features that you have just installed.
Procedure 1. Clear the device policy for the auto_dat device, clear the database policy for the Procedure 1. Clear the device policy for the auto_dat device, clear the database policy for the
default segment, and remove the threshold policy defined for the auto_db database on default segment, and remove the threshold policy defined for the auto_db database on
the default segment. the default segment.
use auto_db use auto_db
go go
exec sp_dbextend 'clear', 'database', auto_db, 'default' exec sp_dbextend 'clear', 'database', auto_db, 'default'
exec sp_dbextend 'clear', 'database', auto_db, 'default' exec sp_dbextend 'clear', 'database', auto_db, 'default'
exec sp_dbextend 'clear', 'threshold', auto_db, 'default' exec sp_dbextend 'clear', 'threshold', auto_db, 'default'
go go
2. Verify the current state of the auto expansion policy with the listfull parameter of 2. Verify the current state of the auto expansion policy with the listfull parameter of
sp_dbextend procedure for both the database and the device. sp_dbextend procedure for both the database and the device.
exec sp_dbextend listfull, 'database', 'auto_db' exec sp_dbextend listfull, 'database', 'auto_db'
exec sp_dbextend listfull, 'device', 'auto_dat' exec sp_dbextend listfull, 'device', 'auto_dat'
go go
3. Drop the auto_db database. Execute the command from the master database. 3. Drop the auto_db database. Execute the command from the master database.
4. Drop the associated database devices. Remember to delete the files in 4. Drop the associated database devices. Remember to delete the files in
$SYBASE/devices associated with these devices. $SYBASE/devices associated with these devices.
exec sp_dropdevice auto_dat exec sp_dropdevice auto_dat
exec sp_dropdevice auto_log exec sp_dropdevice auto_log
go go
5. In Window B, end the tail command by using <ctrl> C to interrupt the process. 5. In Window B, end the tail command by using <ctrl> C to interrupt the process.
Lab 9 - 10 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 9 - 10 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 10: Managing tempdb Module 10: Managing tempdb
Lab 10: User Defined Tempdb Lab 10: User Defined Tempdb
Lab setup You will be using your 2K page size Adaptive Server for this lab. A script will be specified Lab setup You will be using your 2K page size Adaptive Server for this lab. A script will be specified
in Task 1 that will assist in the setting of some account information. in Task 1 that will assist in the setting of some account information.
Objectives After completing this lab, you should be able to: Objectives After completing this lab, you should be able to:
Prepare a temporary database devices and create multiple temporary databases Prepare a temporary database devices and create multiple temporary databases
Bind logins to a temporary database or tempdb group Bind logins to a temporary database or tempdb group
Description In this lab, you will practice the implementating of an additional temporary database Description In this lab, you will practice the implementating of an additional temporary database
configuration. You will also practice the binding of a login with a user-created tempdb. configuration. You will also practice the binding of a login with a user-created tempdb.
Task outline 1. Creating a user defined tempdb Task outline 1. Creating a user defined tempdb
2. Binding of a login to a tempdb 2. Binding of a login to a tempdb
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 10 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 10 - 1
Task 1: Creating a user defined tempdb Task 1: Creating a user defined tempdb
Description In this task, you will initialize new database devices for multiple tempdbs and create the Description In this task, you will initialize new database devices for multiple tempdbs and create the
temporary databases. temporary databases.
Procedure Procedure
For most of the labs, you should open three windows (A, B, and C). For most of the labs, you should open three windows (A, B, and C).
• Window A is your ISQL session connected to your server • Window A is your ISQL session connected to your server
primarily using the ‘sa’ account. In some portions, an ISQL primarily using the ‘sa’ account. In some portions, an ISQL
session is also needed by a user login account as described in the session is also needed by a user login account as described in the
lab instructions. lab instructions.
• Use Window B primarily as a console for starting up Adaptive • Use Window B primarily as a console for starting up Adaptive
Server and executing OS commands. All Adaptive Server Server and executing OS commands. All Adaptive Server
system messages are displayed there instead of in your active system messages are displayed there instead of in your active
ASE client window. ASE client window.
• Window C is your ISQL session connected to your server as • Window C is your ISQL session connected to your server as
needed by user logins, as described in the lab instructions. needed by user logins, as described in the lab instructions.
1. In Window A, open an isql session to your database server using the 'sa' login account. 1. In Window A, open an isql session to your database server using the 'sa' login account.
2. Create the device needed for a user defined tempdb . Change the path to the devices 2. Create the device needed for a user defined tempdb . Change the path to the devices
directory to the correct path for your environment - the Variable $HOME will not directory to the correct path for your environment - the Variable $HOME will not
work. work.
create temporary database tempdb_01 on tempdb_01_device = 10 create temporary database tempdb_01 on tempdb_01_device = 10
4. Temporary databases are almost like normal databases, except they are flagged with a 4. Temporary databases are almost like normal databases, except they are flagged with a
Lab 10 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 10 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 10: Managing tempdb Module 10: Managing tempdb
special status code to denote its usage. Verify this value (131328) from special status code to denote its usage. Verify this value (131328) from
master..sysdatabases, column status3. master..sysdatabases, column status3.
select name, dbid, crdate, status3 from master..sysdatabases select name, dbid, crdate, status3 from master..sysdatabases
The ‘status3’ control bits in master..sysdatabases has decimal The ‘status3’ control bits in master..sysdatabases has decimal
value '256' (131328-131072=256) defined as "user-created value '256' (131328-131072=256) defined as "user-created
tempdb".. tempdb"..
The following script will create a new login, manager_01 with the The following script will create a new login, manager_01 with the
password 'sybase'. password 'sybase'.
The script will also provide an alias to the login that will allow it to The script will also provide an alias to the login that will allow it to
have access to objects owned by the dbo of the database. have access to objects owned by the dbo of the database.
5. In Window B, at a command prompt, change directory to $HOME/sa directory and 5. In Window B, at a command prompt, change directory to $HOME/sa directory and
use the following command to execute the lab10_logins.sql T-SQL script use the following command to execute the lab10_logins.sql T-SQL script
cd $HOME/sa cd $HOME/sa
6. In Window A as the user 'sa', show the current ‘tempdb’ database assignment. 6. In Window A as the user 'sa', show the current ‘tempdb’ database assignment.
sp_tempdb show sp_tempdb show
7. Add the tempdb_01 database to the default group. Currently, Adaptive Server only 7. Add the tempdb_01 database to the default group. Currently, Adaptive Server only
supports the default group. User defined groups are intended for future Adaptive supports the default group. User defined groups are intended for future Adaptive
Server releases. Server releases.
sp_tempdb 'add', tempdb_01, 'default' sp_tempdb 'add', tempdb_01, 'default'
8. Verify the action by showing the current tempdb assignment. 8. Verify the action by showing the current tempdb assignment.
sp_tempdb show sp_tempdb show
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 10 - 3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 10 - 3
Description In this task, you will work on the process of binding a login or application to the temporary Description In this task, you will work on the process of binding a login or application to the temporary
database. database.
Procedure 1. In a third command prompt window, Window C, log into your server as Procedure 1. In a third command prompt window, Window C, log into your server as
'manager_01' with the password 'sybase'. The login will default to 'pubs2' database 'manager_01' with the password 'sybase'. The login will default to 'pubs2' database
which can be verified with a query. which can be verified with a query.
isql -Umanager_01 -Psybase isql -Umanager_01 -Psybase
The 'manager_01' login is bound to the default group and the The 'manager_01' login is bound to the default group and the
account may actually appear in either tempdb or tempdb_01 account may actually appear in either tempdb or tempdb_01
databases. It is unknown as to which database may be chosen databases. It is unknown as to which database may be chosen
for any particular session for the login. for any particular session for the login.
2. In the same Window C, as the manager_01 login, conduct a test to determine which 2. In the same Window C, as the manager_01 login, conduct a test to determine which
tempdb database is being used by the login for this particular session. Use the tempdb database is being used by the login for this particular session. Use the
following command that examines the contents of a new global variable and obtains following command that examines the contents of a new global variable and obtains
the name of the database: The results may be either one of those shown the name of the database: The results may be either one of those shown
Any objects created by this account may appear in either of Any objects created by this account may appear in either of
these tempdb's. To be sure and consistent , it makes sense to these tempdb's. To be sure and consistent , it makes sense to
bind this login to the new user defined tempdb_01 and remove bind this login to the new user defined tempdb_01 and remove
the ambiguity. This is done with the sp_tempdb procedure the ambiguity. This is done with the sp_tempdb procedure
bind option. bind option.
3. In Window A as the sa account, bind the 'manager_01' login to the 'tempdb_01' 3. In Window A as the sa account, bind the 'manager_01' login to the 'tempdb_01'
database explicitly using the default binding. database explicitly using the default binding.
sp_tempdb bind, 'LG', 'manager_01', 'DB', 'tempdb_01' sp_tempdb bind, 'LG', 'manager_01', 'DB', 'tempdb_01'
4. The above command will not affect current database connections and sessions. 4. The above command will not affect current database connections and sessions.
Therefore, using Window C, logout the 'manager_01' account and log back in for the Therefore, using Window C, logout the 'manager_01' account and log back in for the
settings to take effect. settings to take effect.
Lab 10 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 10 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 10: Managing tempdb Module 10: Managing tempdb
5. As the user manager_01, perform the test again to determine which tempdb database 5. As the user manager_01, perform the test again to determine which tempdb database
is being used by this particular session. The result should not be ambiguous. is being used by this particular session. The result should not be ambiguous.
select db_name(@@tempdbid) select db_name(@@tempdbid)
6. Using Window C, submit the following querys that will generate a list of 'Comp' 6. Using Window C, submit the following querys that will generate a list of 'Comp'
books and store the list in a temporary table in the tempdb_01 database and query the books and store the list in a temporary table in the tempdb_01 database and query the
list. list.
select titles.title, titles.title_id, titles.pub_id select titles.title, titles.title_id, titles.pub_id
into #CompBooks into #CompBooks
from titles, publishers from titles, publishers
where titles.pub_id = publishers.pub_id where titles.pub_id = publishers.pub_id
and titles.title like '%Comp%' and titles.title like '%Comp%'
7. Another way to verify the same information, and at the same time to determine which 7. Another way to verify the same information, and at the same time to determine which
tempdb is being used, is to check if the temporary table (#CompBooks) was created in tempdb is being used, is to check if the temporary table (#CompBooks) was created in
‘tempdb_01’. Execute the following statement from the ISQL connection. ‘tempdb_01’. Execute the following statement from the ISQL connection.
select name, id, crdate, loginame select name, id, crdate, loginame
from tempdb_01..sysobjects where name like '%CompBooks%' from tempdb_01..sysobjects where name like '%CompBooks%'
8. Drop the temporary objects from all active database connections. 8. Drop the temporary objects from all active database connections.
drop table #CompBooks drop table #CompBooks
9. End this lab by using your Window B, check to see if you are still located in the 9. End this lab by using your Window B, check to see if you are still located in the
directory “$HOME/sa” and execute the batch file lab10_cleanup.bat. The script will directory “$HOME/sa” and execute the batch file lab10_cleanup.bat. The script will
remove all of the items created in this lab. remove all of the items created in this lab.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 10 - 5 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 10 - 5
Lab 10 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 10 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 11: Administering System Roles and Logins Module 11: Administering System Roles and Logins
Module 11: Administering System Roles and Logins Module 11: Administering System Roles and Logins
Lab 11: Administering System Roles and Logins Lab 11: Administering System Roles and Logins
Lab Setup You will be using your 2K page size Adaptive Server for this lab. Lab Setup You will be using your 2K page size Adaptive Server for this lab.
No other setup is required for this lab. No other setup is required for this lab.
Objectives After completing this lab, you should be able to: Objectives After completing this lab, you should be able to:
Become familiar with ASE security features Become familiar with ASE security features
Description In this lab, you will learn how ASE security features work. Description In this lab, you will learn how ASE security features work.
Task Outline 1. Creating Two New Logins Task Outline 1. Creating Two New Logins
2. Administer the Logins by Granting System Roles to Them 2. Administer the Logins by Granting System Roles to Them
3. Locking a Login 3. Locking a Login
4. Accessing Adaptive Server with Different Logins and Examining their Functional 4. Accessing Adaptive Server with Different Logins and Examining their Functional
Capabilities Capabilities
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 11 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 11 - 1
Task 1: Creating Two New Logins Task 1: Creating Two New Logins
Description In this task, you will create two new logins. Description In this task, you will create two new logins.
Procedure Procedure
For all labs, you should open two windows (“A” and “B”). Unless For all labs, you should open two windows (“A” and “B”). Unless
instructed otherwise, perform all lab exercises in Window A. instructed otherwise, perform all lab exercises in Window A.
You use Window B primarily as a console for starting up Adaptive You use Window B primarily as a console for starting up Adaptive
Server and executing OS commands. All Adaptive Server system Server and executing OS commands. All Adaptive Server system
messages are displayed there instead of in your active ASE client messages are displayed there instead of in your active ASE client
window. window.
1. Create two new logins to the Adaptive Server. 1. Create two new logins to the Adaptive Server.
a. In Window A, connect to Adaptive Server as the sa. a. In Window A, connect to Adaptive Server as the sa.
c. Create another new login with the following characteristics: c. Create another new login with the following characteristics:
Lab 11 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 11 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 11: Administering System Roles and Logins Module 11: Administering System Roles and Logins
Task 2: Administering the Logins by Granting System Roles to Task 2: Administering the Logins by Granting System Roles to
Them Them
Description In this task, you will administer the logins by granting system roles to them. Description In this task, you will administer the logins by granting system roles to them.
Procedure 1. Administer the new logins. Procedure 1. Administer the new logins.
a. Continuing in Window A as the sa, examine the attributes of both new logins, a. Continuing in Window A as the sa, examine the attributes of both new logins,
mary and joe, by using sp_displaylogin. mary and joe, by using sp_displaylogin.
Were the logins created successfully according to the specifications Were the logins created successfully according to the specifications
concerning login name and default database? concerning login name and default database?
A minimum password length of 8 was assigned to joe but no A minimum password length of 8 was assigned to joe but no
assignment was specified when creating the login for mary. By assignment was specified when creating the login for mary. By
default, what is the minimum password length? default, what is the minimum password length?
Are the actual passwords shown in the sp_displaylogin output? Are the actual passwords shown in the sp_displaylogin output?
By default, are any roles assigned to new logins? By default, are any roles assigned to new logins?
By default, are new logins locked or unlocked? By default, are new logins locked or unlocked?
b. Grant the SSO role to mary. b. Grant the SSO role to mary.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 11 - 3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 11 - 3
Description In this task, you will lock a login. Description In this task, you will lock a login.
Procedure 1. Lock the account for mary. Procedure 1. Lock the account for mary.
a. Examine the updated attributes of both new logins, mary and joe, by using a. Examine the updated attributes of both new logins, mary and joe, by using
sp_displaylogin sp_displaylogin
2. Start up client sessions with Adaptive Server by using the new logins. 2. Start up client sessions with Adaptive Server by using the new logins.
a. In Window B, try to connect to Adaptive Server as mary. a. In Window B, try to connect to Adaptive Server as mary.
isql -Umary -P1001nites isql -Umary -P1001nites
Was this the expected behavior? Explain. Was this the expected behavior? Explain.
b. Continuing in Window B, connect to Adaptive Server as joe. b. Continuing in Window B, connect to Adaptive Server as joe.
c. Verify that joe is indeed connected to Adaptive Server and review his login c. Verify that joe is indeed connected to Adaptive Server and review his login
attributes by using sp_displaylogin with no arguments. attributes by using sp_displaylogin with no arguments.
d. Verify that joe is in his default database, model. d. Verify that joe is in his default database, model.
e. Change the password for joe to “10days”. e. Change the password for joe to “10days”.
Lab 11 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 11 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 11: Administering System Roles and Logins Module 11: Administering System Roles and Logins
Was the password change successful? Explain. Was the password change successful? Explain.
f. Change the password for joe to “1001days”. f. Change the password for joe to “1001days”.
g. While connected as joe, attempt to create a new login named johnny with the g. While connected as joe, attempt to create a new login named johnny with the
password “temp1234”. password “temp1234”.
h. As joe, try to unlock the account for mary. h. As joe, try to unlock the account for mary.
The login joe has the sa_role, but can he create new logins and The login joe has the sa_role, but can he create new logins and
unlock others? Explain. unlock others? Explain.
. .
i. Return to window A and, as sa, try to unlock the account for mary. i. Return to window A and, as sa, try to unlock the account for mary.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 11 - 5 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 11 - 5
Task 4: Accessing Adaptive Server with Different Logins and Task 4: Accessing Adaptive Server with Different Logins and
Examining their Functional Capabilities Examining their Functional Capabilities
Description In this task, you will access Adaptive Server with different logins and examine their Description In this task, you will access Adaptive Server with different logins and examine their
functional capabilities. functional capabilities.
Procedure 1. Start up a client session with Adaptive Server by using the mary login. Procedure 1. Start up a client session with Adaptive Server by using the mary login.
a. In Window B, exit the client session for joe and then try to connect as mary. a. In Window B, exit the client session for joe and then try to connect as mary.
Was the connection now successful? Was the connection now successful?
Was this the expected behavior? Explain. Was this the expected behavior? Explain.
b. Verify that mary is indeed connected to Adaptive Server and review her login b. Verify that mary is indeed connected to Adaptive Server and review her login
attributes by using sp_displaylogin with no arguments. attributes by using sp_displaylogin with no arguments.
c. Verify that mary is in her default database, master. c. Verify that mary is in her default database, master.
d. Change the password for mary to “10days”. d. Change the password for mary to “10days”.
This password change was rejected for joe. Was the password This password change was rejected for joe. Was the password
change successful for mary? Explain. change successful for mary? Explain.
e. While connected as mary, attempt to create a new login named johnny with the e. While connected as mary, attempt to create a new login named johnny with the
password “temp1234”. password “temp1234”.
f. As mary, try to lock the account for johnny. f. As mary, try to lock the account for johnny.
Lab 11 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 11 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 11: Administering System Roles and Logins Module 11: Administering System Roles and Logins
g. As mary, try to unlock the account for johnny. g. As mary, try to unlock the account for johnny.
The login joe has the sa_role, and he could not create new logins but The login joe has the sa_role, and he could not create new logins but
he could unlock other accounts. Can mary perform both of these he could unlock other accounts. Can mary perform both of these
tasks with the sso_role? tasks with the sso_role?
2. Drop the newly created logins. 2. Drop the newly created logins.
a. Return to window A and, as the sa, drop the login for joe. a. Return to window A and, as the sa, drop the login for joe.
b. Drop the login for johnny. b. Drop the login for johnny.
c. Drop the login for mary. c. Drop the login for mary.
If mary is still connected to Adaptive Server (in window B), can the If mary is still connected to Adaptive Server (in window B), can the
sa drop the active login? sa drop the active login?
d. Return to window B as mary and exit the client session with Adaptive Server. d. Return to window B as mary and exit the client session with Adaptive Server.
e. Return to window A as the sa and drop the mary login. e. Return to window A as the sa and drop the mary login.
f. Verify that the logins mary, joe, and johnny have all been dropped by examining f. Verify that the logins mary, joe, and johnny have all been dropped by examining
the entries for the name column in the syslogins table. the entries for the name column in the syslogins table.
3. Exit all client sessions with Adaptive Server. 3. Exit all client sessions with Adaptive Server.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 11 - 7 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 11 - 7
Lab 11 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 11 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 12: Managing Database Users and Groups Module 12: Managing Database Users and Groups
Module 12: Managing Database Users and Groups Module 12: Managing Database Users and Groups
Lab 12: Managing Database Users and Groups Lab 12: Managing Database Users and Groups
Lab Setup You will be using your 2K page size Adaptive Server for this lab. Lab Setup You will be using your 2K page size Adaptive Server for this lab.
Note: You need to have completed previous labs in which you created two database Note: You need to have completed previous labs in which you created two database
devices, data_dev and log_dev, and a database named my_db. If you did not finish those devices, data_dev and log_dev, and a database named my_db. If you did not finish those
labs or did not create the devices and database, then please refer to the instructions right labs or did not create the devices and database, then please refer to the instructions right
before step 1 of this lab. before step 1 of this lab.
Objectives After completing this lab, you should be able to: Objectives After completing this lab, you should be able to:
Become familiar with the mechanics of database access via users and groups Become familiar with the mechanics of database access via users and groups
Description In this lab, you will learn the mechanics of database access via users and groups. Description In this lab, you will learn the mechanics of database access via users and groups.
Task Outline 1. Adding Logins to the Server Task Outline 1. Adding Logins to the Server
2. Adding Users to a Database 2. Adding Users to a Database
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 12- 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 12- 1
Task 1: Adding Logins to the Server Task 1: Adding Logins to the Server
Description In this task, you will add logins to the server. Description In this task, you will add logins to the server.
Procedure Procedure
Note: If you have not completed the previous labs in which you Note: If you have not completed the previous labs in which you
should have created two database devices, data_dev and log_dev should have created two database devices, data_dev and log_dev
and a database named my_db, then issue the following commands and a database named my_db, then issue the following commands
now: (see script lab12_setup.sql) (substituting $SYBASE now: (see script lab12_setup.sql) (substituting $SYBASE
appropriately): appropriately):
disk init disk init
name = "data_dev", name = "data_dev",
physname = "$SYBASE/devices/data_dev.dat", physname = "$SYBASE/devices/data_dev.dat",
size = "4M" size = "4M"
go go
create database my_db on data_dev=4 log on log_dev=2 create database my_db on data_dev=4 log on log_dev=2
go go
For all labs, you should open two windows (“A” and “B”). Unless For all labs, you should open two windows (“A” and “B”). Unless
instructed otherwise, perform all lab exercises in Window A. instructed otherwise, perform all lab exercises in Window A.
You use Window B primarily as a console for starting up Adaptive You use Window B primarily as a console for starting up Adaptive
Server and executing OS commands. All Adaptive Server system Server and executing OS commands. All Adaptive Server system
messages are displayed there instead of in your active ASE client messages are displayed there instead of in your active ASE client
window. window.
1. Create three new logins to the Adaptive Server. 1. Create three new logins to the Adaptive Server.
a. In Window A, connect to Adaptive Server as the sa. a. In Window A, connect to Adaptive Server as the sa.
b. Create three new logins with the following characteristics: b. Create three new logins with the following characteristics:
Login names: tom dick harry Login names: tom dick harry
password: friday (for all 3) password: friday (for all 3)
Lab 12 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 12 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 12: Managing Database Users and Groups Module 12: Managing Database Users and Groups
default database: my_db (for all 3) default database: my_db (for all 3)
exec sp_addlogin tom, "friday", my_db exec sp_addlogin tom, "friday", my_db
exec sp_addlogin dick, "friday", my_db exec sp_addlogin dick, "friday", my_db
exec sp_addlogin harry, "friday", my_db exec sp_addlogin harry, "friday", my_db
Suppose harry has forgotten his password and needs help. As a login Suppose harry has forgotten his password and needs help. As a login
configured with the System Security Officer role (sso_role), what configured with the System Security Officer role (sso_role), what
are you enabled to do? are you enabled to do?
As the SSO with a password of sybase, write down the command As the SSO with a password of sybase, write down the command
you would use to give harry the new password saturday but do not you would use to give harry the new password saturday but do not
execute the command. execute the command.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 12- 3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 12- 3
Description In this task, you will add users to a database. Description In this task, you will add users to a database.
Procedure 1. Add these new logins as users in the my_db database. Procedure 1. Add these new logins as users in the my_db database.
a. Access the my_db database. a. Access the my_db database.
b. Add the three new logins, tom, dick, and harry as users to the database. b. Add the three new logins, tom, dick, and harry as users to the database.
c. Verify the existence of the three new users in the database by using sp_helpuser. c. Verify the existence of the three new users in the database by using sp_helpuser.
Do new database users initially belong to any groups? Do new database users initially belong to any groups?
2. Exit all client sessions with Adaptive Server. 2. Exit all client sessions with Adaptive Server.
Lab 12 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 12 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 13: Implementing Roles, Object Permissions, and Groups Module 13: Implementing Roles, Object Permissions, and Groups
Module 13: Implementing Roles, Object Permissions, and Module 13: Implementing Roles, Object Permissions, and
Groups Groups
Lab 13: Implementing Roles, Object Permissions, and Lab 13: Implementing Roles, Object Permissions, and
Groups Groups
Lab Setup You will be using your 2K page size Adaptive Server for this lab. Lab Setup You will be using your 2K page size Adaptive Server for this lab.
Objectives After completing this lab, you should be able to: Objectives After completing this lab, you should be able to:
Work with user-defined roles Work with user-defined roles
Implement object permissions for tables and stored procedures. Implement object permissions for tables and stored procedures.
Description In this lab, you will learn how to work with user-defined roles, how to implement object Description In this lab, you will learn how to work with user-defined roles, how to implement object
permissions for tables and stored procedures. permissions for tables and stored procedures.
Task Outline 1. Creating Groups and Adding Users to Those Groups Task Outline 1. Creating Groups and Adding Users to Those Groups
2. Testing User and Group Permissions 2. Testing User and Group Permissions
3. Creating User-defined Roles and Assigning to Logins 3. Creating User-defined Roles and Assigning to Logins
4. Examining Role Hierarchies and Test Role and Object Permissions 4. Examining Role Hierarchies and Test Role and Object Permissions
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 13 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 13 - 1
Task 1: Creating Groups and Adding Users to Those Groups Task 1: Creating Groups and Adding Users to Those Groups
Description In this task, you will create groups and add users to those groups. Description In this task, you will create groups and add users to those groups.
Procedure Note: If you have not completed the previous labs in which you Procedure Note: If you have not completed the previous labs in which you
should have created two database devices, data_dev and log_dev should have created two database devices, data_dev and log_dev
and a database named my_db, then issue the following commands and a database named my_db, then issue the following commands
now: (see script lab13_setup.sql) (substituting $SYBASE now: (see script lab13_setup.sql) (substituting $SYBASE
appropriately): appropriately):
disk init disk init
name = "data_dev", name = "data_dev",
physname = "$SYBASE/devices/data_dev.dat", physname = "$SYBASE/devices/data_dev.dat",
size = "4M" size = "4M"
go go
create database my_db on data_dev=4 log on log_dev=2 create database my_db on data_dev=4 log on log_dev=2
go go
For all labs, you should open two windows (“A” and “B”). Unless For all labs, you should open two windows (“A” and “B”). Unless
instructed otherwise, perform all lab exercises in Window A. instructed otherwise, perform all lab exercises in Window A.
You use Window B primarily as a console for starting up Adaptive You use Window B primarily as a console for starting up Adaptive
Server and executing OS commands. All Adaptive Server system Server and executing OS commands. All Adaptive Server system
messages are displayed there instead of in your active ASE client messages are displayed there instead of in your active ASE client
window. window.
1. Create a database group and add users to it. 1. Create a database group and add users to it.
a. Continuing in the my_db database as the sa, create a group named programmers. a. Continuing in the my_db database as the sa, create a group named programmers.
b. Create another group named engineers. b. Create another group named engineers.
c. Display the names of all the groups in the database by using sp_helpgroup. c. Display the names of all the groups in the database by using sp_helpgroup.
Lab 13 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 13 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 13: Implementing Roles, Object Permissions, and Groups Module 13: Implementing Roles, Object Permissions, and Groups
d. Add tom, dick, and harry to the programmers group. d. Add tom, dick, and harry to the programmers group.
e. Display the names of the users in the programmers group with sp_helpgroup. e. Display the names of the users in the programmers group with sp_helpgroup.
f. Add harry to the engineers group. f. Add harry to the engineers group.
g. Display the names of the users in the engineers group. g. Display the names of the users in the engineers group.
h. Display the names of the users in the programmers group. h. Display the names of the users in the programmers group.
Can a user be a member of 2 different user-defined groups within Can a user be a member of 2 different user-defined groups within
one database? one database?
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 13 - 3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 13 - 3
Task 2: Testing User and Group Permissions Task 2: Testing User and Group Permissions
Description In this task, you will create tables to test user and group permissions. Description In this task, you will create tables to test user and group permissions.
Procedure 1. Create user tables to test user and group permissions. Procedure 1. Create user tables to test user and group permissions.
a. Continuing in Window A as the sa, activate the database option “select a. Continuing in Window A as the sa, activate the database option “select
into/bulkcopy/pllsort” for the my_db database. into/bulkcopy/pllsort” for the my_db database.
b. Create new tables in the my_db database as shown: b. Create new tables in the my_db database as shown:
select * into principals_data from pubs2..stores select * into principals_data from pubs2..stores
select * into teachers_data from pubs2..stores select * into teachers_data from pubs2..stores
select * into students_data from pubs2..stores select * into students_data from pubs2..stores
c. Grant select permission on the principals_data table to the programmers group as c. Grant select permission on the principals_data table to the programmers group as
shown: shown:
2. Test the permissions for users and groups. 2. Test the permissions for users and groups.
a. In Window B, connect to Adaptive Server as harry password friday, who is not a a. In Window B, connect to Adaptive Server as harry password friday, who is not a
member of the programmers group. member of the programmers group.
b. Verify that harry accesses the my_db database as his default database. b. Verify that harry accesses the my_db database as his default database.
c. Issue a select statement against the principals_data table in the my_db database. c. Issue a select statement against the principals_data table in the my_db database.
None of the database users, tom, dick, or harry own the None of the database users, tom, dick, or harry own the
principals_data table. None of them has been directly granted select principals_data table. None of them has been directly granted select
permissions on the table. Only the programmers group has been permissions on the table. Only the programmers group has been
granted permissions but harry is not a member of that group. granted permissions but harry is not a member of that group.
Therefore, was the query result expected? Therefore, was the query result expected?
Lab 13 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 13 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 13: Implementing Roles, Object Permissions, and Groups Module 13: Implementing Roles, Object Permissions, and Groups
d. In Window B, exit your client session as harry and then connect to Adaptive d. In Window B, exit your client session as harry and then connect to Adaptive
Server as tom, who is a member of the programmers group. Server as tom, who is a member of the programmers group.
e. Verify that tom accesses the my_db database as his default database. e. Verify that tom accesses the my_db database as his default database.
f. Issue a select statement against the principals_data table. f. Issue a select statement against the principals_data table.
None of the database users, tom, dick, or harry own the None of the database users, tom, dick, or harry own the
principals_data table. None of them has been directly granted select principals_data table. None of them has been directly granted select
permissions on the table. Only the programmers group has been permissions on the table. Only the programmers group has been
granted permissions and tom is a member of that group. granted permissions and tom is a member of that group.
Therefore, was the query result expected? Therefore, was the query result expected?
If the table permissions had been granted to public, instead of If the table permissions had been granted to public, instead of
programmers, what do you think would happen to the query for programmers, what do you think would happen to the query for
harry who is in the engineers group? harry who is in the engineers group?
g. In Window A as the sa, revoke select permission on the principals_data table g. In Window A as the sa, revoke select permission on the principals_data table
from the programmers group. from the programmers group.
h. In Window B, as tom, issue the select statement against the principals_data table h. In Window B, as tom, issue the select statement against the principals_data table
again. again.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 13 - 5 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 13 - 5
Task 3: Creating User-defined Roles and Assigning to Logins Task 3: Creating User-defined Roles and Assigning to Logins
Description In this task, you will create user-defined roles and assign to logins. Description In this task, you will create user-defined roles and assign to logins.
Procedure 1. Create three new logins to the Adaptive Server. Procedure 1. Create three new logins to the Adaptive Server.
a. In Window A, connect to Adaptive Server as the sa. a. In Window A, connect to Adaptive Server as the sa.
2. Create user-defined roles and grant permissions to the roles. 2. Create user-defined roles and grant permissions to the roles.
a. From the master database, create three user-defined roles called principals, a. From the master database, create three user-defined roles called principals,
teachers, and students. teachers, and students.
b. Grant the principals role to the login tom. b. Grant the principals role to the login tom.
c. Grant the teachers role to the login dick. c. Grant the teachers role to the login dick.
d. Grant the students role to the login harry. d. Grant the students role to the login harry.
e. Verify that each role has been properly distributed to the users by using e. Verify that each role has been properly distributed to the users by using
sp_displayroles. sp_displayroles.
3. Grant object permissions to the user-defined roles. 3. Grant object permissions to the user-defined roles.
a. Continuing in Window A as the sa, access the my_db database. a. Continuing in Window A as the sa, access the my_db database.
b. Grant the principals role select permission on the principals_data table and then b. Grant the principals role select permission on the principals_data table and then
verify by using sp_helprotect. verify by using sp_helprotect.
c. Grant the teachers role select permission on the teachers_data table and then c. Grant the teachers role select permission on the teachers_data table and then
verify. verify.
Lab 13 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 13 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 13: Implementing Roles, Object Permissions, and Groups Module 13: Implementing Roles, Object Permissions, and Groups
d. Grant the students role select permission on the students_data table and then d. Grant the students role select permission on the students_data table and then
verify. verify.
4. Test the new roles that have just been created. 4. Test the new roles that have just been created.
a. In Window B, connect to Adaptive Server with the login harry (password friday). a. In Window B, connect to Adaptive Server with the login harry (password friday).
b. Verify that harry accesses the my_db database as his default database. b. Verify that harry accesses the my_db database as his default database.
c. Execute a select statement against the students_data table. c. Execute a select statement against the students_data table.
Was the query successful for harry? Was the query successful for harry?
select permission against the students_data table has already been select permission against the students_data table has already been
granted to the students role and harry has that role. Why can’t harry granted to the students role and harry has that role. Why can’t harry
access the table? access the table?
d. Verify that the students role is not currently enabled for harry by using d. Verify that the students role is not currently enabled for harry by using
sp_activeroles. sp_activeroles.
e. Enable the students role for harry and verify. e. Enable the students role for harry and verify.
set role students on set role students on
f. Execute the select statement against the students_data table again. f. Execute the select statement against the students_data table again.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 13 - 7 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 13 - 7
Task 4: Examining Role Hierarchies and Test Role and Object Task 4: Examining Role Hierarchies and Test Role and Object
Permissions Permissions
Description In this task, you will examine role hierarchies and test role and object permissions. Description In this task, you will examine role hierarchies and test role and object permissions.
b. In Window A, where the sa is connected to Adaptive Server, create a role within a b. In Window A, where the sa is connected to Adaptive Server, create a role within a
role by granting the students role to the teachers role. role by granting the students role to the teachers role.
c. Next, create another role within a role by granting the teachers role to the c. Next, create another role within a role by granting the teachers role to the
principals role. principals role.
2. Verify the role hierarchy by using sp_displayroles. 2. Verify the role hierarchy by using sp_displayroles.
a. Verify that the students role does not include any other roles. a. Verify that the students role does not include any other roles.
b. Verify that the teachers role includes the students role. b. Verify that the teachers role includes the students role.
c. Determine which roles the principals role includes. (Hint: use the expand_down c. Determine which roles the principals role includes. (Hint: use the expand_down
argument to sp_displayroles.) argument to sp_displayroles.)
What roles does the principals role include? What roles does the principals role include?
Only the teachers role, not the students role, was explicitly granted Only the teachers role, not the students role, was explicitly granted
to the principals role. Yet the principals role includes the students to the principals role. Yet the principals role includes the students
role. Explain. role. Explain.
Lab 13 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 13 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 13: Implementing Roles, Object Permissions, and Groups Module 13: Implementing Roles, Object Permissions, and Groups
b. Verify that tom accesses the my_db database as his default database. b. Verify that tom accesses the my_db database as his default database.
c. Verify that tom is configured with the principals role by using sp_displaylogin. c. Verify that tom is configured with the principals role by using sp_displaylogin.
d. Try to enable the students role. d. Try to enable the students role.
tom has the principals role and you previously verified that the tom has the principals role and you previously verified that the
principals role includes the students role (via the teachers role). principals role includes the students role (via the teachers role).
Explain why tom can not directly activate the students role. Explain why tom can not directly activate the students role.
f. Reconfirm that the students_data table has select permissions granted to users with f. Reconfirm that the students_data table has select permissions granted to users with
the students role. the students role.
sp_helprotect students_data sp_helprotect students_data
g. Execute a select statement against the students_data table. g. Execute a select statement against the students_data table.
i. Execute the select statement against the students_data table again. i. Execute the select statement against the students_data table again.
Are the roles and table permissions functioning as expected? Are the roles and table permissions functioning as expected?
Explain. Explain.
4. Exit all client sessions with Adaptive Server. 4. Exit all client sessions with Adaptive Server.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 13 - 9 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 13 - 9
Lab 13 - 10 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 13 - 10 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 14: Using Bulk Copy Utility Module 14: Using Bulk Copy Utility
Module 14: Using Bulk Copy Utility Module 14: Using Bulk Copy Utility
Lab 14: Using Bulk Copy Utility Lab 14: Using Bulk Copy Utility
Lab Setup You will be using your 2K page size Adaptive Server for this lab. Lab Setup You will be using your 2K page size Adaptive Server for this lab.
Note: You need to have completed previous labs in which you created a database named Note: You need to have completed previous labs in which you created a database named
my_db. If you did not finish those previous labs, please refer to the following instructions my_db. If you did not finish those previous labs, please refer to the following instructions
right before step 1 of this lab. right before step 1 of this lab.
Objectives After completing this lab, you should be able to: Objectives After completing this lab, you should be able to:
Become familiar with using the bulk copy (bcp) utility. Become familiar with using the bulk copy (bcp) utility.
Analyze the performance difference between fast and slow bcp. Analyze the performance difference between fast and slow bcp.
Description In this lab, you will learn how to use the bulk copy (bcp) utility, and you will analyze the Description In this lab, you will learn how to use the bulk copy (bcp) utility, and you will analyze the
performance difference between fast and slow bcp. performance difference between fast and slow bcp.
Task Outline 1. Create a Table for Testing with bcp Task Outline 1. Create a Table for Testing with bcp
2. Copy Data out and in using Various Formats and Comparing Fast and Slow bcp 2. Copy Data out and in using Various Formats and Comparing Fast and Slow bcp
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 14 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 14 - 1
Note: If you have not completed the previous labs in which you Note: If you have not completed the previous labs in which you
should have created two database devices, data_dev and log_dev should have created two database devices, data_dev and log_dev
and a database named my_db, then issue the following commands and a database named my_db, then issue the following commands
now: (see script lab14_setup.sql) (substituting $SYBASE now: (see script lab14_setup.sql) (substituting $SYBASE
appropriately): appropriately):
disk init disk init
name = "data_dev", name = "data_dev",
physname = "$SYBASE/devices/data_dev.dat", physname = "$SYBASE/devices/data_dev.dat",
size = "4M" size = "4M"
go go
create database my_db on data_dev=4 log on log_dev=2 create database my_db on data_dev=4 log on log_dev=2
go go
For this lab, it would be useful to open two windows (“A” and “B”). For this lab, it would be useful to open two windows (“A” and “B”).
This allows you to have multiple client sessions with ASE This allows you to have multiple client sessions with ASE
simultaneously. simultaneously.
You should exit any active client sessions with Adaptive Server You should exit any active client sessions with Adaptive Server
before continuing. before continuing.
Lab 14 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 14 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 14: Using Bulk Copy Utility Module 14: Using Bulk Copy Utility
Task 1: Create a Table for Testing with bcp Task 1: Create a Table for Testing with bcp
Description In this task, you will create a table for testing with bcp. Description In this task, you will create a table for testing with bcp.
a. Examine the characteristics of the my_db database by using sp_helpdb. a. Examine the characteristics of the my_db database by using sp_helpdb.
Which database options are set for the my_db database? Which database options are set for the my_db database?
For this lab, you need the select into/bulkcopy/pllsort option active to For this lab, you need the select into/bulkcopy/pllsort option active to
create a table using select into syntax. You need the trunc log on create a table using select into syntax. You need the trunc log on
chkpt option set to keep the log from filling up during table inserts chkpt option set to keep the log from filling up during table inserts
and bcp in operations in this lab. and bcp in operations in this lab.
If the select into/bulkcopy/pllsort and trunc log on chkpt options are If the select into/bulkcopy/pllsort and trunc log on chkpt options are
not set, then set both of them now by using sp_dboption . not set, then set both of them now by using sp_dboption .
sp_dboption my_db, "select into/bulkcopy/pllsort", true sp_dboption my_db, "select into/bulkcopy/pllsort", true
sp_dboption my_db, "trunc log on chkpt", true sp_dboption my_db, "trunc log on chkpt", true
2. Create a table to use for testing bcp operations. 2. Create a table to use for testing bcp operations.
a. Access the my_db database. a. Access the my_db database.
b. Create and populate a table named test_authors by issuing the following T-SQL b. Create and populate a table named test_authors by issuing the following T-SQL
commands: commands:
select * into test_authors from pubs2..authors select * into test_authors from pubs2..authors
c. Add more rows to the newly created table by issuing the following T-SQL c. Add more rows to the newly created table by issuing the following T-SQL
commands: commands:
The “go 500” is a perfectly valid T-SQL statement. It tells Adaptive The “go 500” is a perfectly valid T-SQL statement. It tells Adaptive
Server to perform all the commands in the batch 500 times. Server to perform all the commands in the batch 500 times.
insert test_authors select * from pubs2..authors insert test_authors select * from pubs2..authors
go 500 go 500
d. Verify that the table test_authors was created by using sp_help. d. Verify that the table test_authors was created by using sp_help.
Does the table have any indexes? Does the table have any indexes?
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 14 - 3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 14 - 3
Task 2: Copy Data out and in using Various Formats and Task 2: Copy Data out and in using Various Formats and
Comparing Fast and Slow bcp Comparing Fast and Slow bcp
Description In this task, you will copy data out, in using various formats and you will compare fast and Description In this task, you will copy data out, in using various formats and you will compare fast and
slow bcp. slow bcp.
Procedure 1. Copy data out from a table by using bcp with various formats. Procedure 1. Copy data out from a table by using bcp with various formats.
a. In Window B, change the directory to $HOME/sa. a. In Window B, change the directory to $HOME/sa.
cd $HOME/sa cd $HOME/sa
b. Copy out the data from my_db..test_authors to a file named b. Copy out the data from my_db..test_authors to a file named
test_authors.bcp.native by using bcp with native format. test_authors.bcp.native by using bcp with native format.
bcp my_db..test_authors out test_authors.bcp.native -Usa -P -n bcp my_db..test_authors out test_authors.bcp.native -Usa -P -n
c. Copy out the data from my_db..test_authors to a file named c. Copy out the data from my_db..test_authors to a file named
test_authors.bcp.character by using bcp with character format. test_authors.bcp.character by using bcp with character format.
bcp my_db..test_authors out test_authors.bcp.character -Usa -P bcp my_db..test_authors out test_authors.bcp.character -Usa -P
-c -c
d. Compare the file sizes of the two bcp output files by using the Unix ls -l d. Compare the file sizes of the two bcp output files by using the Unix ls -l
command. command.
ls -l test* ls -l test*
Does the bcp character format affect the output file size for identical Does the bcp character format affect the output file size for identical
data? data?
e. Copy out the data from my_db..test_authors to a file named e. Copy out the data from my_db..test_authors to a file named
test_authors.bcp.comma by using bcp with character format and specifying a test_authors.bcp.comma by using bcp with character format and specifying a
comma (,) as the field terminator. comma (,) as the field terminator.
bcp my_db..test_authors out test_authors.bcp.comma -Usa -P -c - bcp my_db..test_authors out test_authors.bcp.comma -Usa -P -c -
t , t ,
f. Compare the file sizes of the three bcp output files by using the Unix ls -l f. Compare the file sizes of the three bcp output files by using the Unix ls -l
command. command.
ls -l test* ls -l test*
Does the bcp field terminator affect the output file size for identical Does the bcp field terminator affect the output file size for identical
data when using the same format (in this case, character format)? data when using the same format (in this case, character format)?
Lab 14 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 14 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 14: Using Bulk Copy Utility Module 14: Using Bulk Copy Utility
2. Copy data into a table by using bcp data files with various formats. 2. Copy data into a table by using bcp data files with various formats.
a. In Window A, as the sa connected to Adaptive Server in the my_db database, a. In Window A, as the sa connected to Adaptive Server in the my_db database,
remove all rows from the table test_authors by using the truncate table command. remove all rows from the table test_authors by using the truncate table command.
truncate table test_authors truncate table test_authors
b. In Window B, copy data into my_db..test_authors from the file named b. In Window B, copy data into my_db..test_authors from the file named
test_authors.bcp.native by using bcp with native format and a batch size of 1000. test_authors.bcp.native by using bcp with native format and a batch size of 1000.
Your bcp in operations may temporarily suspend and you may see Your bcp in operations may temporarily suspend and you may see
messages such as: messages such as:
Space available in the log segment has fallen Space available in the log segment has fallen
critically low in database 'my_db. critically low in database 'my_db.
The transaction log in database my_db is almost full. The transaction log in database my_db is almost full.
Ignore these messages - the database option, trunc log on chkpt, Ignore these messages - the database option, trunc log on chkpt,
allows the server to clear out the transaction log after each batch allows the server to clear out the transaction log after each batch
(1000 rows). Your operation will continue in a few moments. (1000 rows). Your operation will continue in a few moments.
Write down the bcp Clock Time (ms.): total. Write down the bcp Clock Time (ms.): total.
(Your results may vary from the solutions.) (Your results may vary from the solutions.)
In this case the clock time was 377 ms. In this case the clock time was 377 ms.
c. In Window A, as the sa, remove all rows from the table test_authors by using the c. In Window A, as the sa, remove all rows from the table test_authors by using the
truncate table command. truncate table command.
d. In Window B, copy data into my_db..test_authors from the file named d. In Window B, copy data into my_db..test_authors from the file named
test_authors.bcp.character by using bcp with character format and a batch size of test_authors.bcp.character by using bcp with character format and a batch size of
1000. 1000.
bcp my_db..test_authors in test_authors.bcp.character -Usa -P - bcp my_db..test_authors in test_authors.bcp.character -Usa -P -
c -b 1000 c -b 1000
Write down the bcp Clock Time (ms.): total. Write down the bcp Clock Time (ms.): total.
(Your results may vary from the solutions.) (Your results may vary from the solutions.)
For this relatively small table, is there any significant performance For this relatively small table, is there any significant performance
improvement of using the native format data versus the character improvement of using the native format data versus the character
format data? (Note: your results may be different from those shown format data? (Note: your results may be different from those shown
in the solutions.) in the solutions.)
3. Analyze the impact of slow bcp. 3. Analyze the impact of slow bcp.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 14 - 5 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 14 - 5
In step 2d, you noted that the test_authors table had no indexes. In step 2d, you noted that the test_authors table had no indexes.
Combined with the database option, select into/bulkcopy/pllsort, Combined with the database option, select into/bulkcopy/pllsort,
being active, the server was able to perform fast bcp when copying being active, the server was able to perform fast bcp when copying
the data into the table in step 2. the data into the table in step 2.
Now you will create an index on the table and analyze its impact Now you will create an index on the table and analyze its impact
when copying data in with bcp. when copying data in with bcp.
a. In Window A, as the sa, remove all rows from the table test_authors by using the a. In Window A, as the sa, remove all rows from the table test_authors by using the
truncate table command. truncate table command.
c. Verify that the index was created by using sp_helpindex. c. Verify that the index was created by using sp_helpindex.
d. In Window B, copy data into my_db..test_authors from the file named d. In Window B, copy data into my_db..test_authors from the file named
test_authors.bcp.native by using bcp with native format and a batch size of 1000. test_authors.bcp.native by using bcp with native format and a batch size of 1000.
Note: You may see a warning about the transaction log becoming Note: You may see a warning about the transaction log becoming
full. But because you previously set the database option trunc log on full. But because you previously set the database option trunc log on
chkpt to true, Adaptive Server will automatically clear out the log chkpt to true, Adaptive Server will automatically clear out the log
momentarily. momentarily.
Write down the bcp Clock Time (ms.): total. Write down the bcp Clock Time (ms.): total.
(Your results may vary from the solutions.) (Your results may vary from the solutions.)
Compare the clock speed with the value recorded in step 2b. For this Compare the clock speed with the value recorded in step 2b. For this
relatively small table, is there any significant performance relatively small table, is there any significant performance
degradation when loading the identical data with the presence of an degradation when loading the identical data with the presence of an
index? index?
4. Exit all client sessions with Adaptive Server. 4. Exit all client sessions with Adaptive Server.
Lab 14 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 14 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 15: Overview of Automatic Recovery Module 15: Overview of Automatic Recovery
Module 15: Overview of Automatic Recovery Module 15: Overview of Automatic Recovery
Lab 15: Overview of Automatic Recovery Lab 15: Overview of Automatic Recovery
Lab Setup This is a pencil-and-paper activity. There is no setup for this lab. Lab Setup This is a pencil-and-paper activity. There is no setup for this lab.
Objectives After completing this lab, you should be able to: Objectives After completing this lab, you should be able to:
Analyze the effects of the recovery process Analyze the effects of the recovery process
Description In this lab, you will learn how to analyze the effects of the recovery process. Description In this lab, you will learn how to analyze the effects of the recovery process.
Task Outline 1. Examining Various Transaction Sequences and Predict the Results of Automatic Task Outline 1. Examining Various Transaction Sequences and Predict the Results of Automatic
Recovery Recovery
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 15 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 15 - 1
Task 1: Examining Various Transaction Sequences and Predict Task 1: Examining Various Transaction Sequences and Predict
the Results of Automatic Recovery the Results of Automatic Recovery
Description In this task, you will examine various transaction sequences and predict the results of Description In this task, you will examine various transaction sequences and predict the results of
automatic recovery. automatic recovery.
Procedure Procedure
DO NOT EXECUTE any of the commands in this lab. This is a DO NOT EXECUTE any of the commands in this lab. This is a
paper-and-pencil activity. paper-and-pencil activity.
1. Assume the transaction log (syslogs table) on disk has the following records at the time 1. Assume the transaction log (syslogs table) on disk has the following records at the time
of a system failure: of a system failure:
begin tran begin tran
delete table1 where... delete table1 where...
insert table2 values (...) insert table2 values (...)
The tables on disk have the delete but not the insert. The tables on disk have the delete but not the insert.
Will any of the attempted data modifications (the delete and/or the Will any of the attempted data modifications (the delete and/or the
insert) appear in the affected tables, table1 and table2, after insert) appear in the affected tables, table1 and table2, after
recovery? Explain. recovery? Explain.
What work will Adaptive Server have to perform after recovery? What work will Adaptive Server have to perform after recovery?
2. For each of the following sequences of commands, predict what will happen if the 2. For each of the following sequences of commands, predict what will happen if the
server experiences a power failure after the commands are issued and then the server is server experiences a power failure after the commands are issued and then the server is
rebooted. rebooted.
a. Sequence A: a. Sequence A:
begin transaction A begin transaction A
insert tableA values (...) insert tableA values (...)
commit transaction commit transaction
Lab 15 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 15 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 15: Overview of Automatic Recovery Module 15: Overview of Automatic Recovery
Will the inserted row be present in the table tableA after recovery? Will the inserted row be present in the table tableA after recovery?
Explain. Explain.
b. Sequence B: b. Sequence B:
begin transaction B begin transaction B
insert tableB values (...) insert tableB values (...)
Will the inserted row be present in the table tableB after recovery? Will the inserted row be present in the table tableB after recovery?
Explain. Explain.
Would the inserted row be present in the table tableB after recovery Would the inserted row be present in the table tableB after recovery
if the begin tran statement was not used? Explain. if the begin tran statement was not used? Explain.
c. Sequence C: c. Sequence C:
begin transaction C begin transaction C
insert tableC values (...) insert tableC values (...)
checkpoint checkpoint
Will the inserted row be present in the table tableC after recovery? Will the inserted row be present in the table tableC after recovery?
Explain. Explain.
d. Sequence D: d. Sequence D:
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 15 - 3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 15 - 3
checkpoint checkpoint
Will the inserted row be present in the table tableD after recovery? Will the inserted row be present in the table tableD after recovery?
Explain. Explain.
Does the presence of the manual checkpoint affect the recoverability Does the presence of the manual checkpoint affect the recoverability
of this transaction? Explain. of this transaction? Explain.
Lab 15 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 15 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 16: Checking and Fixing Database Consistency Module 16: Checking and Fixing Database Consistency
Module 16: Checking and Fixing Database Consistency Module 16: Checking and Fixing Database Consistency
Lab 16: Checking and Fixing Database Consistency Lab 16: Checking and Fixing Database Consistency
Lab Setup You will be using your 2K page size Adaptive Server for this lab. Lab Setup You will be using your 2K page size Adaptive Server for this lab.
Note: You need to have completed previous labs in which you created a database named Note: You need to have completed previous labs in which you created a database named
my_db. If you did not finish those previous labs, then please refer to the following my_db. If you did not finish those previous labs, then please refer to the following
instructions right before step 1 of this lab. instructions right before step 1 of this lab.
Objectives After completing this lab, you should be able to: Objectives After completing this lab, you should be able to:
Gain experience with some of the standard (“out-of-the-box”) dbcc utility commands Gain experience with some of the standard (“out-of-the-box”) dbcc utility commands
such as dbcc checkdb and dbcc checkalloc. such as dbcc checkdb and dbcc checkalloc.
Understand how to set up the dbccdb database and use dbcc checkstorage. Understand how to set up the dbccdb database and use dbcc checkstorage.
Description In this lab, you will learn how to use standard dbcc utility commands, and you will Description In this lab, you will learn how to use standard dbcc utility commands, and you will
understand how to set up the dbccdb database. understand how to set up the dbccdb database.
Task Outline 1. Executing Standard dbcc Commands Task Outline 1. Executing Standard dbcc Commands
2. Installing the Sybase-Supplied Optional Database, dbccdb 2. Installing the Sybase-Supplied Optional Database, dbccdb
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 16 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 16 - 1
Note: If you have not completed the previous labs in which you Note: If you have not completed the previous labs in which you
created database devices and the my_db database then issue the created database devices and the my_db database then issue the
following commands now (substituting $SYBASE/ appropriately). following commands now (substituting $SYBASE/ appropriately).
disk init disk init
name = "data_dev", name = "data_dev",
physname = "$SYBASE/devices/data_dev.dat", physname = "$SYBASE/devices/data_dev.dat",
size = "4M" size = "4M"
go go
create database my_db on data_dev=4 log on log_dev=2 create database my_db on data_dev=4 log on log_dev=2
go go
exec sp_addlogin tom, "friday", my_db exec sp_addlogin tom, "friday", my_db
exec sp_addlogin dick, "friday", my_db exec sp_addlogin dick, "friday", my_db
exec sp_addlogin harry, "friday", my_db exec sp_addlogin harry, "friday", my_db
go go
use my_db use my_db
go go
For this lab, it would be useful to open two windows (“A” and “B”). For this lab, it would be useful to open two windows (“A” and “B”).
This allows you to have multiple client sessions with ASE This allows you to have multiple client sessions with ASE
simultaneously. simultaneously.
You should exit any active client sessions with Adaptive Server You should exit any active client sessions with Adaptive Server
before continuing. before continuing.
Lab 16 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 16 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 16: Checking and Fixing Database Consistency Module 16: Checking and Fixing Database Consistency
Task 1: Executing Standard dbcc Commands Task 1: Executing Standard dbcc Commands
Description In this task, you will execute standard dbcc commands, such as dbcc checkdb and dbcc Description In this task, you will execute standard dbcc commands, such as dbcc checkdb and dbcc
checkalloc. checkalloc.
Procedure Procedure
1. As a user without privileges, try to use standard dbcc commands to check database 1. As a user without privileges, try to use standard dbcc commands to check database
consistency. consistency.
a. In Window A, connect to Adaptive Server as the user tom (password friday). a. In Window A, connect to Adaptive Server as the user tom (password friday).
b. Determine whether tom has any system roles such as the sso_role by using the b. Determine whether tom has any system roles such as the sso_role by using the
show_role() built-in function. show_role() built-in function.
c. Determine whether tom is the dbo for the my_db database by using sp_helpuser. c. Determine whether tom is the dbo for the my_db database by using sp_helpuser.
Is tom the dbo of the my_db database or does he have any system Is tom the dbo of the my_db database or does he have any system
roles such as the sso_role? roles such as the sso_role?
d. As tom, try to execute dbcc checkdb and dbcc checkalloc. d. As tom, try to execute dbcc checkdb and dbcc checkalloc.
Can any user simply issue these dbcc commands? Can any user simply issue these dbcc commands?
Who can issue these dbcc commands? Who can issue these dbcc commands?
2. As an user with privileges, use standard dbcc commands to check database 2. As an user with privileges, use standard dbcc commands to check database
consistency. consistency.
a. In Window A, exit the Adaptive Server session as tom and then connect as the user a. In Window A, exit the Adaptive Server session as tom and then connect as the user
sa. sa.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 16 - 3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 16 - 3
c. Determine whether tom has any system roles such as the sso_role by using the c. Determine whether tom has any system roles such as the sso_role by using the
show_role() built-in function. show_role() built-in function.
d. Check page allocation in the my_db database by using dbcc checkalloc. d. Check page allocation in the my_db database by using dbcc checkalloc.
e. Perform additional consistency checking in the my_db database by using dbcc e. Perform additional consistency checking in the my_db database by using dbcc
checkdb. checkdb.
f. Check the consistency of the system catalog in the my_db database. f. Check the consistency of the system catalog in the my_db database.
dbcc checkcatalog dbcc checkcatalog
Does the my_db database appear to be in a consistent state? Does the my_db database appear to be in a consistent state?
g. Issue the dbcc checkstorage command in the my_db database. g. Issue the dbcc checkstorage command in the my_db database.
Did the dbcc checkstorage command run successfully? Explain. Did the dbcc checkstorage command run successfully? Explain.
Lab 16 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 16 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 16: Checking and Fixing Database Consistency Module 16: Checking and Fixing Database Consistency
Task 2: Installing the Sybase-supplied Optional Database, Task 2: Installing the Sybase-supplied Optional Database,
dbccdb dbccdb
Description In this task, you will install the dbccdb database and execute dbcc commands against the Description In this task, you will install the dbccdb database and execute dbcc commands against the
my_db database. You will also analyze the requirements of target database and executing my_db database. You will also analyze the requirements of target database and executing
dbcc checkstorage against the my_db database dbcc checkstorage against the my_db database
Procedure 1. Install the dbccdb database. Procedure 1. Install the dbccdb database.
a. Continuing in Window A, as the sa connected to Adaptive Server, determine a. Continuing in Window A, as the sa connected to Adaptive Server, determine
whether the dbccdb database exists. whether the dbccdb database exists.
Does the dbccdb database exist? Does the dbccdb database exist?
What are the major steps to install the dbccdb database and to What are the major steps to install the dbccdb database and to
initialize it for a target database? initialize it for a target database?
b. Determine the resource requirements for the dbccdb database by using b. Determine the resource requirements for the dbccdb database by using
sp_plan_dbccdb my_db and fill in the following chart: sp_plan_dbccdb my_db and fill in the following chart:
Recommended size for dbccdb database Recommended size for dbccdb database
Size of data portion Size of data portion
Size of log portion Size of log portion
Size of scan workspace Size of scan workspace
Size of text workspace Size of text workspace
Size of the cache needed Size of the cache needed
Number of worker processes needed Number of worker processes needed
(process count) (process count)
c. From the master database, initialize data devices for the dbccdb database as c. From the master database, initialize data devices for the dbccdb database as
follows: follows:
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 16 - 5 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 16 - 5
1. For a device for the data portion of dbccdb: 1. For a device for the data portion of dbccdb:
• The logical name of the database device is dbccdb_data • The logical name of the database device is dbccdb_data
• The physical path and file name associated with the new device • The physical path and file name associated with the new device
is in the form: is in the form:
$SYBASE/devices/dbccdb_data.dat $SYBASE/devices/dbccdb_data.dat
• Use the device size recommended by sp_plan_dbccdb • Use the device size recommended by sp_plan_dbccdb
2. For a device for the log portion of dbccdb: 2. For a device for the log portion of dbccdb:
• The logical name of the database device is dbccdb_log • The logical name of the database device is dbccdb_log
• The physical path and file name associated with the new device • The physical path and file name associated with the new device
is in the form: is in the form:
$SYBASE/devices/dbccdb_log.dat $SYBASE/devices/dbccdb_log.dat
• Use the device size recommended by sp_plan_dbccdb for • Use the device size recommended by sp_plan_dbccdb for
the log portion of dbccdb. the log portion of dbccdb.
d. Create the dbccdb database on the newly initialized devices according to the d. Create the dbccdb database on the newly initialized devices according to the
requirements recorded in step 1b. requirements recorded in step 1b.
create database dbccdb create database dbccdb
on dbccdb_data = 21 on dbccdb_data = 21
log on dbccdb_log = 2 log on dbccdb_log = 2
e. Verify that the dbccdb database was created. e. Verify that the dbccdb database was created.
sp_helpdb dbccdb sp_helpdb dbccdb
f. Access the dbccdb database and add segments for the scan and text workspaces to f. Access the dbccdb database and add segments for the scan and text workspaces to
the dbccdb data device. the dbccdb data device.
use dbccdb use dbccdb
exec sp_addsegment scanseg, dbccdb, dbccdb_data exec sp_addsegment scanseg, dbccdb, dbccdb_data
exec sp_addsegment textseg, dbccdb, dbccdb_data exec sp_addsegment textseg, dbccdb, dbccdb_data
Lab 16 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 16 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 16: Checking and Fixing Database Consistency Module 16: Checking and Fixing Database Consistency
g. Reserve 2 MB of the default data cache for the 16K buffer pool by using the g. Reserve 2 MB of the default data cache for the 16K buffer pool by using the
following command: following command:
sp_poolconfig "default data cache", "2M", "16K" sp_poolconfig "default data cache", "2M", "16K"
Later you will configure the dbccdb database to use the Later you will configure the dbccdb database to use the
default data cache (as opposed to a named data cache). The target default data cache (as opposed to a named data cache). The target
data cache must have a sufficiently large 16 K buffer pool. data cache must have a sufficiently large 16 K buffer pool.
h. Configure Adaptive Server for the number of worker processes using the value h. Configure Adaptive Server for the number of worker processes using the value
recorded in step 3b as follows: recorded in step 3b as follows:
sp_configure "number of worker processes", 2 sp_configure "number of worker processes", 2
i. Now try to use dbcc checkstorage against the my_db database. i. Now try to use dbcc checkstorage against the my_db database.
Did the dbcc checkstorage command run successfully? Explain. Did the dbcc checkstorage command run successfully? Explain.
2. Load and configure the dbccdb database. 2. Load and configure the dbccdb database.
a. In Window B, change the directory to $SYBASE/$SYBASE_ASE/scripts. a. In Window B, change the directory to $SYBASE/$SYBASE_ASE/scripts.
b. Execute the T-SQL commands in the script installdbccdb by using isql -i. b. Execute the T-SQL commands in the script installdbccdb by using isql -i.
This Sybase-supplied script creates tables and stored procedures This Sybase-supplied script creates tables and stored procedures
unique to the dbccdb database. Once these tables and procedures unique to the dbccdb database. Once these tables and procedures
are installed, then you can configure the dbccdb database for are installed, then you can configure the dbccdb database for
each target database that you want to run dbcc checkstorage each target database that you want to run dbcc checkstorage
against. against.
c. In Window A, as the sa accessing the dbccdb database, create the scan and text c. In Window A, as the sa accessing the dbccdb database, create the scan and text
workspaces using the recommended sizes recorded in step 3b. workspaces using the recommended sizes recorded in step 3b.
sp_dbcc_createws dbccdb, scanseg, scan_my_db, scan, "96K" sp_dbcc_createws dbccdb, scanseg, scan_my_db, scan, "96K"
sp_dbcc_createws dbccdb, textseg, text_my_db, text, "48K" sp_dbcc_createws dbccdb, textseg, text_my_db, text, "48K"
d. Initialize dbccdb for the target database (my_db) by using sp_dbcc_updateconfig d. Initialize dbccdb for the target database (my_db) by using sp_dbcc_updateconfig
for each of the following parameters: for each of the following parameters:
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 16 - 7 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 16 - 7
• max worker processes (use the value recorded in step 1b) • max worker processes (use the value recorded in step 1b)
• dbcc named cache (use the default data cache and the size • dbcc named cache (use the default data cache and the size
recorded in step 1b) recorded in step 1b)
• scan workspace (use the name just created in step 2c) • scan workspace (use the name just created in step 2c)
• text workspace (use the name just created in step 2c) • text workspace (use the name just created in step 2c)
sp_dbcc_updateconfig my_db, "max worker processes", "2" sp_dbcc_updateconfig my_db, "max worker processes", "2"
sp_dbcc_updateconfig my_db, "dbcc named cache", "default data sp_dbcc_updateconfig my_db, "dbcc named cache", "default data
cache", "1920K" cache", "1920K"
sp_dbcc_updateconfig my_db, "scan workspace", scan_my_db sp_dbcc_updateconfig my_db, "scan workspace", scan_my_db
sp_dbcc_updateconfig my_db, "text workspace", text_my_db sp_dbcc_updateconfig my_db, "text workspace", text_my_db
e. Verify that the my_db database is configured properly in the dbccdb database by e. Verify that the my_db database is configured properly in the dbccdb database by
using sp_dbcc_configreport . using sp_dbcc_configreport .
Do the values match the “suggested” values? Do the values match the “suggested” values?
Did the dbcc checkstorage command run successfully for the my_db Did the dbcc checkstorage command run successfully for the my_db
database? database?
Are any faults or suspect conditions reported? Are any faults or suspect conditions reported?
b. Verify the number of faults and suspect conditions reported by dbcc checkstorage b. Verify the number of faults and suspect conditions reported by dbcc checkstorage
by executing sp_dbcc_summaryreport for the my_db database. by executing sp_dbcc_summaryreport for the my_db database.
4. Exit all client sessions with Adaptive Server. 4. Exit all client sessions with Adaptive Server.
Lab 16 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 16 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 17: Planning for Backups Module 17: Planning for Backups
Module 17: Planning for Backups Module 17: Planning for Backups
Lab 17: Planning for Backups Lab 17: Planning for Backups
Lab Setup This is a pencil-and-paper activity. Lab Setup This is a pencil-and-paper activity.
Objectives After completing this lab, you should be able to: Objectives After completing this lab, you should be able to:
Develop a high-level backup/recovery strategy. Develop a high-level backup/recovery strategy.
Description In this lab, you will learn how to develop a high-level backup/recovery strategy. Description In this lab, you will learn how to develop a high-level backup/recovery strategy.
Task Outline 1. Deciding What Backup Strategy would be Appropriate for your Site Task Outline 1. Deciding What Backup Strategy would be Appropriate for your Site
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 17 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 17 - 1
Task 1: Deciding what Backup Strategy Would be Appropriate Task 1: Deciding what Backup Strategy Would be Appropriate
for Your Site for Your Site
Description In this task, you will choose backup strategy which would be appropriate for your site. Description In this task, you will choose backup strategy which would be appropriate for your site.
Procedure Procedure
DO NOT EXECUTE any of the commands in this lab. This is a DO NOT EXECUTE any of the commands in this lab. This is a
paper-and-pencil activity. paper-and-pencil activity.
Each numbered step in this lab makes a general statement about backups. Read each Each numbered step in this lab makes a general statement about backups. Read each
statement and then answer the questions that follow it. statement and then answer the questions that follow it.
1. Dump devices available to Adaptive Server include both large files on disk and high 1. Dump devices available to Adaptive Server include both large files on disk and high
speed tape devices. speed tape devices.
As a basic strategy, it has been determined that the dump devices on As a basic strategy, it has been determined that the dump devices on
disk are not to be used with automated dump operations. Why has disk are not to be used with automated dump operations. Why has
that strategy been recommended? that strategy been recommended?
2. The use of disk files for dump devices may have an advantage over tape devices in a 2. The use of disk files for dump devices may have an advantage over tape devices in a
particular environment. particular environment.
Which of the following environments can benefit from the advantage Which of the following environments can benefit from the advantage
that disk file dump devices can provide? Explain your answer. that disk file dump devices can provide? Explain your answer.
1. A development environment where backups are often 1. A development environment where backups are often
conducted by developers. conducted by developers.
2. A production environment where backups are provided by a 2. A production environment where backups are provided by a
team of operators on a regularly scheduled basis. team of operators on a regularly scheduled basis.
Lab 17 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 17 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 17: Planning for Backups Module 17: Planning for Backups
3. Given: When a backup and recovery strategy is to be defined, a major part of any plan 3. Given: When a backup and recovery strategy is to be defined, a major part of any plan
is the restoration of critical databases from backups (dumps). is the restoration of critical databases from backups (dumps).
What facilities does Sybase provide to automate the restoration of What facilities does Sybase provide to automate the restoration of
databases from dump files? Explain. databases from dump files? Explain.
4. Capturing statistics about dump and load processes can be invaluable in estimating 4. Capturing statistics about dump and load processes can be invaluable in estimating
durations and provide information about the performance of your system. durations and provide information about the performance of your system.
What three important statistics should be gathered to help estimate What three important statistics should be gathered to help estimate
load and dump times? Explain. load and dump times? Explain.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 17 - 3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 17 - 3
5. When developing your backup and recovery plan, you should consider all of your 5. When developing your backup and recovery plan, you should consider all of your
system and user databases. system and user databases.
Fill in a Yes or No in the “Dump?” column of the following table to Fill in a Yes or No in the “Dump?” column of the following table to
indicate your decision regarding whether to perform regularly scheduled indicate your decision regarding whether to perform regularly scheduled
dumps for the given system and (optional) Sybase-supplied user databases. dumps for the given system and (optional) Sybase-supplied user databases.
Briefly explain each decision. Briefly explain each decision.
6. Your business requirements define whether any particular database should be backed 6. Your business requirements define whether any particular database should be backed
up. Backups are normally required on a periodic basis for any production system up. Backups are normally required on a periodic basis for any production system
database that is modified. Each database in a backup plan may have different database that is modified. Each database in a backup plan may have different
maintenance requirements. Write a short description for each of the following items maintenance requirements. Write a short description for each of the following items
that should be defined for each database in your plan. that should be defined for each database in your plan.
Lab 17 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 17 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 18: Performing a Backup Module 18: Performing a Backup
Lab 18: Performing Backups and Loads Lab 18: Performing Backups and Loads
Lab Setup You will be using your 2K page size Adaptive Server and your Backup Server for this lab. Lab Setup You will be using your 2K page size Adaptive Server and your Backup Server for this lab.
Note: You need to have completed previous labs in which you created a database named Note: You need to have completed previous labs in which you created a database named
my_db. If you did not finish those previous labs, then please refer to the following my_db. If you did not finish those previous labs, then please refer to the following
instructions right before step 1 of this lab. instructions right before step 1 of this lab.
Objectives After completing this lab, you should be able to: Objectives After completing this lab, you should be able to:
Perform full and incremental database dumps Perform full and incremental database dumps
Analyze dump compression differences Analyze dump compression differences
Description In this lab, you will learn how to perform full and incremental database dumps and how to Description In this lab, you will learn how to perform full and incremental database dumps and how to
analyze dump compression differences. analyze dump compression differences.
Task Outline 1. Creating Dump Devices Task Outline 1. Creating Dump Devices
2. Performing a Database Dump and Load 2. Performing a Database Dump and Load
3. Performing a Transaction Dump and Load 3. Performing a Transaction Dump and Load
4. Analyzing the Effects of Dump Compression 4. Analyzing the Effects of Dump Compression
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 18 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 18 - 1
Note: If you have not completed the previous labs in which you Note: If you have not completed the previous labs in which you
created database devices and the my_db database then issue the created database devices and the my_db database then issue the
following commands now (substituting $SYBASE/ appropriately): following commands now (substituting $SYBASE/ appropriately):
disk init disk init
name = "data_dev", name = "data_dev",
physname = "$SYBASE/devices/data_dev.dat", physname = "$SYBASE/devices/data_dev.dat",
size = "4M" size = "4M"
go go
disk init disk init
name = "log_dev", name = "log_dev",
physname = "$SYBASE/devices/log_dev.mir", physname = "$SYBASE/devices/log_dev.mir",
size = 1024 size = 1024
go go
create database my_db on data_dev = 4 log on log_dev create database my_db on data_dev = 4 log on log_dev
= 2 = 2
go go
exec sp_addlogin tom, "friday", my_db exec sp_addlogin tom, "friday", my_db
exec sp_addlogin dick, "friday", my_db exec sp_addlogin dick, "friday", my_db
exec sp_addlogin harry, "friday", my_db exec sp_addlogin harry, "friday", my_db
go go
use my_db use my_db
go go
exec sp_adduser tom exec sp_adduser tom
exec sp_adduser dick exec sp_adduser dick
exec sp_adduser harry exec sp_adduser harry
go go
exec sp_addgroup programmers exec sp_addgroup programmers
exec sp_addgroup engineers exec sp_addgroup engineers
go go
exec sp_changegroup programmers, tom exec sp_changegroup programmers, tom
exec sp_changegroup programmers, dick exec sp_changegroup programmers, dick
exec sp_changegroup engineers, harry exec sp_changegroup engineers, harry
go go
For this lab, it would be useful to open two windows (“A” and “B”). For this lab, it would be useful to open two windows (“A” and “B”).
This allows you to have multiple client sessions with ASE This allows you to have multiple client sessions with ASE
simultaneously. You should exit any active client sessions with simultaneously. You should exit any active client sessions with
Adaptive Server before continuing. Adaptive Server before continuing.
, ,
Lab 18 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 18 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 18: Performing a Backup Module 18: Performing a Backup
Description In this task, you will create dump devices. Description In this task, you will create dump devices.
Procedure Procedure
1. Create disk dump devices. 1. Create disk dump devices.
a. In Window A, connect to Adaptive Server as the sa. a. In Window A, connect to Adaptive Server as the sa.
b. Create a disk dump device named db_dump_dev, which uses a physical file named b. Create a disk dump device named db_dump_dev, which uses a physical file named
db_dump_dev.dat in your $HOME/sa directory. db_dump_dev.dat in your $HOME/sa directory.
sp_addumpdevice "disk", "db_dump_dev", sp_addumpdevice "disk", "db_dump_dev",
"/home/usr/u/dub101/sa/db_dump_dev.dat" "/home/usr/u/dub101/sa/db_dump_dev.dat"
c. Create a second disk dump device named log_dump_dev, which uses a physical c. Create a second disk dump device named log_dump_dev, which uses a physical
file named log_dump_dev.dat in your $HOME/sa directory. file named log_dump_dev.dat in your $HOME/sa directory.
sp_addumpdevice "disk", "log_dump_dev", sp_addumpdevice "disk", "log_dump_dev",
"/home/usr/u/dub101/sa/log_dump_dev.dat" "/home/usr/u/dub101/sa/log_dump_dev.dat"
d. Verify that the two dump devices have been created by using sp_helpdevice. d. Verify that the two dump devices have been created by using sp_helpdevice.
sp_helpdevice db_dump_dev sp_helpdevice db_dump_dev
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 18 - 3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 18 - 3
Task 2: Performing a Database Dump and Load Task 2: Performing a Database Dump and Load
Description In this task, you will perform a database dump and load. Description In this task, you will perform a database dump and load.
Procedure 1. Determine the name of the Backup Server for this Adaptive Server. Procedure 1. Determine the name of the Backup Server for this Adaptive Server.
a. Continuing in Window A as the sa, determine the Backup Server associated with a. Continuing in Window A as the sa, determine the Backup Server associated with
this Adaptive Server by using sp_helpserver. this Adaptive Server by using sp_helpserver.
In Sybase Learning Centers, students are already set up with a In Sybase Learning Centers, students are already set up with a
Backup Server named in the form $DSQUERY_BS, with a Backup Server named in the form $DSQUERY_BS, with a
corresponding entry in the sysservers table. corresponding entry in the sysservers table.
Does the output from sp_helpserver show a server with the logical Does the output from sp_helpserver show a server with the logical
name SYB_BACKUP? If yes, what is the network_name of the name SYB_BACKUP? If yes, what is the network_name of the
Backup Server? Backup Server?
Assume the following situation: You plan to use a remote Backup Assume the following situation: You plan to use a remote Backup
Server called TUNA_BS on a machine called tuna. What tasks must Server called TUNA_BS on a machine called tuna. What tasks must
you perform on the local host to the interfaces file and the sysservers you perform on the local host to the interfaces file and the sysservers
table to make this remote Backup Server known to the (local) table to make this remote Backup Server known to the (local)
Adaptive Server? Adaptive Server?
b. Try to dump the database, my_db, to the dump device db_dump_dev (without b. Try to dump the database, my_db, to the dump device db_dump_dev (without
using compression). using compression).
Was the database dump successful? Explain. Was the database dump successful? Explain.
c. In Window B, start up the Backup Server. c. In Window B, start up the Backup Server.
cd $SYBASE/$SYBASE_ASE/install cd $SYBASE/$SYBASE_ASE/install
Lab 18 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 18 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 18: Performing a Backup Module 18: Performing a Backup
2. Create a table and then dump the database. 2. Create a table and then dump the database.
a. Continuing in Window A as the sa, access the my_db database. a. Continuing in Window A as the sa, access the my_db database.
b. Create a simple table called test_dump with one int column. b. Create a simple table called test_dump with one int column.
create table test_dump (i int) create table test_dump (i int)
c. Insert a row with value “1” into the newly created table. c. Insert a row with value “1” into the newly created table.
insert test_dump values (1) insert test_dump values (1)
d. Dump the database, my_db, to the dump device db_dump_dev (without using d. Dump the database, my_db, to the dump device db_dump_dev (without using
compression). compression).
Was the database dump successful this time? Was the database dump successful this time?
e. Insert another row with value “2” into the test_dump table. e. Insert another row with value “2” into the test_dump table.
3. Load the database from the backup. 3. Load the database from the backup.
a. Access the master database. a. Access the master database.
b. Load the my_db database from the dump device, db_dump_dev. b. Load the my_db database from the dump device, db_dump_dev.
c. Bring the my_db database online. c. Bring the my_db database online.
d. Access the my_db database and examine the contents of the test_dump table. d. Access the my_db database and examine the contents of the test_dump table.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 18 - 5 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 18 - 5
To summarize the sequence just performed, previously you: To summarize the sequence just performed, previously you:
1. inserted a row with value “1”. 1. inserted a row with value “1”.
2. dumped the database. 2. dumped the database.
3. inserted a second row with value “2”. 3. inserted a second row with value “2”.
Are both rows in the table after restoring the database from backup? Are both rows in the table after restoring the database from backup?
Explain. Explain.
4. Assume the following: A database named sales_db has just been backed up to a tape 4. Assume the following: A database named sales_db has just been backed up to a tape
device named public_tape_device, and the tape is still mounted. There is enough space device named public_tape_device, and the tape is still mounted. There is enough space
left on the tape to dump two additional databases, customer_db and employee_db, at left on the tape to dump two additional databases, customer_db and employee_db, at
which point the tape would be full. which point the tape would be full.
What command sequence would you use to dump the two additional databases onto What command sequence would you use to dump the two additional databases onto
the same tape as sales_db without overwriting the sales_db dump information? the same tape as sales_db without overwriting the sales_db dump information?
What command would you use to load the employee_db database? What command would you use to load the employee_db database?
5. Assume you have a large database named huge_db that will not fit on a single dump 5. Assume you have a large database named huge_db that will not fit on a single dump
device. You decide to split the database dump across three dump devices: device. You decide to split the database dump across three dump devices:
dump_device1, dump_device2, and dump_device3. dump_device1, dump_device2, and dump_device3.
What command sequence would you use to accomplish this dump? What command sequence would you use to accomplish this dump?
Lab 18 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 18 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 18: Performing a Backup Module 18: Performing a Backup
Task 3: Performing a Transaction Dump and Load Task 3: Performing a Transaction Dump and Load
Description In this task, you will perform a transaction dump and load. Description In this task, you will perform a transaction dump and load.
1. Perform a full database dump and then a transaction dump. 1. Perform a full database dump and then a transaction dump.
Procedure Procedure
a. Continuing in Window A as the sa: a. Continuing in Window A as the sa:
1. turn off the database option “trunc log on chkpt” for the my_db database. 1. turn off the database option “trunc log on chkpt” for the my_db database.
2. turn on the database option “no chkpt on recovery” for the my_db database. 2. turn on the database option “no chkpt on recovery” for the my_db database.
You are going to perform full and incremental database dumps You are going to perform full and incremental database dumps
in this exercise. The database option, “trunc log on chkpt”, must in this exercise. The database option, “trunc log on chkpt”, must
be off to perform a transaction dump. be off to perform a transaction dump.
Additionally, you will be “breaking” the load sequence to examine Additionally, you will be “breaking” the load sequence to examine
the effects of partial database loads. The database option, “no chkpt the effects of partial database loads. The database option, “no chkpt
on recovery” must be on to perform this task. on recovery” must be on to perform this task.
sp_dboption my_db, "trunc log on chkpt", false sp_dboption my_db, "trunc log on chkpt", false
sp_dboption my_db, "no chkpt on recovery", true sp_dboption my_db, "no chkpt on recovery", true
b. Verify that the database option “trunc log on chkpt” is off and that “no chkpt on b. Verify that the database option “trunc log on chkpt” is off and that “no chkpt on
recovery” is on for the my_db database. recovery” is on for the my_db database.
c. Continuing in the my_db database, insert a row with value “2” into the test_dump c. Continuing in the my_db database, insert a row with value “2” into the test_dump
table. table.
d. Verify the contents of the test_dump table. d. Verify the contents of the test_dump table.
Are there now two rows in the table with values “1” and “2”, Are there now two rows in the table with values “1” and “2”,
respectively? respectively?
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 18 - 7 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 18 - 7
e. Dump the database, my_db, to the dump device db_dump_dev (without using e. Dump the database, my_db, to the dump device db_dump_dev (without using
compression). compression).
f. Insert a row with value “3” into the test_dump table. f. Insert a row with value “3” into the test_dump table.
g. Dump the transaction log for the my_db database to the dump device g. Dump the transaction log for the my_db database to the dump device
log_dump_dev (without using compression). log_dump_dev (without using compression).
2. Load the database from the backup. 2. Load the database from the backup.
a. Access the master database. a. Access the master database.
b. Load the my_db database from the dump device, db_dump_dev. b. Load the my_db database from the dump device, db_dump_dev.
c. Bring the my_db database online. c. Bring the my_db database online.
d. Access the my_db database and examine the contents of the test_dump table. d. Access the my_db database and examine the contents of the test_dump table.
How many rows are in the table after loading the full database How many rows are in the table after loading the full database
dump? dump?
Can the third row be restored from the backup sequence just Can the third row be restored from the backup sequence just
completed? Explain. completed? Explain.
Note: It is not a usual practice to load a transaction log dump once a Note: It is not a usual practice to load a transaction log dump once a
database has been brought online. We are doing it here for database has been brought online. We are doing it here for
demonstration purposes. It is usually done only with the demonstration purposes. It is usually done only with the
standby_access option, and then only for read-only databases (where standby_access option, and then only for read-only databases (where
the dump is loaded - a read/write database could be copied to another the dump is loaded - a read/write database could be copied to another
server this way). It is the no chkpt on recovery option that makes it server this way). It is the no chkpt on recovery option that makes it
possible to do the transaction log load after a database is online, and possible to do the transaction log load after a database is online, and
this is not the normal running mode (again, except for a server this is not the normal running mode (again, except for a server
running read-only and receiving transaction log dumps from another running read-only and receiving transaction log dumps from another
server). Normally, all transaction log dumps are loaded, in sequence, server). Normally, all transaction log dumps are loaded, in sequence,
IMMEDIATELY after loading a database dump, and only when all IMMEDIATELY after loading a database dump, and only when all
those loads are complete is the database brought online. those loads are complete is the database brought online.
Lab 18 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 18 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 18: Performing a Backup Module 18: Performing a Backup
b. Load the transaction dump for the my_db database from the dump device, b. Load the transaction dump for the my_db database from the dump device,
log_dump_dev. log_dump_dev.
c. Bring the my_db database online. c. Bring the my_db database online.
d. Access the my_db database and examine the contents of the test_dump table. d. Access the my_db database and examine the contents of the test_dump table.
How many rows are in the table after loading the full database dump How many rows are in the table after loading the full database dump
AND the transaction dump? AND the transaction dump?
4. Continuing in Window A as the sa, reset the database options. 4. Continuing in Window A as the sa, reset the database options.
1. turn on the database option “trunc log on chkpt” for the my_db database. 1. turn on the database option “trunc log on chkpt” for the my_db database.
2. turn off the database option “no chkpt on recovery” for the my_db database. 2. turn off the database option “no chkpt on recovery” for the my_db database.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 18 - 9 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 18 - 9
Task 4: Analyzing the Effects of Dump Compression Task 4: Analyzing the Effects of Dump Compression
Description In this task, you will analyze the effects of dump compression. Description In this task, you will analyze the effects of dump compression.
Procedure Procedure
1. Perform full database dumps for the my_db database with various compression values. 1. Perform full database dumps for the my_db database with various compression values.
In this section you will perform several database dumps for the same In this section you will perform several database dumps for the same
database using different levels of compression. database using different levels of compression.
Do not use the dump devices created earlier in this lab when Do not use the dump devices created earlier in this lab when
performing the dumps. performing the dumps.
Instead, create distinct physical dump files in the $HOME/sa Instead, create distinct physical dump files in the $HOME/sa
directory. Perform the following types of dumps using the associated directory. Perform the following types of dumps using the associated
file names: file names:
no compression: dump_my_db.no_compress no compression: dump_my_db.no_compress
default compression: dump_my_db.default_compress default compression: dump_my_db.default_compress
level 0 compression: dump_my_db.level0_compress level 0 compression: dump_my_db.level0_compress
level 1 compression: dump_my_db.level1_compress level 1 compression: dump_my_db.level1_compress
level 6 compression: dump_my_db.level6_compress level 6 compression: dump_my_db.level6_compress
level 9 compression: dump_my_db.level9_compress level 9 compression: dump_my_db.level9_compress
a. No compression - use the dump file name: dump_my_db.no_compress: a. No compression - use the dump file name: dump_my_db.no_compress:
dump database my_db to dump database my_db to
"/home/usr/u/dub101/sa/dump_my_db.no_compress" "/home/usr/u/dub101/sa/dump_my_db.no_compress"
b. Default compression - use the dump file name: dump_my_db.default_compress: b. Default compression - use the dump file name: dump_my_db.default_compress:
dump database my_db to dump database my_db to
"compress::/home/usr/u/dub101/sa/dump_my_db.default_compress" "compress::/home/usr/u/dub101/sa/dump_my_db.default_compress"
c. Level 0 compression - use the dump file name: dump_my_db.level0_compress: c. Level 0 compression - use the dump file name: dump_my_db.level0_compress:
dump database my_db to dump database my_db to
"compress::0::/home/usr/u/dub101/sa/dump_my_db.level0_compress" "compress::0::/home/usr/u/dub101/sa/dump_my_db.level0_compress"
d. Level 1 compression - use the dump file name: dump_my_db.level1_compress: d. Level 1 compression - use the dump file name: dump_my_db.level1_compress:
dump database my_db to dump database my_db to
"/home/usr/u/dub101/sa/dump_my_db.level1_compress" "/home/usr/u/dub101/sa/dump_my_db.level1_compress"
with compression = “1” with compression = “1”
Lab 18 - 10 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 18 - 10 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 18: Performing a Backup Module 18: Performing a Backup
e. Level 6 compression - use the dump file name: dump_my_db.level6_compress: e. Level 6 compression - use the dump file name: dump_my_db.level6_compress:
dump database my_db to dump database my_db to
"/home/usr/u/dub101/sa/dump_my_db.level6_compress" "/home/usr/u/dub101/sa/dump_my_db.level6_compress"
with compression = “6” with compression = “6”
f. Level 9 compression - use the dump file name: dump_my_db.level9_compress: f. Level 9 compression - use the dump file name: dump_my_db.level9_compress:
dump database my_db to dump database my_db to
"/home/usr/u/dub101/sa/dump_my_db.level9_compress" "/home/usr/u/dub101/sa/dump_my_db.level9_compress"
with compression = “9” with compression = “9”
2. Analyze the dump file sizes. 2. Analyze the dump file sizes.
a. In Window B, access the $HOME/sa directory. a. In Window B, access the $HOME/sa directory.
cd $HOME/sa cd $HOME/sa
b. Display a listing of the dump files just created by using the Unix ls -l command. b. Display a listing of the dump files just created by using the Unix ls -l command.
ls -l dump_my_db* ls -l dump_my_db*
Why are the default and level 1 compression dumps about the same Why are the default and level 1 compression dumps about the same
size? size?
Why is the level 0 compression about the same size as the dump Why is the level 0 compression about the same size as the dump
made without compression? made without compression?
Which compression produced the smallest dump file size? Would Which compression produced the smallest dump file size? Would
you expect to see a bigger difference for that dump file size you expect to see a bigger difference for that dump file size
(compared to the other dump files) if the database had been much (compared to the other dump files) if the database had been much
larger? larger?
On a heavily loaded system, why might you not want to use the best On a heavily loaded system, why might you not want to use the best
compression (level 9)? compression (level 9)?
3. Exit all client sessions with Adaptive Server. 3. Exit all client sessions with Adaptive Server.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 18 - 11 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 18 - 11
4. Examine the following dump and load sequence and then answer the questions that 4. Examine the following dump and load sequence and then answer the questions that
follow: follow:
This is a thought exercise, you do not have to perform the following commands. This is a thought exercise, you do not have to perform the following commands.
First, a full database dump is performed with no compression as follows: First, a full database dump is performed with no compression as follows:
Then, after some data modification occurs, a transaction dump is performed with level Then, after some data modification occurs, a transaction dump is performed with level
9 compression: 9 compression:
Would the following load sequence be successful? Explain. Would the following load sequence be successful? Explain.
What would be the correct sequence to perform the load? What would be the correct sequence to perform the load?
Lab 18 - 12 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 18 - 12 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 19: Practicing Advanced Backup Techniques Module 19: Practicing Advanced Backup Techniques
Module 19: Practicing Advanced Backup Techniques Module 19: Practicing Advanced Backup Techniques
Lab 19: Practicing Advanced Backup Techniques Lab 19: Practicing Advanced Backup Techniques
Lab Setup You will be using your 2K page size Adaptive Server and your Backup Server for this lab. Lab Setup You will be using your 2K page size Adaptive Server and your Backup Server for this lab.
Objectives After completing this lab, you should be able to: Objectives After completing this lab, you should be able to:
Implement a last-chance threshold procedure Implement a last-chance threshold procedure
Description In this lab, you will learn how to implement a last-chance threshold procedure and you will Description In this lab, you will learn how to implement a last-chance threshold procedure and you will
observe the effects of the quiesce database command. observe the effects of the quiesce database command.
Task Outline 1. Creating a Last-Chance Threshold Procedure Task Outline 1. Creating a Last-Chance Threshold Procedure
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 19 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 19 - 1
Note: If you have not completed the previous labs in which you Note: If you have not completed the previous labs in which you
created database devices and the my_db database then issue the created database devices and the my_db database then issue the
following commands now (substituting $SYBASE/ appropriately): following commands now (substituting $SYBASE/ appropriately):
disk init disk init
name = "data_dev", name = "data_dev",
physname = "$SYBASE/devices/data_dev.dat", physname = "$SYBASE/devices/data_dev.dat",
size = "4M" size = "4M"
go go
disk init disk init
name = "log_dev", name = "log_dev",
physname = "$SYBASE/devices/log_dev.mir", physname = "$SYBASE/devices/log_dev.mir",
size = 1024 size = 1024
go go
create database my_db on data_dev = 4 log on log_dev create database my_db on data_dev = 4 log on log_dev
= 2 = 2
go go
exec sp_addlogin tom, "friday", my_db exec sp_addlogin tom, "friday", my_db
exec sp_addlogin dick, "friday", my_db exec sp_addlogin dick, "friday", my_db
exec sp_addlogin harry, "friday", my_db exec sp_addlogin harry, "friday", my_db
go go
use my_db use my_db
go go
exec sp_adduser tom exec sp_adduser tom
exec sp_adduser dick exec sp_adduser dick
exec sp_adduser harry exec sp_adduser harry
go go
exec sp_addgroup programmers exec sp_addgroup programmers
exec sp_addgroup engineers exec sp_addgroup engineers
go go
exec sp_changegroup programmers, tom exec sp_changegroup programmers, tom
exec sp_changegroup programmers, dick exec sp_changegroup programmers, dick
exec sp_changegroup engineers, harry exec sp_changegroup engineers, harry
go go
For this lab, it would be useful to open two windows (“A” and “B”). For this lab, it would be useful to open two windows (“A” and “B”).
This allows you to have multiple client sessions with ASE This allows you to have multiple client sessions with ASE
simultaneously. simultaneously.
You should exit any active client sessions with Adaptive Server You should exit any active client sessions with Adaptive Server
before continuing. before continuing.
Lab 19 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 19 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 19: Practicing Advanced Backup Techniques Module 19: Practicing Advanced Backup Techniques
Task 1: Creating a Last-chance Threshold Procedure Task 1: Creating a Last-chance Threshold Procedure
Description In this task, you will create a last-chance threshold procedure that dumps the transaction Description In this task, you will create a last-chance threshold procedure that dumps the transaction
log, prints a message to the Adaptive Server error log. You also test the last-chance log, prints a message to the Adaptive Server error log. You also test the last-chance
threshold to verify that it functions properly. threshold to verify that it functions properly.
Procedure Procedure
1. Create a last-chance threshold procedure. 1. Create a last-chance threshold procedure.
a. In Window A, connect to Adaptive Server as the sa. a. In Window A, connect to Adaptive Server as the sa.
b. Turn off the database option “trunc log on chkpt” for the my_db database. b. Turn off the database option “trunc log on chkpt” for the my_db database.
You are going to create a last-chance threshold procedure that You are going to create a last-chance threshold procedure that
performs a transaction log dump. Therefore, the database performs a transaction log dump. Therefore, the database
option, “trunc log on chkpt”, must be off to perform a option, “trunc log on chkpt”, must be off to perform a
transaction dump. transaction dump.
use master use master
sp_dboption my_db, "trunc log on chkpt", false sp_dboption my_db, "trunc log on chkpt", false
c. Verify that the database option “trunc log on chkpt” is off and that “no chkpt on c. Verify that the database option “trunc log on chkpt” is off and that “no chkpt on
recovery” is on for the my_db database. recovery” is on for the my_db database.
d. Continuing in the my_db database, examine the thresholds in place for the d. Continuing in the my_db database, examine the thresholds in place for the
database by using sp_helpthreshold. database by using sp_helpthreshold.
How many thresholds does the database have and where are How many thresholds does the database have and where are
they set? they set?
What is the associated threshold procedure for the last-chance What is the associated threshold procedure for the last-chance
threshold? threshold?
How can you determine whether this stored procedure exists? How can you determine whether this stored procedure exists?
Explain. Explain.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 19 - 3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 19 - 3
e. Create the last-chance threshold procedure, sp_thresholdaction, in the my_db e. Create the last-chance threshold procedure, sp_thresholdaction, in the my_db
database so that it performs a transaction log dump to a disk file and prints an database so that it performs a transaction log dump to a disk file and prints an
appropriate message. appropriate message.
Automatic log dumping should generate a new file name each Automatic log dumping should generate a new file name each
time as opposed to using a fixed file name or a dump device. time as opposed to using a fixed file name or a dump device.
Otherwise, each successive log dump will overwrite the previous Otherwise, each successive log dump will overwrite the previous
one! one!
For this lab you can dump to a simple file name that gets For this lab you can dump to a simple file name that gets
overwritten each time, for example: overwritten each time, for example:
dump tran @dbname to "dump_tran_my_db" dump tran @dbname to "dump_tran_my_db"
Or you can program a more sophisticated file name that is Or you can program a more sophisticated file name that is
unique for each dump, thus preserving the previous dump files. unique for each dump, thus preserving the previous dump files.
For example, your threshold procedure can create a dump file For example, your threshold procedure can create a dump file
name that is a string comprised of the database name and the name that is a string comprised of the database name and the
current system date (including a time stamp): current system date (including a time stamp):
print "LOG DUMP: segment %1! for database %2! dumped", print "LOG DUMP: segment %1! for database %2! dumped",
@segmentname, @dbname @segmentname, @dbname
print "DUMP FILE NAME IS: %1! ", @dump_file_name print "DUMP FILE NAME IS: %1! ", @dump_file_name
2. Test the last-chance threshold procedure. 2. Test the last-chance threshold procedure.
a. Perform a full database dump for the my_db database. a. Perform a full database dump for the my_db database.
Note: If your Backup Server is not started, start it up now. Note: If your Backup Server is not started, start it up now.
Why is this step necessary for the threshold procedure that you just Why is this step necessary for the threshold procedure that you just
created? created?
Transaction log dumps cannot begin a database dump Transaction log dumps cannot begin a database dump
sequence. The sequence must start with a full database sequence. The sequence must start with a full database
dump. dump.
Lab 19 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 19 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 19: Practicing Advanced Backup Techniques Module 19: Practicing Advanced Backup Techniques
b. Create a simple table in the my_db database as follows: b. Create a simple table in the my_db database as follows:
create table test_lct (i int, c char(100)) create table test_lct (i int, c char(100))
c. Force the my_db database to reach the last-chance threshold by performing the c. Force the my_db database to reach the last-chance threshold by performing the
following T-SQL batch. (Note the use of set nocount on and the go 5000.) following T-SQL batch. (Note the use of set nocount on and the go 5000.)
Examine the careful construction of this batch: Examine the careful construction of this batch:
1. It uses set nocount on to eliminate the “rows affected” message 1. It uses set nocount on to eliminate the “rows affected” message
displayed by each insert and delete statement. displayed by each insert and delete statement.
2. The suggested approach is to use a delete followed by a insert so 2. The suggested approach is to use a delete followed by a insert so
that the data segment does not fill up before the log segment does. that the data segment does not fill up before the log segment does.
(No threshold procedure has been set up for the data segment.) (No threshold procedure has been set up for the data segment.)
3. The go 5000 tells Adaptive Server to repeat the batch sequence 3. The go 5000 tells Adaptive Server to repeat the batch sequence
5000 times. 5000 times.
Did you see a warning message concerning the transaction log Did you see a warning message concerning the transaction log
becoming full? If yes, what happened? becoming full? If yes, what happened?
How can you tell that the batch successfully completed 5000 times? How can you tell that the batch successfully completed 5000 times?
Note: If the batch does not complete successfully after a few Note: If the batch does not complete successfully after a few
minutes, it’s possible that your threshold procedure is not minutes, it’s possible that your threshold procedure is not
functioning properly. You may have to open another session functioning properly. You may have to open another session
with Adaptive Server and kill the process in Window A and then with Adaptive Server and kill the process in Window A and then
manually truncate the log for the my_db database: manually truncate the log for the my_db database:
kill spid# kill spid#
go go
dump tran my_db with truncate_only dump tran my_db with truncate_only
go go
Next, if the sp_thresholdaction procedure contains logical Next, if the sp_thresholdaction procedure contains logical
programming mistakes, drop and create it again. Then start the programming mistakes, drop and create it again. Then start the
test sequence in step 2 over again. Also, make sure the Backup test sequence in step 2 over again. Also, make sure the Backup
Server is up and running. Server is up and running.
3. Verify that the threshold procedure performed as programmed. 3. Verify that the threshold procedure performed as programmed.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 19 - 5 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 19 - 5
a. In Window B, change the directory to $SYBASE/$SYBASE_ASE/install. a. In Window B, change the directory to $SYBASE/$SYBASE_ASE/install.
cd $SYBASE/$SYBASE_ASE/install cd $SYBASE/$SYBASE_ASE/install
b. Verify that the threshold procedure print messages were written to the Adaptive b. Verify that the threshold procedure print messages were written to the Adaptive
Server error log ($DSQUERY.log) by examining the log using any available Server error log ($DSQUERY.log) by examining the log using any available
operating system command such as tail or an editor such as vi. operating system command such as tail or an editor such as vi.
tail $DSQUERY.log tail $DSQUERY.log
c. Examine the end of the Backup Server log (${DSQUERY}_BS.log) for messages c. Examine the end of the Backup Server log (${DSQUERY}_BS.log) for messages
concerning the dump performed by the threshold procedure, looking for the last concerning the dump performed by the threshold procedure, looking for the last
occurrence of the phrase “Dumpfile name . . . “. occurrence of the phrase “Dumpfile name . . . “.
tail ${DSQUERY}_BS.log tail ${DSQUERY}_BS.log
d. Verify that the transaction dump file was created by using the Unix ls command. d. Verify that the transaction dump file was created by using the Unix ls command.
ls -l my_db* ls -l my_db*
Based on you examination of the Adaptive Server and Backup Based on you examination of the Adaptive Server and Backup
Server log files, can you conclude that the threshold procedure Server log files, can you conclude that the threshold procedure
performed as programmed? performed as programmed?
4. Continuing in Window A as the sa, turn on the database option “trunc log on chkpt” 4. Continuing in Window A as the sa, turn on the database option “trunc log on chkpt”
for the my_db database (to restore its state for future labs). for the my_db database (to restore its state for future labs).
use master use master
sp_dboption my_db, "trunc log on chkpt", true sp_dboption my_db, "trunc log on chkpt", true
Lab 19 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 19 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 20: Sybase Central Module 20: Sybase Central
There are no labs in this module There are no labs in this module
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 20 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 20 - 1
Lab 20 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 20 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 21: Monitoring the System Module 21: Monitoring the System
Module 21: Monitoring the System Module 21: Monitoring the System
There are no labs in this module There are no labs in this module
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 21 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab 21 - 1
Lab 21 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab 21 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
System and Database Administration: System and Database Administration:
Adaptive Server Enterprise Adaptive Server Enterprise
UNIX Lab Solutions UNIX Lab Solutions
Version 1.1 Version 1.1
Part # EDB356-90-1500-11 Part # EDB356-90-1500-11
There are no labs in this module There are no labs in this module
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 1 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 1 - 1
Lab Solution 1 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 1 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 2: Installing Servers Module 2: Installing Servers
Lab setup This is a pencil-and-paper activity. Lab setup This is a pencil-and-paper activity.
Objectives Answer questions about the ASE operating environment. Objectives Answer questions about the ASE operating environment.
Description In this lab, you will learn ASE operating environment. Description In this lab, you will learn ASE operating environment.
Task Outline 1. Answering the questions regarding file locations, RUNSERVER file and how to Task Outline 1. Answering the questions regarding file locations, RUNSERVER file and how to
start and stop servers start and stop servers
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 2 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 2 - 1
Task 1: Answer the questions regarding file locations, Task 1: Answer the questions regarding file locations,
RUNSERVER file and how to start and stop servers RUNSERVER file and how to start and stop servers
Description In this task, you will answer the questions regarding file locations, RUNSERVER file and Description In this task, you will answer the questions regarding file locations, RUNSERVER file and
how to start and stop servers. how to start and stop servers.
Procedure 1. For each type of ASE file listed below, identify its default location. Procedure 1. For each type of ASE file listed below, identify its default location.
a. The interfaces file: a. The interfaces file:
It is located in the $SYBASE directory. It is located in the $SYBASE directory.
b. The RUNSERVER file: b. The RUNSERVER file:
It is located in the $SYBASE/$SYBASE_ASE/install directory. It is located in the $SYBASE/$SYBASE_ASE/install directory.
c. The ASE errorlog: c. The ASE errorlog:
It is also located in the $SYBASE/$SYBASE_ASE/install directory. It is also located in the $SYBASE/$SYBASE_ASE/install directory.
d. The ASE configuration (.cfg) file: d. The ASE configuration (.cfg) file:
It is located in the $SYBASE/$SYBASE_ASE directory. It is located in the $SYBASE/$SYBASE_ASE directory.
2. Given the following contents of a RUNSERVER file, answer the following questions. 2. Given the following contents of a RUNSERVER file, answer the following questions.
#!/bin/sh #!/bin/sh
# #
# ASE page size (KB): 2K # ASE page size (KB): 2K
# Master device path: /home/usr/u/bur301/ASE- # Master device path: /home/usr/u/bur301/ASE-
15_0/devices/2Kmaster.dat 15_0/devices/2Kmaster.dat
# Error log path: /deltadisk/home/bur301/ASE- # Error log path: /deltadisk/home/bur301/ASE-
15_0/install/BUR301_2K.log 15_0/install/BUR301_2K.log
# Configuration file path: /deltadisk/home/bur301/ASE- # Configuration file path: /deltadisk/home/bur301/ASE-
15_0/BUR301_2K.cfg 15_0/BUR301_2K.cfg
# Directory for shared memory files: /deltadisk/home/bur301/ASE- # Directory for shared memory files: /deltadisk/home/bur301/ASE-
15_0 15_0
# Adaptive Server name: BUR301_2K # Adaptive Server name: BUR301_2K
# #
/deltadisk/home/bur301/ASE-15_0/bin/dataserver \ /deltadisk/home/bur301/ASE-15_0/bin/dataserver \
-d/home/u/bur301/devices/2Kmaster.dat \ -d/home/u/bur301/devices/2Kmaster.dat \
-e/deltadisk/home/bur301/ASE-15_0/install/BUR301_2K.log \ -e/deltadisk/home/bur301/ASE-15_0/install/BUR301_2K.log \
-c/deltadisk/home/bur301/ASE-15_0/BUR301_2K.cfg \ -c/deltadisk/home/bur301/ASE-15_0/BUR301_2K.cfg \
-M/deltadisk/home/bur301/ASE-15_0 \ -M/deltadisk/home/bur301/ASE-15_0 \
-sBUR301_2K \ -sBUR301_2K \
a. What is the name of the Adaptive Server associated with this RUNSERVER file? a. What is the name of the Adaptive Server associated with this RUNSERVER file?
BUR301_2K BUR301_2K
b. What is the physical path to the master device? b. What is the physical path to the master device?
Lab Solution 2 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 2 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 2: Installing Servers Module 2: Installing Servers
The path is $SYBASE/$SYBASE_ASE/devices, which in this case translates The path is $SYBASE/$SYBASE_ASE/devices, which in this case translates
to: /home/usr/u/bur301/devices/ to: /home/usr/u/bur301/devices/
c. What is the name of the master device file for this server? c. What is the name of the master device file for this server?
2Kmaster.dat 2Kmaster.dat
d. What is the path and file name for the ASE errorlog? d. What is the path and file name for the ASE errorlog?
/deltadisk/home/bur301/ASE-15_0/install/BUR301_2K.log /deltadisk/home/bur301/ASE-15_0/install/BUR301_2K.log
e. What is the path and file name for the ASE configuration file? e. What is the path and file name for the ASE configuration file?
/deltadisk/home/bur301/ASE-15_0/BUR301_2K.cfg /deltadisk/home/bur301/ASE-15_0/BUR301_2K.cfg
3. How can you determine if Adaptive Server is running? 3. How can you determine if Adaptive Server is running?
• Use the Sybase utility showserver (filter the output with the Unix grep • Use the Sybase utility showserver (filter the output with the Unix grep
command) command)
• Use the Unix ps command (filter the output with the grep command) • Use the Unix ps command (filter the output with the grep command)
• Establish a direct connection to the Adaptive Server, using a client such as isql • Establish a direct connection to the Adaptive Server, using a client such as isql
• Use the Sybase utility dsedit to ping the server. • Use the Sybase utility dsedit to ping the server.
4. How can you start and stop Adaptive Server? 4. How can you start and stop Adaptive Server?
Start a server with the Sybase utility startserver, for example: Start a server with the Sybase utility startserver, for example:
startserver –f $SYBASE/$SYBASE_ASE/install/RUN_BUR301_2K startserver –f $SYBASE/$SYBASE_ASE/install/RUN_BUR301_2K
Stop a server with the T-SQL shutdown command. Stop a server with the T-SQL shutdown command.
1> shutdown 1> shutdown
2> go 2> go
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 2 - 3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 2 - 3
Lab Solution 2 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 2 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 3: Establishing Connectivity Module 3: Establishing Connectivity
Lab setup The first section is a pencil-and-paper activity. Lab setup The first section is a pencil-and-paper activity.
The second section has hands-on activities to perform. The second section has hands-on activities to perform.
You will be using your 2K-page size Adaptive Server for this lab. You will be using your 2K-page size Adaptive Server for this lab.
Objectives After completing this lab, you should be able to: Objectives After completing this lab, you should be able to:
Analyze the content and format of sample interfaces files Analyze the content and format of sample interfaces files
Establish a client connection to Adaptive Server Establish a client connection to Adaptive Server
Description In this lab, you will learn how to analyze the content and format of interfaces file. You will Description In this lab, you will learn how to analyze the content and format of interfaces file. You will
also learn to establish a client connection to Adaptive Server. also learn to establish a client connection to Adaptive Server.
Task outline 1. Comparing two interfaces file to debug a connectivity problem Task outline 1. Comparing two interfaces file to debug a connectivity problem
2. Starting up Adaptive Server and establishing a client connection 2. Starting up Adaptive Server and establishing a client connection
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 3 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 3 - 1
Task 1: Compare Two Interfaces File to Debug a Connectivity Task 1: Compare Two Interfaces File to Debug a Connectivity
Problem Problem
Description In this task, you will analyze the content and format of sample interfaces files. Description In this task, you will analyze the content and format of sample interfaces files.
Procedure Scenario: You have just assumed responsibility for administering an Adaptive Server Procedure Scenario: You have just assumed responsibility for administering an Adaptive Server
named GALILEO. The server resides on a Unix host named jupiter2 using TCP/IP and named GALILEO. The server resides on a Unix host named jupiter2 using TCP/IP and
Unix sockets. The previous System Administrator installed the server on one machine, and Unix sockets. The previous System Administrator installed the server on one machine, and
completed two client installations on two other machines. The previous administrator had completed two client installations on two other machines. The previous administrator had
done some editing of the interfaces files, and now neither client is able to connect to the done some editing of the interfaces files, and now neither client is able to connect to the
server. Study the interfaces files that appear below. server. Study the interfaces files that appear below.
interfaces on machine #1 (server): interfaces on machine #1 (server):
GALILEO GALILEO
master tcp ether jupiter2 4697 master tcp ether jupiter2 4697
query tcp ether jupiter2 4697 query tcp ether jupiter2 4697
interfaces on machine #2 (client): interfaces on machine #2 (client):
GALILEO GALILEO
master tcp ether jupiter2 4697 master tcp ether jupiter2 4697
interfaces on machine #3 (client): interfaces on machine #3 (client):
GALILEO GALILEO
query tcp ether jupiter2 4967 query tcp ether jupiter2 4967
1. Describe the changes you need to make to establish connectivity for both clients on 1. Describe the changes you need to make to establish connectivity for both clients on
machine #2 and machine #3. machine #2 and machine #3.
The ASE named GALILEO is started by using the sql.ini file on machine #1. The The ASE named GALILEO is started by using the sql.ini file on machine #1. The
master entry is used to start the server on port 4697. Clients running on machine #1 master entry is used to start the server on port 4697. Clients running on machine #1
can connect to the server because a valid query entry exists in the sql.ini file. can connect to the server because a valid query entry exists in the sql.ini file.
The clients on machine #2 cannot connect to GALILEO because the sql.ini file does The clients on machine #2 cannot connect to GALILEO because the sql.ini file does
not contain a query entry. The master entry in any sql.ini file is ignored by any client not contain a query entry. The master entry in any sql.ini file is ignored by any client
trying to connect to the server. The master entry is used when starting up the server. trying to connect to the server. The master entry is used when starting up the server.
Typically client machine sql.ini files should not contain a master entry. Typically client machine sql.ini files should not contain a master entry.
The clients on machine #3 cannot connect to GALILEO because the sql.ini file has a The clients on machine #3 cannot connect to GALILEO because the sql.ini file has a
slight mistake that is not readily visible. The query entry network port number does slight mistake that is not readily visible. The query entry network port number does
not match the master network port number in the sql.ini file on machine #1. (The “9” not match the master network port number in the sql.ini file on machine #1. (The “9”
and the “6” have been transposed.) and the “6” have been transposed.)
Lab Solution 3 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 3 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 3: Establishing Connectivity Module 3: Establishing Connectivity
Task 2: Start up Adaptive Server and Establish a Client Task 2: Start up Adaptive Server and Establish a Client
Connection Connection
Description In this task, you first determine whether Adaptive Server is up and running and then start Description In this task, you first determine whether Adaptive Server is up and running and then start
up Adaptive Server and establish a client connection. up Adaptive Server and establish a client connection.
In this section, you will establish connectivity from your Windows workstation to In this section, you will establish connectivity from your Windows workstation to
Procedure Procedure
your 2K page size Adaptive Server running on the classroom Unix machine. your 2K page size Adaptive Server running on the classroom Unix machine.
Your instructor will provide the following information: Your instructor will provide the following information:
For all labs, you should open two windows (“A” and “B”). Unless For all labs, you should open two windows (“A” and “B”). Unless
instructed otherwise, perform all lab exercises in Window A. instructed otherwise, perform all lab exercises in Window A.
You use Window B primarily as a console for starting up Adaptive You use Window B primarily as a console for starting up Adaptive
Server and executing OS commands. All Adaptive Server system Server and executing OS commands. All Adaptive Server system
messages are displayed there instead of in your active ASE client messages are displayed there instead of in your active ASE client
window. window.
1. Open the “Select a UNIX Host” icon on the PC desktop. 1. Open the “Select a UNIX Host” icon on the PC desktop.
The Instructor will provide the name of the Unix host system to The Instructor will provide the name of the Unix host system to
which you should connect and the User ID and password that you which you should connect and the User ID and password that you
will use for the class. will use for the class.
Fill in the Host name, your User ID, and Password to open an xterm Fill in the Host name, your User ID, and Password to open an xterm
window from the Unix server. window from the Unix server.
Click “OK” to open Window A. Click “OK” to open Window A.
Repeat the process to open Window B. Repeat the process to open Window B.
2. In Window B, examine the Unix environment. 2. In Window B, examine the Unix environment.
a. Verify that you have logged into the Unix server with the correct login name by a. Verify that you have logged into the Unix server with the correct login name by
examining the setting for the $LOGNAME environment variable. (The solutions examining the setting for the $LOGNAME environment variable. (The solutions
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 3 - 3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 3 - 3
dub101 dub101
b. What is the $HOME variable set to? b. What is the $HOME variable set to?
/home/usr/u/dub101 /home/usr/u/dub101
c. What is the $SYBASE variable set to? c. What is the $SYBASE variable set to?
/home/usr/u/dub101 /home/usr/u/dub101
What is the relationship between your $HOME and $SYBASE What is the relationship between your $HOME and $SYBASE
directories? directories?
Your $HOME directory is your $SYBASE directory. Your $HOME directory is your $SYBASE directory.
d. Confirm which directory you are currently in. d. Confirm which directory you are currently in.
pwd pwd
/deltadisk/home/dub101 /deltadisk/home/dub101
Examine your results carefully! Due to system variations, you Examine your results carefully! Due to system variations, you
may see slightly different output than the solutions show. Sybase may see slightly different output than the solutions show. Sybase
Learning Centers use a symbolic link between your $HOME and Learning Centers use a symbolic link between your $HOME and
$SYBASE directories. $SYBASE directories.
For example, the $HOME and $SYBASE environment variable For example, the $HOME and $SYBASE environment variable
may both display as /home/usr/u/dub101; but when you change may both display as /home/usr/u/dub101; but when you change
to either directory and use the Unix command “pwd”, the to either directory and use the Unix command “pwd”, the
directory name appears as /deltadisk/home/dub101. Functionally, directory name appears as /deltadisk/home/dub101. Functionally,
the two directories are identical. the two directories are identical.
Your results when using “pwd” may be different than shown. Your results when using “pwd” may be different than shown.
The key point is that your $HOME directory is also your The key point is that your $HOME directory is also your
$SYBASE directory. $SYBASE directory.
e. What is the $SYBASE_ASE variable set to? e. What is the $SYBASE_ASE variable set to?
ASE-15_0 ASE-15_0
Lab Solution 3 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 3 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 3: Establishing Connectivity Module 3: Establishing Connectivity
f. What is the $DSQUERY variable set to? f. What is the $DSQUERY variable set to?
dub101_2K dub101_2K
The Unix machines in Sybase Learning Centers have two ASE 15.0 The Unix machines in Sybase Learning Centers have two ASE 15.0
servers already installed for each student. The names of the servers servers already installed for each student. The names of the servers
for each student correspond to the respective Unix login name. For for each student correspond to the respective Unix login name. For
example if your Unix login is dub101, then your servers are named: example if your Unix login is dub101, then your servers are named:
DUB101_2K and DUB101_2K and
DUB101_8K. DUB101_8K.
The difference between the two servers is the page size used. The difference between the two servers is the page size used.
DUB101_2K will use a 2K page size while DUB101_8K uses an 8K DUB101_2K will use a 2K page size while DUB101_8K uses an 8K
page size. page size.
You will be performing lab exercises primarily on the 2K server. You will be performing lab exercises primarily on the 2K server.
Feel free to explore the differences between the 2K and the 8K page Feel free to explore the differences between the 2K and the 8K page
server for any comparisons that you would like to make. server for any comparisons that you would like to make.
Each student also has a Backup Server whose name is associated Each student also has a Backup Server whose name is associated
with the 2K Adaptive Server, for example: with the 2K Adaptive Server, for example:
DUB101_2K_BS DUB101_2K_BS
3. Examine the Unix interfaces file. 3. Examine the Unix interfaces file.
a. Display the contents of your interfaces file by using the Unix cat or more a. Display the contents of your interfaces file by using the Unix cat or more
command. command.
cd $SYBASE cd $SYBASE
DUB101_2K DUB101_2K
master tcp ether corona 11020 master tcp ether corona 11020
query tcp ether corona 11020 query tcp ether corona 11020
DUB101_8K DUB101_8K
master tcp ether corona 11027 master tcp ether corona 11027
query tcp ether corona 11027 query tcp ether corona 11027
DUB101_2K_BS DUB101_2K_BS
master tcp ether corona 11023 master tcp ether corona 11023
query tcp ether corona 11023 query tcp ether corona 11023
b. Record the host name and port number for the 2K page size server in the following b. Record the host name and port number for the 2K page size server in the following
chart. chart.
• Recall, in this lab environment, the 2K server name is in the form: • Recall, in this lab environment, the 2K server name is in the form:
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 3 - 5 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 3 - 5
4. Use the Sybase Directory Services Editor utility, dsedit, to add an entry for your Unix 4. Use the Sybase Directory Services Editor utility, dsedit, to add an entry for your Unix
2K page size Adaptive Server on the PC client. 2K page size Adaptive Server on the PC client.
dsedit is a Sybase Windows utility that can be used to make a Unix- dsedit is a Sybase Windows utility that can be used to make a Unix-
based Adaptive Server available to PC client applications such as based Adaptive Server available to PC client applications such as
isql or Interactive SQL without having to open a Unix command isql or Interactive SQL without having to open a Unix command
prompt window. prompt window.
a. From the taskbar on the Windows Desktop, select: a. From the taskbar on the Windows Desktop, select:
Start->Programs->Sybase->Connectivity ->Open Client Directory Service Start->Programs->Sybase->Connectivity ->Open Client Directory Service
Editor Editor
b. In the Select Directory Service window, click Interfaces Driver and then click b. In the Select Directory Service window, click Interfaces Driver and then click
OK. OK.
c. From the menubar of the DSEDIT1 window, click Server Object and select Add. c. From the menubar of the DSEDIT1 window, click Server Object and select Add.
Lab Solution 3 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 3 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 3: Establishing Connectivity Module 3: Establishing Connectivity
d. In the Server Name text field of the Input Server Name window, enter the name d. In the Server Name text field of the Input Server Name window, enter the name
of your 2K page size Adaptive Server that resides on the Unix host and then click of your 2K page size Adaptive Server that resides on the Unix host and then click
OK. OK.
e. In the left panel of the DSEDIT1 window, click the name of the new server entry e. In the left panel of the DSEDIT1 window, click the name of the new server entry
that has been added. that has been added.
f. In the right panel of the DSEDIT1 window, click the Server Address attribute. f. In the right panel of the DSEDIT1 window, click the Server Address attribute.
g. Continuing in the right panel of the DSEDIT1 window, right-click the Server g. Continuing in the right panel of the DSEDIT1 window, right-click the Server
Address attribute and select Modify Attribute. Address attribute and select Modify Attribute.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 3 - 7 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 3 - 7
h. In the Network Address Attribute window, click Add. h. In the Network Address Attribute window, click Add.
i. In the Input Network Address For Protocol window, enter the Unix host name i. In the Input Network Address For Protocol window, enter the Unix host name
and port number as recorded in step 3b of this section. and port number as recorded in step 3b of this section.
The Unix host name and port number must be separated by a The Unix host name and port number must be separated by a
comma, for example: comma, for example:
corona.education,11020 corona.education,11020
j. In the Network Address Attribute window, verify the entry and then click OK. j. In the Network Address Attribute window, verify the entry and then click OK.
k. In the right panel of the DSEDIT1 window, verify that the Server Address for the k. In the right panel of the DSEDIT1 window, verify that the Server Address for the
new server entry is correct. new server entry is correct.
l. Exit the dsedit utility. l. Exit the dsedit utility.
5. Determine whether the Unix 2K ASE is up and running. 5. Determine whether the Unix 2K ASE is up and running.
List four ways to determine whether Adaptive Server is running on List four ways to determine whether Adaptive Server is running on
Unix. Unix.
1. Connect with a client application such as isql or jisql. 1. Connect with a client application such as isql or jisql.
2. Use the Sybase Windows utility Dsedit to ping the server. 2. Use the Sybase Windows utility Dsedit to ping the server.
(valid only if you added the server entry using Dsedit) (valid only if you added the server entry using Dsedit)
3. Use the Sybase Unix utility showserver. 3. Use the Sybase Unix utility showserver.
4. Use the Unix OS utility ps. 4. Use the Unix OS utility ps.
a. Method 1: Use a client application as follows: a. Method 1: Use a client application as follows:
b. In Window A, try to connect to your Unix 2K page size ASE by using isql and the b. In Window A, try to connect to your Unix 2K page size ASE by using isql and the
sa login with a NULL password. sa login with a NULL password.
You can certainly use isql from a Unix command prompt window. You can certainly use isql from a Unix command prompt window.
Additionally, you can use isql from a Windows command prompt if Additionally, you can use isql from a Windows command prompt if
you used the Sybase Windows utility Dsedit to make your Unix- you used the Sybase Windows utility Dsedit to make your Unix-
based 2K page size Adaptive Server available to PC client based 2K page size Adaptive Server available to PC client
applications. applications.
isql -Usa -P -S DUB101_2K isql -Usa -P -S DUB101_2K
Lab Solution 3 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 3 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 3: Establishing Connectivity Module 3: Establishing Connectivity
6. In Window B, start your Unix 2K page size Adaptive Server by using the Sybase 6. In Window B, start your Unix 2K page size Adaptive Server by using the Sybase
startserver utility with the appropriate RUNSERVER file. startserver utility with the appropriate RUNSERVER file.
The startserver command must be issued from a Unix command The startserver command must be issued from a Unix command
prompt, not a Windows command prompt. prompt, not a Windows command prompt.
cd $SYBASE/$SYBASE_ASE/install cd $SYBASE/$SYBASE_ASE/install
7. Determine whether the Unix 2K ASE is up and running by using a client application as 7. Determine whether the Unix 2K ASE is up and running by using a client application as
follows: follows:
a. In Window A, try to connect to your Unix 2K page size ASE by using isql and the a. In Window A, try to connect to your Unix 2K page size ASE by using isql and the
sa login with a NULL password. sa login with a NULL password.
b. Verify that you have connected to the desired Adaptive Server by using the T-SQL b. Verify that you have connected to the desired Adaptive Server by using the T-SQL
command to view the global variable @@servername as follows: command to view the global variable @@servername as follows:
c. Determine the ASE version by using the T-SQL command to view the global c. Determine the ASE version by using the T-SQL command to view the global
variable @@version as follows: variable @@version as follows:
Adaptive Server Enterprise/15.0/EBF 12780 GA/P/Linux Intel/Linux Adaptive Server Enterprise/15.0/EBF 12780 GA/P/Linux Intel/Linux
2.4.21-20.ELsmp i686/asemain/2127/32-bit/FBO/Tue Jul 19 02:57:32 2.4.21-20.ELsmp i686/asemain/2127/32-bit/FBO/Tue Jul 19 02:57:32
2005 2005
8. Determine whether the Unix 2K ASE is up and running by using the Ping capability of 8. Determine whether the Unix 2K ASE is up and running by using the Ping capability of
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 3 - 9 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 3 - 9
dsedit. dsedit.
a. Launch the Sybase dsedit Utility as in steps 4a and 4b of this section. a. Launch the Sybase dsedit Utility as in steps 4a and 4b of this section.
b. In the left panel of the DSEDIT1 window, click the Unix 2K server name. b. In the left panel of the DSEDIT1 window, click the Unix 2K server name.
c. Continuing in the left panel of the DSEDIT1 window, right-click the Unix 2K c. Continuing in the left panel of the DSEDIT1 window, right-click the Unix 2K
server name and select Ping Server. server name and select Ping Server.
d. In the Ping window, click Ping. The details should show Connection succeeded. d. In the Ping window, click Ping. The details should show Connection succeeded.
Lab Solution 3 - 10 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 3 - 10 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 4: Configuring Server Behavior Module 4: Configuring Server Behavior
Lab setup You will be using your 2K page size Adaptive Server for this lab. Lab setup You will be using your 2K page size Adaptive Server for this lab.
Objectives After completing this lab, you should be able to configure Adaptive Server for varying Objectives After completing this lab, you should be able to configure Adaptive Server for varying
processing needs processing needs
Description In this lab, you will how to configure Adaptive Server for varying processing needs and Description In this lab, you will how to configure Adaptive Server for varying processing needs and
restart the server using different configurations. restart the server using different configurations.
Task outline 1. Creating a customized configuration file and using it to start the server Task outline 1. Creating a customized configuration file and using it to start the server
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 4 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 4 - 1
Task 1: Create a Customized Configuration File Task 1: Create a Customized Configuration File
Description In this task, you will create a customized configuration file for specific processing needs Description In this task, you will create a customized configuration file for specific processing needs
and you will restart the server using different configuration files. and you will restart the server using different configuration files.
Procedure Procedure
Scenario: You are responsible for an Adaptive Server that has differing processing Scenario: You are responsible for an Adaptive Server that has differing processing
requirements during different times of the day. During business hours, there are many requirements during different times of the day. During business hours, there are many
users doing online transaction processing. During nonbusiness hours, there is little or no users doing online transaction processing. During nonbusiness hours, there is little or no
user activity, and batch processes are run. You need to create configuration files for each user activity, and batch processes are run. You need to create configuration files for each
processing requirement, and then put those files into use. processing requirement, and then put those files into use.
Note: The configuration settings used in this lab are being used for demonstration purposes Note: The configuration settings used in this lab are being used for demonstration purposes
only and are not meant to suggest appropriate values for a real-world production server. only and are not meant to suggest appropriate values for a real-world production server.
For all labs, you should open two windows (“A” and “B”). Unless For all labs, you should open two windows (“A” and “B”). Unless
instructed otherwise, perform all lab exercises in Window A. instructed otherwise, perform all lab exercises in Window A.
You use Window B primarily as a console for starting up Adaptive You use Window B primarily as a console for starting up Adaptive
Server and executing OS commands. All Adaptive Server system Server and executing OS commands. All Adaptive Server system
messages are displayed there instead of in your active ASE client messages are displayed there instead of in your active ASE client
window. window.
1. Describe two ways to make a backup copy of the active Adaptive Server configuration 1. Describe two ways to make a backup copy of the active Adaptive Server configuration
file. (Hint: one way is to use T-SQL commands.) file. (Hint: one way is to use T-SQL commands.)
1. The most obvious way to make a backup copy of any file is to use an operating 1. The most obvious way to make a backup copy of any file is to use an operating
system command such as "cp". system command such as "cp".
2. For Sybase ASE configuration files there is another method: you can use the 2. For Sybase ASE configuration files there is another method: you can use the
sp_configure command with appropriate arguments. sp_configure command with appropriate arguments.
2. Create a backup copy of the current configuration file. 2. Create a backup copy of the current configuration file.
a. By default, where are ASE configuration files located? a. By default, where are ASE configuration files located?
By default, they are located in the $SYBASE/$SYBASE_ASE directory. By default, they are located in the $SYBASE/$SYBASE_ASE directory.
b. In Window B, perform a directory listing of your ASE configuration files. (Recall b. In Window B, perform a directory listing of your ASE configuration files. (Recall
that the classroom setup provides you with a 2K and an 8K page size server.) that the classroom setup provides you with a 2K and an 8K page size server.)
cd $SYBASE/$SYBASE_ASE cd $SYBASE/$SYBASE_ASE
ls -l *.cfg ls -l *.cfg
Lab Solution 4 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 4 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 4: Configuring Server Behavior Module 4: Configuring Server Behavior
-rw-r--r-- 1 dub101 sybase 8685 Sep 30 15:46 DUB101_2K.cfg -rw-r--r-- 1 dub101 sybase 8685 Sep 30 15:46 DUB101_2K.cfg
-rw-r--r-- 1 dub101 sybase 8685 Sep 30 15:46 DUB101_8K.cfg -rw-r--r-- 1 dub101 sybase 8685 Sep 30 15:46 DUB101_8K.cfg
c. Make a backup copy of the 2K configuration file and name it 2K_backup.cfg by c. Make a backup copy of the 2K configuration file and name it 2K_backup.cfg by
using the method of your choosing (OS commands or sp_configure). using the method of your choosing (OS commands or sp_configure).
Method 1: using OS commands Method 1: using OS commands
Method 2: Use the T-SQL command sp_configure. Method 2: Use the T-SQL command sp_configure.
d. Verify that the backup configuration file was created by performing a directory d. Verify that the backup configuration file was created by performing a directory
listing of your ASE configuration files. listing of your ASE configuration files.
cd $SYBASE/$SYBASE_ASE cd $SYBASE/$SYBASE_ASE
ls -l *.cfg ls -l *.cfg
-rw-r--r-- 1 dub101 sybase 8583 Oct 2 17:26 2K_backup.cfg -rw-r--r-- 1 dub101 sybase 8583 Oct 2 17:26 2K_backup.cfg
-rw-r--r-- 1 dub101 sybase 8685 Sep 30 15:46 DUB101_2K.cfg -rw-r--r-- 1 dub101 sybase 8685 Sep 30 15:46 DUB101_2K.cfg
-rw-r--r-- 1 dub101 sybase 8685 Sep 30 15:46 DUB101_8K.cfg -rw-r--r-- 1 dub101 sybase 8685 Sep 30 15:46 DUB101_8K.cfg
3. Describe two ways to modify Adaptive Server configuration parameters. 3. Describe two ways to modify Adaptive Server configuration parameters.
1. The safest way to make ASE configuration changes is by using the sp_configure 1. The safest way to make ASE configuration changes is by using the sp_configure
command with appropriate arguments. command with appropriate arguments.
2. Alternatively, you can make configuration changes by directly editing the 2. Alternatively, you can make configuration changes by directly editing the
configuration file and then, for dynamic parameters only, using the sp_configure configuration file and then, for dynamic parameters only, using the sp_configure
command to "read" the changes from the edited file into the server. If you make command to "read" the changes from the edited file into the server. If you make
changes to static configuration parameters then you must reboot ASE to activate changes to static configuration parameters then you must reboot ASE to activate
the changes. the changes.
4. Create a custom configuration file for batch processing requirements. 4. Create a custom configuration file for batch processing requirements.
(Method 1 - sp_configure) (Method 1 - sp_configure)
To create a custom configuration file, use either: To create a custom configuration file, use either:
Method 1 (sp_configure - use this step 4) Method 1 (sp_configure - use this step 4)
or or
Method 2 (manually create and edit a new file - proceed Method 2 (manually create and edit a new file - proceed
to step 5) to step 5)
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 4 - 3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 4 - 3
a. For batch processing requirements, create a configuration file named batch.cfg that a. For batch processing requirements, create a configuration file named batch.cfg that
has the following differences from the current (default values) configuration file: has the following differences from the current (default values) configuration file:
user log cache size = 4096 user log cache size = 4096
allow remote access = 0 allow remote access = 0
b. In Window A, connect to the 2K server using the sa login with a NULL password. b. In Window A, connect to the 2K server using the sa login with a NULL password.
exec sp_configure "user log cache size", 4096 exec sp_configure "user log cache size", 4096
exec sp_configure "allow remote access", 0 exec sp_configure "allow remote access", 0
go go
Parameter Name Default Memory Used Config Value Run Parameter Name Default Memory Used Config Value Run
Value Unit Type Value Unit Type
------------------------------ ----------- ----------- ------------ ----- ------------------------------ ----------- ----------- ------------ -----
------- -------------------- ---------- ------- -------------------- ----------
user log cache size 2048 0 4096 user log cache size 2048 0 4096
2048 bytes static 2048 bytes static
Note that the configuration parameter user log cache size is static. Note that the configuration parameter user log cache size is static.
Changes to this value require a server reboot. Changes to this value require a server reboot.
The configuration parameter allow remote access is dynamic. The configuration parameter allow remote access is dynamic.
Changes to this value do not require a server reboot. Changes to this value do not require a server reboot.
d. In Window B, locate the active 2K server configuration file and make a copy of it d. In Window B, locate the active 2K server configuration file and make a copy of it
named batch.cfg. named batch.cfg.
cd $SYBASE/$SYBASE_ASE cd $SYBASE/$SYBASE_ASE
Lab Solution 4 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 4 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 4: Configuring Server Behavior Module 4: Configuring Server Behavior
e. Verify that the customized configuration file was created by performing a e. Verify that the customized configuration file was created by performing a
directory listing of your ASE configuration files. directory listing of your ASE configuration files.
ls -l *.cfg ls -l *.cfg
-rw-r--r-- 1 dub101 sybase 8583 Oct 2 17:26 2K_backup.cfg -rw-r--r-- 1 dub101 sybase 8583 Oct 2 17:26 2K_backup.cfg
-rw-r--r-- 1 dub101 sybase 8574 Oct 2 17:36 batch.cfg -rw-r--r-- 1 dub101 sybase 8574 Oct 2 17:36 batch.cfg
-rw-r--r-- 1 dub101 sybase 8574 Oct 2 17:32 DUB101_2K.cfg -rw-r--r-- 1 dub101 sybase 8574 Oct 2 17:32 DUB101_2K.cfg
-rw-r--r-- 1 dub101 sybase 8685 Sep 30 15:46 DUB101_8K.cfg -rw-r--r-- 1 dub101 sybase 8685 Sep 30 15:46 DUB101_8K.cfg
5. Create a custom configuration file for batch processing requirements. 5. Create a custom configuration file for batch processing requirements.
(Method 2 - manually create and edit a new configuration file) (Method 2 - manually create and edit a new configuration file)
Skip this step if you used Method 1 (sp_configure) in the last step. Skip this step if you used Method 1 (sp_configure) in the last step.
a. In Window B, locate the backup configuration file, 2K_backup.cfg, which you a. In Window B, locate the backup configuration file, 2K_backup.cfg, which you
created in step 2 for the 2K server and make a copy of it named batch.cfg. created in step 2 for the 2K server and make a copy of it named batch.cfg.
cd $SYBASE/$SYBASE_ASE cd $SYBASE/$SYBASE_ASE
b. Edit batch.cfg by using a text editor such as vi to make the following changes b. Edit batch.cfg by using a text editor such as vi to make the following changes
shown in bold: shown in bold:
user log cache size = 4096 user log cache size = 4096
allow remote access = 0 allow remote access = 0
c. Verify that the customized configuration file was created by performing a c. Verify that the customized configuration file was created by performing a
directory listing of your ASE configuration files. directory listing of your ASE configuration files.
ls -l *.cfg ls -l *.cfg
-rw-r--r-- 1 dub101 sybase 8583 Oct 2 17:26 2K_backup.cfg -rw-r--r-- 1 dub101 sybase 8583 Oct 2 17:26 2K_backup.cfg
-rw-r--r-- 1 dub101 sybase 8574 Oct 2 17:36 batch.cfg -rw-r--r-- 1 dub101 sybase 8574 Oct 2 17:36 batch.cfg
-rw-r--r-- 1 dub101 sybase 8574 Oct 2 17:32 DUB101_2K.cfg -rw-r--r-- 1 dub101 sybase 8574 Oct 2 17:32 DUB101_2K.cfg
-rw-r--r-- 1 dub101 sybase 8685 Sep 30 15:46 DUB101_8K.cfg -rw-r--r-- 1 dub101 sybase 8685 Sep 30 15:46 DUB101_8K.cfg
d. Although not required, it is recommended that you perform a simple verification of d. Although not required, it is recommended that you perform a simple verification of
manual changes to a configuration file by issuing the following T-SQL command manual changes to a configuration file by issuing the following T-SQL command
in Window A: (make the appropriate substitution for bur301.) in Window A: (make the appropriate substitution for bur301.)
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 4 - 5 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 4 - 5
Msg 5852, Level 16, State 1: Msg 5852, Level 16, State 1:
Server 'BUR301_2K', Procedure 'sp_configure', Line 327: Server 'BUR301_2K', Procedure 'sp_configure', Line 327:
Changing the value of 'user log cache size' is not allowed since it Changing the value of 'user log cache size' is not allowed since it
is a static option. is a static option.
(return status = 1) (return status = 1)
You can expect an error message from this command because the You can expect an error message from this command because the
configuration parameter user log cache size is static. The error configuration parameter user log cache size is static. The error
message is simply for informational purposes to warn that changes to message is simply for informational purposes to warn that changes to
this value cannot be imported ("read") from a configuration file. this value cannot be imported ("read") from a configuration file.
Changes to this value require a server reboot. Changes to this value require a server reboot.
No error message is displayed for the configuration parameter allow No error message is displayed for the configuration parameter allow
remote access because it is dynamic. Changes to this value do not remote access because it is dynamic. Changes to this value do not
require a server reboot. require a server reboot.
6. If the only value changes in batch.cfg were for dynamic configuration parameters, 6. If the only value changes in batch.cfg were for dynamic configuration parameters,
would it be necessary to reboot ASE to activate the changes? Explain. would it be necessary to reboot ASE to activate the changes? Explain.
No. A reboot is not required to read in values from a configuration file for No. A reboot is not required to read in values from a configuration file for
dynamic parameter changes. Dynamic parameter changes can be read in from a dynamic parameter changes. Dynamic parameter changes can be read in from a
file and activated as follows: file and activated as follows:
7. Activate the configuration parameter changes from the customized configuration file 7. Activate the configuration parameter changes from the customized configuration file
named batch.cfg. named batch.cfg.
a. In Window A, as the sa connected to Adaptive Server, shut down your 2K a. In Window A, as the sa connected to Adaptive Server, shut down your 2K
Adaptive Server. (A reboot is required because there are static parameter changes.) Adaptive Server. (A reboot is required because there are static parameter changes.)
shutdown shutdown
go go
b. In Window B, change the directory to $SYBASE/$SYBASE_ASE/install. b. In Window B, change the directory to $SYBASE/$SYBASE_ASE/install.
cd $SYBASE/$SYBASE_ASE/install cd $SYBASE/$SYBASE_ASE/install
c. Make a copy of the 2K RUNSERVER file (for example RUN_BUR301_2K) and c. Make a copy of the 2K RUNSERVER file (for example RUN_BUR301_2K) and
name it RUN_2K_batch. name it RUN_2K_batch.
d. Edit the new RUNSERVER file, RUN_2K_batch, so that it starts the 2K server d. Edit the new RUNSERVER file, RUN_2K_batch, so that it starts the 2K server
using the customized configuration file batch.cfg. using the customized configuration file batch.cfg.
Lab Solution 4 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 4 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 4: Configuring Server Behavior Module 4: Configuring Server Behavior
It is a good practice to make a change such as this on a backup copy It is a good practice to make a change such as this on a backup copy
of the original RUNSERVER file. Edit the comment as well as the of the original RUNSERVER file. Edit the comment as well as the
dataserver executable argument. dataserver executable argument.
#!/bin/sh #!/bin/sh
# #
# ASE page size (KB): 2K # ASE page size (KB): 2K
# Master device path: /home/usr/u/dub101/devices/2Kmaster.dat # Master device path: /home/usr/u/dub101/devices/2Kmaster.dat
# Error log path: /home/usr/u/dub101/ASE-15_0/install/DUB101_2K.log # Error log path: /home/usr/u/dub101/ASE-15_0/install/DUB101_2K.log
# Configuration file path: /home/usr/u/dub101/ASE-15_0/batch.cfg # Configuration file path: /home/usr/u/dub101/ASE-15_0/batch.cfg
# Directory for shared memory files: /home/usr/u/dub101/ASE-15_0 # Directory for shared memory files: /home/usr/u/dub101/ASE-15_0
# Adaptive Server name: DUB101_2K # Adaptive Server name: DUB101_2K
# #
/home/usr/u/dub101/ASE-15_0/bin/dataserver \ /home/usr/u/dub101/ASE-15_0/bin/dataserver \
-d/home/usr/u/dub101/devices/2Kmaster.dat \ -d/home/usr/u/dub101/devices/2Kmaster.dat \
-e/home/usr/u/dub101/ASE-15_0/install/DUB101_2K.log \ -e/home/usr/u/dub101/ASE-15_0/install/DUB101_2K.log \
-c/home/usr/u/dub101/ASE-15_0/batch.cfg \ -c/home/usr/u/dub101/ASE-15_0/batch.cfg \
-M/home/usr/u/dub101/ASE-15_0 \ -M/home/usr/u/dub101/ASE-15_0 \
-sDUB101_2K \ -sDUB101_2K \
e. Start the 2K page size Adaptive Server by using the Sybase startserver utility e. Start the 2K page size Adaptive Server by using the Sybase startserver utility
with the RUN_2K_batch file. with the RUN_2K_batch file.
8. Verify that the customized configuration file, batch.cfg, was used to start up the server. 8. Verify that the customized configuration file, batch.cfg, was used to start up the server.
a. In Window A, connect to the 2K server using the sa login with a NULL password. a. In Window A, connect to the 2K server using the sa login with a NULL password.
b. Examine the configuration settings for "allow remote access" and "user log cache b. Examine the configuration settings for "allow remote access" and "user log cache
size". size".
exec sp_configure "user log cache size" exec sp_configure "user log cache size"
exec sp_configure "allow remote access" exec sp_configure "allow remote access"
go go
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 4 - 7 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 4 - 7
Parameter Name Default Memory Used Config Value Run Parameter Name Default Memory Used Config Value Run
Value Unit Type Value Unit Type
------------------------------ ----------- ----------- ------------ ----- ------------------------------ ----------- ----------- ------------ -----
------- -------------------- ---------- ------- -------------------- ----------
user log cache size 2048 0 4096 user log cache size 2048 0 4096
4096 bytes static 4096 bytes static
Proof that the customized configuration file was used is that the run Proof that the customized configuration file was used is that the run
value for the static parameter, “user log cache size”, is different from value for the static parameter, “user log cache size”, is different from
its default value. its default value.
9. Restart the server using the original configuration file. 9. Restart the server using the original configuration file.
a. In Window A, as the sa connected to Adaptive Server, shut down your 2K a. In Window A, as the sa connected to Adaptive Server, shut down your 2K
Adaptive Server. Adaptive Server.
shutdown shutdown
go go
The SQL Server is terminating this process. The SQL Server is terminating this process.
b. In Window B, change the directory to $SYBASE/$SYBASE_ASE. b. In Window B, change the directory to $SYBASE/$SYBASE_ASE.
cd $SYBASE/$SYBASE_ASE cd $SYBASE/$SYBASE_ASE
c. Restore the backup copy of the 2K configuration file, 2K_backup.cfg to the c. Restore the backup copy of the 2K configuration file, 2K_backup.cfg to the
original configuration file which was named in the form $DSQUERY.cfg. original configuration file which was named in the form $DSQUERY.cfg.
cd $SYBASE/$SYBASE_ASE/install cd $SYBASE/$SYBASE_ASE/install
Lab Solution 4 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 4 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 4: Configuring Server Behavior Module 4: Configuring Server Behavior
e. Start your 2K page size Adaptive Server by using the Sybase startserver utility e. Start your 2K page size Adaptive Server by using the Sybase startserver utility
with the original RUNSERVER file, RUN_$DSQUERY, which uses the original with the original RUNSERVER file, RUN_$DSQUERY, which uses the original
configuration file. configuration file.
10. Verify that the original configuration file, $DSQUERY.cfg, was used to start up the 10. Verify that the original configuration file, $DSQUERY.cfg, was used to start up the
server. server.
a. In Window A, connect to the 2K server using the sa login with a NULL password. a. In Window A, connect to the 2K server using the sa login with a NULL password.
exec sp_configure "user log cache size" exec sp_configure "user log cache size"
exec sp_configure "allow remote access" exec sp_configure "allow remote access"
go go
Parameter Name Default Memory Used Config Value Run Parameter Name Default Memory Used Config Value Run
Value Unit Type Value Unit Type
------------------------------ ----------- ----------- ------------ ----- ------------------------------ ----------- ----------- ------------ -----
------- -------------------- ---------- ------- -------------------- ----------
user log cache size 2048 0 2048 user log cache size 2048 0 2048
2048 bytes static 2048 bytes static
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 4 - 9 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 4 - 9
Proof that the original configuration file was used is that the run Proof that the original configuration file was used is that the run
values for these parameters are at their default values. values for these parameters are at their default values.
11. Exit all client sessions with Adaptive Server. 11. Exit all client sessions with Adaptive Server.
Lab Solution 4 - 10 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 4 - 10 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 5: Configuring Memory Module 5: Configuring Memory
Lab setup You will be using your 2K page size Adaptive Server for this lab. There is no additional Lab setup You will be using your 2K page size Adaptive Server for this lab. There is no additional
setup for this lab. setup for this lab.
Objectives After completing this lab, you should be able to: Objectives After completing this lab, you should be able to:
Calculate the appropriate configuration value for the procedure cache Calculate the appropriate configuration value for the procedure cache
Description In this lab, you will learn how to calculate the appropriate configuration value for the Description In this lab, you will learn how to calculate the appropriate configuration value for the
procedure cache. procedure cache.
Task outline 1. Analyzing the impact of changing configuration parameters on the procedure cache Task outline 1. Analyzing the impact of changing configuration parameters on the procedure cache
2. Estimating the amount of memory needed for procedure cache 2. Estimating the amount of memory needed for procedure cache
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 5 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 5 - 1
Task 1: Analyzing the Impact of Changing Configuration Task 1: Analyzing the Impact of Changing Configuration
Parameters on the Procedure Cache Parameters on the Procedure Cache
Description In this task, you will analyze the impact of changing configuration parameters on the Description In this task, you will analyze the impact of changing configuration parameters on the
procedure cache. procedure cache.
Procedure Procedure
For all labs, you should open two windows (“A” and “B”). Unless For all labs, you should open two windows (“A” and “B”). Unless
instructed otherwise, perform all lab exercises in Window A. instructed otherwise, perform all lab exercises in Window A.
You use Window B primarily as a console for starting up Adaptive You use Window B primarily as a console for starting up Adaptive
Server and executing OS commands. All Adaptive Server system Server and executing OS commands. All Adaptive Server system
messages are displayed there instead of in your active ASE client messages are displayed there instead of in your active ASE client
window. window.
1. Examine the default status of the ASE memory model. 1. Examine the default status of the ASE memory model.
a. In Window A, connect to Adaptive Server as the sa login using the NULL a. In Window A, connect to Adaptive Server as the sa login using the NULL
password. password.
b. Examine the following ASE configuration parameters by using sp_configure and b. Examine the following ASE configuration parameters by using sp_configure and
fill in the following chart. (Your values may be slightly different). fill in the following chart. (Your values may be slightly different).
Parameter Name Default Memory Used Config Value Run Parameter Name Default Memory Used Config Value Run
Value Unit Type Value Unit Type
------------------------------ ----------- ----------- ------------ ----- ------------------------------ ----------- ----------- ------------ -----
------- -------------------- ---------- ------- -------------------- ----------
max memory 40960 81920 40960 max memory 40960 81920 40960
40960 memory pages(2k) dynamic 40960 memory pages(2k) dynamic
Lab Solution 5 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 5 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 5: Configuring Memory Module 5: Configuring Memory
total logical memory 40960 56716 28358 total logical memory 40960 56716 28358
28358 memory pages(2k) read-only 28358 memory pages(2k) read-only
max memory total logical procedure cache max memory total logical procedure cache
memory size memory size
Memory Used (KB) 81920 56716 14822 Memory Used (KB) 81920 56716 14822
Pages Used (2 KB) 40960 28358 7000 Pages Used (2 KB) 40960 28358 7000
Based on the current memory used for “max memory” and “total Based on the current memory used for “max memory” and “total
logical memory”, is there room to increase configuration parameters logical memory”, is there room to increase configuration parameters
that use memory without increasing “max memory”? that use memory without increasing “max memory”?
Yes. There is just over 25 MB available in the logical Yes. There is just over 25 MB available in the logical
memory allocation - the difference between “max memory” memory allocation - the difference between “max memory”
(81920 KB) and “total logical memory” (56716 KB). (81920 KB) and “total logical memory” (56716 KB).
2. Analyze the impact of changing memory-related ASE configuration parameters on the 2. Analyze the impact of changing memory-related ASE configuration parameters on the
sizes of the data and procedure caches. sizes of the data and procedure caches.
a. Verify that the configuration parameter “number of user connections” is running a. Verify that the configuration parameter “number of user connections” is running
with its default value of 25. with its default value of 25.
Parameter Name Default Memory Used Config Value Run Parameter Name Default Memory Used Config Value Run
Value Unit Type Value Unit Type
------------------------------ ----------- ----------- ------------ ----- ------------------------------ ----------- ----------- ------------ -----
------- -------------------- ---------- ------- -------------------- ----------
number of user connections 25 4804 25 number of user connections 25 4804 25
25 number dynamic 25 number dynamic
b. Increase the “number of user connections” to 50. b. Increase the “number of user connections” to 50.
sp_configure "number of user connections", 50 sp_configure "number of user connections", 50
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 5 - 3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 5 - 3
Parameter Name Default Memory Used Config Value Run Parameter Name Default Memory Used Config Value Run
Value Unit Type Value Unit Type
------------------------------ ----------- ----------- ------------ ----- ------------------------------ ----------- ----------- ------------ -----
------- -------------------- ---------- ------- -------------------- ----------
number of user connections 25 9480 50 number of user connections 25 9480 50
50 number dynamic 50 number dynamic
Changing the value of the “number of user connections” to 50 Changing the value of the “number of user connections” to 50
increases the amount of memory ASE uses by how much? increases the amount of memory ASE uses by how much?
5552 KB 5552 KB
Does the server need to be rebooted for a change to this memory- Does the server need to be rebooted for a change to this memory-
related parameter to take effect? Explain. related parameter to take effect? Explain.
No. Even though this parameter consumes memory, it is No. Even though this parameter consumes memory, it is
dynamic and the server does not need to be rebooted. The dynamic and the server does not need to be rebooted. The
additional logical memory is grabbed from the “max additional logical memory is grabbed from the “max
memory”. memory”.
c. Examine the following ASE configuration parameters again by using c. Examine the following ASE configuration parameters again by using
sp_configure and fill in the following chart: sp_configure and fill in the following chart:
"max memory" "max memory"
"logical memory" "logical memory"
"procedure cache" "procedure cache"
Parameter Name Default Memory Used Config Value Run Parameter Name Default Memory Used Config Value Run
Value Unit Type Value Unit Type
------------------------------ ----------- ----------- ------------ ----- ------------------------------ ----------- ----------- ------------ -----
------- -------------------- ---------- ------- -------------------- ----------
max memory 40960 81920 40960 max memory 40960 81920 40960
40960 memory pages(2k) dynamic 40960 memory pages(2k) dynamic
Lab Solution 5 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 5 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 5: Configuring Memory Module 5: Configuring Memory
procedure cache size 7000 14822 7000 procedure cache size 7000 14822 7000
7000 memory pages(2k) dynamic 7000 memory pages(2k) dynamic
max memory total logical procedure cache max memory total logical procedure cache
memory size memory size
Memory Used (KB) 81920 62378 14822 Memory Used (KB) 81920 62378 14822
Has the memory model changed from the values you recorded in Has the memory model changed from the values you recorded in
step 1b? step 1b?
Some values stayed the same: “max memory” and Some values stayed the same: “max memory” and
“procedure cache size”. But notice that the “total logical “procedure cache size”. But notice that the “total logical
memory” increased by 5662 KB, as expected from increasing memory” increased by 5662 KB, as expected from increasing
the “number of user connections”. the “number of user connections”.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 5 - 5 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 5 - 5
Task 2: Estimating the Amount of Memory Needed for Task 2: Estimating the Amount of Memory Needed for
Procedure Cache Procedure Cache
Description In this task, you will estimate the amount of memory needed for procedure cache and you Description In this task, you will estimate the amount of memory needed for procedure cache and you
will determine whether the procedure cache is currently under- or over sized according to will determine whether the procedure cache is currently under- or over sized according to
your calculation. your calculation.
Procedure 1. Estimate the amount of memory needed for procedure cache by obtaining the average Procedure 1. Estimate the amount of memory needed for procedure cache by obtaining the average
plan size for the largest database in the system. plan size for the largest database in the system.
Make the assumption that the largest number of concurrent users is Make the assumption that the largest number of concurrent users is
125. 125.
Because we do not have any large production databases we will use Because we do not have any large production databases we will use
the sybsystemprocs database to perform the calculation. the sybsystemprocs database to perform the calculation.
In a productive system you will have databases that are more In a productive system you will have databases that are more
appropriate for these calculations. appropriate for these calculations.
Calculate the average plan size for the largest database. Calculate the average plan size for the largest database.
The required procedure cache size will be estimated as (the largest The required procedure cache size will be estimated as (the largest
number of concurrent users) times (the average plan size) times a number of concurrent users) times (the average plan size) times a
factor of 1.25. factor of 1.25.
a. Determine the average plan size of the sybsystemprocs database. a. Determine the average plan size of the sybsystemprocs database.
size_in_2K_pages size_in_2K_pages
---------------- ----------------
17 17
b. Calculate the required procedure cache size as the number of concurrent users b. Calculate the required procedure cache size as the number of concurrent users
times the total of the average plan sizes times a factor of 1.25: times the total of the average plan sizes times a factor of 1.25:
Estimated procedure cache size (in 2KB pages) Estimated procedure cache size (in 2KB pages)
= (number of concurrent users) * (average plan size) * 1.25 = (number of concurrent users) * (average plan size) * 1.25
= ( 125 ) * ( 17 ) * 1.25 = ( 125 ) * ( 17 ) * 1.25
= 2656.25 = 2656.25
= 2657 (Rounded up) = 2657 (Rounded up)
Lab Solution 5 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 5 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 5: Configuring Memory Module 5: Configuring Memory
Is the procedure cache currently under- or oversized according to Is the procedure cache currently under- or oversized according to
your calculation? (Hint: refer to the values you recorded in step 1b.) your calculation? (Hint: refer to the values you recorded in step 1b.)
The procedure cache has a current run value of 7000 (2KB) The procedure cache has a current run value of 7000 (2KB)
pages. Therefore, according to the calculated requirement of pages. Therefore, according to the calculated requirement of
2657 pages, the current run value for the procedure cache is 2657 pages, the current run value for the procedure cache is
oversize and adequate for our needs. oversize and adequate for our needs.
2. The procedure cache size is running at the default and minimum for the server and so 2. The procedure cache size is running at the default and minimum for the server and so
does not need to be changed based on our calculation,. The command to re-configure does not need to be changed based on our calculation,. The command to re-configure
Adaptive Server for the required procedure cache size, if necessary, is given here. Adaptive Server for the required procedure cache size, if necessary, is given here.
sp_configure "procedure cache size", <required number of pages> sp_configure "procedure cache size", <required number of pages>
3. You can now exit all client sessions with Adaptive Server. 3. You can now exit all client sessions with Adaptive Server.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 5 - 7 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 5 - 7
Lab Solution 5 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 5 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 6: Initializing and Using Devices Module 6: Initializing and Using Devices
Module 6: Initializing and Using Devices Module 6: Initializing and Using Devices
Lab 6: Initializing and Using Devices Lab 6: Initializing and Using Devices
Lab setup You will be using your 2K page size Adaptive Server for this lab. There is no additional Lab setup You will be using your 2K page size Adaptive Server for this lab. There is no additional
setup for this lab. setup for this lab.
Objectives After completing this lab, you should be able to: Objectives After completing this lab, you should be able to:
Create data devices Create data devices
Implement device mirroring Implement device mirroring
Move a database device from one physical file to another by using disk mirroring Move a database device from one physical file to another by using disk mirroring
commands commands
Description In this lab, you will learn how to create data devices and how to implement device Description In this lab, you will learn how to create data devices and how to implement device
mirroring and you will also learn how to Move a database device from one physical file to mirroring and you will also learn how to Move a database device from one physical file to
another by using disk mirroring commands. another by using disk mirroring commands.
Task outline 1. Creating New Database Devices Task outline 1. Creating New Database Devices
2. Implementing Mirroring for a Database Device 2. Implementing Mirroring for a Database Device
3. Analyzing Mirroring Requirements 3. Analyzing Mirroring Requirements
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 6 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 6 - 1
Task 1: Creating New Database Devices Task 1: Creating New Database Devices
Description In this task, you will create new database devices. Description In this task, you will create new database devices.
Procedure Procedure
For all labs, you should open two windows (“A” and “B”). Unless For all labs, you should open two windows (“A” and “B”). Unless
instructed otherwise, perform all lab exercises in Window A. instructed otherwise, perform all lab exercises in Window A.
You use Window B primarily as a console for starting up Adaptive You use Window B primarily as a console for starting up Adaptive
Server and executing OS commands. All Adaptive Server system Server and executing OS commands. All Adaptive Server system
messages are displayed there instead of in your active ASE client messages are displayed there instead of in your active ASE client
window. window.
1. Given the following specifications for initializing a new database device, fill in the 1. Given the following specifications for initializing a new database device, fill in the
following diagram. following diagram.
• The device is for your 2K page size ASE, $DSQUERY • The device is for your 2K page size ASE, $DSQUERY
• The logical name of the database device is data_dev • The logical name of the database device is data_dev
• The physical path and file name associated with the new device • The physical path and file name associated with the new device
is in the form: is in the form:
$SYBASE/devices/data_dev.dat $SYBASE/devices/data_dev.dat
• The device size is to be 4 MB • The device size is to be 4 MB
Lab Solution 6 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 6 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 6: Initializing and Using Devices Module 6: Initializing and Using Devices
2. Initialize a new database device for your 2K page size Adaptive Server. 2. Initialize a new database device for your 2K page size Adaptive Server.
a. In Window B, change the directory to $HOME/sa. a. In Window B, change the directory to $HOME/sa.
cd $HOME/sa cd $HOME/sa
b. Write a T-SQL script file named data_dev.sql that contains the command to b. Write a T-SQL script file named data_dev.sql that contains the command to
initialize a database device named data_dev according to the specifications initialize a database device named data_dev according to the specifications
outlined in step 1. Specify the device size in MB. Remember to substitute your outlined in step 1. Specify the device size in MB. Remember to substitute your
specific path in place of the one given here. specific path in place of the one given here.
/* create the data_dev device */ /* create the data_dev device */
use master use master
go go
c. Create the new database device by executing the commands in the newly created c. Create the new database device by executing the commands in the newly created
T-SQL script data_dev.sql. T-SQL script data_dev.sql.
3. Examine the characteristics of the devices available in your Adaptive Server. 3. Examine the characteristics of the devices available in your Adaptive Server.
a. In Window A, connect to Adaptive Server as the sa. a. In Window A, connect to Adaptive Server as the sa.
b. Verify that the new device, data_dev, was created by using sp_helpdevice. b. Verify that the new device, data_dev, was created by using sp_helpdevice.
sp_helpdevice data_dev sp_helpdevice data_dev
c. Examine the contents of the sysdevices table, by using a select statement. c. Examine the contents of the sysdevices table, by using a select statement.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 6 - 3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 6 - 3
select name, status, phyname from sysdevices select name, status, phyname from sysdevices
tapedump1 16 tapedump1 16
/dev/nst0 /dev/nst0
tapedump2 16 tapedump2 16
/dev/nst1 /dev/nst1
The master device default device status is on when a server is built The master device default device status is on when a server is built
and should be turned off if the server is to be used as a production and should be turned off if the server is to be used as a production
server. server.
The master device likely shows a status of 3 indicating that it is a The master device likely shows a status of 3 indicating that it is a
default device. Turn off the default status with following command: default device. Turn off the default status with following command:
Now look again at the status of each device by Now look again at the status of each device by
running the previous select statement to look at the running the previous select statement to look at the
status codes for the devices. status codes for the devices.
d. Use the following reference table, which explains each bit in the status column, to d. Use the following reference table, which explains each bit in the status column, to
answer the questions that follow: answer the questions that follow:
Lab Solution 6 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 6 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 6: Initializing and Using Devices Module 6: Initializing and Using Devices
Based on the status column output of the previous query, which Based on the status column output of the previous query, which
devices, if any, are default devices? devices, if any, are default devices?
There are no default devices present once the master device There are no default devices present once the master device
has been changed has been changed
What are the characteristics of the master device? What are the characteristics of the master device?
The master device now has a status of 2, making it simply a The master device now has a status of 2, making it simply a
physical disk physical disk
What are the characteristics of the data_dev device? What are the characteristics of the data_dev device?
The data_dev device has a status of 16386, indicating that it is The data_dev device has a status of 16386, indicating that it is
a physical disk and dsync is on. a physical disk and dsync is on.
4. Make a new database device a default device. 4. Make a new database device a default device.
a. In Window A, as the sa connected to Adaptive Server, drop the new device a. In Window A, as the sa connected to Adaptive Server, drop the new device
data_dev by using the sp_dropdevice command. data_dev by using the sp_dropdevice command.
Strictly speaking, you do not have to drop a device to change its Strictly speaking, you do not have to drop a device to change its
default status. You are dropping the device for two demonstration default status. You are dropping the device for two demonstration
purposes: purposes:
1. Understand the mechanics of dropping a device at both the ASE 1. Understand the mechanics of dropping a device at both the ASE
and the OS levels. and the OS levels.
2. Ultimately, you want to modify the T-SQL script used to initialize 2. Ultimately, you want to modify the T-SQL script used to initialize
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 6 - 5 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 6 - 5
the device to also turn the default status on right after the disk init the device to also turn the default status on right after the disk init
command. command.
cd $SYBASE/$SYBASE_ASE/devices cd $SYBASE/$SYBASE_ASE/devices
rm data_dev.dat rm data_dev.dat
c. Continuing in Window B, change the directory back to $HOME/sa and modify the c. Continuing in Window B, change the directory back to $HOME/sa and modify the
T-SQL script file named data_dev.sql to initialize a database device named T-SQL script file named data_dev.sql to initialize a database device named
data_dev, making it a default device. data_dev, making it a default device.
/* create the data_dev device */ /* create the data_dev device */
use master use master
go go
d. Create the new, default database device by executing the commands in the newly d. Create the new, default database device by executing the commands in the newly
created T-SQL script data_dev.sql. created T-SQL script data_dev.sql.
e. In Window A, as the sa connected to Adaptive Server, verify that the new device, e. In Window A, as the sa connected to Adaptive Server, verify that the new device,
data_dev, was created as a default device by using sp_helpdevice. data_dev, was created as a default device by using sp_helpdevice.
Lab Solution 6 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 6 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 6: Initializing and Using Devices Module 6: Initializing and Using Devices
5. Given the following specifications for initializing a new database device, fill in the 5. Given the following specifications for initializing a new database device, fill in the
following diagram. following diagram.
• The device is for your 2K page size ASE, $DSQUERY • The device is for your 2K page size ASE, $DSQUERY
• The logical name of the database device is log_dev • The logical name of the database device is log_dev
• The physical path and file name associated with the new device • The physical path and file name associated with the new device
is in the form: is in the form:
$SYBASE/devices/log_dev.dat $SYBASE/devices/log_dev.dat
• The device size is to be 2 MB • The device size is to be 2 MB
• Do not make the device a default device • Do not make the device a default device
6. Initialize a new database device for your 2K page size Adaptive Server. 6. Initialize a new database device for your 2K page size Adaptive Server.
a. In Window B, write a new T-SQL script file named log_dev.sql that contains the a. In Window B, write a new T-SQL script file named log_dev.sql that contains the
command to initialize a database device named log_dev according to the command to initialize a database device named log_dev according to the
specifications outlined in step 5. Specify the device size in 2K pages. Remember specifications outlined in step 5. Specify the device size in 2K pages. Remember
to substitute your specific path in place of the one given here. to substitute your specific path in place of the one given here.
/* create the log_dev device */ /* create the log_dev device */
use master use master
go go
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 6 - 7 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 6 - 7
b. Create the new database device by executing the commands in the newly created b. Create the new database device by executing the commands in the newly created
T-SQL script log_dev.sql. T-SQL script log_dev.sql.
c. In Window A, verify the successful creation of the device named log_dev by using c. In Window A, verify the successful creation of the device named log_dev by using
sp_helpdevice. sp_helpdevice.
sp_helpdevice log_dev sp_helpdevice log_dev
7. (Optional) Write queries to examine all the logical and physical device names for the 7. (Optional) Write queries to examine all the logical and physical device names for the
server. server.
a. In Window A, as the sa connected to Adaptive Server, retrieve all the logical and a. In Window A, as the sa connected to Adaptive Server, retrieve all the logical and
physical device names by running sp_helpdevice. physical device names by running sp_helpdevice.
sp_helpdevice sp_helpdevice
Lab Solution 6 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 6 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 6: Initializing and Using Devices Module 6: Initializing and Using Devices
b. Write a query against sysdevices that retrieves only the logical and physical device b. Write a query against sysdevices that retrieves only the logical and physical device
names for the server. names for the server.
select name, phyname from sysdevices select name, phyname from sysdevices
c. Write a query against sysdevices that retrieves only logical and physical database c. Write a query against sysdevices that retrieves only logical and physical database
device names (exclude tape dump devices) for the server. device names (exclude tape dump devices) for the server.
select name, phyname from sysdevices select name, phyname from sysdevices
where cntrltype = 0 where cntrltype = 0
Task 2: Implementing Mirroring for a Database Device Task 2: Implementing Mirroring for a Database Device
Description In this task, you will implement mirroring for a database device. Description In this task, you will implement mirroring for a database device.
Procedure Procedure
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 6 - 9 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 6 - 9
In this section of the lab, you gain experience setting up, mirroring, In this section of the lab, you gain experience setting up, mirroring,
and interpreting the output from system stored procedures as well as and interpreting the output from system stored procedures as well as
from direct queries of system tables. With this experience, you will from direct queries of system tables. With this experience, you will
be able to quickly set up a database device mirror if needed, and to be able to quickly set up a database device mirror if needed, and to
assess the status of all devices in your environment. assess the status of all devices in your environment.
With ASE 15.0, the configuration parameter “disable disk mirroring” With ASE 15.0, the configuration parameter “disable disk mirroring”
is a static parameter and the default is “disabled” Therefore, the is a static parameter and the default is “disabled” Therefore, the
parameter will need to be changed and the server must be re-booted parameter will need to be changed and the server must be re-booted
to have the configuration set to allow disk mirroring. to have the configuration set to allow disk mirroring.
1. In Window A, as the sa connected to ASE, configure the server to allow disk mirroring 1. In Window A, as the sa connected to ASE, configure the server to allow disk mirroring
by changing the default value of “disable disk mirroring” from 1 to 0. by changing the default value of “disable disk mirroring” from 1 to 0.
sp_configure ‘disable disk mirroring’, 0 sp_configure ‘disable disk mirroring’, 0
Parameter Name Default Memory Used Config Value Run Parameter Name Default Memory Used Config Value Run
Value Unit Type Value Unit Type
------------------------------ ----------- ----------- ------------ ------ ------------------------------ ----------- ----------- ------------ ------
------ -------------------- ---------- ------ -------------------- ----------
disable disk mirroring 1 0 0 disable disk mirroring 1 0 0
1 switch static 1 switch static
a. Shutdown the Adaptive Server with the following command. a. Shutdown the Adaptive Server with the following command.
shutdown shutdown
go go
b. In Window B, cd to $SYBASE/$SYBASE_ASE/install and re-start the server b. In Window B, cd to $SYBASE/$SYBASE_ASE/install and re-start the server
with the following command with the following command
startserver –f RUN_$DSQUERY startserver –f RUN_$DSQUERY
Lab Solution 6 - 10 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 6 - 10 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 6: Initializing and Using Devices Module 6: Initializing and Using Devices
2. In Window A, as the sa connected to Adaptive Server, display the details about the 2. In Window A, as the sa connected to Adaptive Server, display the details about the
newly created device, log_dev, by using sp_helpdevice. newly created device, log_dev, by using sp_helpdevice.
sp_helpdevice log_dev sp_helpdevice log_dev
3. Review the mirroring requirements for the device log_dev from the following 3. Review the mirroring requirements for the device log_dev from the following
specifications and then complete the following diagram: specifications and then complete the following diagram:
• The physical path and file name associated with the mirror • The physical path and file name associated with the mirror
device is in the form: device is in the form:
$SYBASE/devices/log_dev.mir $SYBASE/devices/log_dev.mir
Note: For this lab environment you are placing the device mirror file Note: For this lab environment you are placing the device mirror file
on the same physical disk as the device file itself. In a production on the same physical disk as the device file itself. In a production
system you would normally place the mirror file on a separate disk. system you would normally place the mirror file on a separate disk.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 6 - 11 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 6 - 11
4. Mirror the log device log_dev. 4. Mirror the log device log_dev.
a. In Window A, as the sa connected to Adaptive Server, mirror the log device a. In Window A, as the sa connected to Adaptive Server, mirror the log device
log_dev by following the requirements outlined in step 2 and issuing the disk log_dev by following the requirements outlined in step 2 and issuing the disk
mirror command. Be sure to change the path to your home directory path. mirror command. Be sure to change the path to your home directory path.
disk mirror disk mirror
name = "log_dev", name = "log_dev",
mirror = "/home/usr/u/dub101/devices/log_dev.mir" mirror = "/home/usr/u/dub101/devices/log_dev.mir"
Creating the physical file for the mirror... Creating the physical file for the mirror...
Starting Dynamic Mirroring of 1024 pages for logical device 'log_dev'. Starting Dynamic Mirroring of 1024 pages for logical device 'log_dev'.
The remaining 1024 pages are currently unallocated and will be mirrored as The remaining 1024 pages are currently unallocated and will be mirrored as
they are allocated. they are allocated.
b. Verify that mirroring was successful by using sp_helpdevice. b. Verify that mirroring was successful by using sp_helpdevice.
sp_helpdevice log_dev sp_helpdevice log_dev
Lab Solution 6 - 12 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 6 - 12 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 6: Initializing and Using Devices Module 6: Initializing and Using Devices
c. Use the following reference table, which explains each bit in the status column, to c. Use the following reference table, which explains each bit in the status column, to
answer the questions that follow: answer the questions that follow:
Describe the attributes of the device based on the status value. Describe the attributes of the device based on the status value.
The value of the status field indicates 17122, which is the sum The value of the status field indicates 17122, which is the sum
of the following bits: of the following bits:
2 = physical disk 2 = physical disk
32 = serial writes 32 = serial writes
64 = device enabled 64 = device enabled
128 = reads enabled 128 = reads enabled
512 = mirror enabled 512 = mirror enabled
16384 = dsync on 16384 = dsync on
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 6 - 13 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 6 - 13
At this point, you have experience with setting up a device mirror and assessing the At this point, you have experience with setting up a device mirror and assessing the
status of devices in your environment. In this part of the lab, you will turn mirroring on status of devices in your environment. In this part of the lab, you will turn mirroring on
and off for the secondary side of the mirrored device. For a live system, if the secondary and off for the secondary side of the mirrored device. For a live system, if the secondary
side of the mirror fails, you can take it offline, replace it, and then remirror it to turn side of the mirror fails, you can take it offline, replace it, and then remirror it to turn
mirroring back on. mirroring back on.
5. Temporarily deactivate mirroring for a device. 5. Temporarily deactivate mirroring for a device.
a. In Window A, as the sa connected to Adaptive Server, deactivate the secondary a. In Window A, as the sa connected to Adaptive Server, deactivate the secondary
side of the mirror for the log_dev device by using the disk unmirror command. side of the mirror for the log_dev device by using the disk unmirror command.
b. Query the sysdevices table for the log_dev entry. b. Query the sysdevices table for the log_dev entry.
low high status cntrltype name low high status cntrltype name
phyname phyname
mirrorname mirrorname
vdevno crdate resizedate vdevno crdate resizedate
status2 status2
------------------------------------------------------------------- -------------------------------------------------------------------
0 1023 18658 0 log_dev 0 1023 18658 0 log_dev
/home/usr/u/dub101/devices/log_dev.dat /home/usr/u/dub101/devices/log_dev.dat
/home/usr/u/dub101/devices/log_dev.mir /home/usr/u/dub101/devices/log_dev.mir
4 Oct 3 2005 9:06AM NULL 4 Oct 3 2005 9:06AM NULL
0 0
Describe the attributes of the device based on the status value. Describe the attributes of the device based on the status value.
Note that the status bits total 18658, which is the sum of the Note that the status bits total 18658, which is the sum of the
following bits: following bits:
2 = physical disk 2 = physical disk
32 = serial writes 32 = serial writes
64 = device enabled 64 = device enabled
128 = reads enabled 128 = reads enabled
2048 = primary mirror side only 2048 = primary mirror side only
16384 = dsync on 16384 = dsync on
c. Reactivate the secondary side of the mirror for log_dev by issuing the disk c. Reactivate the secondary side of the mirror for log_dev by issuing the disk
Lab Solution 6 - 14 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 6 - 14 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 6: Initializing and Using Devices Module 6: Initializing and Using Devices
Starting Dynamic Mirroring of 1024 pages for logical device 'log_dev'. Starting Dynamic Mirroring of 1024 pages for logical device 'log_dev'.
The remaining 1024 pages are currently unallocated and will be mirrored as The remaining 1024 pages are currently unallocated and will be mirrored as
they are allocated. they are allocated.
d. Query the sysdevices table, again, for the log_dev entry only this time just get the d. Query the sysdevices table, again, for the log_dev entry only this time just get the
status.. status..
status status
------ ------
17122 17122
Describe the attributes of the device based on the status value. Describe the attributes of the device based on the status value.
Note that the status bit has reverted back to 17122 (as when Note that the status bit has reverted back to 17122 (as when
the disk mirror command was issued in step 3). the disk mirror command was issued in step 3).
2 = physical disk 2 = physical disk
32 = serial writes 32 = serial writes
64 = device enabled 64 = device enabled
128 = reads enabled 128 = reads enabled
512 = mirror enabled 512 = mirror enabled
16384 = dsync on 16384 = dsync on
Now turn mirroring on and off for the primary side of the mirror. For a live system, if Now turn mirroring on and off for the primary side of the mirror. For a live system, if
the primary side has failed over to the secondary side of the mirror, it will need to be the primary side has failed over to the secondary side of the mirror, it will need to be
taken offline, replaced, and then re-mirrored to turn mirroring back on. taken offline, replaced, and then re-mirrored to turn mirroring back on.
6. Temporarily deactivate mirroring for the primary side of a device. 6. Temporarily deactivate mirroring for the primary side of a device.
a. Deactivate mirroring for the primary side of device log_dev by issuing the disk a. Deactivate mirroring for the primary side of device log_dev by issuing the disk
unmirror command. unmirror command.
disk unmirror name = "log_dev", side = "primary" disk unmirror name = "log_dev", side = "primary"
b. Query the sysdevices table for the log_dev status entry again. b. Query the sysdevices table for the log_dev status entry again.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 6 - 15 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 6 - 15
Describe the attributes of the device based on the status value. Describe the attributes of the device based on the status value.
Now the status bits total 16866: Now the status bits total 16866:
2 = physical disk 2 = physical disk
32 = serial writes 32 = serial writes
64 = device enabled 64 = device enabled
128 = reads enabled 128 = reads enabled
256 = secondary side mirror only 256 = secondary side mirror only
16384 = dsync on 16384 = dsync on
c. Reactivate the primary side of the mirror for log_dev by issuing the disk remirror c. Reactivate the primary side of the mirror for log_dev by issuing the disk remirror
command. command.
Starting Dynamic Mirroring of 1024 pages for logical device Starting Dynamic Mirroring of 1024 pages for logical device
'log_dev'. 'log_dev'.
The remaining 1024 pages are currently unallocated and will be The remaining 1024 pages are currently unallocated and will be
mirrored as they are allocated. mirrored as they are allocated.
d. Query the sysdevices table for the log_dev entry. d. Query the sysdevices table for the log_dev entry.
status status
------ ------
17122 17122
(1 row affected) (1 row affected)
Describe the attributes of the device based on the status value. Describe the attributes of the device based on the status value.
Note that the status has reverted back to 17122 (as when the Note that the status has reverted back to 17122 (as when the
disk mirror command was first issued in step 3). disk mirror command was first issued in step 3).
2 = physical disk 2 = physical disk
32 = serial writes 32 = serial writes
64 = device enabled 64 = device enabled
128 = reads enabled 128 = reads enabled
512 = mirror enabled 512 = mirror enabled
16384 = dsync on 16384 = dsync on
So far you have temporarily turned mirroring on and off for both the primary and So far you have temporarily turned mirroring on and off for both the primary and
secondary sides of the mirror. Now permanently disable the primary side of the mirror. secondary sides of the mirror. Now permanently disable the primary side of the mirror.
7. Permanently disable the primary side of a device mirror. 7. Permanently disable the primary side of a device mirror.
a. Permanently disable the primary side of the mirror for the log_dev device. a. Permanently disable the primary side of the mirror for the log_dev device.
Lab Solution 6 - 16 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 6 - 16 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 6: Initializing and Using Devices Module 6: Initializing and Using Devices
b. Query the sysdevices table for the log_dev entry. b. Query the sysdevices table for the log_dev entry.
status status
------ ------
16386 16386
Describe the attributes of the device based on the status value. Describe the attributes of the device based on the status value.
Note that the status bits total now 16386 (as when the disk Note that the status bits total now 16386 (as when the disk
init command was originally issued in Section A, step 2). init command was originally issued in Section A, step 2).
2 = physical disk 2 = physical disk
16384 = dsync on 16384 = dsync on
The device log_dev is now unmirrored. What is the name of the The device log_dev is now unmirrored. What is the name of the
physical device file, log_dev.dat or log_dev.mir? physical device file, log_dev.dat or log_dev.mir?
The full path of the physical device file is: The full path of the physical device file is:
/home/usr/u/dub101/devices/log_dev.mir. /home/usr/u/dub101/devices/log_dev.mir.
(.mir NOT .dat) (.mir NOT .dat)
In effect, what have you actually done to the original device that was In effect, what have you actually done to the original device that was
initialized in Section A, step 2. initialized in Section A, step 2.
In effect you have moved the logical device named log_dev In effect you have moved the logical device named log_dev
completely off a physical file named log_dev.dat and onto a completely off a physical file named log_dev.dat and onto a
physical file named log_dev.mir. physical file named log_dev.mir.
c. In Window B, remove the physical device (primary side) file. c. In Window B, remove the physical device (primary side) file.
Remember, the .mir file is now the active physical device file so Remember, the .mir file is now the active physical device file so
make sure you remove the .dat file !!!!! make sure you remove the .dat file !!!!!
cd $SYBASE/devices cd $SYBASE/devices
rm log_dev.dat rm log_dev.dat
8. Exit all client sessions with Adaptive Server. 8. Exit all client sessions with Adaptive Server.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 6 - 17 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 6 - 17
Description In this task, you will analyze mirroring requirements as a paper and pencil activity. Description In this task, you will analyze mirroring requirements as a paper and pencil activity.
Procedure Now that you have experience turning mirroring on and off and moving devices by using Procedure Now that you have experience turning mirroring on and off and moving devices by using
disk mirroring commands, take a few minutes to consider what devices should or should disk mirroring commands, take a few minutes to consider what devices should or should
not be mirrored. not be mirrored.
1. Given that your production environment has limited disk resource constraints, you can 1. Given that your production environment has limited disk resource constraints, you can
mirror only three of the devices listed below. Which would you choose to mirror? mirror only three of the devices listed below. Which would you choose to mirror?
A_dev The master device A_dev The master device
B_dev Contains tempdb B_dev Contains tempdb
C_dev Contains data from frequently updated database1 C_dev Contains data from frequently updated database1
D_dev Contains log from frequently updated database1 D_dev Contains log from frequently updated database1
E_dev Contains data from frequently updated database2 E_dev Contains data from frequently updated database2
F_dev Contains log from frequently updated database2 F_dev Contains log from frequently updated database2
You would probably want to mirror the following devices: You would probably want to mirror the following devices:
A_dev (master device) A_dev (master device)
D_dev (log device) D_dev (log device)
F_dev (log device) F_dev (log device)
This allows for continuous uptime of the server in the event that the master This allows for continuous uptime of the server in the event that the master
device crashes and continuous uptime and recoverability of the user databases if device crashes and continuous uptime and recoverability of the user databases if
either side of the log device mirrors becomes disabled. For further detail, see the either side of the log device mirrors becomes disabled. For further detail, see the
“Backup” module. “Backup” module.
2. In the previous example, what if C_dev and D_dev were used for a “read-only” 2. In the previous example, what if C_dev and D_dev were used for a “read-only”
database? Would your answer change? database? Would your answer change?
In this case, you would probably want to mirror the following devices: In this case, you would probably want to mirror the following devices:
A_dev (master device) , E_dev (data device) , F_dev (log device) A_dev (master device) , E_dev (data device) , F_dev (log device)
In this scenario, the master device is still protected; continuous uptime and In this scenario, the master device is still protected; continuous uptime and
recoverability of the frequently updated database is enhanced. Recoverability for recoverability of the frequently updated database is enhanced. Recoverability for
the “read-only” database is not an issue because the database is not being the “read-only” database is not an issue because the database is not being
modified, but continuous uptime is compromised if one of its database devices modified, but continuous uptime is compromised if one of its database devices
fails. fails.
3. Consider your own production environment. Which devices will you choose to mirror? 3. Consider your own production environment. Which devices will you choose to mirror?
Lab Solution 6 - 18 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 6 - 18 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 7: Creating and Using Databases Module 7: Creating and Using Databases
Module 7: Creating and Using Databases Module 7: Creating and Using Databases
Lab 7: Creating and Using Databases Lab 7: Creating and Using Databases
Lab setup You will be using your 2K and 8K page size Adaptive Servers for this lab. Lab setup You will be using your 2K and 8K page size Adaptive Servers for this lab.
Note: You need to have completed Lab 6: Devices in which you created two database Note: You need to have completed Lab 6: Devices in which you created two database
devices, data_dev and log_dev on the 2K server. If you did not finish that lab or did not devices, data_dev and log_dev on the 2K server. If you did not finish that lab or did not
create the two devices, then create the devices now on your 2K page size Adaptive Server create the two devices, then create the devices now on your 2K page size Adaptive Server
by using the following two commands (substituting $SYBASE/ appropriately): NOTE: The by using the following two commands (substituting $SYBASE/ appropriately): NOTE: The
extension of the log_dev is mir and it needs to be that due to actions in lab 6. extension of the log_dev is mir and it needs to be that due to actions in lab 6.
Objectives After completing this lab, you should be able to: Objectives After completing this lab, you should be able to:
Create a database Create a database
Turn database options on and off Turn database options on and off
Understand table space requirements between Adaptive Servers that use different Understand table space requirements between Adaptive Servers that use different
logical page sizes logical page sizes
Write queries that return useful database diagnostics Write queries that return useful database diagnostics
Description In this lab, you will learn how to create a database, turn database options on and off, and Description In this lab, you will learn how to create a database, turn database options on and off, and
also how to write queries that return useful database diagnostics. also how to write queries that return useful database diagnostics.
Task outline 1. Creating a 6MB database, separating the data from the log, verifying, and also turning Task outline 1. Creating a 6MB database, separating the data from the log, verifying, and also turning
the dbo use only option on/off for the database the dbo use only option on/off for the database
2. Analyzing table space requirements between a 2K and 8K AS 2. Analyzing table space requirements between a 2K and 8K AS
3. Writing queries ising sysdevices, sysusages and sysdatabases 3. Writing queries ising sysdevices, sysusages and sysdatabases
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 7 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 7 - 1
Description In this task, you will create a 6MB database, separating the data from the log, verifying and Description In this task, you will create a 6MB database, separating the data from the log, verifying and
also turning the dbo use only option on/off for the database. also turning the dbo use only option on/off for the database.
Procedure In a previous lab you created two database devices named data_dev and log_dev. The Procedure In a previous lab you created two database devices named data_dev and log_dev. The
device sizes are 4 MB and 2 MB, respectively. If you did not create the two devices, please device sizes are 4 MB and 2 MB, respectively. If you did not create the two devices, please
refer to the Lab Setup in the Exercise Overview for this lab for instructions about creating refer to the Lab Setup in the Exercise Overview for this lab for instructions about creating
the devices. the devices.
In this lab you create a 6 MB database named my_db striped across these two devices. The In this lab you create a 6 MB database named my_db striped across these two devices. The
data portion (4 MB) of the database will be separated from the log (2 MB) as the following data portion (4 MB) of the database will be separated from the log (2 MB) as the following
diagram demonstrates: diagram demonstrates:
For all labs, you should open two windows (“A” and “B”). Unless For all labs, you should open two windows (“A” and “B”). Unless
instructed otherwise, perform all lab exercises in Window A. instructed otherwise, perform all lab exercises in Window A.
You use Window B primarily as a console for starting up Adaptive You use Window B primarily as a console for starting up Adaptive
Server and executing OS commands. All Adaptive Server system Server and executing OS commands. All Adaptive Server system
messages are displayed there instead of in your active ASE client messages are displayed there instead of in your active ASE client
window. window.
Lab Solution 7 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 7 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 7: Creating and Using Databases Module 7: Creating and Using Databases
cd $HOME/sa cd $HOME/sa
b. Write a T-SQL script file named create_db.sql that contains the command to b. Write a T-SQL script file named create_db.sql that contains the command to
create the database with the following specifications: create the database with the following specifications:
c. Create the new database my_db on the 2K page size Adaptive Server by executing c. Create the new database my_db on the 2K page size Adaptive Server by executing
the command in the newly created T-SQL script create_db.sql. the command in the newly created T-SQL script create_db.sql.
isql -Usa -P -S $DSQUERY -i create_db.sql isql -Usa -P -S $DSQUERY -i create_db.sql
CREATE DATABASE: allocating 2048 logical pages (4.0 megabytes) on CREATE DATABASE: allocating 2048 logical pages (4.0 megabytes) on
disk 'data_dev'. disk 'data_dev'.
CREATE DATABASE: allocating 1024 logical pages (2.0 megabytes) on CREATE DATABASE: allocating 1024 logical pages (2.0 megabytes) on
disk 'log_dev'. disk 'log_dev'.
2. Examine the characteristics of the new database my_db. 2. Examine the characteristics of the new database my_db.
a. In Window A, connect to the 2K Adaptive Server as the sa. a. In Window A, connect to the 2K Adaptive Server as the sa.
isql -Usa -P isql -Usa -P
b. Verify that the new database was created by using sp_helpdb. b. Verify that the new database was created by using sp_helpdb.
sp_helpdb my_db sp_helpdb my_db
name db_size owner dbid created status name db_size owner dbid created status
----- ------------- ----- ------ ------------------ -------------- ----- ------------- ----- ------ ------------------ --------------
my_db 6.0 MB sa 5 Oct 04, 2005 no options set my_db 6.0 MB sa 5 Oct 04, 2005 no options set
-------------------------------------------------------------- --------------------------------------------------------------
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 7 - 3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 7 - 3
log only free kbytes = 2038 log only free kbytes = 2038
(return status = 0) (return status = 0)
Was the database created according to the specifications in step 1b? Was the database created according to the specifications in step 1b?
Explain. Explain.
Yes. The database is named my_db and is 6 MB in total size. Yes. The database is named my_db and is 6 MB in total size.
The data is separated from the log as follows: The data is separated from the log as follows:
The data portion is 4 MB and resides on the data_dev device. The data portion is 4 MB and resides on the data_dev device.
The log is 2 MB and resides on the log_dev device. The log is 2 MB and resides on the log_dev device.
Are any database options set? (Hint: examine the status column of Are any database options set? (Hint: examine the status column of
the sp_helpdb output.) the sp_helpdb output.)
No database options are currently set. No database options are currently set.
c. Query the sysdatabases table for the my_db entry. c. Query the sysdatabases table for the my_db entry.
select * from sysdatabases where name = "my_db" select * from sysdatabases where name = "my_db"
name dbid suid status version logptr name dbid suid status version logptr
crdate crdate
dumptrdate status2 audflags deftabaud dumptrdate status2 audflags deftabaud
defvwaud defpraud def_remote_type defvwaud defpraud def_remote_type
def_remote_loc def_remote_loc
status3 status4 audflags2 status3 status4 audflags2
------------------------------ ------ ----------- ------ ------- -- ------------------------------ ------ ----------- ------ ------- --
my_db 5 1 0 1 my_db 5 1 0 1
2051 Oct 4 2005 12:31PM 2051 Oct 4 2005 12:31PM
Oct 4 2005 12:31PM 0 0 0 Oct 4 2005 12:31PM 0 0 0
0 0 NULL 0 0 NULL
NULL NULL
131072 0 NULL 131072 0 NULL
b. Display all the database objects by using sp_help. b. Display all the database objects by using sp_help.
sp_help sp_help
Lab Solution 7 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 7 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 7: Creating and Using Databases Module 7: Creating and Using Databases
Jar_name Jar_name
-------- --------
c. Based on the output from sp_help, what objects other than system tables does the c. Based on the output from sp_help, what objects other than system tables does the
database contain? database contain?
The output shows that there is only one other object – a view called The output shows that there is only one other object – a view called
sysquerymetrics. sysquerymetrics.
d. How can you control which user objects a newly created database has? (Do not d. How can you control which user objects a newly created database has? (Do not
make any changes to your server!) make any changes to your server!)
Any objects existing in the model database (before creating a new database), Any objects existing in the model database (before creating a new database),
will result in those objects existing in subsequently created databases. will result in those objects existing in subsequently created databases.
4. Activate and then deactivate database options. 4. Activate and then deactivate database options.
a. Set the database option dbo use only for the my_db database. a. Set the database option dbo use only for the my_db database.
use master use master
sp_dboption my_db, "dbo use only", true sp_dboption my_db, "dbo use only", true
Database option 'dbo use only' turned ON for database 'my_db'. Database option 'dbo use only' turned ON for database 'my_db'.
Running CHECKPOINT on database 'my_db' for option 'dbo use only' to Running CHECKPOINT on database 'my_db' for option 'dbo use only' to
take effect. take effect.
(return status = 0) (return status = 0)
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 7 - 5 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 7 - 5
b. Verify that the database option was turned on by using sp_helpdb. b. Verify that the database option was turned on by using sp_helpdb.
sp_helpdb sp_helpdb
name db_size owner dbid created name db_size owner dbid created
status status
-------------- ------------- ----- ------ ------------------ -------------- ------------- ----- ------ ------------------
master 13.0 MB sa 1 Sep 30, 2005 master 13.0 MB sa 1 Sep 30, 2005
mixed log and data mixed log and data
model 3.0 MB sa 3 Sep 30, 2005 model 3.0 MB sa 3 Sep 30, 2005
mixed log and data mixed log and data
my_db 6.0 MB sa 5 Oct 04, 2005 my_db 6.0 MB sa 5 Oct 04, 2005
dbo use only dbo use only
pubs2 4.0 MB sa 4 Sep 30, 2005 pubs2 4.0 MB sa 4 Sep 30, 2005
trunc log on chkpt, mixed log and data trunc log on chkpt, mixed log and data
sybsystemdb 3.0 MB sa 31513 Sep 30, 2005 sybsystemdb 3.0 MB sa 31513 Sep 30, 2005
mixed log and data mixed log and data
sybsystemprocs 120.0 MB sa 31514 Sep 30, 2005 sybsystemprocs 120.0 MB sa 31514 Sep 30, 2005
trunc log on chkpt, mixed log and data trunc log on chkpt, mixed log and data
tempdb 4.0 MB sa 2 Oct 03, 2005 tempdb 4.0 MB sa 2 Oct 03, 2005
select into/bulkcopy/pllsort, trunc log on chkpt, mixed log and select into/bulkcopy/pllsort, trunc log on chkpt, mixed log and
data data
c. Turn off dbo use only for the my_db database. c. Turn off dbo use only for the my_db database.
use master use master
sp_dboption my_db, "dbo use only", false sp_dboption my_db, "dbo use only", false
Database option 'dbo use only' turned OFF for database 'my_db'. Database option 'dbo use only' turned OFF for database 'my_db'.
Running CHECKPOINT on database 'my_db' for option 'dbo use only' to Running CHECKPOINT on database 'my_db' for option 'dbo use only' to
take effect. take effect.
d. Verify that the database option was turned off by using sp_helpdb. d. Verify that the database option was turned off by using sp_helpdb.
sp_helpdb sp_helpdb
name db_size owner dbid created name db_size owner dbid created
status status
-------------- ------------- ----- ------ ------------------ -------------- ------------- ----- ------ ------------------
master 13.0 MB sa 1 Sep 30, 2005 master 13.0 MB sa 1 Sep 30, 2005
mixed log and data mixed log and data
model 3.0 MB sa 3 Sep 30, 2005 model 3.0 MB sa 3 Sep 30, 2005
mixed log and data mixed log and data
my_db 6.0 MB sa 5 Oct 04, 2005 my_db 6.0 MB sa 5 Oct 04, 2005
no options set no options set
pubs2 4.0 MB sa 4 Sep 30, 2005 pubs2 4.0 MB sa 4 Sep 30, 2005
trunc log on chkpt, mixed log and data trunc log on chkpt, mixed log and data
sybsystemdb 3.0 MB sa 31513 Sep 30, 2005 sybsystemdb 3.0 MB sa 31513 Sep 30, 2005
mixed log and data mixed log and data
sybsystemprocs 120.0 MB sa 31514 Sep 30, 2005 sybsystemprocs 120.0 MB sa 31514 Sep 30, 2005
trunc log on chkpt, mixed log and data trunc log on chkpt, mixed log and data
tempdb 4.0 MB sa 2 Oct 03, 2005 tempdb 4.0 MB sa 2 Oct 03, 2005
select into/bulkcopy/pllsort, trunc log on chkpt, mixed log and select into/bulkcopy/pllsort, trunc log on chkpt, mixed log and
data data
Lab Solution 7 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 7 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 7: Creating and Using Databases Module 7: Creating and Using Databases
Task 2: Analyzing table space requirements between a 2K and Task 2: Analyzing table space requirements between a 2K and
8K ASE 8K ASE
Description In this task, you will analyze table space requirements between a 2K and 8K ASE. Description In this task, you will analyze table space requirements between a 2K and 8K ASE.
Procedure Procedure
As of version 12.5 of ASE, you have to choose a page size for the As of version 12.5 of ASE, you have to choose a page size for the
server during installation. The choices are 2K, 4K 8K and 16K. 16K server during installation. The choices are 2K, 4K 8K and 16K. 16K
is usually too large a size to choose for the logical page size, as this is usually too large a size to choose for the logical page size, as this
entails a lot of additional overhead. Each table takes up at least 16K entails a lot of additional overhead. Each table takes up at least 16K
of disk space, even if it holds little information. When the last page of disk space, even if it holds little information. When the last page
of a table contains little information, close to 16K of space is unused of a table contains little information, close to 16K of space is unused
on that page. The initial size of the system tables for a newly created on that page. The initial size of the system tables for a newly created
database on a 16K server is also quite large: 9.4Mb. 16K can be the database on a 16K server is also quite large: 9.4Mb. 16K can be the
appropriate logical page size for the server, but only when very large appropriate logical page size for the server, but only when very large
rows and query results will be the norm. rows and query results will be the norm.
In this lab we will compare a 2K logical page size server and an 8K In this lab we will compare a 2K logical page size server and an 8K
logical page size server. An 8K choice will demonstrate the logical page size server. An 8K choice will demonstrate the
differences more readily than a choice of 4K. differences more readily than a choice of 4K.
1. Explore some of the characteristics of a 2K page size Adaptive Server. 1. Explore some of the characteristics of a 2K page size Adaptive Server.
a. Continuing in Window A as the sa connected to the 2K Adaptive Server, verify a. Continuing in Window A as the sa connected to the 2K Adaptive Server, verify
that this is indeed a 2K page size server by examining the Adaptive Server global that this is indeed a 2K page size server by examining the Adaptive Server global
variable @@maxpagesize. variable @@maxpagesize.
select @@maxpagesize select @@maxpagesize
----------- -----------
2048 2048
c. Execute sp_spaceused on the following tables in the model database and fill in the c. Execute sp_spaceused on the following tables in the model database and fill in the
chart that follows: chart that follows:
For the entire database For the entire database
sp_spaceused sp_spaceused
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 7 - 7 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 7 - 7
name rowtotal reserved data index_size unused name rowtotal reserved data index_size unused
---------- -------- -------- ---- ---------- ------ ---------- -------- -------- ---- ---------- ------
sysobjects 30 62 KB 4 KB 8 KB 50 KB sysobjects 30 62 KB 4 KB 8 KB 50 KB
name rowtotal reserved data index_size unused name rowtotal reserved data index_size unused
------------- -------- -------- ----- ---------- ------ ------------- -------- -------- ----- ---------- ------
sysprocedures 0 78 KB 38 KB 4 KB 36 KB sysprocedures 0 78 KB 38 KB 4 KB 36 KB
2K Server model database sysobjects sysprocedures 2K Server model database sysobjects sysprocedures
reserved (KB) 1688 KB 62 KB 78 KB reserved (KB) 1688 KB 62 KB 78 KB
data (KB) 160 KB 4 KB 38 KB data (KB) 160 KB 4 KB 38 KB
index_size (KB) 170 KB 8 KB 4 KB index_size (KB) 170 KB 8 KB 4 KB
2. End your client session with the 2K Adaptive Server. 2. End your client session with the 2K Adaptive Server.
exit exit
3. Explore similar characteristics of an 8K page size Adaptive Server. 3. Explore similar characteristics of an 8K page size Adaptive Server.
a. In Window B, start your 8K page size Adaptive Server by using the Sybase a. In Window B, start your 8K page size Adaptive Server by using the Sybase
startserver utility with the appropriate RUNSERVER file. startserver utility with the appropriate RUNSERVER file.
The Unix machines in Sybase Learning Centers have two ASE 15.0 The Unix machines in Sybase Learning Centers have two ASE 15.0
servers already installed for each student. The names of the servers servers already installed for each student. The names of the servers
for each student correspond to the respective Unix login name. For for each student correspond to the respective Unix login name. For
example if your Unix login is dub101, then your servers are named: example if your Unix login is dub101, then your servers are named:
DUB101_2K and DUB101_2K and
DUB101_8K. DUB101_8K.
The difference between the two servers is the page size used. The difference between the two servers is the page size used.
DUB101_2K uses a 2K page size while DUB101_8K uses an 8K DUB101_2K uses a 2K page size while DUB101_8K uses an 8K
page size. page size.
Lab Solution 7 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 7 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 7: Creating and Using Databases Module 7: Creating and Using Databases
In Sybase Learning Centers, the Unix environment variable In Sybase Learning Centers, the Unix environment variable
DSQUERY8 has been set up as a convenience to point to your 8K DSQUERY8 has been set up as a convenience to point to your 8K
Adaptive Server. Note that this is not a standard Sybase environment Adaptive Server. Note that this is not a standard Sybase environment
variable like DSQUERY. variable like DSQUERY.
cd $SYBASE/$SYBASE_ASE/install cd $SYBASE/$SYBASE_ASE/install
startserver -f RUN_$DSQUERY8 startserver -f RUN_$DSQUERY8
00:00000:00001:2005/10/04 13:16:01.21 server Recovery complete. 00:00000:00001:2005/10/04 13:16:01.21 server Recovery complete.
00:00000:00001:2005/10/04 13:16:01.21 server ASE's default unicode sort 00:00000:00001:2005/10/04 13:16:01.21 server ASE's default unicode sort
order is 'binary'. order is 'binary'.
00:00000:00001:2005/10/04 13:16:01.21 server ASE's default sort order is: 00:00000:00001:2005/10/04 13:16:01.21 server ASE's default sort order is:
00:00000:00001:2005/10/04 13:16:01.21 server 'bin_iso_1' (ID = 50) 00:00000:00001:2005/10/04 13:16:01.21 server 'bin_iso_1' (ID = 50)
00:00000:00001:2005/10/04 13:16:01.21 server on top of default character 00:00000:00001:2005/10/04 13:16:01.21 server on top of default character
set: set:
00:00000:00001:2005/10/04 13:16:01.21 server 'iso_1' (ID = 1). 00:00000:00001:2005/10/04 13:16:01.21 server 'iso_1' (ID = 1).
00:00000:00001:2005/10/04 13:16:01.21 server Master device size: 89 00:00000:00001:2005/10/04 13:16:01.21 server Master device size: 89
megabytes, or 45568 virtual pages. (A virtual page is megabytes, or 45568 virtual pages. (A virtual page is
2048 bytes.) 2048 bytes.)
b. In Window A, connect to the 8K Adaptive Server as the sa using the NULL b. In Window A, connect to the 8K Adaptive Server as the sa using the NULL
password. password.
isql -Usa -P -S $DSQUERY8 isql -Usa -P -S $DSQUERY8
c. Verify that this is indeed an 8K page size server by examining the Adaptive Server c. Verify that this is indeed an 8K page size server by examining the Adaptive Server
global variable @@maxpagesize. global variable @@maxpagesize.
select @@maxpagesize select @@maxpagesize
----------- -----------
8192 8192
e. Execute sp_spaceused on the following tables in the model database and fill in the e. Execute sp_spaceused on the following tables in the model database and fill in the
chart that follows: chart that follows:
For the entire database For the entire database
sp_spaceused sp_spaceused
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 7 - 9 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 7 - 9
name rowtotal reserved data index_size unused name rowtotal reserved data index_size unused
---------- -------- -------- ---- ---------- ------ ---------- -------- -------- ---- ---------- ------
sysobjects 30 248 KB 8 KB 32 KB 208 KB sysobjects 30 248 KB 8 KB 32 KB 208 KB
name rowtotal reserved data index_size unused name rowtotal reserved data index_size unused
------------- -------- -------- ----- ---------- ------ ------------- -------- -------- ----- ---------- ------
sysprocedures 0 192 KB 40 KB 16 KB 136 KB sysprocedures 0 192 KB 40 KB 16 KB 136 KB
8K Server model database sysobjects sysprocedures 8K Server model database sysobjects sysprocedures
reserved (KB) 6496 KB 248 KB 192 KB reserved (KB) 6496 KB 248 KB 192 KB
data (KB) 344 KB 8 KB 40 KB data (KB) 344 KB 8 KB 40 KB
index_size (KB) 624 KB 32 KB 16 KB index_size (KB) 624 KB 32 KB 16 KB
Both the 2K and 8K Adaptive Servers have their model database in Both the 2K and 8K Adaptive Servers have their model database in
its default condition with no added user objects. its default condition with no added user objects.
Explain why databases and tables with similar content take up Explain why databases and tables with similar content take up
significantly more space on an 8K server than on a 2K server. significantly more space on an 8K server than on a 2K server.
On any page size Adaptive Server, the minimum allocation On any page size Adaptive Server, the minimum allocation
for an object is one extent. for an object is one extent.
On a 2K server, all pages are 2K. One extent consists of 8 On a 2K server, all pages are 2K. One extent consists of 8
pages, which corresponds to 16K (8 pages * 2K per page). pages, which corresponds to 16K (8 pages * 2K per page).
On an 8K server, all pages are 8K. One extent consists of 8 On an 8K server, all pages are 8K. One extent consists of 8
pages, which corresponds to 64K (8 pages * 8K per page). pages, which corresponds to 64K (8 pages * 8K per page).
Many system tables do not fill even one extent, but space is Many system tables do not fill even one extent, but space is
reserved for that entire extent nonetheless (minimum reserved for that entire extent nonetheless (minimum
allocation). The same is true of each system table index. allocation). The same is true of each system table index.
Therefore, there is far more space reserved in an 8K server Therefore, there is far more space reserved in an 8K server
for system tables, much of it unused (at least to start with). for system tables, much of it unused (at least to start with).
4. End your client session with the 8K Adaptive Server. 4. End your client session with the 8K Adaptive Server.
Exit Exit
Lab Solution 7 - 10 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 7 - 10 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 7: Creating and Using Databases Module 7: Creating and Using Databases
Task 3: Writing Queries using sysdevices, sysusages, and Task 3: Writing Queries using sysdevices, sysusages, and
sysdatabases sysdatabases
Description In this task, you will write queries that use sysdevices, sysusages and sysdatabases. Description In this task, you will write queries that use sysdevices, sysusages and sysdatabases.
Procedure 1. Write queries against system tables that return useful device and database diagnostics. Procedure 1. Write queries against system tables that return useful device and database diagnostics.
a. In Window A, connect to your 2K Adaptive Server as the sa. a. In Window A, connect to your 2K Adaptive Server as the sa.
isql -Usa -P isql -Usa -P
b. Write a query to show which databases are on database device data_dev. (Hint: b. Write a query to show which databases are on database device data_dev. (Hint:
Comparing sysusages.vdevno with sysdevices.vdevno will tell you which device Comparing sysusages.vdevno with sysdevices.vdevno will tell you which device
each database fragment is on.) each database fragment is on.)
use master use master
my_db my_db
Or, for tidier output (although physical path may be truncated): Or, for tidier output (although physical path may be truncated):
select distinct select distinct
“Physical Device” = convert(char(40), sysdevices.phyname), “Physical Device” = convert(char(40), sysdevices.phyname),
“Database Name” = convert(char(15), sysdatabases.name) “Database Name” = convert(char(15), sysdatabases.name)
from sysdevices, sysdatabases, sysusages from sysdevices, sysdatabases, sysusages
where sysdevices.name = 'data_dev' where sysdevices.name = 'data_dev'
and sysusages.dbid = sysdatabases.dbid and sysusages.dbid = sysdatabases.dbid
and sysdevices.vdevno = sysusages.vdevno and sysdevices.vdevno = sysusages.vdevno
c. Execute the query again for only the master device. c. Execute the query again for only the master device.
select distinct select distinct
“Physical Device” = convert(char(40), sysdevices.phyname), “Physical Device” = convert(char(40), sysdevices.phyname),
“Database Name” = convert(char(15), sysdatabases.name) “Database Name” = convert(char(15), sysdatabases.name)
from sysdevices, sysdatabases, sysusages from sysdevices, sysdatabases, sysusages
where sysdevices.name = 'master' where sysdevices.name = 'master'
and sysusages.dbid = sysdatabases.dbid and sysusages.dbid = sysdatabases.dbid
and sysdevices.vdevno = sysusages.vdevno and sysdevices.vdevno = sysusages.vdevno
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 7 - 11 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 7 - 11
d. Write another query to determine how much free space there is on the device d. Write another query to determine how much free space there is on the device
data_dev. (Hint: The relevant rows in sysusages can be found using the same data_dev. (Hint: The relevant rows in sysusages can be found using the same
comparison as in the previous query.) comparison as in the previous query.)
select select
name, name,
size = (d.high + 1), size = (d.high + 1),
used = sum(u.size), used = sum(u.size),
left = (d.high + 1) - sum(u.size) left = (d.high + 1) - sum(u.size)
from from
sysdevices d, sysusages u sysdevices d, sysusages u
where where
name = "data_dev" name = "data_dev"
and u.vdevno = d.vdevno and u.vdevno = d.vdevno
group by name group by name
e. Perform a similar query to determine how much free space there is on the master e. Perform a similar query to determine how much free space there is on the master
device. device.
select select
name, name,
size = (d.high + 1), size = (d.high + 1),
used = sum(u.size), used = sum(u.size),
left = (d.high + 1) - sum(u.size) left = (d.high + 1) - sum(u.size)
from from
sysdevices d, sysusages u sysdevices d, sysusages u
where where
name = "master" name = "master"
and u.vdevno = d.vdevno and u.vdevno = d.vdevno
group by name group by name
f. End your client session with the 2K Adaptive Server. f. End your client session with the 2K Adaptive Server.
exit exit
Lab Solution 7 - 12 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 7 - 12 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 7: Creating and Using Databases Module 7: Creating and Using Databases
2. Given the following output from sysusages for a hypothetical database named sales, 2. Given the following output from sysusages for a hypothetical database named sales,
write down the command sequence that was used to create the database. (Assume that write down the command sequence that was used to create the database. (Assume that
the device names associated with vdevno values 5, 6, and 7 are dev1, dev2, and dev3, the device names associated with vdevno values 5, 6, and 7 are dev1, dev2, and dev3,
respectively.) respectively.)
select * from sysusages where dbid = db_id('sales') select * from sysusages where dbid = db_id('sales')
go go
dbid segmap lstart size vstart pad unreservedpgs crdate vdevno dbid segmap lstart size vstart pad unreservedpgs crdate vdevno
------ ------ ------ ----- ------ ---- ------------- ------------ ------ ------ ------ ------ ----- ------ ---- ------------- ------------ ------
6 3 0 1024 0 NULL 168 Oct 4 2005 5 6 3 0 1024 0 NULL 168 Oct 4 2005 5
6 4 1024 512 0 NULL 510 Oct 4 2005 6 6 4 1024 512 0 NULL 510 Oct 4 2005 6
6 3 1536 512 0 NULL 510 Oct 4 2005 7 6 3 1536 512 0 NULL 510 Oct 4 2005 7
The command sequence to create the database is: The command sequence to create the database is:
create database sales on dev1 = 2 log on dev2 = 1 create database sales on dev1 = 2 log on dev2 = 1
go go
3. Exit all client sessions with Adaptive Server. 3. Exit all client sessions with Adaptive Server.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 7 - 13 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 7 - 13
Lab Solution 7 - 14 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 7 - 14 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 8: Suggested Disk Resource Strategies Module 8: Suggested Disk Resource Strategies
Module 8: Suggested Disk Resource Strategies Module 8: Suggested Disk Resource Strategies
Lab 8: Using Free Space Thresholds Lab 8: Using Free Space Thresholds
Lab setup You will be using your 2K page size Adaptive Server for this lab. Lab setup You will be using your 2K page size Adaptive Server for this lab.
Note: If you have not completed lab 7 in which you should have Note: If you have not completed lab 7 in which you should have
created two database devices, data_dev, and log_dev and a database created two database devices, data_dev, and log_dev and a database
named my_db, then issue the following commands now (see script named my_db, then issue the following commands now (see script
lab08_setup.sql) (substituting $SYBASE appropriately): lab08_setup.sql) (substituting $SYBASE appropriately):
disk init disk init
name = "data_dev", name = "data_dev",
physname = "$SYBASE/devices/data_dev.dat", physname = "$SYBASE/devices/data_dev.dat",
size = "4M" size = "4M"
go go
Objectives After completing this lab, you should be able to: Objectives After completing this lab, you should be able to:
Create a free space threshold procedure Create a free space threshold procedure
Establish a threshold on a database segment to report when the free space drops below Establish a threshold on a database segment to report when the free space drops below
a specified level. a specified level.
Verify that the free space threshold delivers messages to the server log. Verify that the free space threshold delivers messages to the server log.
Description In this lab, you will learn how to construct a free space threshold procedure and set it in Description In this lab, you will learn how to construct a free space threshold procedure and set it in
use in a database to report a shortage of space. use in a database to report a shortage of space.
Task outline 1. Creating and verifying a free space threshold Task outline 1. Creating and verifying a free space threshold
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1 Lab Solution 8 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1 Lab Solution 8 - 1
Task 1: Creating a free space threshold procedure Task 1: Creating a free space threshold procedure
Description In this task, you will create a free space threshold procedure for the my_db database. Description In this task, you will create a free space threshold procedure for the my_db database.
Procedure Procedure
For all labs, you should open two windows (“A” and “B”). Unless For all labs, you should open two windows (“A” and “B”). Unless
instructed otherwise, perform all lab exercises in Window A. instructed otherwise, perform all lab exercises in Window A.
You use Window B primarily as a console for starting up Adaptive You use Window B primarily as a console for starting up Adaptive
Server and executing OS commands. All Adaptive Server system Server and executing OS commands. All Adaptive Server system
messages are displayed there instead of in your active ASE client messages are displayed there instead of in your active ASE client
window. window.
1. Examine the current state of the my_db database. 1. Examine the current state of the my_db database.
a. In Window A, connect to the 2K Adaptive Server as the sa and use the my_db a. In Window A, connect to the 2K Adaptive Server as the sa and use the my_db
database database
b. Examine the layout of my_db by using sp_helpdb to determine the free space in b. Examine the layout of my_db by using sp_helpdb to determine the free space in
the default data segment. the default data segment.
sp_helpdb my_db sp_helpdb my_db
name db_size owner dbid created status name db_size owner dbid created status
----- ------------- ----- ------ ---------------- ------------- ----- ------------- ----- ------ ---------------- -------------
my_db 6.0 MB sa 5 Mar 26, 2006 no options set my_db 6.0 MB sa 5 Mar 26, 2006 no options set
Lab Solution 8 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 8 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 8: Suggested Disk Resource Strategies Module 8: Suggested Disk Resource Strategies
The database that we will be using is small, however, the principle The database that we will be using is small, however, the principle
is the same for any database. It is important to have time to react to is the same for any database. It is important to have time to react to
a shortage of space within a database. To do so it is necessary to a shortage of space within a database. To do so it is necessary to
establish a threshold and keep track of the messages in the log file. establish a threshold and keep track of the messages in the log file.
For this exercise, we wish to know when the database is down to For this exercise, we wish to know when the database is down to
only 400 pages left as free space so there is time to increase the size only 400 pages left as free space so there is time to increase the size
or other action. or other action.
b. Verify the stored procedure was created by using sp_helptext: b. Verify the stored procedure was created by using sp_helptext:
3. Continuing in Window A and still using the my_db database, use sp_helpthreshold 3. Continuing in Window A and still using the my_db database, use sp_helpthreshold
stored procedure to determine what thresholds are currently defined for the my_db stored procedure to determine what thresholds are currently defined for the my_db
database. database.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1 Lab Solution 8 - 3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1 Lab Solution 8 - 3
sp_helpthreshold sp_helpthreshold
segment name free pages last chance? threshold procedure segment name free pages last chance? threshold procedure
------------ ----------- ------------ ------------------- ------------ ----------- ------------ -------------------
logsegment 88 1 sp_thresholdaction logsegment 88 1 sp_thresholdaction
The database is created with a threshold for the logsegment that The database is created with a threshold for the logsegment that
records an entry in the error log when the transaction log reaches 88 records an entry in the error log when the transaction log reaches 88
free pages and the transaction log will need to be trunctated to free free pages and the transaction log will need to be trunctated to free
up additional space. You may see the results of this threshold when up additional space. You may see the results of this threshold when
testing for correct operation of the threshold that we will be creating. testing for correct operation of the threshold that we will be creating.
4. Create a free space threshold within the my_db database that will use the first_alert 4. Create a free space threshold within the my_db database that will use the first_alert
threshold procedure when the free space in the default (data) segment reaches 400 threshold procedure when the free space in the default (data) segment reaches 400
pages. Use the sp_addthreshold stored procedure. pages. Use the sp_addthreshold stored procedure.
sp_addthreshold my_db, “default”, 400, first_alert sp_addthreshold my_db, “default”, 400, first_alert
Adding threshold for segment 'default' at '400' pages. Adding threshold for segment 'default' at '400' pages.
DBCC execution completed. If DBCC printed error messages, contact a DBCC execution completed. If DBCC printed error messages, contact a
user with System Administrator (SA) role. user with System Administrator (SA) role.
(return status = 0) (return status = 0)
5. Recheck the currently defined thresholds with sp_helpthreshold 5. Recheck the currently defined thresholds with sp_helpthreshold
sp_helpthreshold sp_helpthreshold
segment name free pages last chance? threshold procedure segment name free pages last chance? threshold procedure
------------ ----------- ------------ ------------------- ------------ ----------- ------------ -------------------
default 400 0 first_alert default 400 0 first_alert
logsegment 88 1 sp_thresholdaction logsegment 88 1 sp_thresholdaction
6. Change the dboption for my_db database to allow for "select into" capability to help 6. Change the dboption for my_db database to allow for "select into" capability to help
build up a table to use space in the data segment. Use the following set of commands: build up a table to use space in the data segment. Use the following set of commands:
use master use master
sp_dboption my_db, 'select into', true sp_dboption my_db, 'select into', true
7. Create a table within my_db where data can be added to test the threshold that was 7. Create a table within my_db where data can be added to test the threshold that was
added. Use the following select statement: added. Use the following select statement:
select * into titles from pubs2..titles select * into titles from pubs2..titles
Lab Solution 8 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 8 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 8: Suggested Disk Resource Strategies Module 8: Suggested Disk Resource Strategies
8. Check the current status of free space within the default segment using 8. Check the current status of free space within the default segment using
sp_helpsegment. sp_helpsegment.
sp_helpsegment 'default' sp_helpsegment 'default'
9. Insert data into the titles table to fill the default segment using the following statement: 9. Insert data into the titles table to fill the default segment using the following statement:
[The use of the number 250 after the go (a space after the go is required also) will have [The use of the number 250 after the go (a space after the go is required also) will have
the effect of issuing the command 250 times We will issue this command twice with the effect of issuing the command 250 times We will issue this command twice with
the truncating of the transaction log in between] the truncating of the transaction log in between]
a. Insert data into the titles table using the following command: a. Insert data into the titles table using the following command:
insert into titles select * from pubs2..titles insert into titles select * from pubs2..titles
go 250 go 250
b. Truncate the my_db database transaction log with the following command: b. Truncate the my_db database transaction log with the following command:
dump tran my_db with truncate_only dump tran my_db with truncate_only
c. Again, insert data into the titles table using the following command c. Again, insert data into the titles table using the following command
insert into titles select * from pubs2..titles insert into titles select * from pubs2..titles
go 250 go 250
Conduct a search of the error log by any method that will show the Conduct a search of the error log by any method that will show the
entry that contains information about pages left in the default entry that contains information about pages left in the default
segment. Use Notepad or the find command at a command prompt. segment. Use Notepad or the find command at a command prompt.
10. In Window B at a command prompt, search the error log for the string "pages left in" 10. In Window B at a command prompt, search the error log for the string "pages left in"
using the following command: using the following command:
grep "pages left in" $SYBASE/$SYBASE_ASE/install/$DSQUERY.log grep "pages left in" $SYBASE/$SYBASE_ASE/install/$DSQUERY.log
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1 Lab Solution 8 - 5 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1 Lab Solution 8 - 5
11. Perform a final check of the segment with sp_helpsegment 11. Perform a final check of the segment with sp_helpsegment
sp_helpsegment 'default' sp_helpsegment 'default'
Did the threshold work as you expected? Did the threshold work as you expected?
Yes. a report was sent to the error log to identify that the Yes. a report was sent to the error log to identify that the
threshold was reached. threshold was reached.
12. Drop table titles from the database. 12. Drop table titles from the database.
Lab Solution 8 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 8 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 9: Auto Expansion Module 9: Auto Expansion
Lab setup You will be using your 2K page size Adaptive Server for this lab. There is no additional Lab setup You will be using your 2K page size Adaptive Server for this lab. There is no additional
setup for this lab. setup for this lab.
Objectives After completing this lab, you should be able to: Objectives After completing this lab, you should be able to:
Install and configure Adaptive Server for Auto Expansion Install and configure Adaptive Server for Auto Expansion
Understand the administrative limitations when not employing Auto Expansion Understand the administrative limitations when not employing Auto Expansion
Define the database and device level policies for triggering Auto Expansion Define the database and device level policies for triggering Auto Expansion
Realize the benefits provided by Auto Expansion. Realize the benefits provided by Auto Expansion.
Understand the process in removing the functionality. Understand the process in removing the functionality.
Description In this lab, you will learn how to setup your Adaptive Server to support Auto Expansion of Description In this lab, you will learn how to setup your Adaptive Server to support Auto Expansion of
database and devices. You will define the threshold needed to fire the expansion process. database and devices. You will define the threshold needed to fire the expansion process.
You will learn the advantages of using Auto Expansion feature sets as compared to having You will learn the advantages of using Auto Expansion feature sets as compared to having
the default database functionality. the default database functionality.
Task outline 1. Installing Auto Expansion scripts Task outline 1. Installing Auto Expansion scripts
2. Verifying default database behavior 2. Verifying default database behavior
3. Setup Auto Database and Device Expansion Policy 3. Setup Auto Database and Device Expansion Policy
4. Validating and simulating effects of Auto Expansion 4. Validating and simulating effects of Auto Expansion
5. Removing Auto Expansion 5. Removing Auto Expansion
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 9 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 9 - 1
Task 1: Installing Auto Expansion scripts Task 1: Installing Auto Expansion scripts
Description In this task, you will create new database devices for auto expansion and create the test Description In this task, you will create new database devices for auto expansion and create the test
databases. databases.
Procedure Procedure
For most of the labs, you should open two windows (“A” and “B”). For most of the labs, you should open two windows (“A” and “B”).
• Window A is your ISQL session connected to your server • Window A is your ISQL session connected to your server
primarily using the ‘sa’ account. This is where you enter the lab primarily using the ‘sa’ account. This is where you enter the lab
commands and SQL statements. commands and SQL statements.
• You use Window B for monitoring the Adaptive Server errorlog • You use Window B for monitoring the Adaptive Server errorlog
file. file.
Where there is no mention of Window name, use Window A. Where there is no mention of Window name, use Window A.
1. Connect to the host machine and run the auto expansion install script using the 1. Connect to the host machine and run the auto expansion install script using the
following command. following command.
cd $SYBASE/$SYBASE_ASE/scripts/ cd $SYBASE/$SYBASE_ASE/scripts/
isql -Usa -P -iinstalldbextend -o$HOME/sa/output.txt isql -Usa -P -iinstalldbextend -o$HOME/sa/output.txt
2. Verify from the output file that the script ran successfully. If the output file contains 2. Verify from the output file that the script ran successfully. If the output file contains
errors, resolve the problem and re-run the script before proceeding. Consult your errors, resolve the problem and re-run the script before proceeding. Consult your
instructor if you need assistance. instructor if you need assistance.
3. In your Window B, start monitoring your Adaptive Server errorlog file with the Linux 3. In your Window B, start monitoring your Adaptive Server errorlog file with the Linux
utility ‘tail’. The errorlog file name is in the form <ServerName>.log. utility ‘tail’. The errorlog file name is in the form <ServerName>.log.
cd $SYBASE/$SYBASE_ASE/install/ cd $SYBASE/$SYBASE_ASE/install/
tail -f $DSQUERY.log tail -f $DSQUERY.log
Lab Solution 9 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 9 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 9: Auto Expansion Module 9: Auto Expansion
4. Login to your server as 'sa' and create the devices needed for this lab. Replace the file 4. Login to your server as 'sa' and create the devices needed for this lab. Replace the file
path appropriately. Run the commands from master database. path appropriately. Run the commands from master database.
create database auto_db on auto_dat=3 log on auto_log=3 create database auto_db on auto_dat=3 log on auto_log=3
go go
CREATE DATABASE: allocating 1536 logical pages (3.0 megabytes) on CREATE DATABASE: allocating 1536 logical pages (3.0 megabytes) on
disk 'auto_dat'. disk 'auto_dat'.
CREATE DATABASE: allocating 1536 logical pages (3.0 megabytes) on CREATE DATABASE: allocating 1536 logical pages (3.0 megabytes) on
disk 'auto_log'. disk 'auto_log'.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 9 - 3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 9 - 3
Task 2: Verifying default database behavior Task 2: Verifying default database behavior
Description In this task, you will simulate data change that will saturate the default segment of the Description In this task, you will simulate data change that will saturate the default segment of the
auto_db database. In the process, you will acquire an understanding of Adaptive Servers auto_db database. In the process, you will acquire an understanding of Adaptive Servers
behavior when database segments run out of space. behavior when database segments run out of space.
Procedure 1. In order to minimize needed administrative actions when device and segments are Procedure 1. In order to minimize needed administrative actions when device and segments are
saturated, we will enable the database option "abort tran on log full". This command saturated, we will enable the database option "abort tran on log full". This command
is executed from the master database. is executed from the master database.
sp_dboption auto_db, "abort tran on log full", "true" sp_dboption auto_db, "abort tran on log full", "true"
go go
Database option 'abort tran on log full' turned ON for database Database option 'abort tran on log full' turned ON for database
'auto_db'. 'auto_db'.
Running CHECKPOINT on database 'auto_db' for option 'abort tran Running CHECKPOINT on database 'auto_db' for option 'abort tran
on log full' to take effect. on log full' to take effect.
(return status = 0) (return status = 0)
2. Enable the "select into bulkcopy" option so we can transfer data from pubs2 database 2. Enable the "select into bulkcopy" option so we can transfer data from pubs2 database
to simulate OLTP transactions. to simulate OLTP transactions.
sp_dboption auto_db, "select into", "true" sp_dboption auto_db, "select into", "true"
go go
Database option 'select into/bulkcopy/pllsort' turned ON for Database option 'select into/bulkcopy/pllsort' turned ON for
database 'auto_db'. database 'auto_db'.
Running CHECKPOINT on database 'auto_db' for option 'select Running CHECKPOINT on database 'auto_db' for option 'select
into/bulkcopy/pllsort' to take effect. into/bulkcopy/pllsort' to take effect.
(return status = 0) (return status = 0)
3. Capture the database space information for auto_db as a baseline, prior to any data 3. Capture the database space information for auto_db as a baseline, prior to any data
change. Take note of the value for the "log only free kbytes" as well as the "free change. Take note of the value for the "log only free kbytes" as well as the "free
kbytes" for auto_dat device. Capture a summary report, as shown below, by kbytes" for auto_dat device. Capture a summary report, as shown below, by
executing the command from the master database. executing the command from the master database.
Enter Value for "free kbytes" for auto_dat ____1340____ Enter Value for "free kbytes" for auto_dat ____1340____
Enter Value for "log only free kbytes" 1305_____ Enter Value for "log only free kbytes" 1305_____
name db_size owner dbid created status name db_size owner dbid created status
------- ------------- ----- ------ ------------------ --------- ------- ------------- ----- ------ ------------------ ---------
------------------------------------------- -------------------------------------------
auto_db 6.0 MB sa 7 Oct 06, 2005 select auto_db 6.0 MB sa 7 Oct 06, 2005 select
into/bulkcopy/pllsort, abort tran on log full into/bulkcopy/pllsort, abort tran on log full
Lab Solution 9 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 9 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 9: Auto Expansion Module 9: Auto Expansion
-------------------------------------------------------------- --------------------------------------------------------------
log only free kbytes = 3058 log only free kbytes = 3058
(return status = 0) (return status = 0)
4. Capture the device space utilization for auto_dat as a baseline before any size 4. Capture the device space utilization for auto_dat as a baseline before any size
changes. Take note of the original device size. changes. Take note of the original device size.
sp_helpdevice auto_dat sp_helpdevice auto_dat
go go
5. Simulate an OLTP transaction that can fill up the database default segment. The first 5. Simulate an OLTP transaction that can fill up the database default segment. The first
statement creates an empty auto_db..blurbs table using the pubs2..blurbs table statement creates an empty auto_db..blurbs table using the pubs2..blurbs table
definition. Next you will execute an INSERT from the pubs2..blurbs table for 110 definition. Next you will execute an INSERT from the pubs2..blurbs table for 110
iterations. Run the following commands within the context of auto_db database. iterations. Run the following commands within the context of auto_db database.
use auto_db use auto_db
go go
select * into blurbs from pubs2..blurbs where 1=2 select * into blurbs from pubs2..blurbs where 1=2
go go
insert into blurbs select * from pubs2..blurbs insert into blurbs select * from pubs2..blurbs
go 110 go 110
(2 messgages are reported – one msg deleted to save space) (2 messgages are reported – one msg deleted to save space)
Msg 1105, Level 17, State 2: Msg 1105, Level 17, State 2:
Server 'DUB102_2K', Line 1: Server 'DUB102_2K', Line 1:
Can't allocate space for object 'blurbs' in database 'auto_db' Can't allocate space for object 'blurbs' in database 'auto_db'
because 'default' segment is full/has no free extents. If you because 'default' segment is full/has no free extents. If you
ran out of space in syslogs, dump the transaction log. ran out of space in syslogs, dump the transaction log.
Otherwise, use ALTER DATABASE to increase the size of the Otherwise, use ALTER DATABASE to increase the size of the
segment. segment.
Command has been aborted. Command has been aborted.
110 xacts: 110 xacts:
6. The pubs2..blurbs table contains 6 rows. Running the INSERT statement 110 times 6. The pubs2..blurbs table contains 6 rows. Running the INSERT statement 110 times
successfully should have resulted in 660 rows being inserted into auto_db..blurbs successfully should have resulted in 660 rows being inserted into auto_db..blurbs
table. Each individual INSERT is a transaction. Check to see how many rows actually table. Each individual INSERT is a transaction. Check to see how many rows actually
exist. exist.
select count(*) from blurbs select count(*) from blurbs
go go
----------- -----------
648 648
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 9 - 5 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 9 - 5
How many rows were inserted ? Explain. How many rows were inserted ? Explain.
The number of rows inserted was 648, this shows that the last The number of rows inserted was 648, this shows that the last
two transactions (660-648=12, therefore 12/6=2) failed due to a two transactions (660-648=12, therefore 12/6=2) failed due to a
full default (data) segment as shown in the error message. full default (data) segment as shown in the error message.
7. Re-run sp_helpdb on the database to gather space utilization statistics after saturating 7. Re-run sp_helpdb on the database to gather space utilization statistics after saturating
the 'default' segment. the 'default' segment.
sp_helpdb auto_db sp_helpdb auto_db
go go
What is the value for auto_dat free kbytes? 0 . What is the value for auto_dat free kbytes? 0 .
What is the value for “log only free kbytes” 1734 . What is the value for “log only free kbytes” 1734 .
Lab Solution 9 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 9 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 9: Auto Expansion Module 9: Auto Expansion
Task 3: Setup Auto Database and Device Expansion Policy Task 3: Setup Auto Database and Device Expansion Policy
Description In this task, you will define auto expansion policies for database and devices as well as Description In this task, you will define auto expansion policies for database and devices as well as
create the threshold that will trigger the process. create the threshold that will trigger the process.
Procedure 1. Cleanup the changes made by the initial testing. Truncate the blurbs table in the Procedure 1. Cleanup the changes made by the initial testing. Truncate the blurbs table in the
auto_db database. auto_db database.
truncate table blurbs truncate table blurbs
go go
2. Purge the auto_db transaction log to free up space for additional testing. 2. Purge the auto_db transaction log to free up space for additional testing.
dump tran auto_db with truncate_only dump tran auto_db with truncate_only
go go
3. Verify that space is available with sp_helpdb and that free kbytes have returned to 3. Verify that space is available with sp_helpdb and that free kbytes have returned to
near baseline. near baseline.
sp_helpdb auto_db sp_helpdb auto_db
go go
name db_size owner dbid created status name db_size owner dbid created status
------- ------------- ----- ------ ------------------ --------- ------- ------------- ----- ------ ------------------ ---------
------------------------------------------- -------------------------------------------
auto_db 6.0 MB sa 7 Oct 06, 2005 select auto_db 6.0 MB sa 7 Oct 06, 2005 select
into/bulkcopy/pllsort, abort tran on log full into/bulkcopy/pllsort, abort tran on log full
-------------------------------------------------------------- --------------------------------------------------------------
log only free kbytes = 3058 log only free kbytes = 3058
sp_dbextend 'set', 'database', auto_db, 'default', '1M', '10MB' sp_dbextend 'set', 'database', auto_db, 'default', '1M', '10MB'
go go
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 9 - 7 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 9 - 7
5. Define the device expansion policy for the auto_dat device to increase size by 5 MB 5. Define the device expansion policy for the auto_dat device to increase size by 5 MB
each time the expansion is fired and set the maximum size policy to 50 MB. each time the expansion is fired and set the maximum size policy to 50 MB.
sp_dbextend 'set', 'device', 'auto_dat', '5m', '50m' sp_dbextend 'set', 'device', 'auto_dat', '5m', '50m'
go go
6. Once the database and device expansion policies are set, the next step is to define the 6. Once the database and device expansion policies are set, the next step is to define the
threshold policy. The threshold policy is the triggering mechanism of the auto threshold policy. The threshold policy is the triggering mechanism of the auto
expansion feature. Using the following command, auto expansion will fire when the expansion feature. Using the following command, auto expansion will fire when the
default segment has only 1 MB of free space left. default segment has only 1 MB of free space left.
sp_dbextend 'set', 'threshold', auto_db, 'default', '1m' sp_dbextend 'set', 'threshold', auto_db, 'default', '1m'
go go
Adding threshold for segment 'default' at '512' pages. Adding threshold for segment 'default' at '512' pages.
DBCC execution completed. If DBCC printed error messages, DBCC execution completed. If DBCC printed error messages,
contact a user with System Administrator (SA) role. contact a user with System Administrator (SA) role.
(return status = 0) (return status = 0)
7. View the auto database expansion policy currently configured for auto_db database. 7. View the auto database expansion policy currently configured for auto_db database.
sp_dbextend listfull, 'database', 'auto_db' sp_dbextend listfull, 'database', 'auto_db'
go go
name segment item value status comment name segment item value status comment
--------- ------- ------- ------ ------- ---------------------- --------- ------- ------- ------ ------- ----------------------
server-wide (n/a) (n/a) (n/a) enabled set='Oct 6 2005 12:44PM' server-wide (n/a) (n/a) (n/a) enabled set='Oct 6 2005 12:44PM'
auto_db default growby 1M enabled set='Oct 6 2005 4:27PM' auto_db default growby 1M enabled set='Oct 6 2005 4:27PM'
auto_db default maxsize 10MB enabled set='Oct 6 2005 4:27PM' auto_db default maxsize 10MB enabled set='Oct 6 2005 4:27PM'
default (all) growby 10% enabled set='Oct 6 2005 12:44PM' default (all) growby 10% enabled set='Oct 6 2005 12:44PM'
Log segment free space currently is 1529 logical pages (3058K). Log segment free space currently is 1529 logical pages (3058K).
(return status = 0) (return status = 0)
8. View the auto device expansion policy currently configured for auto_dat device. 8. View the auto device expansion policy currently configured for auto_dat device.
sp_dbextend listfull, 'device', 'auto_dat' sp_dbextend listfull, 'device', 'auto_dat'
go go
name segment item value status comment name segment item value status comment
----------- ------- ------- ----- ------- ------------------------ ----------- ------- ------- ----- ------- ------------------------
- -
server-wide (n/a) (n/a) (n/a) enabled set='Oct 6 2005 12:44PM' server-wide (n/a) (n/a) (n/a) enabled set='Oct 6 2005 12:44PM'
auto_dat (n/a) growby 5m enabled set='Oct 6 2005 4:25PM' auto_dat (n/a) growby 5m enabled set='Oct 6 2005 4:25PM'
auto_dat (n/a) maxsize 50m enabled set='Oct 6 2005 4:25PM' auto_dat (n/a) maxsize 50m enabled set='Oct 6 2005 4:25PM'
Lab Solution 9 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 9 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 9: Auto Expansion Module 9: Auto Expansion
9. View the threshold policy for the auto_db database. 9. View the threshold policy for the auto_db database.
sp_dbextend list, 'threshold', 'auto_db' sp_dbextend list, 'threshold', 'auto_db'
go go
segment name free pages free pages (KB) threshold procedure segment name free pages free pages (KB) threshold procedure
status status
------------ ----------- --------------- ------------------- - ------------ ----------- --------------- ------------------- -
------------------ ------------------
default 512 1024 sp_dbxt_extend_db default 512 1024 sp_dbxt_extend_db
logsegment 120 240 sp_thresholdaction logsegment 120 240 sp_thresholdaction
last-chance,enabled last-chance,enabled
Log segment free space currently is 1529 logical pages (3058K) Log segment free space currently is 1529 logical pages (3058K)
(return status = 0) (return status = 0)
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 9 - 9 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 9 - 9
Task 4: Validating and simulating effects of Auto Expansion Task 4: Validating and simulating effects of Auto Expansion
Description This task will demonstrate the capabilities of auto expansion. Description This task will demonstrate the capabilities of auto expansion.
Procedure 1. Execute the insert command once again for 110 times to simulate data changes. Procedure 1. Execute the insert command once again for 110 times to simulate data changes.
insert into blurbs select * from pubs2..blurbs insert into blurbs select * from pubs2..blurbs
go 110 go 110
2. In your Window B, the Adaptive Server errorlog will display the following message 2. In your Window B, the Adaptive Server errorlog will display the following message
confirming the use of auto expansion feature. confirming the use of auto expansion feature.
./*** other information removed for brevity ***/ ./*** other information removed for brevity ***/
. .
. .
00:00000:00024:2005/10/06 16:34:55.06 server background task 00:00000:00024:2005/10/06 16:34:55.06 server background task
message: sp_dbxt_do_resize_dev: Device auto_dat of size 3M message: sp_dbxt_do_resize_dev: Device auto_dat of size 3M
resized by 5M to a total size of 8M. resized by 5M to a total size of 8M.
00:00000:00024:2005/10/06 16:34:55.24 server background task 00:00000:00024:2005/10/06 16:34:55.24 server background task
message: ALTER DATABASE auto_db on auto_dat = '1.0M' -- message: ALTER DATABASE auto_db on auto_dat = '1.0M' --
Segment: default Segment: default
00:00000:00024:2005/10/06 16:34:55.24 server Extending 00:00000:00024:2005/10/06 16:34:55.24 server Extending
database by 512 pages (1.0 megabytes) on disk auto_dat database by 512 pages (1.0 megabytes) on disk auto_dat
00:00000:00024:2005/10/06 16:34:55.32 server background task 00:00000:00024:2005/10/06 16:34:55.32 server background task
message: Database 'auto_db' was altered by total size '1M' for message: Database 'auto_db' was altered by total size '1M' for
segment 'default'. segment 'default'.
00:00000:00025:2005/10/06 16:35:08.25 server background task 00:00000:00025:2005/10/06 16:35:08.25 server background task
message: Threshold action procedure 'sp_dbxt_extend_db' fired message: Threshold action procedure 'sp_dbxt_extend_db' fired
in db 'auto_db' on segment 'default'. Space left: 512 logical in db 'auto_db' on segment 'default'. Space left: 512 logical
pages ('1M'). pages ('1M').
00:00000:00025:2005/10/06 16:35:08.25 server background task 00:00000:00025:2005/10/06 16:35:08.25 server background task
message: ALTER DATABASE auto_db on auto_dat = '1.0M' -- message: ALTER DATABASE auto_db on auto_dat = '1.0M' --
Segment: default Segment: default
00:00000:00025:2005/10/06 16:35:08.26 server Extending 00:00000:00025:2005/10/06 16:35:08.26 server Extending
database by 512 pages (1.0 megabytes) on disk auto_dat database by 512 pages (1.0 megabytes) on disk auto_dat
00:00000:00025:2005/10/06 16:35:08.27 server background task 00:00000:00025:2005/10/06 16:35:08.27 server background task
message: Database 'auto_db' was altered by total size '1M' for message: Database 'auto_db' was altered by total size '1M' for
segment 'default'. segment 'default'.
. .
. .
./*** other information removed for brevity ***/ ./*** other information removed for brevity ***/
3. Verify the result for the auto_dat device using sp_helpdevice procedure. 3. Verify the result for the auto_dat device using sp_helpdevice procedure.
sp_helpdevice auto_dat sp_helpdevice auto_dat
go go
Lab Solution 9 - 10 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 9 - 10 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 9: Auto Expansion Module 9: Auto Expansion
What has happened to the device size ? What has happened to the device size ?
The device has increased size from 3 Mb to 8 Mb. The device has increased size from 3 Mb to 8 Mb.
4. Check the space allocation for the auto_db database after auto expansion with 4. Check the space allocation for the auto_db database after auto expansion with
sp_helpdb. sp_helpdb.
sp_helpdb auto_db sp_helpdb auto_db
go go
name db_size owner dbid created status name db_size owner dbid created status
------- ------------- ----- ------ ------------------ --------- ------- ------------- ----- ------ ------------------ ---------
------------------------------------------- -------------------------------------------
auto_db 8.0 MB sa 7 Oct 06, 2005 select auto_db 8.0 MB sa 7 Oct 06, 2005 select
into/bulkcopy/pllsort, abort tran on log full into/bulkcopy/pllsort, abort tran on log full
What has changed with device fragments ? Is this what is expected What has changed with device fragments ? Is this what is expected
after the settings that were made for Auto Expansion ? after the settings that were made for Auto Expansion ?
There are now two additional data device fragments of 1 Mb There are now two additional data device fragments of 1 Mb
size. The two slices corresponds to the event of the last two size. The two slices corresponds to the event of the last two
transactions that failed due to full default segment. YES – This is transactions that failed due to full default segment. YES – This is
what was expected to happen. what was expected to happen.
5. Check that the current policy for auto_db database is consistent against its segments 5. Check that the current policy for auto_db database is consistent against its segments
and the device layouts. Particularly for the default segment. A return status of 0 and the device layouts. Particularly for the default segment. A return status of 0
indicates no error. indicates no error.
sp_dbextend 'check', 'database', 'auto_db', 'default' sp_dbextend 'check', 'database', 'auto_db', 'default'
go go
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 9 - 11 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 9 - 11
6. Auto expansion feature can also be tested through a simulation exercise. Run the 6. Auto expansion feature can also be tested through a simulation exercise. Run the
following command to simulate expansion. The 4th parameter defines the number of following command to simulate expansion. The 4th parameter defines the number of
iterations and defaults to ‘1’ if not specified. iterations and defaults to ‘1’ if not specified.
use auto_db use auto_db
go go
sp_dbextend 'simulate', auto_db, 'default', '1' sp_dbextend 'simulate', auto_db, 'default', '1'
go go
NO REAL WORK WILL BE DONE. Simulate database / device expansion NO REAL WORK WILL BE DONE. Simulate database / device expansion
in a dry-run mode 1 time(s). in a dry-run mode 1 time(s).
These are the series of database/device expansions that would These are the series of database/device expansions that would
have happened if the threshold on database 'auto_db', segment have happened if the threshold on database 'auto_db', segment
'default' were to fire 1 time(s). 'default' were to fire 1 time(s).
Summary of device/database sizes after 1 simulated extensions: Summary of device/database sizes after 1 simulated extensions:
=============================================================== ===============================================================
devicename initial size final size devicename initial size final size
---------- ------------ ---------- ---------- ------------ ----------
auto_dat 8.0M 8.0M auto_dat 8.0M 8.0M
Database 'auto_db', segment 'default' would be altered from an Database 'auto_db', segment 'default' would be altered from an
initial size of '5M' by '1M' for a resultant total size of initial size of '5M' by '1M' for a resultant total size of
'6M'. '6M'.
To actually expand the database manually for this threshold, To actually expand the database manually for this threshold,
issue: sp_dbextend 'execute', 'auto_db', 'default', '1' issue: sp_dbextend 'execute', 'auto_db', 'default', '1'
(return status = 0) (return status = 0)
It is possible to apply the expansion immediately, bypassing the It is possible to apply the expansion immediately, bypassing the
threshold, by using the command parameter “execute” of the threshold, by using the command parameter “execute” of the
sp_dbextend procedure. sp_dbextend procedure.
Lab Solution 9 - 12 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 9 - 12 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 9: Auto Expansion Module 9: Auto Expansion
Description The procedures discussed in this task will remove the auto expansion feature and bring Description The procedures discussed in this task will remove the auto expansion feature and bring
back the environment to its default setting. It is a good exercise to see how you can back the environment to its default setting. It is a good exercise to see how you can
remove the features that you have just installed. remove the features that you have just installed.
Procedure 1. Clear the device policy for the auto_dat device, clear the database policy for the Procedure 1. Clear the device policy for the auto_dat device, clear the database policy for the
default segment, and remove the threshold policy defined for the auto_db database on default segment, and remove the threshold policy defined for the auto_db database on
the default segment. the default segment.
use auto_db use auto_db
go go
exec sp_dbextend 'clear', 'database', auto_db, 'default' exec sp_dbextend 'clear', 'database', auto_db, 'default'
exec sp_dbextend 'clear', 'database', auto_db, 'default' exec sp_dbextend 'clear', 'database', auto_db, 'default'
exec sp_dbextend 'clear', 'threshold', auto_db, 'default' exec sp_dbextend 'clear', 'threshold', auto_db, 'default'
go go
2. Verify the current state of the auto expansion policy with the listfull parameter of 2. Verify the current state of the auto expansion policy with the listfull parameter of
sp_dbextend procedure for both the database and the device. sp_dbextend procedure for both the database and the device.
exec sp_dbextend listfull, 'database', 'auto_db' exec sp_dbextend listfull, 'database', 'auto_db'
exec sp_dbextend listfull, 'device', 'auto_dat' exec sp_dbextend listfull, 'device', 'auto_dat'
go go
name segment item value status comment name segment item value status comment
----------- ------- ------ ----- ------- ------------------------- ----------- ------- ------ ----- ------- -------------------------
server-wide (n/a) (n/a) (n/a) enabled set='Oct 6 2005 12:33PM' server-wide (n/a) (n/a) (n/a) enabled set='Oct 6 2005 12:33PM'
default (all) growby 10% enabled set='Oct 6 2005 12:33PM' default (all) growby 10% enabled set='Oct 6 2005 12:33PM'
Log segment free space currently is 868 logical pages (1736K). Log segment free space currently is 868 logical pages (1736K).
(return status = 0) (return status = 0)
name segment item value status comment name segment item value status comment
----------- ------- ------- ----- ------- ------------------------- ----------- ------- ------- ----- ------- -------------------------
server-wide (n/a) (n/a) (n/a) enabled set='Oct 6 2005 12:33PM' server-wide (n/a) (n/a) (n/a) enabled set='Oct 6 2005 12:33PM'
auto_dat (n/a) growby 5m enabled set='Oct 6 2005 2:41PM' auto_dat (n/a) growby 5m enabled set='Oct 6 2005 2:41PM'
auto_dat (n/a) maxsize 50m enabled set='Oct 6 2005 2:41PM' auto_dat (n/a) maxsize 50m enabled set='Oct 6 2005 2:41PM'
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 9 - 13 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 9 - 13
3. Drop the auto_db database. Execute the command from the master database. 3. Drop the auto_db database. Execute the command from the master database.
4. Drop the associated database devices. Remember to delete the files in 4. Drop the associated database devices. Remember to delete the files in
$SYBASE/devices associated with these devices. $SYBASE/devices associated with these devices.
exec sp_dropdevice auto_dat exec sp_dropdevice auto_dat
exec sp_dropdevice auto_log exec sp_dropdevice auto_log
go go
5. In Window B, end the tail command by using <ctrl> C to interrupt the process. 5. In Window B, end the tail command by using <ctrl> C to interrupt the process.
Lab Solution 9 - 14 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 9 - 14 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 10: Managing tempdb Module 10: Managing tempdb
Lab 10: User Defined Tempdb Lab 10: User Defined Tempdb
Lab setup You will be using your 2K page size Adaptive Server for this lab. A script will be specified Lab setup You will be using your 2K page size Adaptive Server for this lab. A script will be specified
in Task 1 that will assist in the setting of some account information. in Task 1 that will assist in the setting of some account information.
Objectives After completing this lab, you should be able to: Objectives After completing this lab, you should be able to:
Prepare a temporary database devices and create multiple temporary databases Prepare a temporary database devices and create multiple temporary databases
Bind logins to a temporary database or tempdb group Bind logins to a temporary database or tempdb group
Description In this lab, you will practice the implementating of an additional temporary database Description In this lab, you will practice the implementating of an additional temporary database
configuration. You will also practice the binding of a login with a user-created tempdb. configuration. You will also practice the binding of a login with a user-created tempdb.
Task outline 1. Creating a user defined tempdb Task outline 1. Creating a user defined tempdb
2. Binding of a login to a tempdb 2. Binding of a login to a tempdb
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 10 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 10 - 1
Task 1: Creating a user defined tempdb Task 1: Creating a user defined tempdb
Description In this task, you will initialize new database devices for multiple tempdbs and create the Description In this task, you will initialize new database devices for multiple tempdbs and create the
temporary databases. temporary databases.
Procedure Procedure
For most of the labs, you should open three windows (A, B, and C). For most of the labs, you should open three windows (A, B, and C).
• Window A is your ISQL session connected to your server • Window A is your ISQL session connected to your server
primarily using the ‘sa’ account. In some portions, an ISQL primarily using the ‘sa’ account. In some portions, an ISQL
session is also needed by a user login account as described in the session is also needed by a user login account as described in the
lab instructions. lab instructions.
• Use Window B primarily as a console for starting up Adaptive • Use Window B primarily as a console for starting up Adaptive
Server and executing OS commands. All Adaptive Server Server and executing OS commands. All Adaptive Server
system messages are displayed there instead of in your active system messages are displayed there instead of in your active
ASE client window. ASE client window.
• Window C is your ISQL session connected to your server as • Window C is your ISQL session connected to your server as
needed by user logins, as described in the lab instructions. needed by user logins, as described in the lab instructions.
1. In Window A, open an isql session to your database server using the 'sa' login account. 1. In Window A, open an isql session to your database server using the 'sa' login account.
2. Create the device needed for a user defined tempdb . Change the path to the devices 2. Create the device needed for a user defined tempdb . Change the path to the devices
directory to the correct path for your environment - the Variable $HOME will not directory to the correct path for your environment - the Variable $HOME will not
work. work.
create temporary database tempdb_01 on tempdb_01_device = 10 create temporary database tempdb_01 on tempdb_01_device = 10
CREATE DATABASE: allocating 5120 logical pages (10.0 megabytes) on CREATE DATABASE: allocating 5120 logical pages (10.0 megabytes) on
disk 'tempdb_01_device'. disk 'tempdb_01_device'.
Lab Solution 10 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 10 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
4. Temporary databases are almost like normal databases, except they are flagged with a 4. Temporary databases are almost like normal databases, except they are flagged with a
special status code to denote its usage. Verify this value (131328) from special status code to denote its usage. Verify this value (131328) from
master..sysdatabases, column status3. master..sysdatabases, column status3.
select name, dbid, crdate, status3 from master..sysdatabases select name, dbid, crdate, status3 from master..sysdatabases
The ‘status3’ control bits in master..sysdatabases has decimal The ‘status3’ control bits in master..sysdatabases has decimal
value '256' (131328-131072=256) defined as "user-created value '256' (131328-131072=256) defined as "user-created
tempdb".. tempdb"..
The following script will create a new login, manager_01 with the The following script will create a new login, manager_01 with the
password 'sybase'. password 'sybase'.
The script will also provide an alias to the login that will allow it to The script will also provide an alias to the login that will allow it to
have access to objects owned by the dbo of the database. have access to objects owned by the dbo of the database.
5. In Window B, at a command prompt, change directory to $HOME/sa directory and 5. In Window B, at a command prompt, change directory to $HOME/sa directory and
use the following command to execute the lab10_logins.sql T-SQL script use the following command to execute the lab10_logins.sql T-SQL script
cd $HOME/sa cd $HOME/sa
6. In Window A as the user 'sa', show the current ‘tempdb’ database assignment. 6. In Window A as the user 'sa', show the current ‘tempdb’ database assignment.
sp_tempdb show sp_tempdb show
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 10 - 3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 10 - 3
------------------------- -------------------------
default default
Login Application Group Database Hardness Login Application Group Database Hardness
----- ----------- ----- -------- -------- ----- ----------- ----- -------- --------
7. Add the tempdb_01 database to the default group. Currently, Adaptive Server only 7. Add the tempdb_01 database to the default group. Currently, Adaptive Server only
supports the default group. User defined groups are intended for future Adaptive supports the default group. User defined groups are intended for future Adaptive
Server releases. Server releases.
sp_tempdb 'add', tempdb_01, 'default' sp_tempdb 'add', tempdb_01, 'default'
8. Verify the action by showing the current tempdb assignment. 8. Verify the action by showing the current tempdb assignment.
sp_tempdb show sp_tempdb show
Login Application Group Database Hardness Login Application Group Database Hardness
----- ----------- ----- -------- -------- ----- ----------- ----- -------- --------
Lab Solution 10 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 10 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 10 - 5 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 10 - 5
Description In this task, you will work on the process of binding a login or application to the temporary Description In this task, you will work on the process of binding a login or application to the temporary
database. database.
Procedure 1. In a third command prompt window, Window C, log into your server as Procedure 1. In a third command prompt window, Window C, log into your server as
'manager_01' with the password 'sybase'. The login will default to 'pubs2' database 'manager_01' with the password 'sybase'. The login will default to 'pubs2' database
which can be verified with a query. which can be verified with a query.
isql -Umanager_01 -Psybase isql -Umanager_01 -Psybase
------------------------------ ------------------------------
pubs2 pubs2
The 'manager_01' login is bound to the default group and the The 'manager_01' login is bound to the default group and the
account may actually appear in either tempdb or tempdb_01 account may actually appear in either tempdb or tempdb_01
databases. It is unknown as to which database may be chosen databases. It is unknown as to which database may be chosen
for any particular session for the login. for any particular session for the login.
2. In the same Window C, as the manager_01 login, conduct a test to determine which 2. In the same Window C, as the manager_01 login, conduct a test to determine which
tempdb database is being used by the login for this particular session. Use the tempdb database is being used by the login for this particular session. Use the
following command that examines the contents of a new global variable and obtains following command that examines the contents of a new global variable and obtains
the name of the database: The results may be either one of those shown the name of the database: The results may be either one of those shown
------------------------------ ------------------------------
tempdb tempdb
------------------------------ ------------------------------
tempdb_01 tempdb_01
Lab Solution 10 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 10 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Any objects created by this account may appear in either of Any objects created by this account may appear in either of
these tempdb's. To be sure and consistent , it makes sense to these tempdb's. To be sure and consistent , it makes sense to
bind this login to the new user defined tempdb_01 and remove bind this login to the new user defined tempdb_01 and remove
the ambiguity. This is done with the sp_tempdb procedure the ambiguity. This is done with the sp_tempdb procedure
bind option. bind option.
3. In Window A as the sa account, bind the 'manager_01' login to the 'tempdb_01' 3. In Window A as the sa account, bind the 'manager_01' login to the 'tempdb_01'
database explicitly using the default binding. database explicitly using the default binding.
sp_tempdb bind, 'LG', 'manager_01', 'DB', 'tempdb_01' sp_tempdb bind, 'LG', 'manager_01', 'DB', 'tempdb_01'
4. The above command will not affect current database connections and sessions. 4. The above command will not affect current database connections and sessions.
Therefore, using Window C, logout the 'manager_01' account and log back in for the Therefore, using Window C, logout the 'manager_01' account and log back in for the
settings to take effect. settings to take effect.
5. As the user manager_01, perform the test again to determine which tempdb database 5. As the user manager_01, perform the test again to determine which tempdb database
is being used by this particular session. The result should not be ambiguous. is being used by this particular session. The result should not be ambiguous.
select db_name(@@tempdbid) select db_name(@@tempdbid)
------------------------------ ------------------------------
tempdb_01 tempdb_01
6. Using Window C, submit the following querys that will generate a list of 'Comp' 6. Using Window C, submit the following querys that will generate a list of 'Comp'
books and store the list in a temporary table in the tempdb_01 database and query the books and store the list in a temporary table in the tempdb_01 database and query the
list. list.
select titles.title, titles.title_id, titles.pub_id select titles.title, titles.title_id, titles.pub_id
into #CompBooks into #CompBooks
from titles, publishers from titles, publishers
where titles.pub_id = publishers.pub_id where titles.pub_id = publishers.pub_id
and titles.title like '%Comp%' and titles.title like '%Comp%'
title title
title_id pub_id title_id pub_id
--------------------------------------------------------------- ---------------------------------------------------------------
-------- ------ -------- ------
You Can Combat Computer Stress! You Can Combat Computer Stress!
BU2075 0736 BU2075 0736
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 10 - 7 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 10 - 7
7. Another way to verify the same information, and at the same time to determine which 7. Another way to verify the same information, and at the same time to determine which
tempdb is being used, is to check if the temporary table (#CompBooks) was created in tempdb is being used, is to check if the temporary table (#CompBooks) was created in
‘tempdb_01’. Execute the following statement from the ISQL connection. ‘tempdb_01’. Execute the following statement from the ISQL connection.
select name, id, crdate, loginame select name, id, crdate, loginame
from tempdb_01..sysobjects where name like '%CompBooks%' from tempdb_01..sysobjects where name like '%CompBooks%'
go go
name name
id crdate loginame id crdate loginame
--------------------------------------------------------------- ---------------------------------------------------------------
#CompBooks00000140009897590 #CompBooks00000140009897590
1429632064 Oct 3 2005 9:35AM manager_01 1429632064 Oct 3 2005 9:35AM manager_01
8. Drop the temporary objects from all active database connections. 8. Drop the temporary objects from all active database connections.
drop table #CompBooks drop table #CompBooks
go go
9. End this lab by using your Window B, check to see if you are still located in the 9. End this lab by using your Window B, check to see if you are still located in the
directory “$HOME/sa” and execute the batch file lab10_cleanup.bat. The script will directory “$HOME/sa” and execute the batch file lab10_cleanup.bat. The script will
remove all of the items created in this lab. remove all of the items created in this lab.
Lab Solution 10 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 10 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Module 11: Administering System Roles and Logins Module 11: Administering System Roles and Logins
Lab 11: Administering System Roles and Logins Lab 11: Administering System Roles and Logins
Lab Setup You will be using your 2K page size Adaptive Server for this lab. Lab Setup You will be using your 2K page size Adaptive Server for this lab.
No other setup is required for this lab. No other setup is required for this lab.
Objectives After completing this lab, you should be able to: Objectives After completing this lab, you should be able to:
Become familiar with ASE security features Become familiar with ASE security features
Description In this lab, you will learn how ASE security features work. Description In this lab, you will learn how ASE security features work.
Task Outline 1. Creating Two New Logins Task Outline 1. Creating Two New Logins
2. Administer the Logins by Granting System Roles to Them 2. Administer the Logins by Granting System Roles to Them
3. Locking a Login 3. Locking a Login
4. Accessing Adaptive Server with Different Logins and Examining their Functional 4. Accessing Adaptive Server with Different Logins and Examining their Functional
Capabilities Capabilities
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 11 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 11 - 1
Task 1: Creating Two New Logins Task 1: Creating Two New Logins
Description In this task, you will create two new logins. Description In this task, you will create two new logins.
Procedure Procedure
For all labs, you should open two windows (“A” and “B”). Unless For all labs, you should open two windows (“A” and “B”). Unless
instructed otherwise, perform all lab exercises in Window A. instructed otherwise, perform all lab exercises in Window A.
You use Window B primarily as a console for starting up Adaptive You use Window B primarily as a console for starting up Adaptive
Server and executing OS commands. All Adaptive Server system Server and executing OS commands. All Adaptive Server system
messages are displayed there instead of in your active ASE client messages are displayed there instead of in your active ASE client
window. window.
1. Create two new logins to the Adaptive Server. 1. Create two new logins to the Adaptive Server.
a. In Window A, connect to Adaptive Server as the sa. a. In Window A, connect to Adaptive Server as the sa.
isql -Usa -P isql -Usa -P
b. Create a new login with the following characteristics: b. Create a new login with the following characteristics:
c. Create another new login with the following characteristics: c. Create another new login with the following characteristics:
Lab Solution 11 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 11 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 11: Administering System Roles and Logins Module 11: Administering System Roles and Logins
Task 2: Administering the Logins by Granting System Roles to Task 2: Administering the Logins by Granting System Roles to
Them Them
Description In this task, you will administer the logins by granting system roles to them. Description In this task, you will administer the logins by granting system roles to them.
Procedure 1. Administer the new logins. Procedure 1. Administer the new logins.
a. Continuing in Window A as the sa, examine the attributes of both new logins, a. Continuing in Window A as the sa, examine the attributes of both new logins,
mary and joe, by using sp_displaylogin. mary and joe, by using sp_displaylogin.
sp_displaylogin mary sp_displaylogin mary
Suid: 3 Suid: 3
Loginame: mary Loginame: mary
Fullname: Fullname:
Default Database: master Default Database: master
Default Language: Default Language:
Auto Login Script: Auto Login Script:
Configured Authorization: Configured Authorization:
Locked: NO Locked: NO
Date of Last Password Change: Oct 5 2005 2:20AM Date of Last Password Change: Oct 5 2005 2:20AM
Password expiration interval: 0 Password expiration interval: 0
Password expired: NO Password expired: NO
Minimum password length: 6 Minimum password length: 6
Maximum failed logins: 0 Maximum failed logins: 0
Current failed login attempts: Current failed login attempts:
Authenticate with: ANY Authenticate with: ANY
(return status = 0) (return status = 0)
Suid: 4 Suid: 4
Loginame: joe Loginame: joe
Fullname: Fullname:
Default Database: model Default Database: model
Default Language: Default Language:
Auto Login Script: Auto Login Script:
Configured Authorization: Configured Authorization:
Locked: NO Locked: NO
Date of Last Password Change: Oct 5 2005 2:22AM Date of Last Password Change: Oct 5 2005 2:22AM
Password expiration interval: 0 Password expiration interval: 0
Password expired: NO Password expired: NO
Minimum password length: 8 Minimum password length: 8
Maximum failed logins: 0 Maximum failed logins: 0
Current failed login attempts: Current failed login attempts:
Authenticate with: ANY Authenticate with: ANY
(return status = 0) (return status = 0)
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 11 - 3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 11 - 3
Were the logins created successfully according to the specifications Were the logins created successfully according to the specifications
concerning login name and default database? concerning login name and default database?
Yes. The login mary has master as the default database while Yes. The login mary has master as the default database while
joe has the model database. joe has the model database.
A minimum password length of 8 was assigned to joe but no A minimum password length of 8 was assigned to joe but no
assignment was specified when creating the login for mary. By assignment was specified when creating the login for mary. By
default, what is the minimum password length? default, what is the minimum password length?
Six (6) Six (6)
Are the actual passwords shown in the sp_displaylogin output? Are the actual passwords shown in the sp_displaylogin output?
No! No!
By default, are any roles assigned to new logins? By default, are any roles assigned to new logins?
No. No.
By default, are new logins locked or unlocked? By default, are new logins locked or unlocked?
New logins are initially unlocked. New logins are initially unlocked.
b. Grant the SSO role to mary. b. Grant the SSO role to mary.
grant role sso_role to mary grant role sso_role to mary
Lab Solution 11 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 11 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 11: Administering System Roles and Logins Module 11: Administering System Roles and Logins
Description In this task, you will lock a login. Description In this task, you will lock a login.
Procedure 1. Lock the account for mary. Procedure 1. Lock the account for mary.
sp_locklogin mary, "lock" sp_locklogin mary, "lock"
a. Examine the updated attributes of both new logins, mary and joe, by using a. Examine the updated attributes of both new logins, mary and joe, by using
sp_displaylogin sp_displaylogin
sp_displaylogin mary sp_displaylogin mary
Suid: 3 Suid: 3
Loginame: mary Loginame: mary
Fullname: Fullname:
Default Database: master Default Database: master
Default Language: Default Language:
Auto Login Script: Auto Login Script:
Configured Authorization: Configured Authorization:
sso_role (default ON) sso_role (default ON)
Locked: YES Locked: YES
Date of Last Password Change: Oct 5 2005 2:20AM Date of Last Password Change: Oct 5 2005 2:20AM
Password expiration interval: 0 Password expiration interval: 0
Password expired: NO Password expired: NO
Minimum password length: 6 Minimum password length: 6
Maximum failed logins: 0 Maximum failed logins: 0
Current failed login attempts: Current failed login attempts:
Authenticate with: ANY Authenticate with: ANY
(return status = 0) (return status = 0)
sp_displaylogin joe sp_displaylogin joe
Suid: 4 Suid: 4
Loginame: joe Loginame: joe
Fullname: Fullname:
Default Database: model Default Database: model
Default Language: Default Language:
Auto Login Script: Auto Login Script:
Configured Authorization: Configured Authorization:
sa_role (default ON) sa_role (default ON)
Locked: NO Locked: NO
Date of Last Password Change: Oct 5 2005 2:22AM Date of Last Password Change: Oct 5 2005 2:22AM
Password expiration interval: 0 Password expiration interval: 0
Password expired: NO Password expired: NO
Minimum password length: 8 Minimum password length: 8
Maximum failed logins: 0 Maximum failed logins: 0
Current failed login attempts: Current failed login attempts:
Authenticate with: ANY Authenticate with: ANY
(return status = 0) (return status = 0)
2. Start up client sessions with Adaptive Server by using the new logins. 2. Start up client sessions with Adaptive Server by using the new logins.
a. In Window B, try to connect to Adaptive Server as mary. a. In Window B, try to connect to Adaptive Server as mary.
isql -Umary -P1001nites isql -Umary -P1001nites
Msg 4002, Level 14, State 1: Msg 4002, Level 14, State 1:
Server 'DUB103_2K': Server 'DUB103_2K':
Login failed. Login failed.
CT-LIBRARY error: CT-LIBRARY error:
ct_connect(): protocol specific layer: external error: ct_connect(): protocol specific layer: external error:
The attempt to co The attempt to co
nnect to the server failed. nnect to the server failed.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 11 - 5 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 11 - 5
b. Continuing in Window B, connect to Adaptive Server as joe. b. Continuing in Window B, connect to Adaptive Server as joe.
isql -Ujoe -P1001nites isql -Ujoe -P1001nites
c. Verify that joe is indeed connected to Adaptive Server and review his login c. Verify that joe is indeed connected to Adaptive Server and review his login
attributes by using sp_displaylogin with no arguments. attributes by using sp_displaylogin with no arguments.
sp_displaylogin sp_displaylogin
Suid: 4 Suid: 4
Loginame: joe Loginame: joe
Fullname: Fullname:
Default Database: model Default Database: model
Default Language: Default Language:
Auto Login Script: Auto Login Script:
Configured Authorization: Configured Authorization:
sa_role (default ON) sa_role (default ON)
Locked: NO Locked: NO
Date of Last Password Change: Oct 5 2005 2:22AM Date of Last Password Change: Oct 5 2005 2:22AM
Password expiration interval: 0 Password expiration interval: 0
Password expired: NO Password expired: NO
Minimum password length: 8 Minimum password length: 8
Maximum failed logins: 0 Maximum failed logins: 0
Current failed login attempts: Current failed login attempts:
Authenticate with: ANY Authenticate with: ANY
(return status = 0) (return status = 0)
d. Verify that joe is in his default database, model. d. Verify that joe is in his default database, model.
select db_name() select db_name()
------------------------------ ------------------------------
model model
(1 row affected) (1 row affected)
e. Change the password for joe to “10days”. e. Change the password for joe to “10days”.
sp_password "1001nites", "10days" sp_password "1001nites", "10days"
Msg 10317, Level 14, State 1: Msg 10317, Level 14, State 1:
Server 'DUB103_2K', Procedure 'sp_password', Line 110: Server 'DUB103_2K', Procedure 'sp_password', Line 110:
The specified password is too short. Passwords must be at least The specified password is too short. Passwords must be at least
8 character(s) long. 8 character(s) long.
Msg 17720, Level 16, State 1: Msg 17720, Level 16, State 1:
Server 'DUB103_2K', Procedure 'sp_password', Line 120: Server 'DUB103_2K', Procedure 'sp_password', Line 120:
Error: Unable to set the Password. Error: Unable to set the Password.
(return status = 1) (return status = 1)
Was the password change successful? Explain. Was the password change successful? Explain.
No. The minimum password length for joe is eight (8) No. The minimum password length for joe is eight (8)
characters. characters.
Lab Solution 11 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 11 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 11: Administering System Roles and Logins Module 11: Administering System Roles and Logins
f. Change the password for joe to “1001days”. f. Change the password for joe to “1001days”.
sp_password "1001nites", "1001days" sp_password "1001nites", "1001days"
g. While connected as joe, attempt to create a new login named johnny with the g. While connected as joe, attempt to create a new login named johnny with the
password “temp1234”. password “temp1234”.
sp_addlogin johnny, temp1234 sp_addlogin johnny, temp1234
Msg 567, Level 16, State 1: Msg 567, Level 16, State 1:
Server 'DUB103_2K', Procedure 'sp_addlogin', Line 138: Server 'DUB103_2K', Procedure 'sp_addlogin', Line 138:
You must have the following role(s) to execute this You must have the following role(s) to execute this
command/procedure: command/procedure:
'sso_role'. Please contact a user with the appropriate role for 'sso_role'. Please contact a user with the appropriate role for
help. help.
(return status = 1) (return status = 1)
h. As joe, try to unlock the account for mary. h. As joe, try to unlock the account for mary.
sp_locklogin mary, unlock sp_locklogin mary, unlock
Msg 567, Level 16, State 1: Msg 567, Level 16, State 1:
Server 'DUB103_2K', Procedure 'sp_locklogin', Line 145: Server 'DUB103_2K', Procedure 'sp_locklogin', Line 145:
You must have the following role(s) to execute this You must have the following role(s) to execute this
command/procedure: command/procedure:
'sso_role'. Please contact a user with the appropriate role for 'sso_role'. Please contact a user with the appropriate role for
help. help.
(return status = 1) (return status = 1)
The login joe has the sa_role, but can he create new logins and The login joe has the sa_role, but can he create new logins and
unlock others? Explain. unlock others? Explain.
No .The sa_role role alone is not enough to perform all No .The sa_role role alone is not enough to perform all
Adaptive Server administrative tasks. The role is also not Adaptive Server administrative tasks. The role is also not
sufficient to unlock accounts. You must have ‘sso_role’ to sufficient to unlock accounts. You must have ‘sso_role’ to
execute this command. execute this command.
i. Return to window A and, as sa, try to unlock the account for mary. i. Return to window A and, as sa, try to unlock the account for mary.
sp_locklogin mary, unlock sp_locklogin mary, unlock
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 11 - 7 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 11 - 7
Task 4: Accessing Adaptive Server with Different Logins and Task 4: Accessing Adaptive Server with Different Logins and
Examining their Functional Capabilities Examining their Functional Capabilities
Description In this task, you will access Adaptive Server with different logins and examine their Description In this task, you will access Adaptive Server with different logins and examine their
functional capabilities. functional capabilities.
Procedure 1. Start up a client session with Adaptive Server by using the mary login. Procedure 1. Start up a client session with Adaptive Server by using the mary login.
a. In Window B, exit the client session for joe and then try to connect as mary. a. In Window B, exit the client session for joe and then try to connect as mary.
exit exit
Was the connection now successful? Was the connection now successful?
Yes. Yes.
Was this the expected behavior? Explain. Was this the expected behavior? Explain.
Yes. The sa login unlocked the mary login in the previous Yes. The sa login unlocked the mary login in the previous
step. step.
b. Verify that mary is indeed connected to Adaptive Server and review her login b. Verify that mary is indeed connected to Adaptive Server and review her login
attributes by using sp_displaylogin with no arguments. attributes by using sp_displaylogin with no arguments.
sp_displaylogin sp_displaylogin
Suid: 3 Suid: 3
Loginame: mary Loginame: mary
Fullname: Fullname:
Default Database: master Default Database: master
Default Language: Default Language:
Auto Login Script: Auto Login Script:
Configured Authorization: Configured Authorization:
sso_role (default ON) sso_role (default ON)
Locked: NO Locked: NO
Date of Last Password Change: Oct 5 2005 2:20AM Date of Last Password Change: Oct 5 2005 2:20AM
Password expiration interval: 0 Password expiration interval: 0
Password expired: NO Password expired: NO
Minimum password length: 6 Minimum password length: 6
Maximum failed logins: 0 Maximum failed logins: 0
Current failed login attempts: Current failed login attempts:
Authenticate with: ANY Authenticate with: ANY
(return status = 0) (return status = 0)
c. Verify that mary is in her default database, master. c. Verify that mary is in her default database, master.
select db_name() select db_name()
------------------------------ ------------------------------
master master
Lab Solution 11 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 11 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 11: Administering System Roles and Logins Module 11: Administering System Roles and Logins
d. Change the password for mary to “10days”. d. Change the password for mary to “10days”.
sp_password "1001nites", "10days" sp_password "1001nites", "10days"
This password change was rejected for joe. Was the password This password change was rejected for joe. Was the password
change successful for mary? Explain. change successful for mary? Explain.
Yes. Unlike joe, mary does not have a minimum password Yes. Unlike joe, mary does not have a minimum password
length of eight (8) characters. length of eight (8) characters.
e. While connected as mary, attempt to create a new login named johnny with the e. While connected as mary, attempt to create a new login named johnny with the
password “temp1234”. password “temp1234”.
sp_addlogin johnny, temp1234 sp_addlogin johnny, temp1234
f. As mary, try to lock the account for johnny. f. As mary, try to lock the account for johnny.
sp_locklogin johnny, "lock" sp_locklogin johnny, "lock"
g. As mary, try to unlock the account for johnny. g. As mary, try to unlock the account for johnny.
sp_locklogin johnny, "unlock" sp_locklogin johnny, "unlock"
The login joe has the sa_role, and he could not create new logins but The login joe has the sa_role, and he could not create new logins but
he could unlock other accounts. Can mary perform both of these he could unlock other accounts. Can mary perform both of these
tasks with the sso_role? tasks with the sso_role?
Yes. A login with the sso_role can both create and lock/ Yes. A login with the sso_role can both create and lock/
unlock logins. The login joe, with the sa_role, was unable to unlock logins. The login joe, with the sa_role, was unable to
create new logins. create new logins.
2. Drop the newly created logins. 2. Drop the newly created logins.
a. Return to window A and, as the sa, drop the login for joe. a. Return to window A and, as the sa, drop the login for joe.
sp_droplogin joe sp_droplogin joe
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 11 - 9 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 11 - 9
b. Drop the login for johnny. b. Drop the login for johnny.
sp_droplogin johnny sp_droplogin johnny
c. Drop the login for mary. c. Drop the login for mary.
sp_droplogin mary sp_droplogin mary
Warning: the specified account is currently active. Warning: the specified account is currently active.
Nothing changed. Nothing changed.
(return status = 1) (return status = 1)
If mary is still connected to Adaptive Server (in window B), can the If mary is still connected to Adaptive Server (in window B), can the
sa drop the active login? sa drop the active login?
No. No.
d. Return to window B as mary and exit the client session with Adaptive Server. d. Return to window B as mary and exit the client session with Adaptive Server.
exit exit
e. Return to window A as the sa and drop the mary login. e. Return to window A as the sa and drop the mary login.
sp_droplogin mary sp_droplogin mary
f. Verify that the logins mary, joe, and johnny have all been dropped by examining f. Verify that the logins mary, joe, and johnny have all been dropped by examining
the entries in the syslogins table. the entries in the syslogins table.
select name from master..syslogins select name from master..syslogins
name name
-------------------------- --------------------------
probe probe
sa sa
3. Exit all client sessions with Adaptive Server. 3. Exit all client sessions with Adaptive Server.
Lab Solution 11 - 10 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 11 - 10 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 12: Managing Database Users and Groups Module 12: Managing Database Users and Groups
Module 12: Managing Database Users and Groups Module 12: Managing Database Users and Groups
Lab 12: Managing Database Users and Groups Lab 12: Managing Database Users and Groups
Lab Setup You will be using your 2K page size Adaptive Server for this lab. Lab Setup You will be using your 2K page size Adaptive Server for this lab.
Note: You need to have completed previous labs in which you created two database Note: You need to have completed previous labs in which you created two database
devices, data_dev and log_dev, and a database named my_db. If you did not finish those devices, data_dev and log_dev, and a database named my_db. If you did not finish those
labs or did not create the devices and database, then please refer to the instructions right labs or did not create the devices and database, then please refer to the instructions right
before step 1 of this lab. before step 1 of this lab.
Objectives After completing this lab, you should be able to: Objectives After completing this lab, you should be able to:
Become familiar with the mechanics of database access via users and groups Become familiar with the mechanics of database access via users and groups
Description In this lab, you will learn the mechanics of database access via users and groups. Description In this lab, you will learn the mechanics of database access via users and groups.
Task Outline 1. Adding Logins to the Server Task Outline 1. Adding Logins to the Server
2. Adding Users to a Database 2. Adding Users to a Database
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 12- 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 12- 1
Task 1: Adding Logins to the Server Task 1: Adding Logins to the Server
Description In this task, you will add logins to the server. Description In this task, you will add logins to the server.
Procedure Procedure
Note: If you have not completed the previous labs in which you Note: If you have not completed the previous labs in which you
should have created two database devices, data_dev and log_dev should have created two database devices, data_dev and log_dev
and a database named my_db, then issue the following commands and a database named my_db, then issue the following commands
now: (see script lab12_setup.sql) (substituting $SYBASE now: (see script lab12_setup.sql) (substituting $SYBASE
appropriately): appropriately):
disk init disk init
name = "data_dev", name = "data_dev",
physname = "$SYBASE/devices/data_dev.dat", physname = "$SYBASE/devices/data_dev.dat",
size = "4M" size = "4M"
go go
create database my_db on data_dev=4 log on log_dev=2 create database my_db on data_dev=4 log on log_dev=2
go go
For all labs, you should open two windows (“A” and “B”). Unless For all labs, you should open two windows (“A” and “B”). Unless
instructed otherwise, perform all lab exercises in Window A. instructed otherwise, perform all lab exercises in Window A.
You use Window B primarily as a console for starting up Adaptive You use Window B primarily as a console for starting up Adaptive
Server and executing OS commands. All Adaptive Server system Server and executing OS commands. All Adaptive Server system
messages are displayed there instead of in your active ASE client messages are displayed there instead of in your active ASE client
window. window.
1. Create three new logins to the Adaptive Server. 1. Create three new logins to the Adaptive Server.
a. In Window A, connect to Adaptive Server as the sa. a. In Window A, connect to Adaptive Server as the sa.
b. Create three new logins with the following characteristics: b. Create three new logins with the following characteristics:
Lab Solution 12 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 12 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 12: Managing Database Users and Groups Module 12: Managing Database Users and Groups
Login names: tom dick harry Login names: tom dick harry
password: friday (for all 3) password: friday (for all 3)
default database: my_db (for all 3) default database: my_db (for all 3)
exec sp_addlogin tom, "friday", my_db exec sp_addlogin tom, "friday", my_db
exec sp_addlogin dick, "friday", my_db exec sp_addlogin dick, "friday", my_db
exec sp_addlogin harry, "friday", my_db exec sp_addlogin harry, "friday", my_db
Suppose harry has forgotten his password and needs help. As a login Suppose harry has forgotten his password and needs help. As a login
configured with the System Security Officer role (sso_role), what configured with the System Security Officer role (sso_role), what
are you enabled to do? are you enabled to do?
As an SSO, you could assign harry a new password by As an SSO, you could assign harry a new password by
executing the sp_password stored procedure with the executing the sp_password stored procedure with the
following syntax: following syntax:
sp_password <caller_passwd>, <new_passwd>, sp_password <caller_passwd>, <new_passwd>,
<login_name> <login_name>
As the SSO with a password of sybase, write down the command As the SSO with a password of sybase, write down the command
you would use to give harry the new password saturday but do not you would use to give harry the new password saturday but do not
execute the command. execute the command.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 12- 3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 12- 3
Description In this task, you will add users to a database. Description In this task, you will add users to a database.
Procedure 1. Add these new logins as users in the my_db database. Procedure 1. Add these new logins as users in the my_db database.
a. Access the my_db database. a. Access the my_db database.
use my_db use my_db
b. Add the three new logins, tom, dick, and harry as users to the database. b. Add the three new logins, tom, dick, and harry as users to the database.
exec sp_adduser tom exec sp_adduser tom
exec sp_adduser dick exec sp_adduser dick
exec sp_adduser harry exec sp_adduser harry
c. Verify the existence of the three new users in the database by using sp_helpuser. c. Verify the existence of the three new users in the database by using sp_helpuser.
sp_helpuser sp_helpuser
Do new database users initially belong to any groups? Do new database users initially belong to any groups?
Yes. All database users are members of the public group. Yes. All database users are members of the public group.
2. Exit all client sessions with Adaptive Server. 2. Exit all client sessions with Adaptive Server.
Lab Solution 12 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 12 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 13: Implementing Roles, Object Permissions, and Groups Module 13: Implementing Roles, Object Permissions, and Groups
Module 13: Implementing Roles, Object Permissions, and Module 13: Implementing Roles, Object Permissions, and
Groups Groups
Lab 13: Implementing Roles, Object Permissions, and Lab 13: Implementing Roles, Object Permissions, and
Groups Groups
Lab Setup You will be using your 2K page size Adaptive Server for this lab. Lab Setup You will be using your 2K page size Adaptive Server for this lab.
Objectives After completing this lab, you should be able to: Objectives After completing this lab, you should be able to:
Work with user-defined roles Work with user-defined roles
Implement object permissions for tables and stored procedures. Implement object permissions for tables and stored procedures.
Description In this lab, you will learn how to work with user-defined roles, how to implement object Description In this lab, you will learn how to work with user-defined roles, how to implement object
permissions for tables and stored procedures. permissions for tables and stored procedures.
Task Outline 1. Creating Groups and Adding Users to Those Groups Task Outline 1. Creating Groups and Adding Users to Those Groups
2. Testing User and Group Permissions 2. Testing User and Group Permissions
3. Creating User-Defined Roles and Assign to Logins 3. Creating User-Defined Roles and Assign to Logins
4. Examining Role Hierarchies and Test Role and Object Permissions 4. Examining Role Hierarchies and Test Role and Object Permissions
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 13 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 13 - 1
Task 1: Creating Groups and Adding Users to Those Groups Task 1: Creating Groups and Adding Users to Those Groups
Description In this task, you will create groups and add users to those groups. Description In this task, you will create groups and add users to those groups.
Procedure Note: If you have not completed the previous labs in which you Procedure Note: If you have not completed the previous labs in which you
should have created two database devices, data_dev and log_dev should have created two database devices, data_dev and log_dev
and a database named my_db, then issue the following commands and a database named my_db, then issue the following commands
now: (see script lab13_setup.sql) (substituting $SYBASE now: (see script lab13_setup.sql) (substituting $SYBASE
appropriately): appropriately):
disk init disk init
name = "data_dev", name = "data_dev",
physname = "$SYBASE/devices/data_dev.dat", physname = "$SYBASE/devices/data_dev.dat",
size = "4M" size = "4M"
go go
create database my_db on data_dev=4 log on log_dev=2 create database my_db on data_dev=4 log on log_dev=2
go go
For all labs, you should open two windows (“A” and “B”). Unless For all labs, you should open two windows (“A” and “B”). Unless
instructed otherwise, perform all lab exercises in Window A. instructed otherwise, perform all lab exercises in Window A.
You use Window B primarily as a console for starting up Adaptive You use Window B primarily as a console for starting up Adaptive
Server and executing OS commands. All Adaptive Server system Server and executing OS commands. All Adaptive Server system
messages are displayed there instead of in your active ASE client messages are displayed there instead of in your active ASE client
window. window.
1. Create a database group and add users to it. 1. Create a database group and add users to it.
a. Continuing in the my_db database as the sa, create a group named programmers. a. Continuing in the my_db database as the sa, create a group named programmers.
b. Create another group named engineers. b. Create another group named engineers.
Lab Solution 13 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 13 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 13: Implementing Roles, Object Permissions, and Groups Module 13: Implementing Roles, Object Permissions, and Groups
c. Display the names of all the groups in the database by using sp_helpgroup. c. Display the names of all the groups in the database by using sp_helpgroup.
sp_helpgroup sp_helpgroup
d. Add tom, dick, and harry to the programmers group. d. Add tom, dick, and harry to the programmers group.
e. Display the names of the users in the programmers group. e. Display the names of the users in the programmers group.
f. Add harry to the engineers group. f. Add harry to the engineers group.
g. Display the names of the users in the engineers group. g. Display the names of the users in the engineers group.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 13 - 3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 13 - 3
h. Display the names of the users in the programmers group. h. Display the names of the users in the programmers group.
Can a user be a member of 2 different user-defined groups within Can a user be a member of 2 different user-defined groups within
one database? one database?
No. A database user can be a member of only one group No. A database user can be a member of only one group
other than public. Notice that harry only belongs to the other than public. Notice that harry only belongs to the
engineers group even though he was not explicitly removed engineers group even though he was not explicitly removed
from the programmers group. from the programmers group.
, ,
Lab Solution 13 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 13 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 13: Implementing Roles, Object Permissions, and Groups Module 13: Implementing Roles, Object Permissions, and Groups
Task 2: Testing User and Group Permissions Task 2: Testing User and Group Permissions
Description In this task, you will create tables to test user and group permissions. Description In this task, you will create tables to test user and group permissions.
Procedure 1. Create user tables to test user and group permissions. Procedure 1. Create user tables to test user and group permissions.
a. Continuing in Window A as the sa, activate the database option “select a. Continuing in Window A as the sa, activate the database option “select
into/bulkcopy/pllsort” for the my_db database. into/bulkcopy/pllsort” for the my_db database.
use master use master
sp_dboption my_db, "select into/bulkcopy/pllsort", true sp_dboption my_db, "select into/bulkcopy/pllsort", true
Database option 'select into/bulkcopy/pllsort' turned ON for Database option 'select into/bulkcopy/pllsort' turned ON for
database 'my_db'. database 'my_db'.
Running CHECKPOINT on database 'my_db' for option 'select Running CHECKPOINT on database 'my_db' for option 'select
into/bulkcopy/pllsort' into/bulkcopy/pllsort'
to take effect. to take effect.
(return status = 0) (return status = 0)
b. Create new tables in the my_db database as shown: b. Create new tables in the my_db database as shown:
use my_db use my_db
select * into principals_data from pubs2..stores select * into principals_data from pubs2..stores
select * into teachers_data from pubs2..stores select * into teachers_data from pubs2..stores
select * into students_data from pubs2..stores select * into students_data from pubs2..stores
c. Grant select permission on the principals_data table to the programmers group as c. Grant select permission on the principals_data table to the programmers group as
shown: shown:
b. Verify that harry accesses the my_db database as his default database. b. Verify that harry accesses the my_db database as his default database.
select db_name() select db_name()
------------------------------ ------------------------------
my_db my_db
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 13 - 5 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 13 - 5
c. Issue a select statement against the principals_data table in the my_db database. c. Issue a select statement against the principals_data table in the my_db database.
select * from principals_data select * from principals_data
Msg 10330, Level 14, State 1: Msg 10330, Level 14, State 1:
Server 'DUB103_2K', Line 1: Server 'DUB103_2K', Line 1:
SELECT permission denied on object principals_data, database SELECT permission denied on object principals_data, database
my_db, owner dbo my_db, owner dbo
None of the database users, tom, dick, or harry own the None of the database users, tom, dick, or harry own the
principals_data table. None of them has been directly granted select principals_data table. None of them has been directly granted select
permissions on the table. Only the programmers group has been permissions on the table. Only the programmers group has been
granted permissions but harry is not a member of that group. granted permissions but harry is not a member of that group.
Therefore, was the query result expected? Therefore, was the query result expected?
Yes. harry was rightfully denied access to the table. Yes. harry was rightfully denied access to the table.
d. In Window B, exit your client session as harry and then connect to Adaptive d. In Window B, exit your client session as harry and then connect to Adaptive
Server as tom, who is a member of the programmers group. Server as tom, who is a member of the programmers group.
exit exit
e. Verify that tom accesses the my_db database as his default database. e. Verify that tom accesses the my_db database as his default database.
select db_name() select db_name()
------------------------------ ------------------------------
my_db my_db
f. Issue a select statement against the principals_data table. f. Issue a select statement against the principals_data table.
Lab Solution 13 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 13 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 13: Implementing Roles, Object Permissions, and Groups Module 13: Implementing Roles, Object Permissions, and Groups
None of the database users, tom, dick, or harry own the None of the database users, tom, dick, or harry own the
principals_data table. None of them has been directly granted select principals_data table. None of them has been directly granted select
permissions on the table. Only the programmers group has been permissions on the table. Only the programmers group has been
granted permissions and tom is a member of that group. granted permissions and tom is a member of that group.
Therefore, was the query result expected? Therefore, was the query result expected?
Yes. tom gained rightful access to the table. Yes. tom gained rightful access to the table.
If the table permissions had been granted to public, instead of If the table permissions had been granted to public, instead of
programmers, what do you think would happen to the query for programmers, what do you think would happen to the query for
harry who is in the engineers group? harry who is in the engineers group?
In this case, harry (as well as tom and dick) would have In this case, harry (as well as tom and dick) would have
successful queries. Recall that all database users are successful queries. Recall that all database users are
members of the public group and, at most, one user-defined members of the public group and, at most, one user-defined
group. group.
g. In Window A as the sa, revoke select permission on the principals_data table g. In Window A as the sa, revoke select permission on the principals_data table
from the programmers group as shown:. from the programmers group as shown:.
revoke select on principals_data from programmers revoke select on principals_data from programmers
h. In Window B, as tom, issue the select statement against the principals_data table h. In Window B, as tom, issue the select statement against the principals_data table
again. again.
Msg 10330, Level 14, State 1: Msg 10330, Level 14, State 1:
Server 'DUB103_2K', Line 1: Server 'DUB103_2K', Line 1:
SELECT permission denied on object principals_data, database my_db, SELECT permission denied on object principals_data, database my_db,
owner dbo owner dbo
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 13 - 7 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 13 - 7
Task 3: Creating User-defined Roles and Assigning to Logins Task 3: Creating User-defined Roles and Assigning to Logins
Description In this task, you will create user-defined roles and assign to logins. Description In this task, you will create user-defined roles and assign to logins.
Procedure 1. Create three new logins to the Adaptive Server. Procedure 1. Create three new logins to the Adaptive Server.
a. In Window A, connect to Adaptive Server as the sa. a. In Window A, connect to Adaptive Server as the sa.
isql -Usa -P isql -Usa -P
2. Create user-defined roles and grant permissions to the roles. 2. Create user-defined roles and grant permissions to the roles.
a. From the master database, create three user-defined roles called principals, a. From the master database, create three user-defined roles called principals,
teachers, and students. teachers, and students.
use master use master
b. Grant the principals role to the login tom. b. Grant the principals role to the login tom.
grant role principals to tom grant role principals to tom
c. Grant the teachers role to the login dick. c. Grant the teachers role to the login dick.
grant role teachers to dick grant role teachers to dick
d. Grant the students role to the login harry. d. Grant the students role to the login harry.
grant role students to harry grant role students to harry
e. Verify that each role has been properly distributed to the users by using e. Verify that each role has been properly distributed to the users by using
sp_displayroles. sp_displayroles.
sp_displayroles tom sp_displayroles tom
Lab Solution 13 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 13 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 13: Implementing Roles, Object Permissions, and Groups Module 13: Implementing Roles, Object Permissions, and Groups
3. Grant object permissions to the user-defined roles. 3. Grant object permissions to the user-defined roles.
a. Continuing in Window A as the sa, access the my_db database. a. Continuing in Window A as the sa, access the my_db database.
use my_db use my_db
b. Grant the principals role select permission on the principals_data table and then b. Grant the principals role select permission on the principals_data table and then
verify by using sp_helprotect. verify by using sp_helprotect.
grant select on principals_data to principals grant select on principals_data to principals
grantor grantee type action object column grantor grantee type action object column
grantable grantable
------- ---------- ----- ------ --------------- ------ ------- ------- ---------- ----- ------ --------------- ------ -------
-- --
dbo principals Grant Select principals_data All FALSE dbo principals Grant Select principals_data All FALSE
c. Grant the teachers role select permission on the teachers_data table and then c. Grant the teachers role select permission on the teachers_data table and then
verify. verify.
grant select on teachers_data to teachers grant select on teachers_data to teachers
grantor grantee type action object column grantable grantor grantee type action object column grantable
------- -------- ----- ------ ------------- ------ --------- ------- -------- ----- ------ ------------- ------ ---------
dbo teachers Grant Select teachers_data All FALSE dbo teachers Grant Select teachers_data All FALSE
d. Grant the students role select permission on the students_data table and then d. Grant the students role select permission on the students_data table and then
verify. verify.
grant select on students_data to students grant select on students_data to students
grantor grantee type action object column grantable grantor grantee type action object column grantable
------- -------- ----- ------ ------------- ------ --------- ------- -------- ----- ------ ------------- ------ ---------
dbo students Grant Select students_data All FALSE dbo students Grant Select students_data All FALSE
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 13 - 9 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 13 - 9
4. Test the new roles that have just been created. 4. Test the new roles that have just been created.
a. In Window B, connect to Adaptive Server with the login harry (password friday). a. In Window B, connect to Adaptive Server with the login harry (password friday).
isql -Uharry -Pfriday isql -Uharry -Pfriday
b. Verify that harry accesses the my_db database as his default database. b. Verify that harry accesses the my_db database as his default database.
select db_name() select db_name()
------------------------------ ------------------------------
my_db my_db
c. Execute a select statement against the students_data table. c. Execute a select statement against the students_data table.
select * from students_data select * from students_data
Msg 10330, Level 14, State 1: Msg 10330, Level 14, State 1:
Server 'DUB103_2K', Line 1: Server 'DUB103_2K', Line 1:
SELECT permission denied on object students_data, database SELECT permission denied on object students_data, database
my_db, owner dbo my_db, owner dbo
Was the query successful for harry? Was the query successful for harry?
No. No.
select permission against the students_data table has already been select permission against the students_data table has already been
granted to the students role and harry has that role. Why can’t harry granted to the students role and harry has that role. Why can’t harry
access the table? access the table?
The students role was successfully created and assigned to The students role was successfully created and assigned to
harry but the role was not set up to be activated at login. harry but the role was not set up to be activated at login.
Therefore harry must manually enable the role. Therefore harry must manually enable the role.
d. Verify that the students role is not currently enabled for harry by using d. Verify that the students role is not currently enabled for harry by using
sp_activeroles. sp_activeroles.
sp_activeroles sp_activeroles
e. Enable the students role for harry and verify. e. Enable the students role for harry and verify.
set role students on set role students on
Lab Solution 13 - 10 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 13 - 10 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 13: Implementing Roles, Object Permissions, and Groups Module 13: Implementing Roles, Object Permissions, and Groups
f. Execute the select statement against the students_data table again. f. Execute the select statement against the students_data table again.
select * from students_data select * from students_data
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 13 - 11 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 13 - 11
Task 4: Examining Role Hierarchies and Test Role and Object Task 4: Examining Role Hierarchies and Test Role and Object
Permissions Permissions
Description In this task, you will examine role hierarchies and test role and object permissions. Description In this task, you will examine role hierarchies and test role and object permissions.
b. In Window A, where the sa is connected to Adaptive Server, create a role within a b. In Window A, where the sa is connected to Adaptive Server, create a role within a
role by granting the teachers role to the principals role. role by granting the teachers role to the principals role.
grant role teachers to principals grant role teachers to principals
c. Next, create another role within a role by granting the students role to the teachers c. Next, create another role within a role by granting the students role to the teachers
role. role.
grant role students to teachers grant role students to teachers
2. Verify the role hierarchy by using sp_displayroles. 2. Verify the role hierarchy by using sp_displayroles.
a. Verify that the students role does not include any other roles. a. Verify that the students role does not include any other roles.
sp_displayroles students sp_displayroles students
b. Verify that the teachers role includes the students role. b. Verify that the teachers role includes the students role.
sp_displayroles teachers sp_displayroles teachers
c. Determine which roles the principals role includes. (Hint: use the expand_down c. Determine which roles the principals role includes. (Hint: use the expand_down
argument to sp_displayroles.) argument to sp_displayroles.)
Lab Solution 13 - 12 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 13 - 12 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 13: Implementing Roles, Object Permissions, and Groups Module 13: Implementing Roles, Object Permissions, and Groups
Role Name Parent Role Name Role Name Parent Role Name
Level Level
------------------------------ ------------------------------ ------------------------------ ------------------------------
------ ------
teachers principals teachers principals
1 1
students teachers students teachers
2 2
What roles does the principals role include? What roles does the principals role include?
The principals role includes the teachers and students roles. The principals role includes the teachers and students roles.
Only the teachers role, not the students role, was explicitly granted Only the teachers role, not the students role, was explicitly granted
to the principals role. Yet the principals role includes the students to the principals role. Yet the principals role includes the students
role. Explain. role. Explain.
Any role includes the roles explicitly granted to it. By Any role includes the roles explicitly granted to it. By
extension, a role also implicitly includes the roles granted to extension, a role also implicitly includes the roles granted to
its included roles. its included roles.
b. Verify that tom accesses the my_db database as his default database. b. Verify that tom accesses the my_db database as his default database.
select db_name() select db_name()
------------------------------ ------------------------------
my_db my_db
c. Verify that tom is configured with the principals role by using sp_displaylogin. c. Verify that tom is configured with the principals role by using sp_displaylogin.
sp_displaylogin sp_displaylogin
Suid: 3 Suid: 3
Loginame: tom Loginame: tom
Fullname: Fullname:
Default Database: my_db Default Database: my_db
Default Language: Default Language:
Auto Login Script: Auto Login Script:
Configured Authorization: Configured Authorization:
principals (default OFF) principals (default OFF)
Locked: NO Locked: NO
Date of Last Password Change: Oct 6 2005 2:49AM Date of Last Password Change: Oct 6 2005 2:49AM
Password expiration interval: 0 Password expiration interval: 0
Password expired: NO Password expired: NO
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 13 - 13 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 13 - 13
d. Try to enable the students role. d. Try to enable the students role.
set role students on set role students on
Msg 10319, Level 14, State 1: Msg 10319, Level 14, State 1:
Server 'DUB103_2K', Line 1: Server 'DUB103_2K', Line 1:
SET ROLE fails. The caller is not granted with the specified SET ROLE fails. The caller is not granted with the specified
role. Please role. Please
contact a user with System Security Officer (SSO) role for contact a user with System Security Officer (SSO) role for
help. help.
tom has the principals role and you previously verified that the tom has the principals role and you previously verified that the
principals role includes the students role (via the teachers role). principals role includes the students role (via the teachers role).
Explain why tom can not directly activate the students role. Explain why tom can not directly activate the students role.
A user can only enable the roles that are explicitly assigned A user can only enable the roles that are explicitly assigned
to them. tom does not explicitly have the students role (nor to them. tom does not explicitly have the students role (nor
the teachers role), but the principals role includes the teachers the teachers role), but the principals role includes the teachers
role which includes the students role. Therefore by simply role which includes the students role. Therefore by simply
enabling his configured role, principals, tom will have the enabling his configured role, principals, tom will have the
other two roles. other two roles.
f. Reconfirm that the students_data table has select permissions granted to users with f. Reconfirm that the students_data table has select permissions granted to users with
the students role. the students role.
sp_helprotect students_data sp_helprotect students_data
grantor grantee type action object column grantable grantor grantee type action object column grantable
------- -------- ----- ------ ------------- ------ --------- ------- -------- ----- ------ ------------- ------ ---------
dbo students Grant Select students_data All FALSE dbo students Grant Select students_data All FALSE
g. Execute a select statement against the students_data table. g. Execute a select statement against the students_data table.
select * from students_data select * from students_data
Lab Solution 13 - 14 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 13 - 14 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 13: Implementing Roles, Object Permissions, and Groups Module 13: Implementing Roles, Object Permissions, and Groups
i. Execute the select statement against the students_data table again. i. Execute the select statement against the students_data table again.
select * from students_data select * from students_data
Msg 10330, Level 14, State 1: Msg 10330, Level 14, State 1:
Server 'DUB103_2K', Line 1: Server 'DUB103_2K', Line 1:
SELECT permission denied on object students_data, database SELECT permission denied on object students_data, database
my_db, owner dbo my_db, owner dbo
Are the roles and table permissions functioning as expected? Are the roles and table permissions functioning as expected?
Explain. Explain.
Yes. Yes.
4. Exit all client sessions with Adaptive Server. 4. Exit all client sessions with Adaptive Server.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 13 - 15 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 13 - 15
Lab Solution 13 - 16 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 13 - 16 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 14: Using Bulk Copy Utility Module 14: Using Bulk Copy Utility
Module 14: Using Bulk Copy Utility Module 14: Using Bulk Copy Utility
Lab 14: Using Bulk Copy Utility Lab 14: Using Bulk Copy Utility
Lab Setup You will be using your 2K page size Adaptive Server for this lab. Lab Setup You will be using your 2K page size Adaptive Server for this lab.
Note: You need to have completed previous labs in which you created a database named Note: You need to have completed previous labs in which you created a database named
my_db. If you did not finish those previous labs, please refer to the following instructions my_db. If you did not finish those previous labs, please refer to the following instructions
right before step 1 of this lab. right before step 1 of this lab.
Objectives After completing this lab, you should be able to: Objectives After completing this lab, you should be able to:
Become familiar with using the bulk copy (bcp) utility. Become familiar with using the bulk copy (bcp) utility.
Analyze the performance difference between fast and slow bcp. Analyze the performance difference between fast and slow bcp.
Description In this lab, you will learn how to use the bulk copy (bcp) utility, and you will analyze the Description In this lab, you will learn how to use the bulk copy (bcp) utility, and you will analyze the
performance difference between fast and slow bcp. performance difference between fast and slow bcp.
Task Outline 1. Creating a Table for Testing with bcp Task Outline 1. Creating a Table for Testing with bcp
2. Copying Data out and in Using Various Formats and Comparing Fast and Slow 2. Copying Data out and in Using Various Formats and Comparing Fast and Slow
bcp bcp
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 14 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 14 - 1
Note: If you have not completed the previous labs in which you Note: If you have not completed the previous labs in which you
should have created two database devices, data_dev and log_dev should have created two database devices, data_dev and log_dev
and a database named my_db, then issue the following commands and a database named my_db, then issue the following commands
now: (see script lab14_setup.sql) (substituting $SYBASE now: (see script lab14_setup.sql) (substituting $SYBASE
appropriately): appropriately):
disk init disk init
name = "data_dev", name = "data_dev",
physname = "$SYBASE/devices/data_dev.dat", physname = "$SYBASE/devices/data_dev.dat",
size = "4M" size = "4M"
go go
create database my_db on data_dev=4 log on log_dev=2 create database my_db on data_dev=4 log on log_dev=2
go go
For this lab, it would be useful to open two windows (“A” and “B”). For this lab, it would be useful to open two windows (“A” and “B”).
This allows you to have multiple client sessions with ASE This allows you to have multiple client sessions with ASE
simultaneously. simultaneously.
You should exit any active client sessions with Adaptive Server You should exit any active client sessions with Adaptive Server
before continuing. before continuing.
Lab Solution 14 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 14 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 14: Using Bulk Copy Utility Module 14: Using Bulk Copy Utility
Task 1: Create a Table for Testing with bcp Task 1: Create a Table for Testing with bcp
Description In this task, you will create a table for testing with bcp. Description In this task, you will create a table for testing with bcp.
a. Examine the characteristics of the my_db database by using sp_helpdb. a. Examine the characteristics of the my_db database by using sp_helpdb.
sp_helpdb sp_helpdb
name db_size owner dbid created name db_size owner dbid created
status status
-------------- ------------- ----- ------ ------------------ -------------- ------------- ----- ------ ------------------
---------------------------------------------------------- ----------------------------------------------------------
---------- ----------
master 13.0 MB sa 1 Sep 30, 2005 master 13.0 MB sa 1 Sep 30, 2005
mixed log and data mixed log and data
model 3.0 MB sa 3 Sep 30, 2005 model 3.0 MB sa 3 Sep 30, 2005
mixed log and data mixed log and data
my_db 6.0 MB sa 5 Oct 04, 2005 my_db 6.0 MB sa 5 Oct 04, 2005
select into/bulkcopy/pllsort select into/bulkcopy/pllsort
pubs2 4.0 MB sa 4 Sep 30, 2005 pubs2 4.0 MB sa 4 Sep 30, 2005
trunc log on chkpt, mixed log and data trunc log on chkpt, mixed log and data
sybsystemdb 3.0 MB sa 31513 Sep 30, 2005 sybsystemdb 3.0 MB sa 31513 Sep 30, 2005
mixed log and data mixed log and data
sybsystemprocs 120.0 MB sa 31514 Sep 30, 2005 sybsystemprocs 120.0 MB sa 31514 Sep 30, 2005
trunc log on chkpt, mixed log and data trunc log on chkpt, mixed log and data
tempdb 4.0 MB sa 2 Oct 05, 2005 tempdb 4.0 MB sa 2 Oct 05, 2005
select into/bulkcopy/pllsort, trunc log on chkpt, mixed select into/bulkcopy/pllsort, trunc log on chkpt, mixed
log and data log and data
(1 row affected) (1 row affected)
(return status = 0) (return status = 0)
Which database options are set for the my_db database? Which database options are set for the my_db database?
The select into/bulkcopy/pllsort option is set. The select into/bulkcopy/pllsort option is set.
For this lab, you need the select into/bulkcopy/pllsort option active to For this lab, you need the select into/bulkcopy/pllsort option active to
create a table using select into syntax. You need the trunc log on create a table using select into syntax. You need the trunc log on
chkpt option set to keep the log from filling up during table inserts chkpt option set to keep the log from filling up during table inserts
and bcp in operations in this lab. and bcp in operations in this lab.
If the select into/bulkcopy/pllsort and trunc log on chkpt options are If the select into/bulkcopy/pllsort and trunc log on chkpt options are
not set, then set both of them now by using sp_dboption . not set, then set both of them now by using sp_dboption .
sp_dboption my_db, "select into/bulkcopy/pllsort", true sp_dboption my_db, "select into/bulkcopy/pllsort", true
sp_dboption my_db, "trunc log on chkpt", true sp_dboption my_db, "trunc log on chkpt", true
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 14 - 3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 14 - 3
2. Create a table to use for testing bcp operations. 2. Create a table to use for testing bcp operations.
a. Access the my_db database. a. Access the my_db database.
use my_db use my_db
b. Create and populate a table named test_authors by issuing the following T-SQL b. Create and populate a table named test_authors by issuing the following T-SQL
commands: commands:
select * into test_authors select * into test_authors
from pubs2..authors from pubs2..authors
c. Add more rows to the newly created table by issuing the following T-SQL c. Add more rows to the newly created table by issuing the following T-SQL
commands: commands:
The “go 500” is a perfectly valid T-SQL statement. It tells Adaptive The “go 500” is a perfectly valid T-SQL statement. It tells Adaptive
Server to perform all the commands in the batch 500 times. Server to perform all the commands in the batch 500 times.
d. Verify that the table test_authors was created by using sp_help. d. Verify that the table test_authors was created by using sp_help.
Lab Solution 14 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 14 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 14: Using Bulk Copy Utility Module 14: Using Bulk Copy Utility
0 0
state char 2 NULL NULL 1 NULL NULL state char 2 NULL NULL 1 NULL NULL
NULL NULL NULL NULL
0 0
country varchar 12 NULL NULL 1 NULL NULL country varchar 12 NULL NULL 1 NULL NULL
NULL NULL NULL NULL
0 0
postalcode char 10 NULL NULL 1 NULL NULL postalcode char 10 NULL NULL 1 NULL NULL
NULL NULL NULL NULL
0 0
Object does not have any indexes. Object does not have any indexes.
No defined keys for this object. No defined keys for this object.
name type partition_type partitions partition_keys name type partition_type partitions partition_keys
------------ ---------- -------------- ----------- -------------- ------------ ---------- -------------- ----------- --------------
test_authors base table roundrobin 1 NULL test_authors base table roundrobin 1 NULL
Partition_Conditions Partition_Conditions
-------------------- --------------------
NULL NULL
Does the table have any indexes? Does the table have any indexes?
No. No.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 14 - 5 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 14 - 5
Task 2: Copy Data out and in using Various Formats and Task 2: Copy Data out and in using Various Formats and
Comparing Fast and Slow bcp Comparing Fast and Slow bcp
Description In this task, you will copy data out, in using various formats and you will compare fast and Description In this task, you will copy data out, in using various formats and you will compare fast and
slow bcp. slow bcp.
Procedure 1. Copy data out from a table by using bcp with various formats. Procedure 1. Copy data out from a table by using bcp with various formats.
a. In Window B, change the directory to $HOME/sa. a. In Window B, change the directory to $HOME/sa.
cd $HOME/sa cd $HOME/sa
b. Copy out the data from my_db..test_authors to a file named b. Copy out the data from my_db..test_authors to a file named
test_authors.bcp.native by using bcp with native format. test_authors.bcp.native by using bcp with native format.
bcp my_db..test_authors out test_authors.bcp.native -Usa -P -n bcp my_db..test_authors out test_authors.bcp.native -Usa -P -n
c. Copy out the data from my_db..test_authors to a file named c. Copy out the data from my_db..test_authors to a file named
test_authors.bcp.character by using bcp with character format. test_authors.bcp.character by using bcp with character format.
bcp my_db..test_authors out test_authors.bcp.character -Usa -P bcp my_db..test_authors out test_authors.bcp.character -Usa -P
-c -c
Lab Solution 14 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 14 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 14: Using Bulk Copy Utility Module 14: Using Bulk Copy Utility
d. Compare the file sizes of the two bcp output files by using the Unix ls -l d. Compare the file sizes of the two bcp output files by using the Unix ls -l
command. command.
ls -l test* ls -l test*
-rw-r--r-- 1 dub101 sybase 918333 Oct 7 08:29 -rw-r--r-- 1 dub101 sybase 918333 Oct 7 08:29
test_authors.bcp.character test_authors.bcp.character
-rw-r--r-- 1 dub101 sybase 1022040 Oct 7 08:26 -rw-r--r-- 1 dub101 sybase 1022040 Oct 7 08:26
test_authors.bcp.native test_authors.bcp.native
Does the bcp character format affect the output file size for identical Does the bcp character format affect the output file size for identical
data? data?
Yes. In this case the native format file is about 100,000 bytes Yes. In this case the native format file is about 100,000 bytes
(100 KB) smaller than the character format file, roughly (100 KB) smaller than the character format file, roughly
10% smaller. 10% smaller.
e. Copy out the data from my_db..test_authors to a file named e. Copy out the data from my_db..test_authors to a file named
test_authors.bcp.comma by using bcp with character format and specifying a test_authors.bcp.comma by using bcp with character format and specifying a
comma (,) as the field terminator. comma (,) as the field terminator.
bcp my_db..test_authors out test_authors.bcp.comma -Usa -P -c - bcp my_db..test_authors out test_authors.bcp.comma -Usa -P -c -
t , t ,
f. Compare the file sizes of the three bcp output files by using the Unix ls -l f. Compare the file sizes of the three bcp output files by using the Unix ls -l
command. command.
ls -l test* ls -l test*
-rw-r--r-- 1 dub101 sybase 918333 Oct 7 08:29 -rw-r--r-- 1 dub101 sybase 918333 Oct 7 08:29
test_authors.bcp.character test_authors.bcp.character
-rw-r--r-- 1 dub101 sybase 918333 Oct 7 08:32 -rw-r--r-- 1 dub101 sybase 918333 Oct 7 08:32
test_authors.bcp.comma test_authors.bcp.comma
-rw-r--r-- 1 dub101 sybase 1022040 Oct 7 08:26 -rw-r--r-- 1 dub101 sybase 1022040 Oct 7 08:26
test_authors.bcp.native test_authors.bcp.native
Does the bcp field terminator affect the output file size for identical Does the bcp field terminator affect the output file size for identical
data when using the same format (in this case, character format)? data when using the same format (in this case, character format)?
No. The two files, test_authors.bcp.character and No. The two files, test_authors.bcp.character and
test_authors.bcp.comma, are the same size. test_authors.bcp.comma, are the same size.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 14 - 7 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 14 - 7
2. Copy data into a table by using bcp data files with various formats. 2. Copy data into a table by using bcp data files with various formats.
a. In Window A, as the sa connected to Adaptive Server in the my_db database, a. In Window A, as the sa connected to Adaptive Server in the my_db database,
remove all rows from the table test_authors by using the truncate table command. remove all rows from the table test_authors by using the truncate table command.
truncate table test_authors truncate table test_authors
b. In Window B, copy data into my_db..test_authors from the file named b. In Window B, copy data into my_db..test_authors from the file named
test_authors.bcp.native by using bcp with native format and a batch size of 1000. test_authors.bcp.native by using bcp with native format and a batch size of 1000.
Your bcp in operations may temporarily suspend and you may see Your bcp in operations may temporarily suspend and you may see
messages such as: messages such as:
Space available in the log segment has fallen Space available in the log segment has fallen
critically low in database 'my_db. critically low in database 'my_db.
The transaction log in database my_db is almost full. The transaction log in database my_db is almost full.
Ignore these messages - the database option, trunc log on chkpt, Ignore these messages - the database option, trunc log on chkpt,
allows the server to clear out the transaction log after each batch allows the server to clear out the transaction log after each batch
(1000 rows). Your operation will continue in a few moments. (1000 rows). Your operation will continue in a few moments.
Write down the bcp Clock Time (ms.): total. Write down the bcp Clock Time (ms.): total.
(Your results may vary from the solutions.) (Your results may vary from the solutions.)
In this case the clock time was 377 ms. In this case the clock time was 377 ms.
Lab Solution 14 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 14 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 14: Using Bulk Copy Utility Module 14: Using Bulk Copy Utility
c. In Window A, as the sa, remove all rows from the table test_authors by using the c. In Window A, as the sa, remove all rows from the table test_authors by using the
truncate table command. truncate table command.
truncate table test_authors truncate table test_authors
d. In Window B, copy data into my_db..test_authors from the file named d. In Window B, copy data into my_db..test_authors from the file named
test_authors.bcp.character by using bcp with character format and a batch size of test_authors.bcp.character by using bcp with character format and a batch size of
1000. 1000.
bcp my_db..test_authors in test_authors.bcp.character -Usa -P - bcp my_db..test_authors in test_authors.bcp.character -Usa -P -
c -b 1000 c -b 1000
Write down the bcp Clock Time (ms.): total. Write down the bcp Clock Time (ms.): total.
(Your results may vary from the solutions.) (Your results may vary from the solutions.)
In this case the clock time was 375 ms. In this case the clock time was 375 ms.
For this relatively small table, is there any significant performance For this relatively small table, is there any significant performance
improvement of using the native format data versus the character improvement of using the native format data versus the character
format data? (Note: your results may be different from those shown format data? (Note: your results may be different from those shown
in the solutions.) in the solutions.)
In this case, No. Native format ran in 377 ms. while In this case, No. Native format ran in 377 ms. while
character format took 375 ms. – 2 ms slower. Keep in mind character format took 375 ms. – 2 ms slower. Keep in mind
this is a relatively small data sample and your results may this is a relatively small data sample and your results may
vary, especially with a heavy system load. In general though, vary, especially with a heavy system load. In general though,
native format is faster than character format. native format is faster than character format.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 14 - 9 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 14 - 9
3. Analyze the impact of slow bcp. 3. Analyze the impact of slow bcp.
In step 2d, you noted that the test_authors table had no indexes. In step 2d, you noted that the test_authors table had no indexes.
Combined with the database option, select into/bulkcopy/pllsort, Combined with the database option, select into/bulkcopy/pllsort,
being active, the server was able to perform fast bcp when copying being active, the server was able to perform fast bcp when copying
the data into the table in step 2. the data into the table in step 2.
Now you will create an index on the table and analyze its impact Now you will create an index on the table and analyze its impact
when copying data in with bcp. when copying data in with bcp.
a. In Window A, as the sa, remove all rows from the table test_authors by using the a. In Window A, as the sa, remove all rows from the table test_authors by using the
truncate table command. truncate table command.
truncate table test_authors truncate table test_authors
c. Verify that the index was created by using sp_helpindex. c. Verify that the index was created by using sp_helpindex.
sp_helpindex test_authors sp_helpindex test_authors
Object has the following indexes Object has the following indexes
Lab Solution 14 - 10 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 14 - 10 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 14: Using Bulk Copy Utility Module 14: Using Bulk Copy Utility
d. In Window B, copy data into my_db..test_authors from the file named d. In Window B, copy data into my_db..test_authors from the file named
test_authors.bcp.native by using bcp with native format and a batch size of 1000. test_authors.bcp.native by using bcp with native format and a batch size of 1000.
Note: You may see a warning about the transaction log becoming Note: You may see a warning about the transaction log becoming
full. But because you previously set the database option trunc log on full. But because you previously set the database option trunc log on
chkpt to true, Adaptive Server will automatically clear out the log chkpt to true, Adaptive Server will automatically clear out the log
momentarily. momentarily.
bcp my_db..test_authors in test_authors.bcp.native -Usa -P -n - bcp my_db..test_authors in test_authors.bcp.native -Usa -P -n -
b 1000 b 1000
Server Message: DUB101_2K - Msg 7415, Level 10, State 1: Server Message: DUB101_2K - Msg 7415, Level 10, State 1:
The transaction log in database my_db is almost full. Your The transaction log in database my_db is almost full. Your
transaction is being suspended until space is made available i transaction is being suspended until space is made available i
n the log. n the log.
Batch successfully bulk-copied to SQL Server. Batch successfully bulk-copied to SQL Server.
8000 rows sent to SQL Server. 8000 rows sent to SQL Server.
Batch successfully bulk-copied to SQL Server. Batch successfully bulk-copied to SQL Server.
9000 rows sent to SQL Server. 9000 rows sent to SQL Server.
Batch successfully bulk-copied to SQL Server. Batch successfully bulk-copied to SQL Server.
10000 rows sent to SQL Server. 10000 rows sent to SQL Server.
Batch successfully bulk-copied to SQL Server. Batch successfully bulk-copied to SQL Server.
11000 rows sent to SQL Server. 11000 rows sent to SQL Server.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 14 - 11 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 14 - 11
Write down the bcp Clock Time (ms.): total. Write down the bcp Clock Time (ms.): total.
(Your results may vary from the solutions.) (Your results may vary from the solutions.)
In this case the clock time was 33726 ms. In this case the clock time was 33726 ms.
Compare the clock speed with the value recorded in step 2b. For this Compare the clock speed with the value recorded in step 2b. For this
relatively small table, is there any significant performance relatively small table, is there any significant performance
degradation when loading the identical data with the presence of an degradation when loading the identical data with the presence of an
index? index?
Yes. The clock speed jumped from 377 ms (fast bcp with no Yes. The clock speed jumped from 377 ms (fast bcp with no
index) to 33726 ms. (slow bcp with the index) - more than 89 index) to 33726 ms. (slow bcp with the index) - more than 89
times slower. times slower.
4. Exit all client sessions with Adaptive Server. 4. Exit all client sessions with Adaptive Server.
Lab Solution 14 - 12 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 14 - 12 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 15: Overview of Automatic Recovery Module 15: Overview of Automatic Recovery
Module 15: Overview of Automatic Recovery Module 15: Overview of Automatic Recovery
Lab 15-1: Overview of Automatic Recovery Lab 15-1: Overview of Automatic Recovery
Lab Setup This is a pencil-and-paper activity. There is no setup for this lab. Lab Setup This is a pencil-and-paper activity. There is no setup for this lab.
Objectives After completing this lab, you should be able to: Objectives After completing this lab, you should be able to:
Analyze the effects of the recovery process Analyze the effects of the recovery process
Description In this lab, you will learn how to analyze the effects of the recovery process. Description In this lab, you will learn how to analyze the effects of the recovery process.
Task Outline 1. Examining Various Transaction Sequences and Predict the Results of Automatic Task Outline 1. Examining Various Transaction Sequences and Predict the Results of Automatic
Recovery Recovery
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 15 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 15 - 1
Task 1: Examining Various Transaction Sequences and Predict Task 1: Examining Various Transaction Sequences and Predict
the Results of Automatic Recovery the Results of Automatic Recovery
Description In this task, you will examine various transaction sequences and predict the results of Description In this task, you will examine various transaction sequences and predict the results of
automatic recovery. automatic recovery.
Procedure Procedure
DO NOT EXECUTE any of the commands in this lab. This is a DO NOT EXECUTE any of the commands in this lab. This is a
paper-and-pencil activity. paper-and-pencil activity.
1. Assume the transaction log (syslogs table) on disk has the following records at the time 1. Assume the transaction log (syslogs table) on disk has the following records at the time
of a system failure: of a system failure:
begin tran begin tran
delete table1 where... delete table1 where...
insert table2 values (...) insert table2 values (...)
The tables on disk have the delete but not the insert. The tables on disk have the delete but not the insert.
Will any of the attempted data modifications (the delete and/or the Will any of the attempted data modifications (the delete and/or the
insert) appear in the affected tables, table1 and table2, after insert) appear in the affected tables, table1 and table2, after
recovery? Explain. recovery? Explain.
No. The log shows a transaction that was not committed for No. The log shows a transaction that was not committed for
this multi-statement transaction. Adaptive Server guarantees this multi-statement transaction. Adaptive Server guarantees
that neither the delete nor the insert will be present in their that neither the delete nor the insert will be present in their
respective tables after recovery. Both tables will appear as respective tables after recovery. Both tables will appear as
they did before the “begin tran” statement. they did before the “begin tran” statement.
What work will Adaptive Server have to perform after recovery? What work will Adaptive Server have to perform after recovery?
The delete will have to be rolled back because it was written The delete will have to be rolled back because it was written
to the table on disk. to the table on disk.
2. For each of the following sequences of commands, predict what will happen if the 2. For each of the following sequences of commands, predict what will happen if the
server experiences a power failure after the commands are issued and then the server is server experiences a power failure after the commands are issued and then the server is
rebooted. rebooted.
a. Sequence A: a. Sequence A:
begin transaction A begin transaction A
insert tableA values (...) insert tableA values (...)
commit transaction commit transaction
go go
Lab Solution 15 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 15 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 15: Overview of Automatic Recovery Module 15: Overview of Automatic Recovery
Will the inserted row be present in the table tableA after recovery? Will the inserted row be present in the table tableA after recovery?
Explain. Explain.
Yes. The log contains a completed transaction, which was Yes. The log contains a completed transaction, which was
written to disk following the “go” after the commit written to disk following the “go” after the commit
statement. Therefore the inserted row will be in the table. If statement. Therefore the inserted row will be in the table. If
the inserted row did not actually make it to disk in the table the inserted row did not actually make it to disk in the table
tableA (for example, by an automatic checkpoint) before the tableA (for example, by an automatic checkpoint) before the
server came down, then Adaptive Server guarantees that the server came down, then Adaptive Server guarantees that the
transaction will be rolled forward and the data will appear in transaction will be rolled forward and the data will appear in
the table. the table.
b. Sequence B: b. Sequence B:
begin transaction B begin transaction B
insert tableB values (...) insert tableB values (...)
go go
Will the inserted row be present in the table tableB after recovery? Will the inserted row be present in the table tableB after recovery?
Explain. Explain.
No. In this scenario, the transaction was not committed, No. In this scenario, the transaction was not committed,
therefore the inserted row will not be in the table after therefore the inserted row will not be in the table after
recovery. There are several sub-scenarios: recovery. There are several sub-scenarios:
1. If the log records and the inserted row actually was 1. If the log records and the inserted row actually was
written to disk (for example, by an automatic checkpoint) written to disk (for example, by an automatic checkpoint)
before the server came down, then Adaptive Server before the server came down, then Adaptive Server
guarantees that the transaction will be rolled back and the guarantees that the transaction will be rolled back and the
inserted row will not appear in the table. inserted row will not appear in the table.
2. It is possible that neither the log records nor the inserted 2. It is possible that neither the log records nor the inserted
row data was written to disk in this scenario (no manual or row data was written to disk in this scenario (no manual or
automatic checkpoint). The net effect is still the same - the automatic checkpoint). The net effect is still the same - the
inserted row will not appear in the table. inserted row will not appear in the table.
Would the inserted row be present in the table tableB after recovery Would the inserted row be present in the table tableB after recovery
if the begin tran statement was not used? Explain. if the begin tran statement was not used? Explain.
Yes. In the default state of unchained mode, this sequence Yes. In the default state of unchained mode, this sequence
represents a complete transaction. The log records are represents a complete transaction. The log records are
flushed to disk following the execution of the “go”. Therefore flushed to disk following the execution of the “go”. Therefore
the inserted row will be in the table after recovery. If the the inserted row will be in the table after recovery. If the
inserted row did not actually make it to disk in the table inserted row did not actually make it to disk in the table
tableB (for example, by an automatic checkpoint) before the tableB (for example, by an automatic checkpoint) before the
server came down, then Adaptive Server guarantees that the server came down, then Adaptive Server guarantees that the
transaction will be rolled forward and the data will appear in transaction will be rolled forward and the data will appear in
the table. the table.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 15 - 3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 15 - 3
c. Sequence C: c. Sequence C:
begin transaction C begin transaction C
insert tableC values (...) insert tableC values (...)
go go
checkpoint checkpoint
go go
Will the inserted row be present in the table tableC after recovery? Will the inserted row be present in the table tableC after recovery?
Explain. Explain.
No. Even though the checkpoint flushed both the log records No. Even though the checkpoint flushed both the log records
and the inserted row to disk, the key point is that the and the inserted row to disk, the key point is that the
transaction remains uncommitted. The server will roll back transaction remains uncommitted. The server will roll back
the transaction and the inserted row will not be in the table. the transaction and the inserted row will not be in the table.
d. Sequence D: d. Sequence D:
checkpoint checkpoint
go go
Will the inserted row be present in the table tableD after recovery? Will the inserted row be present in the table tableD after recovery?
Explain. Explain.
Yes. For this committed transaction, the server guarantees Yes. For this committed transaction, the server guarantees
that the inserted row will be in the table. that the inserted row will be in the table.
Does the presence of the manual checkpoint affect the recoverability Does the presence of the manual checkpoint affect the recoverability
of this transaction? Explain. of this transaction? Explain.
No. The log records for this committed transaction are No. The log records for this committed transaction are
flushed to disk following the “go”. Recoverability is flushed to disk following the “go”. Recoverability is
guaranteed at that point. The checkpoint simply flushes any guaranteed at that point. The checkpoint simply flushes any
additional dirty pages, such as the data pages, to disk. This additional dirty pages, such as the data pages, to disk. This
may help speed up the recovery process by minimizing the may help speed up the recovery process by minimizing the
actual work Adaptive Server has to perform during recovery actual work Adaptive Server has to perform during recovery
to ensure that the data is in the table. to ensure that the data is in the table.
Lab Solution 15 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 15 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 16: Checking and Fixing Database Consistency Module 16: Checking and Fixing Database Consistency
Module 16: Checking and Fixing Database Consistency Module 16: Checking and Fixing Database Consistency
Lab 16: Checking and Fixing Database Consistency Lab 16: Checking and Fixing Database Consistency
Lab Setup You will be using your 2K page size Adaptive Server for this lab. Lab Setup You will be using your 2K page size Adaptive Server for this lab.
Note: You need to have completed previous labs in which you created a database named Note: You need to have completed previous labs in which you created a database named
my_db. If you did not finish those previous labs, then please refer to the following my_db. If you did not finish those previous labs, then please refer to the following
instructions right before step 1 of this lab. instructions right before step 1 of this lab.
Objectives After completing this lab, you should be able to: Objectives After completing this lab, you should be able to:
Gain experience with some of the standard (“out-of-the-box”) dbcc utility commands Gain experience with some of the standard (“out-of-the-box”) dbcc utility commands
such as dbcc checkdb and dbcc checkalloc. such as dbcc checkdb and dbcc checkalloc.
Understand how to set up the dbccdb database and use dbcc checkstorage. Understand how to set up the dbccdb database and use dbcc checkstorage.
Description In this lab, you will learn how to use standard dbcc utility commands, and you will Description In this lab, you will learn how to use standard dbcc utility commands, and you will
understand how to set up the dbccdb database. understand how to set up the dbccdb database.
Task Outline 1. Executing Standard dbcc Commands Task Outline 1. Executing Standard dbcc Commands
2. Installing the Sybase-Supplied Optional Database, dbccdb 2. Installing the Sybase-Supplied Optional Database, dbccdb
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 16 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 16 - 1
Note: If you have not completed the previous labs in which you Note: If you have not completed the previous labs in which you
created database devices and the my_db database then issue the created database devices and the my_db database then issue the
following commands now (substituting $SYBASE/ appropriately). following commands now (substituting $SYBASE/ appropriately).
disk init disk init
name = "data_dev", name = "data_dev",
physname = "$SYBASE/devices/data_dev.dat", physname = "$SYBASE/devices/data_dev.dat",
size = "4M" size = "4M"
go go
create database my_db on data_dev=4 log on log_dev=2 create database my_db on data_dev=4 log on log_dev=2
go go
exec sp_addlogin tom, "friday", my_db exec sp_addlogin tom, "friday", my_db
exec sp_addlogin dick, "friday", my_db exec sp_addlogin dick, "friday", my_db
exec sp_addlogin harry, "friday", my_db exec sp_addlogin harry, "friday", my_db
go go
use my_db use my_db
go go
For this lab, it would be useful to open two windows (“A” and “B”). For this lab, it would be useful to open two windows (“A” and “B”).
This allows you to have multiple client sessions with ASE This allows you to have multiple client sessions with ASE
simultaneously. simultaneously.
You should exit any active client sessions with Adaptive Server You should exit any active client sessions with Adaptive Server
before continuing. before continuing.
Lab Solution 16 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 16 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 16: Checking and Fixing Database Consistency Module 16: Checking and Fixing Database Consistency
Task 1: Executing Standard dbcc Commands Task 1: Executing Standard dbcc Commands
Description In this task, you will execute standard dbcc commands, such as dbcc checkdb and dbcc Description In this task, you will execute standard dbcc commands, such as dbcc checkdb and dbcc
checkalloc. checkalloc.
Procedure Procedure
1. As a user without privileges, try to use standard dbcc commands to check database 1. As a user without privileges, try to use standard dbcc commands to check database
consistency. consistency.
a. In Window A, connect to Adaptive Server as the user tom (password friday). a. In Window A, connect to Adaptive Server as the user tom (password friday).
isql -Utom -Pfriday isql -Utom -Pfriday
b. Determine whether tom has any system roles such as the sso_role by using the b. Determine whether tom has any system roles such as the sso_role by using the
show_role() built-in function. show_role() built-in function.
select show_role() select show_role()
--------------------------------------------------------------- ---------------------------------------------------------------
NULL NULL
c. Determine whether tom is the dbo for the my_db database by using sp_helpuser. c. Determine whether tom is the dbo for the my_db database by using sp_helpuser.
sp_helpuser sp_helpuser
Is tom the dbo of the my_db database or does he have any system Is tom the dbo of the my_db database or does he have any system
roles such as the sso_role? roles such as the sso_role?
No. No.
d. As tom, try to execute dbcc checkdb and dbcc checkalloc. d. As tom, try to execute dbcc checkdb and dbcc checkalloc.
dbcc checkdb dbcc checkdb
Checking current database: Logical pagesize is 2048 bytes Checking current database: Logical pagesize is 2048 bytes
Msg 10302, Level 14, State 1: Msg 10302, Level 14, State 1:
Server 'DUB201_2K', Line 1: Server 'DUB201_2K', Line 1:
Only the DBO of database 'my_db' or a user with System Only the DBO of database 'my_db' or a user with System
Administrator (SA) role can run this command. Administrator (SA) role can run this command.
DBCC execution completed. If DBCC printed error messages, DBCC execution completed. If DBCC printed error messages,
contact a user with System Administrator (SA) role. contact a user with System Administrator (SA) role.
Checking current database: Logical pagesize is 2048 bytes Checking current database: Logical pagesize is 2048 bytes
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 16 - 3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 16 - 3
Database 'my_db' is not in single user mode - may find spurious Database 'my_db' is not in single user mode - may find spurious
allocation problems due to transactions in progress. allocation problems due to transactions in progress.
Msg 10302, Level 14, State 1: Msg 10302, Level 14, State 1:
Server 'DUB201_2K', Line 1: Server 'DUB201_2K', Line 1:
Only the DBO of database 'my_db' or a user with System Only the DBO of database 'my_db' or a user with System
Administrator (SA) role Administrator (SA) role
can run this command. can run this command.
DBCC execution completed. If DBCC printed error messages, DBCC execution completed. If DBCC printed error messages,
contact a user with System Administrator (SA) role. contact a user with System Administrator (SA) role.
Can any user simply issue these dbcc commands? Can any user simply issue these dbcc commands?
No. No.
Who can issue these dbcc commands? Who can issue these dbcc commands?
The dbo of the database or any user with the sa_role active The dbo of the database or any user with the sa_role active
can issue these commands. can issue these commands.
2. As an user with privileges, use standard dbcc commands to check database 2. As an user with privileges, use standard dbcc commands to check database
consistency. consistency.
a. In Window A, exit the Adaptive Server session as tom and then connect as the user a. In Window A, exit the Adaptive Server session as tom and then connect as the user
sa. sa.
exit exit
c. Determine whether tom has any system roles such as the sso_role by using the c. Determine whether tom has any system roles such as the sso_role by using the
show_role() built-in function. show_role() built-in function.
select show_role() select show_role()
--------------------------------------------------------------- ---------------------------------------------------------------
sa_role sso_role oper_role sybase_ts_role sa_role sso_role oper_role sybase_ts_role
d. Check page allocation in the my_db database by using dbcc checkalloc. d. Check page allocation in the my_db database by using dbcc checkalloc.
dbcc checkalloc dbcc checkalloc
Checking current database: Logical pagesize is 2048 bytes Checking current database: Logical pagesize is 2048 bytes
Database 'my_db' is not in single user mode - may find spurious Database 'my_db' is not in single user mode - may find spurious
allocation problems due to transactions in progress. allocation problems due to transactions in progress.
*************************************************************** ***************************************************************
TABLE: sysobjects OBJID = 1 TABLE: sysobjects OBJID = 1
PARTITION ID=1 FIRST=1 ROOT=1 SORT=0 PARTITION ID=1 FIRST=1 ROOT=1 SORT=0
Data level: indid 0, partition 1. 3 Data pages allocated and 1 Data level: indid 0, partition 1. 3 Data pages allocated and 1
Extents allocated. Extents allocated.
PARTITION ID=1 FIRST=161 ROOT=160 SORT=1 PARTITION ID=1 FIRST=161 ROOT=160 SORT=1
Indid : 2, partition : 1. 2 Index pages allocated and 2 Extents Indid : 2, partition : 1. 2 Index pages allocated and 2 Extents
allocated. allocated.
PARTITION ID=1 FIRST=10 ROOT=9 SORT=0 PARTITION ID=1 FIRST=10 ROOT=9 SORT=0
Lab Solution 16 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 16 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 16: Checking and Fixing Database Consistency Module 16: Checking and Fixing Database Consistency
Indid : 3, partition : 1. 2 Index pages allocated and 1 Extents Indid : 3, partition : 1. 2 Index pages allocated and 1 Extents
allocated. allocated.
TOTAL # of extents = 4 TOTAL # of extents = 4
*************************************************************** ***************************************************************
TABLE: sysindexes OBJID = 2 TABLE: sysindexes OBJID = 2
PARTITION ID=2 FIRST=16 ROOT=16 SORT=0 PARTITION ID=2 FIRST=16 ROOT=16 SORT=0
Data level: indid 0, partition 2. 7 Data pages allocated and 1 Data level: indid 0, partition 2. 7 Data pages allocated and 1
Extents allocated. Extents allocated.
PARTITION ID=2 FIRST=34 ROOT=33 SORT=0 PARTITION ID=2 FIRST=34 ROOT=33 SORT=0
Indid : 2, partition : 2. 2 Index pages allocated and 1 Extents Indid : 2, partition : 2. 2 Index pages allocated and 1 Extents
allocated. allocated.
TOTAL # of extents = 2 TOTAL # of extents = 2
*************************************************************** ***************************************************************
Alloc page 256 (# of extent=32 used pages=58 ref pages=58) Alloc page 256 (# of extent=32 used pages=58 ref pages=58)
Alloc page 512 (# of extent=32 used pages=59 ref pages=55) Alloc page 512 (# of extent=32 used pages=59 ref pages=55)
Alloc page 768 (# of extent=32 used pages=181 ref pages=179) Alloc page 768 (# of extent=32 used pages=181 ref pages=179)
Alloc page 1024 (# of extent=32 used pages=249 ref pages=248) Alloc page 1024 (# of extent=32 used pages=249 ref pages=248)
Alloc page 1280 (# of extent=32 used pages=236 ref pages=235) Alloc page 1280 (# of extent=32 used pages=236 ref pages=235)
Alloc page 1536 (# of extent=32 used pages=30 ref pages=30) Alloc page 1536 (# of extent=32 used pages=30 ref pages=30)
Alloc page 1792 (# of extent=32 used pages=1 ref pages=0) Alloc page 1792 (# of extent=32 used pages=1 ref pages=0)
Alloc page 2048 (# of extent=32 used pages=7 ref pages=1) Alloc page 2048 (# of extent=32 used pages=7 ref pages=1)
Alloc page 2304 (# of extent=32 used pages=1 ref pages=0) Alloc page 2304 (# of extent=32 used pages=1 ref pages=0)
Alloc page 2560 (# of extent=32 used pages=1 ref pages=0) Alloc page 2560 (# of extent=32 used pages=1 ref pages=0)
Alloc page 2816 (# of extent=32 used pages=1 ref pages=0) Alloc page 2816 (# of extent=32 used pages=1 ref pages=0)
Total (# of extent=384 used pages=931 ref pages=897) in this Total (# of extent=384 used pages=931 ref pages=897) in this
database database
DBCC execution completed. If DBCC printed error messages, contact a DBCC execution completed. If DBCC printed error messages, contact a
user with System Administrator (SA) role. user with System Administrator (SA) role.
e. Perform additional consistency checking in the my_db database by using dbcc e. Perform additional consistency checking in the my_db database by using dbcc
checkdb. checkdb.
Checking current database: Logical pagesize is 2048 bytes Checking current database: Logical pagesize is 2048 bytes
Checking table 'sysobjects' (object ID 1): Logical page size is Checking table 'sysobjects' (object ID 1): Logical page size is
2048 bytes. 2048 bytes.
The total number of data pages in partition 'sysobjects_1' The total number of data pages in partition 'sysobjects_1'
(partition ID 1) is 3. (partition ID 1) is 3.
The total number of data pages in this table is 3. The total number of data pages in this table is 3.
Table has 41 data rows. Table has 41 data rows.
Checking table 'sysindexes' (object ID 2): Logical page size is Checking table 'sysindexes' (object ID 2): Logical page size is
2048 bytes. 2048 bytes.
The total number of data pages in partition 'sysindexes_2' The total number of data pages in partition 'sysindexes_2'
(partition ID 2) is 7. (partition ID 2) is 7.
The total number of data pages in this table is 7. The total number of data pages in this table is 7.
Table has 78 data rows. Table has 78 data rows.
Checking table 'syscolumns' (object ID 3): Logical page size is Checking table 'syscolumns' (object ID 3): Logical page size is
2048 bytes. 2048 bytes.
The total number of data pages in partition 'syscolumns_3' The total number of data pages in partition 'syscolumns_3'
(partition ID 3) is 14. (partition ID 3) is 14.
The total number of data pages in this table is 14. The total number of data pages in this table is 14.
Table has 489 data rows. Table has 489 data rows.
Checking table 'systypes' (object ID 4): Logical page size is 2048 Checking table 'systypes' (object ID 4): Logical page size is 2048
bytes. bytes.
The total number of data pages in partition 'systypes_4' (partition The total number of data pages in partition 'systypes_4' (partition
ID 4) is 2. ID 4) is 2.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 16 - 5 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 16 - 5
The total number of data pages in this table is 2. The total number of data pages in this table is 2.
Table has 42 data rows. Table has 42 data rows.
Checking table 'syslogs' (object ID 8): Logical page size is 2048 Checking table 'syslogs' (object ID 8): Logical page size is 2048
bytes. bytes.
The total number of data pages in partition 'syslogs_8' (partition The total number of data pages in partition 'syslogs_8' (partition
ID 8) is 2. ID 8) is 2.
The total number of data pages in this table is 2. The total number of data pages in this table is 2.
Table has 32 data rows. Table has 32 data rows.
DBCC execution completed. If DBCC printed error messages, contact a DBCC execution completed. If DBCC printed error messages, contact a
user with System Administrator (SA) role. user with System Administrator (SA) role.
f. Check the consistency of the system catalog in the my_db database. f. Check the consistency of the system catalog in the my_db database.
dbcc checkcatalog dbcc checkcatalog
Checking current database: Logical pagesize is 2048 bytes Checking current database: Logical pagesize is 2048 bytes
The following segments have been defined for database 5 (database The following segments have been defined for database 5 (database
name my_db). name my_db).
virtual device number virtual start addr size (logical pages) virtual device number virtual start addr size (logical pages)
segments segments
--------------------- -------------------- -------------------- --------------------- -------------------- --------------------
------------ ------------
3 0 2048 3 0 2048
0 0
1 1
4 0 1024 4 0 1024
2 2
DBCC execution completed. If DBCC printed error messages, contact a DBCC execution completed. If DBCC printed error messages, contact a
user with System Administrator (SA) role. user with System Administrator (SA) role.
Does the my_db database appear to be in a consistent state? Does the my_db database appear to be in a consistent state?
Yes. The dbcc consistency checks did not report any Yes. The dbcc consistency checks did not report any
problems. problems.
g. Issue the dbcc checkstorage command in the my_db database. g. Issue the dbcc checkstorage command in the my_db database.
Checking my_db: Logical pagesize is 2048 bytes Checking my_db: Logical pagesize is 2048 bytes
Msg 9964, Level 16, State 2: Msg 9964, Level 16, State 2:
Server 'DUB101_2K', Line 1: Server 'DUB101_2K', Line 1:
Database 'dbccdb' was not found. Use sp_helpdb to list the Database 'dbccdb' was not found. Use sp_helpdb to list the
available databases. available databases.
Did the dbcc checkstorage command run successfully? Explain. Did the dbcc checkstorage command run successfully? Explain.
No. The error message clearly indicates that the dbccdb No. The error message clearly indicates that the dbccdb
database was not found. database was not found.
Lab Solution 16 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 16 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 16: Checking and Fixing Database Consistency Module 16: Checking and Fixing Database Consistency
Task 2: Installing the Sybase-supplied Optional Database, Task 2: Installing the Sybase-supplied Optional Database,
dbccdb dbccdb
Description In this task, you will install the dbccdb database and execute dbcc commands against the Description In this task, you will install the dbccdb database and execute dbcc commands against the
my_db database. You will also analyze the requirements of target database and executing my_db database. You will also analyze the requirements of target database and executing
dbcc checkstorage against the my_db database dbcc checkstorage against the my_db database
Procedure 1. Install the dbccdb database. Procedure 1. Install the dbccdb database.
a. Continuing in Window A, as the sa connected to Adaptive Server, determine a. Continuing in Window A, as the sa connected to Adaptive Server, determine
whether the dbccdb database exists. whether the dbccdb database exists.
sp_helpdb dbccdb sp_helpdb dbccdb
Msg 17590, Level 16, State 1: Msg 17590, Level 16, State 1:
Server 'SUB!01_2K', Procedure 'sp_helpdb', Line 81: Server 'SUB!01_2K', Procedure 'sp_helpdb', Line 81:
The specified database does not exist. The specified database does not exist.
(return status = 1) (return status = 1)
Does the dbccdb database exist? Does the dbccdb database exist?
No. No.
What are the major steps to install the dbccdb database and to What are the major steps to install the dbccdb database and to
initialize it for a target database? initialize it for a target database?
1. Run sp_plan_dbccdb to obtain recommendations for the 1. Run sp_plan_dbccdb to obtain recommendations for the
dbccdb database. dbccdb database.
2. Use disk init to initialize disk devices for the dbccdb data 2. Use disk init to initialize disk devices for the dbccdb data
and the log. and the log.
3. Use create database to create dbccdb on the data disk 3. Use create database to create dbccdb on the data disk
devices. devices.
4. (Optional) Add segments for the scan and text workspaces 4. (Optional) Add segments for the scan and text workspaces
to the dbccdb data device. to the dbccdb data device.
5. (Optional) Create a named data cache and bind the dbccdb 5. (Optional) Create a named data cache and bind the dbccdb
database to it. (Whether you bind the dbccdb database to a database to it. (Whether you bind the dbccdb database to a
named cache or not, the cache dbccdb uses must have a 16K named cache or not, the cache dbccdb uses must have a 16K
buffer pool configured). buffer pool configured).
6. Create the scan and text workspaces. 6. Create the scan and text workspaces.
7. Create the tables for dbccdb by using the installdbccdb 7. Create the tables for dbccdb by using the installdbccdb
script. script.
8. Create and initialize the scan and text workspaces. 8. Create and initialize the scan and text workspaces.
9. Use sp_dbcc_updateconfig to initialize the dbccdb database 9. Use sp_dbcc_updateconfig to initialize the dbccdb database
for the target database. for the target database.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 16 - 7 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 16 - 7
b. Determine the resource requirements for the dbccdb database by using b. Determine the resource requirements for the dbccdb database by using
sp_plan_dbccdb my_db and fill in the following chart: sp_plan_dbccdb my_db and fill in the following chart:
sp_plan_dbccdb my_db sp_plan_dbccdb my_db
Recommended size for dbccdb database is 14MB (data = 12MB, log = Recommended size for dbccdb database is 14MB (data = 12MB, log =
2MB). 2MB).
No suitable devices for dbccdb in master..sysdevices. No suitable devices for dbccdb in master..sysdevices.
Recommended values for workspace size, cache size and process count Recommended values for workspace size, cache size and process count
are: are:
dbname scan ws text ws cache process count dbname scan ws text ws cache process count
my_db 96K 48K 1280K 2 my_db 96K 48K 1280K 2
Recommended size for dbccdb database 14 MB Recommended size for dbccdb database 14 MB
Size of data portion 12 MB Size of data portion 12 MB
Size of log portion 2 MB Size of log portion 2 MB
Size of scan workspace 96 KB Size of scan workspace 96 KB
Size of text workspace 48 KB Size of text workspace 48 KB
Size of the cache needed 1280 KB Size of the cache needed 1280 KB
Number of worker processes needed 2 Number of worker processes needed 2
(process count) (process count)
c. From the master database, initialize data devices for the dbccdb database as c. From the master database, initialize data devices for the dbccdb database as
follows: follows:
1. For a device for the data portion of dbccdb: 1. For a device for the data portion of dbccdb:
• The logical name of the database device is dbccdb_data • The logical name of the database device is dbccdb_data
• The physical path and file name associated with the new device • The physical path and file name associated with the new device
is in the form: is in the form:
$SYBASE/devices/dbccdb_data.dat $SYBASE/devices/dbccdb_data.dat
• Use the device size recommended by sp_plan_dbccdb • Use the device size recommended by sp_plan_dbccdb
2. For a device for the log portion of dbccdb: 2. For a device for the log portion of dbccdb:
• The logical name of the database device is dbccdb_log • The logical name of the database device is dbccdb_log
• The physical path and file name associated with the new device • The physical path and file name associated with the new device
is in the form: is in the form:
$SYBASE/devices/dbccdb_log.dat $SYBASE/devices/dbccdb_log.dat
• Use the device size recommended by sp_plan_dbccdb for • Use the device size recommended by sp_plan_dbccdb for
the log portion of dbccdb. the log portion of dbccdb.
Lab Solution 16 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 16 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 16: Checking and Fixing Database Consistency Module 16: Checking and Fixing Database Consistency
d. Create the dbccdb database on the newly initialized devices according to the d. Create the dbccdb database on the newly initialized devices according to the
requirements recorded in step 1b. requirements recorded in step 1b.
create database dbccdb create database dbccdb
on dbccdb_data = 12 on dbccdb_data = 12
log on dbccdb_log = 2 log on dbccdb_log = 2
CREATE DATABASE: allocating 6144 logical pages (12.0 megabytes) on CREATE DATABASE: allocating 6144 logical pages (12.0 megabytes) on
disk 'dbccdb_data'. disk 'dbccdb_data'.
CREATE DATABASE: allocating 1024 logical pages (2.0 megabytes) on CREATE DATABASE: allocating 1024 logical pages (2.0 megabytes) on
disk 'dbccdb_log'. disk 'dbccdb_log'.
e. Verify that the dbccdb database was created. e. Verify that the dbccdb database was created.
sp_helpdb dbccdb sp_helpdb dbccdb
name db_size owner dbid created status name db_size owner dbid created status
------ ------------- ----- ------ ----------------- ------------- ------ ------------- ----- ------ ----------------- -------------
dbccdb 14.0 MB sa 31515 Oct 09, 2005 no options set dbccdb 14.0 MB sa 31515 Oct 09, 2005 no options set
device_fragments size usage device_fragments size usage
created free kbytes created free kbytes
------------------------------ ------------- -------------------- - ------------------------------ ------------- -------------------- -
------------------------ ---------------- ------------------------ ----------------
dbccdb_data 12.0 MB data only dbccdb_data 12.0 MB data only
Oct 9 2005 3:58PM 10520 Oct 9 2005 3:58PM 10520
dbccdb_log 2.0 MB log only dbccdb_log 2.0 MB log only
Oct 9 2005 3:58PM not applicable Oct 9 2005 3:58PM not applicable
-------------------------------------------------------------- --------------------------------------------------------------
log only free kbytes = 2038 log only free kbytes = 2038
(return status = 0) (return status = 0)
f. Access the dbccdb database and add segments for the scan and text workspaces to f. Access the dbccdb database and add segments for the scan and text workspaces to
the dbccdb data device. the dbccdb data device.
use dbccdb use dbccdb
exec sp_addsegment scanseg, dbccdb, dbccdb_data exec sp_addsegment scanseg, dbccdb, dbccdb_data
DBCC execution completed. If DBCC printed error messages, contact a DBCC execution completed. If DBCC printed error messages, contact a
user with System Administrator (SA) role. user with System Administrator (SA) role.
Segment created. Segment created.
(return status = 0) (return status = 0)
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 16 - 9 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 16 - 9
exec sp_addsegment textseg, dbccdb, dbccdb_data exec sp_addsegment textseg, dbccdb, dbccdb_data
DBCC execution completed. If DBCC printed error messages, DBCC execution completed. If DBCC printed error messages,
contact a user with contact a user with
System Administrator (SA) role. System Administrator (SA) role.
Segment created. Segment created.
(return status = 0) (return status = 0)
g. Reserve 2 MB of the default data cache for the 16K buffer pool by using the g. Reserve 2 MB of the default data cache for the 16K buffer pool by using the
following command: following command:
sp_poolconfig "default data cache", "2M", "16K" sp_poolconfig "default data cache", "2M", "16K"
Later you will configure the dbccdb database to use the Later you will configure the dbccdb database to use the
default data cache (as opposed to a named data cache). The target default data cache (as opposed to a named data cache). The target
data cache must have a sufficiently large 16 K buffer pool. data cache must have a sufficiently large 16 K buffer pool.
h. Configure Adaptive Server for the number of worker processes using the value h. Configure Adaptive Server for the number of worker processes using the value
recorded in step 3b as follows: recorded in step 3b as follows:
sp_configure "number of worker processes", 2 sp_configure "number of worker processes", 2
Parameter Name Default Memory Used Config Parameter Name Default Memory Used Config
Value Run Value Unit Type Value Run Value Unit Type
------------------------------ ----------- ----------- ----------- ------------------------------ ----------- ----------- -----------
- ------------ -------------------- ---------- - ------------ -------------------- ----------
number of worker processes 0 389 number of worker processes 0 389
2 2 number dynamic 2 2 number dynamic
Configuration option changed. ASE need not be rebooted since the Configuration option changed. ASE need not be rebooted since the
option is dynamic. option is dynamic.
Changing the value of 'number of worker processes' to '2' increases Changing the value of 'number of worker processes' to '2' increases
the amount of memory ASE uses by 12 K. the amount of memory ASE uses by 12 K.
(return status = 0) (return status = 0)
i. Now try to use dbcc checkstorage against the my_db database. i. Now try to use dbcc checkstorage against the my_db database.
dbcc checkstorage (my_db) dbcc checkstorage (my_db)
Checking my_db: Logical pagesize is 2048 bytes Checking my_db: Logical pagesize is 2048 bytes
Msg 9965, Level 20, State 1: Msg 9965, Level 20, State 1:
Server 'DUB101_2K', Line 1: Server 'DUB101_2K', Line 1:
The entries in dbcc_config for database 'my_db' are either missing The entries in dbcc_config for database 'my_db' are either missing
or invalid. Use sp_dbcc_evaluatedb to determine or invalid. Use sp_dbcc_evaluatedb to determine
appropriate values for the entries and sp_dbcc_updateconfig to set appropriate values for the entries and sp_dbcc_updateconfig to set
them. them.
DBCC CHECKSTORAGE for database 'my_db' encountered an error. Some DBCC CHECKSTORAGE for database 'my_db' encountered an error. Some
results may not be available. Correct the problems results may not be available. Correct the problems
reported and reexecute the CHECKSTORAGE command. reported and reexecute the CHECKSTORAGE command.
Lab Solution 16 - 10 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 16 - 10 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 16: Checking and Fixing Database Consistency Module 16: Checking and Fixing Database Consistency
Did the dbcc checkstorage command run successfully? Explain. Did the dbcc checkstorage command run successfully? Explain.
No. Notice the error message: “The entries in dbcc_config No. Notice the error message: “The entries in dbcc_config
for database 'my_db' are either missing or invalid.” for database 'my_db' are either missing or invalid.”
Basically, just the presence of the dbccdb database does not Basically, just the presence of the dbccdb database does not
mean that you can simply run dbcc checkstorage against any mean that you can simply run dbcc checkstorage against any
database. The dbccdb database must be loaded with tables database. The dbccdb database must be loaded with tables
specific to dbccdb (via the installdbccdb script) and then specific to dbccdb (via the installdbccdb script) and then
configured for each target database. You have more setup configured for each target database. You have more setup
work to do! work to do!
2. Load and configure the dbccdb database. 2. Load and configure the dbccdb database.
a. In Window B, change the directory to $SYBASE/$SYBASE_ASE/scripts. a. In Window B, change the directory to $SYBASE/$SYBASE_ASE/scripts.
cd $SYBASE/$SYBASE_ASE/scripts cd $SYBASE/$SYBASE_ASE/scripts
b. Execute the T-SQL commands in the script installdbccdb by using isql -i. b. Execute the T-SQL commands in the script installdbccdb by using isql -i.
This Sybase-supplied script creates tables and stored procedures This Sybase-supplied script creates tables and stored procedures
unique to the dbccdb database. Once these tables and procedures unique to the dbccdb database. Once these tables and procedures
are installed, then you can configure the dbccdb database for are installed, then you can configure the dbccdb database for
each target database that you want to run dbcc checkstorage each target database that you want to run dbcc checkstorage
isql -Usa -P -i installdbccdb isql -Usa -P -i installdbccdb
c. In Window A, as the sa accessing the dbccdb database, create the scan and text c. In Window A, as the sa accessing the dbccdb database, create the scan and text
workspaces using the recommended sizes recorded in step 3b. workspaces using the recommended sizes recorded in step 3b.
sp_dbcc_createws dbccdb, scanseg, scan_my_db, scan, "96K" sp_dbcc_createws dbccdb, scanseg, scan_my_db, scan, "96K"
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 16 - 11 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 16 - 11
Workspace scan_my_db of 96KB size has been created successfully in Workspace scan_my_db of 96KB size has been created successfully in
dbccdb database. dbccdb database.
(return status = 0) (return status = 0)
sp_dbcc_createws dbccdb, textseg, text_my_db, text, "48K" sp_dbcc_createws dbccdb, textseg, text_my_db, text, "48K"
Workspace text_my_db of 48KB size has been created successfully in Workspace text_my_db of 48KB size has been created successfully in
dbccdb database. dbccdb database.
d. Initialize dbccdb for the target database (my_db) by using sp_dbcc_updateconfig d. Initialize dbccdb for the target database (my_db) by using sp_dbcc_updateconfig
for each of the following parameters: for each of the following parameters:
• max worker processes (use the value recorded in step 1b) • max worker processes (use the value recorded in step 1b)
• dbcc named cache (use the default data cache and the size • dbcc named cache (use the default data cache and the size
recorded in step 1b) recorded in step 1b)
• scan workspace (use the name just created in step 2c) • scan workspace (use the name just created in step 2c)
• text workspace (use the name just created in step 2c) • text workspace (use the name just created in step 2c)
sp_dbcc_updateconfig my_db, "max worker processes", "2" sp_dbcc_updateconfig my_db, "max worker processes", "2"
The value of the dbcc configuration parameter 'max worker The value of the dbcc configuration parameter 'max worker
processes' for database my_db has been updated. processes' for database my_db has been updated.
(return status = 0) (return status = 0)
sp_dbcc_updateconfig my_db, "dbcc named cache", "default data sp_dbcc_updateconfig my_db, "dbcc named cache", "default data
cache", "1920K" cache", "1920K"
The value of the dbcc configuration parameter 'dbcc named cache' The value of the dbcc configuration parameter 'dbcc named cache'
for database my_db has been updated. for database my_db has been updated.
(return status = 0) (return status = 0)
sp_dbcc_updateconfig my_db, "scan workspace", scan_my_db sp_dbcc_updateconfig my_db, "scan workspace", scan_my_db
The value of the dbcc configuration parameter 'scan workspace' for The value of the dbcc configuration parameter 'scan workspace' for
database my_db has been updated. database my_db has been updated.
(return status = 0) (return status = 0)
sp_dbcc_updateconfig my_db, "text workspace", text_my_db sp_dbcc_updateconfig my_db, "text workspace", text_my_db
The value of the dbcc configuration parameter 'text workspace' for The value of the dbcc configuration parameter 'text workspace' for
database my_db has been updated. database my_db has been updated.
(return status = 0) (return status = 0)
e. Verify that the my_db database is configured properly in the dbccdb database by e. Verify that the my_db database is configured properly in the dbccdb database by
Lab Solution 16 - 12 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 16 - 12 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 16: Checking and Fixing Database Consistency Module 16: Checking and Fixing Database Consistency
Reporting configuration information of database my_db. Reporting configuration information of database my_db.
Do the values match the “suggested” values? Do the values match the “suggested” values?
Yes. Yes.
Checking my_db: Logical pagesize is 2048 bytes Checking my_db: Logical pagesize is 2048 bytes
Storage checks for 'my_db' are complete. DBCC is now recording the Storage checks for 'my_db' are complete. DBCC is now recording the
results in the dbccdb database. results in the dbccdb database.
DBCC CHECKSTORAGE for database 'my_db' sequence 1 completed at Oct DBCC CHECKSTORAGE for database 'my_db' sequence 1 completed at Oct
9 2005 4:41PM. 0 faults and 0 suspect conditions were located. 0 9 2005 4:41PM. 0 faults and 0 suspect conditions were located. 0
checks were aborted. You should investigate the recorded faults, checks were aborted. You should investigate the recorded faults,
and plan a course of action that will correct them. and plan a course of action that will correct them.
Did the dbcc checkstorage command run successfully for the my_db Did the dbcc checkstorage command run successfully for the my_db
database? database?
Yes! Yes!
Are any faults or suspect conditions reported? Are any faults or suspect conditions reported?
No. No.
b. Verify the number of faults and suspect conditions reported by dbcc checkstorage b. Verify the number of faults and suspect conditions reported by dbcc checkstorage
by executing sp_dbcc_summaryreport for the my_db database. by executing sp_dbcc_summaryreport for the my_db database.
sp_dbcc_summaryreport my_db sp_dbcc_summaryreport my_db
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 16 - 13 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 16 - 13
=================================================================== ===================================================================
(return status = 0) (return status = 0)
4. Exit all client sessions with Adaptive Server. 4. Exit all client sessions with Adaptive Server.
Lab Solution 16 - 14 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 16 - 14 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 17: Planning for Backups Module 17: Planning for Backups
Module 17: Planning for Backups Module 17: Planning for Backups
Lab 17: Planning for Backups Lab 17: Planning for Backups
Lab Setup This is a pencil-and-paper activity. Lab Setup This is a pencil-and-paper activity.
Objectives After completing this lab, you should be able to: Objectives After completing this lab, you should be able to:
Develop a high-level backup/recovery strategy. Develop a high-level backup/recovery strategy.
Description In this lab, you will learn how to develop a high-level backup/recovery strategy. Description In this lab, you will learn how to develop a high-level backup/recovery strategy.
Task Outline 1. Deciding What Backup Strategy would be Appropriate for your Site Task Outline 1. Deciding What Backup Strategy would be Appropriate for your Site
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 17 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 17 - 1
Task 1: Deciding what Backup Strategy Would be Appropriate Task 1: Deciding what Backup Strategy Would be Appropriate
for Your Site for Your Site
Description In this task, you will choose backup strategy which would be appropriate for your site. Description In this task, you will choose backup strategy which would be appropriate for your site.
Procedure Procedure
DO NOT EXECUTE any of the commands in this lab. This is a DO NOT EXECUTE any of the commands in this lab. This is a
paper-and-pencil activity. paper-and-pencil activity.
Each numbered step in this lab makes a general statement about backups. Read each Each numbered step in this lab makes a general statement about backups. Read each
statement and then answer the questions that follow it. statement and then answer the questions that follow it.
1. Dump devices available to Adaptive Server include both large files on disk and high 1. Dump devices available to Adaptive Server include both large files on disk and high
speed tape devices. speed tape devices.
As a basic strategy, it has been determined that the dump devices on As a basic strategy, it has been determined that the dump devices on
disk are not to be used with automated dump operations. Why has disk are not to be used with automated dump operations. Why has
that strategy been recommended? that strategy been recommended?
A dump to a disk device overwrites an existing file unless you A dump to a disk device overwrites an existing file unless you
specify a number of days to retain the file as part of the specify a number of days to retain the file as part of the
dump command - overwrites are automatic. dump command - overwrites are automatic.
A dump to a tape device will not overwrite any other dumps A dump to a tape device will not overwrite any other dumps
on the tape unless you tell it to. on the tape unless you tell it to.
2. The use of disk files for dump devices may have an advantage over tape devices in a 2. The use of disk files for dump devices may have an advantage over tape devices in a
particular environment. particular environment.
Which of the following environments can benefit from the advantage Which of the following environments can benefit from the advantage
that disk file dump devices can provide? Explain your answer. that disk file dump devices can provide? Explain your answer.
1. A development environment where backups are often 1. A development environment where backups are often
conducted by developers. conducted by developers.
2. A production environment where backups are provided by a 2. A production environment where backups are provided by a
team of operators on a regularly scheduled basis. team of operators on a regularly scheduled basis.
The development environment can make better use of the The development environment can make better use of the
disk file dump devices. The backups are usually complete disk file dump devices. The backups are usually complete
backups every day and the automatic overwrite feature is backups every day and the automatic overwrite feature is
Lab Solution 17 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 17 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 17: Planning for Backups Module 17: Planning for Backups
desirable. The dumps can be completely automated, desirable. The dumps can be completely automated,
requiring no user intervention. Additionally, dumping to requiring no user intervention. Additionally, dumping to
disk devices is generally faster than dumping to tape. disk devices is generally faster than dumping to tape.
3. Given: When a backup and recovery strategy is to be defined, a major part of any plan 3. Given: When a backup and recovery strategy is to be defined, a major part of any plan
is the restoration of critical databases from backups (dumps). is the restoration of critical databases from backups (dumps).
What facilities does Sybase provide to automate the restoration of What facilities does Sybase provide to automate the restoration of
databases from dump files? Explain. databases from dump files? Explain.
While Sybase does provide automatic database “recovery” in While Sybase does provide automatic database “recovery” in
the event of a system failure, such as a power outage, Sybase the event of a system failure, such as a power outage, Sybase
does not provide any facilities to automate the restoration of does not provide any facilities to automate the restoration of
databases in the event of disk failures. Database restoration databases in the event of disk failures. Database restoration
from backups is not usually automated due to the nature of from backups is not usually automated due to the nature of
restoration. Ideally, you would plan for a disaster but hope restoration. Ideally, you would plan for a disaster but hope
that database restoration is something you never have to that database restoration is something you never have to
perform. perform.
Restoring databases from backups is typically performed Restoring databases from backups is typically performed
when a catastrophe has occurred, such as a disk failure. The when a catastrophe has occurred, such as a disk failure. The
setup necessary to begin a restoration should involve DBA setup necessary to begin a restoration should involve DBA
interaction. Procedures should be developed, but not interaction. Procedures should be developed, but not
automated, to address restoration. automated, to address restoration.
4. Capturing statistics about dump and load processes can be invaluable in estimating 4. Capturing statistics about dump and load processes can be invaluable in estimating
durations and provide information about the performance of your system. durations and provide information about the performance of your system.
What three important statistics should be gathered to help estimate What three important statistics should be gathered to help estimate
load and dump times? Explain. load and dump times? Explain.
1. Total database size 1. Total database size
2. Total number of used pages 2. Total number of used pages
3. Total execution time 3. Total execution time
For dumps, the time to execute is fairly linear based upon the For dumps, the time to execute is fairly linear based upon the
number of used pages. For loads, the time to execute is based number of used pages. For loads, the time to execute is based
on both the total database size and the number of used pages on both the total database size and the number of used pages
being restored. being restored.
Understanding and monitoring database size and usage is Understanding and monitoring database size and usage is
useful when planning a regimen for databases that have not useful when planning a regimen for databases that have not
yet leveled off in size. Gathering these statistics will help to yet leveled off in size. Gathering these statistics will help to
define alternative approaches as the data volume increases. define alternative approaches as the data volume increases.
5. When developing your backup and recovery plan, you should consider all of your 5. When developing your backup and recovery plan, you should consider all of your
system and user databases. system and user databases.
Fill in a Yes or No in the “Dump?” column of the following table to Fill in a Yes or No in the “Dump?” column of the following table to
indicate your decision regarding whether to perform regularly scheduled indicate your decision regarding whether to perform regularly scheduled
dumps for the given system and (optional) Sybase-supplied user databases. dumps for the given system and (optional) Sybase-supplied user databases.
Briefly explain each decision. Briefly explain each decision.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 17 - 3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 17 - 3
6. Your business requirements define whether any particular database should be backed 6. Your business requirements define whether any particular database should be backed
up. Backups are normally required on a periodic basis for any production system up. Backups are normally required on a periodic basis for any production system
database that is modified. Each database in a backup plan may have different database that is modified. Each database in a backup plan may have different
maintenance requirements. Write a short description for each of the following items maintenance requirements. Write a short description for each of the following items
that should be defined for each database in your plan. that should be defined for each database in your plan.
Lab Solution 17 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 17 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 18: Performing a Backup Module 18: Performing a Backup
Lab 18: Performing Backups and Loads Lab 18: Performing Backups and Loads
Lab Setup You will be using your 2K page size Adaptive Server and your Backup Server for this lab. Lab Setup You will be using your 2K page size Adaptive Server and your Backup Server for this lab.
Note: You need to have completed previous labs in which you created a database named Note: You need to have completed previous labs in which you created a database named
my_db. If you did not finish those previous labs, then please refer to the following my_db. If you did not finish those previous labs, then please refer to the following
instructions right before step 1 of this lab. instructions right before step 1 of this lab.
Objectives After completing this lab, you should be able to: Objectives After completing this lab, you should be able to:
Perform full and incremental database dumps Perform full and incremental database dumps
Analyze dump compression differences Analyze dump compression differences
Description In this lab, you will learn how to perform full and incremental database dumps and how to Description In this lab, you will learn how to perform full and incremental database dumps and how to
analyze dump compression differences. analyze dump compression differences.
Task Outline 1. Creating Dump Devices Task Outline 1. Creating Dump Devices
2. Performing a Database Dump and Load 2. Performing a Database Dump and Load
3. Performing a Transaction Dump and Load 3. Performing a Transaction Dump and Load
4. Analyzing the Effects of Dump Compression 4. Analyzing the Effects of Dump Compression
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 18 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 18 - 1
Note: If you have not completed the previous labs in which you Note: If you have not completed the previous labs in which you
created database devices and the my_db database then issue the created database devices and the my_db database then issue the
following commands now (substituting $SYBASE/ appropriately): following commands now (substituting $SYBASE/ appropriately):
disk init disk init
name = "data_dev", name = "data_dev",
physname = "$SYBASE/devices/data_dev.dat", physname = "$SYBASE/devices/data_dev.dat",
size = "4M" size = "4M"
go go
disk init disk init
name = "log_dev", name = "log_dev",
physname = "$SYBASE/devices/log_dev.mir", physname = "$SYBASE/devices/log_dev.mir",
size = 1024 size = 1024
go go
create database my_db on data_dev = 4 log on log_dev create database my_db on data_dev = 4 log on log_dev
= 2 = 2
go go
exec sp_addlogin tom, "friday", my_db exec sp_addlogin tom, "friday", my_db
exec sp_addlogin dick, "friday", my_db exec sp_addlogin dick, "friday", my_db
exec sp_addlogin harry, "friday", my_db exec sp_addlogin harry, "friday", my_db
go go
use my_db use my_db
go go
exec sp_adduser tom exec sp_adduser tom
exec sp_adduser dick exec sp_adduser dick
exec sp_adduser harry exec sp_adduser harry
go go
exec sp_addgroup programmers exec sp_addgroup programmers
exec sp_addgroup engineers exec sp_addgroup engineers
go go
exec sp_changegroup programmers, tom exec sp_changegroup programmers, tom
exec sp_changegroup programmers, dick exec sp_changegroup programmers, dick
exec sp_changegroup engineers, harry exec sp_changegroup engineers, harry
go go
For this lab, it would be useful to open two windows (“A” and “B”). For this lab, it would be useful to open two windows (“A” and “B”).
This allows you to have multiple client sessions with ASE This allows you to have multiple client sessions with ASE
simultaneously. You should exit any active client sessions with simultaneously. You should exit any active client sessions with
Adaptive Server before continuing. Adaptive Server before continuing.
, ,
Lab Solution 18 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 18 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 18: Performing a Backup Module 18: Performing a Backup
Description In this task, you will create dump devices. Description In this task, you will create dump devices.
Procedure Procedure
1. Create disk dump devices. 1. Create disk dump devices.
a. In Window A, connect to Adaptive Server as the sa. a. In Window A, connect to Adaptive Server as the sa.
isql -Usa -P isql -Usa -P
b. Create a disk dump device named db_dump_dev, which uses a physical file named b. Create a disk dump device named db_dump_dev, which uses a physical file named
db_dump_dev.dat in your $HOME/sa directory. db_dump_dev.dat in your $HOME/sa directory.
sp_addumpdevice "disk", "db_dump_dev", sp_addumpdevice "disk", "db_dump_dev",
"/home/usr/u/dub101/sa/db_dump_dev.dat" "/home/usr/u/dub101/sa/db_dump_dev.dat"
c. Create a second disk dump device named log_dump_dev, which uses a physical c. Create a second disk dump device named log_dump_dev, which uses a physical
file named log_dump_dev.dat in your $HOME/sa directory. file named log_dump_dev.dat in your $HOME/sa directory.
sp_addumpdevice "disk", "log_dump_dev", sp_addumpdevice "disk", "log_dump_dev",
"/home/usr/u/dub101/sa/log_dump_dev.dat" "/home/usr/u/dub101/sa/log_dump_dev.dat"
d. Verify that the two dump devices have been created by using sp_helpdevice. d. Verify that the two dump devices have been created by using sp_helpdevice.
sp_helpdevice db_dump_dev sp_helpdevice db_dump_dev
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 18 - 3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 18 - 3
Task 2: Performing a Database Dump and Load Task 2: Performing a Database Dump and Load
Description In this task, you will perform a database dump and load. Description In this task, you will perform a database dump and load.
Procedure 1. Determine the name of the Backup Server for this Adaptive Server. Procedure 1. Determine the name of the Backup Server for this Adaptive Server.
a. Continuing in Window A as the sa, determine the Backup Server associated with a. Continuing in Window A as the sa, determine the Backup Server associated with
this Adaptive Server by using sp_helpserver. this Adaptive Server by using sp_helpserver.
sp_helpserver sp_helpserver
In Sybase Learning Centers, students are already set up with a In Sybase Learning Centers, students are already set up with a
Backup Server named in the form $DSQUERY_BS, with a Backup Server named in the form $DSQUERY_BS, with a
corresponding entry in the sysservers table. corresponding entry in the sysservers table.
Does the output from sp_helpserver show a server with the logical Does the output from sp_helpserver show a server with the logical
name SYB_BACKUP? If yes, what is the network_name of the name SYB_BACKUP? If yes, what is the network_name of the
Backup Server? Backup Server?
Yes, there is an entry for SYB_BACKUP and the Yes, there is an entry for SYB_BACKUP and the
network_name in this case is DUB101_2K_BS network_name in this case is DUB101_2K_BS
($DSQUERY_BS). ($DSQUERY_BS).
Assume the following situation: You plan to use a remote Backup Assume the following situation: You plan to use a remote Backup
Server called TUNA_BS on a machine called tuna. What tasks must Server called TUNA_BS on a machine called tuna. What tasks must
you perform on the local host to the interfaces file and the sysservers you perform on the local host to the interfaces file and the sysservers
table to make this remote Backup Server known to the (local) table to make this remote Backup Server known to the (local)
Adaptive Server? Adaptive Server?
For remote Backup Servers, the only task required on the For remote Backup Servers, the only task required on the
local host is add an appropriate entry to the local interfaces local host is add an appropriate entry to the local interfaces
file for the remote Backup Server, TUNA_BS. No entry is file for the remote Backup Server, TUNA_BS. No entry is
required in the local Adaptive Server sysservers table for required in the local Adaptive Server sysservers table for
TUNA_BS because when you specify a remote Backup TUNA_BS because when you specify a remote Backup
Server (with the “dump ... at” option), the sysservers table is Server (with the “dump ... at” option), the sysservers table is
Lab Solution 18 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 18 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 18: Performing a Backup Module 18: Performing a Backup
b. Try to dump the database, my_db, to the dump device db_dump_dev (without b. Try to dump the database, my_db, to the dump device db_dump_dev (without
using compression). using compression).
dump database my_db to db_dump_dev dump database my_db to db_dump_dev
Msg 7205, Level 17, State 2: Msg 7205, Level 17, State 2:
Server 'DUB101_2K', Line 1: Server 'DUB101_2K', Line 1:
Can't open a connection to site 'SYB_BACKUP'. See the error Can't open a connection to site 'SYB_BACKUP'. See the error
log file in the SQL Server boot directory. log file in the SQL Server boot directory.
Msg 7205, Level 18, State 3: Msg 7205, Level 18, State 3:
Server 'DUB101_2K', Line 1: Server 'DUB101_2K', Line 1:
Can't open a connection to site 'SYB_BACKUP'. See the error Can't open a connection to site 'SYB_BACKUP'. See the error
log file in the SQL Server boot directory. log file in the SQL Server boot directory.
Was the database dump successful? Explain. Was the database dump successful? Explain.
No. Even though there is an entry in sysservers for the No. Even though there is an entry in sysservers for the
Backup Server, the Backup Server must be up and running Backup Server, the Backup Server must be up and running
to perform a database dump or load. to perform a database dump or load.
c. In Window B, start up the Backup Server. c. In Window B, start up the Backup Server.
cd $SYBASE/$SYBASE_ASE/install cd $SYBASE/$SYBASE_ASE/install
Backup Server/15.0/EBF 12780 GA/Linux Intel/Linux 2.4.21-20.ELsmp Backup Server/15.0/EBF 12780 GA/Linux Intel/Linux 2.4.21-20.ELsmp
i686/asemain/2584/32-bit/OPT/Thu Aug 1 8 00:01:42 2005 i686/asemain/2584/32-bit/OPT/Thu Aug 1 8 00:01:42 2005
Confidential property of Sybase, Inc. Confidential property of Sybase, Inc.
Copyright 1987, 2005 Copyright 1987, 2005
Sybase, Inc. All rights reserved. Sybase, Inc. All rights reserved.
Unpublished rights reserved under U.S. copyright laws. Unpublished rights reserved under U.S. copyright laws.
This software contains confidential and trade secret information of This software contains confidential and trade secret information of
Sybase, Inc. Use, duplication or disclosure of the software and Sybase, Inc. Use, duplication or disclosure of the software and
documentation by the U.S. Government is subject to documentation by the U.S. Government is subject to
restrictions set forth in a license agreement between the restrictions set forth in a license agreement between the
Government and Sybase, Inc. or other written agreement Government and Sybase, Inc. or other written agreement
specifying the Government's rights to use the software and any specifying the Government's rights to use the software and any
applicable FAR provisions, for example, FAR 52.227-19. applicable FAR provisions, for example, FAR 52.227-19.
Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
Logging Backup Server messages in file '/home/usr/u/dub101/ASE- Logging Backup Server messages in file '/home/usr/u/dub101/ASE-
15_0/install/DUB101_2K_BS.log' 15_0/install/DUB101_2K_BS.log'
2. Create a table and then dump the database. 2. Create a table and then dump the database.
a. Continuing in Window A as the sa, access the my_db database. a. Continuing in Window A as the sa, access the my_db database.
use my_db use my_db
b. Create a simple table called test_dump with one int column. b. Create a simple table called test_dump with one int column.
create table test_dump (i int) create table test_dump (i int)
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 18 - 5 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 18 - 5
c. Insert a row with value “1” into the newly created table. c. Insert a row with value “1” into the newly created table.
insert test_dump values (1) insert test_dump values (1)
d. Dump the database, my_db, to the dump device db_dump_dev (without using d. Dump the database, my_db, to the dump device db_dump_dev (without using
compression). compression).
dump database my_db to db_dump_dev dump database my_db to db_dump_dev
Backup Server session id is: 5. Use this value when executing the Backup Server session id is: 5. Use this value when executing the
'sp_volchanged' system stored procedure after 'sp_volchanged' system stored procedure after
fulfilling any volume change request from the Backup Server. fulfilling any volume change request from the Backup Server.
Backup Server: 4.41.1.1: Creating new disk file Backup Server: 4.41.1.1: Creating new disk file
/home/usr/u/dub101/sa/db_dump_dev.dat. /home/usr/u/dub101/sa/db_dump_dev.dat.
Backup Server: 6.28.1.1: Dumpfile name 'my_db05282112BA ' section Backup Server: 6.28.1.1: Dumpfile name 'my_db05282112BA ' section
number 1 mounted on disk file number 1 mounted on disk file
'/home/usr/u/dub101/sa/db_dump_dev.dat' '/home/usr/u/dub101/sa/db_dump_dev.dat'
Backup Server: 4.188.1.1: Database my_db: 2378 kilobytes (100%) Backup Server: 4.188.1.1: Database my_db: 2378 kilobytes (100%)
DUMPed. DUMPed.
Backup Server: 3.43.1.1: Dump phase number 1 completed. Backup Server: 3.43.1.1: Dump phase number 1 completed.
Backup Server: 3.43.1.1: Dump phase number 2 completed. Backup Server: 3.43.1.1: Dump phase number 2 completed.
Backup Server: 3.43.1.1: Dump phase number 3 completed. Backup Server: 3.43.1.1: Dump phase number 3 completed.
Backup Server: 4.188.1.1: Database my_db: 2392 kilobytes (100%) Backup Server: 4.188.1.1: Database my_db: 2392 kilobytes (100%)
DUMPed. DUMPed.
Backup Server: 3.42.1.1: DUMP is complete (database my_db). Backup Server: 3.42.1.1: DUMP is complete (database my_db).
Was the database dump successful this time? Was the database dump successful this time?
Yes. Yes.
e. Insert another row with value “2” into the test_dump table. e. Insert another row with value “2” into the test_dump table.
insert test_dump values (2) insert test_dump values (2)
3. Load the database from the backup. 3. Load the database from the backup.
a. Access the master database. a. Access the master database.
use master use master
b. Load the my_db database from the dump device, db_dump_dev. b. Load the my_db database from the dump device, db_dump_dev.
load database my_db from db_dump_dev load database my_db from db_dump_dev
Backup Server session id is: 9. Use this value when executing the Backup Server session id is: 9. Use this value when executing the
'sp_volchanged' system stored procedure after 'sp_volchanged' system stored procedure after
fulfilling any volume change request from the Backup Server. fulfilling any volume change request from the Backup Server.
Backup Server: 6.28.1.1: Dumpfile name 'my_db05282112BA ' section Backup Server: 6.28.1.1: Dumpfile name 'my_db05282112BA ' section
number 1 mounted on disk file number 1 mounted on disk file
'/home/usr/u/dub101/sa/db_dump_dev.dat' '/home/usr/u/dub101/sa/db_dump_dev.dat'
Backup Server: 4.188.1.1: Database my_db: 5256 kilobytes (85%) Backup Server: 4.188.1.1: Database my_db: 5256 kilobytes (85%)
LOADed. LOADed.
Lab Solution 18 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 18 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 18: Performing a Backup Module 18: Performing a Backup
Backup Server: 4.188.1.1: Database my_db: 6150 kilobytes (100%) Backup Server: 4.188.1.1: Database my_db: 6150 kilobytes (100%)
LOADed. LOADed.
Backup Server: 4.188.1.1: Database my_db: 6160 kilobytes (100%) Backup Server: 4.188.1.1: Database my_db: 6160 kilobytes (100%)
LOADed. LOADed.
Backup Server: 3.42.1.1: LOAD is complete (database my_db). Backup Server: 3.42.1.1: LOAD is complete (database my_db).
Started estimating recovery log boundaries for database 'my_db'. Started estimating recovery log boundaries for database 'my_db'.
Database 'my_db', checkpoint=(2183, 2), first=(2183, 2), Database 'my_db', checkpoint=(2183, 2), first=(2183, 2),
last=(2184, 3). last=(2184, 3).
Completed estimating recovery log boundaries for database 'my_db'. Completed estimating recovery log boundaries for database 'my_db'.
Started ANALYSIS pass for database 'my_db'. Started ANALYSIS pass for database 'my_db'.
Completed ANALYSIS pass for database 'my_db'. Completed ANALYSIS pass for database 'my_db'.
Started REDO pass for database 'my_db'. The total number of log Started REDO pass for database 'my_db'. The total number of log
records to process is 16. records to process is 16.
Redo pass of recovery has processed 2 committed and 0 aborted Redo pass of recovery has processed 2 committed and 0 aborted
transactions. transactions.
Completed REDO pass for database 'my_db'. Completed REDO pass for database 'my_db'.
Use the ONLINE DATABASE command to bring this database online; ASE Use the ONLINE DATABASE command to bring this database online; ASE
will not bring it online automatically. will not bring it online automatically.
c. Bring the my_db database online. c. Bring the my_db database online.
online database my_db online database my_db
Started estimating recovery log boundaries for database 'my_db'. Started estimating recovery log boundaries for database 'my_db'.
Database 'my_db', checkpoint=(2183, 2), first=(2183, 2), Database 'my_db', checkpoint=(2183, 2), first=(2183, 2),
last=(2184, 3). last=(2184, 3).
Completed estimating recovery log boundaries for database 'my_db'. Completed estimating recovery log boundaries for database 'my_db'.
Started ANALYSIS pass for database 'my_db'. Started ANALYSIS pass for database 'my_db'.
Completed ANALYSIS pass for database 'my_db'. Completed ANALYSIS pass for database 'my_db'.
Recovery of database 'my_db' will undo incomplete nested top Recovery of database 'my_db' will undo incomplete nested top
actions. actions.
Database 'my_db' is now online. Database 'my_db' is now online.
d. Access the my_db database and examine the contents of the test_dump table. d. Access the my_db database and examine the contents of the test_dump table.
use my_db use my_db
i i
----------- -----------
1 1
To summarize the sequence just performed, previously you: To summarize the sequence just performed, previously you:
1. inserted a row with value “1”. 1. inserted a row with value “1”.
2. dumped the database. 2. dumped the database.
3. inserted a second row with value “2”. 3. inserted a second row with value “2”.
Are both rows in the table after restoring the database from backup? Are both rows in the table after restoring the database from backup?
Explain. Explain.
No. At the time the database dump was performed, there was No. At the time the database dump was performed, there was
only one row in the table. A database load is a complete only one row in the table. A database load is a complete
overwrite of the database, therefore the table was restored to overwrite of the database, therefore the table was restored to
its original state before the dump, with just the one row. its original state before the dump, with just the one row.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 18 - 7 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 18 - 7
4. Assume the following: A database named sales_db has just been backed up to a tape 4. Assume the following: A database named sales_db has just been backed up to a tape
device named public_tape_device, and the tape is still mounted. There is enough space device named public_tape_device, and the tape is still mounted. There is enough space
left on the tape to dump two additional databases, customer_db and employee_db, at left on the tape to dump two additional databases, customer_db and employee_db, at
which point the tape would be full. which point the tape would be full.
What command sequence would you use to dump the two additional databases onto What command sequence would you use to dump the two additional databases onto
the same tape as sales_db without overwriting the sales_db dump information? the same tape as sales_db without overwriting the sales_db dump information?
dump database employee_db to public_tape_device with unload dump database employee_db to public_tape_device with unload
What command would you use to load the employee_db database? What command would you use to load the employee_db database?
load database employee_db from public_tape_device load database employee_db from public_tape_device
5. Assume you have a large database named huge_db that will not fit on a single dump 5. Assume you have a large database named huge_db that will not fit on a single dump
device. You decide to split the database dump across three dump devices: device. You decide to split the database dump across three dump devices:
dump_device1, dump_device2, and dump_device3. dump_device1, dump_device2, and dump_device3.
What command sequence would you use to accomplish this dump? What command sequence would you use to accomplish this dump?
Lab Solution 18 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 18 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 18: Performing a Backup Module 18: Performing a Backup
Task 3: Performing a Transaction Dump and Load Task 3: Performing a Transaction Dump and Load
Description In this task, you will perform a transaction dump and load. Description In this task, you will perform a transaction dump and load.
1. Perform a full database dump and then a transaction dump. 1. Perform a full database dump and then a transaction dump.
Procedure Procedure
a. Continuing in Window A as the sa: a. Continuing in Window A as the sa:
1. turn off the database option “trunc log on chkpt” for the my_db database. 1. turn off the database option “trunc log on chkpt” for the my_db database.
2. turn on the database option “no chkpt on recovery” for the my_db database. 2. turn on the database option “no chkpt on recovery” for the my_db database.
You are going to perform full and incremental database dumps You are going to perform full and incremental database dumps
in this exercise. The database option, “trunc log on chkpt”, must in this exercise. The database option, “trunc log on chkpt”, must
be off to perform a transaction dump. be off to perform a transaction dump.
Additionally, you will be “breaking” the load sequence to examine Additionally, you will be “breaking” the load sequence to examine
the effects of partial database loads. The database option, “no chkpt the effects of partial database loads. The database option, “no chkpt
on recovery” must be on to perform this task. on recovery” must be on to perform this task.
sp_dboption my_db, "trunc log on chkpt", false sp_dboption my_db, "trunc log on chkpt", false
Database option 'trunc log on chkpt' turned OFF for database Database option 'trunc log on chkpt' turned OFF for database
'my_db'. 'my_db'.
Running CHECKPOINT on database 'my_db' for option 'trunc log on Running CHECKPOINT on database 'my_db' for option 'trunc log on
chkpt' to take effect. chkpt' to take effect.
(return status = 0) (return status = 0)
sp_dboption my_db, "no chkpt on recovery", true sp_dboption my_db, "no chkpt on recovery", true
Database option 'no chkpt on recovery' turned ON for database Database option 'no chkpt on recovery' turned ON for database
'my_db'. 'my_db'.
Running CHECKPOINT on database 'my_db' for option 'no chkpt on Running CHECKPOINT on database 'my_db' for option 'no chkpt on
recovery' to take effect. recovery' to take effect.
(return status = 0) (return status = 0)
b. Verify that the database option “trunc log on chkpt” is off and that “no chkpt on b. Verify that the database option “trunc log on chkpt” is off and that “no chkpt on
recovery” is on for the my_db database. recovery” is on for the my_db database.
sp_helpdb my_db sp_helpdb my_db
name db_size owner dbid created status name db_size owner dbid created status
----- ------------- ----- ------ ------------------ -------------- ----- ------------- ----- ------ ------------------ --------------
------------------------------------ ------------------------------------
my_db 6.0 MB sa 5 Oct 04, 2005 select my_db 6.0 MB sa 5 Oct 04, 2005 select
into/bulkcopy/pllsort, no chkpt on recovery into/bulkcopy/pllsort, no chkpt on recovery
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 18 - 9 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 18 - 9
c. Continuing in the my_db database, insert a row with value “2” into the test_dump c. Continuing in the my_db database, insert a row with value “2” into the test_dump
table. table.
insert test_dump values (2) insert test_dump values (2)
d. Verify the contents of the test_dump table. d. Verify the contents of the test_dump table.
select * from test_dump select * from test_dump
i i
----------- -----------
1 1
2 2
Are there now two rows in the table with values “1” and “2”, Are there now two rows in the table with values “1” and “2”,
respectively? respectively?
Yes. Yes.
e. Dump the database, my_db, to the dump device db_dump_dev (without using e. Dump the database, my_db, to the dump device db_dump_dev (without using
compression). compression).
dump database my_db to db_dump_dev dump database my_db to db_dump_dev
Backup Server session id is: 12. Use this value when executing Backup Server session id is: 12. Use this value when executing
the 'sp_volchanged' system stored procedure after the 'sp_volchanged' system stored procedure after
fulfilling any volume change request from the Backup Server. fulfilling any volume change request from the Backup Server.
Backup Server: 6.28.1.1: Dumpfile name 'my_db052821179A ' section Backup Server: 6.28.1.1: Dumpfile name 'my_db052821179A ' section
number 1 mounted on disk file number 1 mounted on disk file
'/home/usr/u/dub101/sa/db_dump_dev.dat' '/home/usr/u/dub101/sa/db_dump_dev.dat'
Backup Server: 4.188.1.1: Database my_db: 2374 kilobytes (100%) Backup Server: 4.188.1.1: Database my_db: 2374 kilobytes (100%)
DUMPed. DUMPed.
Backup Server: 3.43.1.1: Dump phase number 1 completed. Backup Server: 3.43.1.1: Dump phase number 1 completed.
Backup Server: 3.43.1.1: Dump phase number 2 completed. Backup Server: 3.43.1.1: Dump phase number 2 completed.
Backup Server: 3.43.1.1: Dump phase number 3 completed. Backup Server: 3.43.1.1: Dump phase number 3 completed.
Backup Server: 4.188.1.1: Database my_db: 2388 kilobytes (100%) Backup Server: 4.188.1.1: Database my_db: 2388 kilobytes (100%)
DUMPed. DUMPed.
Backup Server: 3.42.1.1: DUMP is complete (database my_db). Backup Server: 3.42.1.1: DUMP is complete (database my_db).
f. Insert a row with value “3” into the test_dump table. f. Insert a row with value “3” into the test_dump table.
insert test_dump values (3) insert test_dump values (3)
g. Dump the transaction log for the my_db database to the dump device g. Dump the transaction log for the my_db database to the dump device
log_dump_dev (without using compression). log_dump_dev (without using compression).
dump tran my_db to log_dump_dev dump tran my_db to log_dump_dev
Backup Server session id is: 16. Use this value when executing Backup Server session id is: 16. Use this value when executing
the 'sp_volchanged' system stored procedure after the 'sp_volchanged' system stored procedure after
fulfilling any volume change request from the Backup Server. fulfilling any volume change request from the Backup Server.
Lab Solution 18 - 10 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 18 - 10 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 18: Performing a Backup Module 18: Performing a Backup
Backup Server: 4.41.1.1: Creating new disk file Backup Server: 4.41.1.1: Creating new disk file
/home/usr/u/dub101/sa/log_dump_dev.dat. /home/usr/u/dub101/sa/log_dump_dev.dat.
Backup Server: 6.28.1.1: Dumpfile name 'my_db05282118A2 ' section Backup Server: 6.28.1.1: Dumpfile name 'my_db05282118A2 ' section
number 1 mounted on disk file number 1 mounted on disk file
'/home/usr/u/dub101/sa/log_dump_dev.dat' '/home/usr/u/dub101/sa/log_dump_dev.dat'
Backup Server: 4.58.1.1: Database my_db: 6 kilobytes DUMPed. Backup Server: 4.58.1.1: Database my_db: 6 kilobytes DUMPed.
Backup Server: 4.58.1.1: Database my_db: 10 kilobytes DUMPed. Backup Server: 4.58.1.1: Database my_db: 10 kilobytes DUMPed.
Backup Server: 3.43.1.1: Dump phase number 3 completed. Backup Server: 3.43.1.1: Dump phase number 3 completed.
Backup Server: 4.58.1.1: Database my_db: 14 kilobytes DUMPed. Backup Server: 4.58.1.1: Database my_db: 14 kilobytes DUMPed.
Backup Server: 3.42.1.1: DUMP is complete (database my_db). Backup Server: 3.42.1.1: DUMP is complete (database my_db).
2. Load the database from the backup. 2. Load the database from the backup.
a. Access the master database. a. Access the master database.
use master use master
b. Load the my_db database from the dump device, db_dump_dev. b. Load the my_db database from the dump device, db_dump_dev.
load database my_db from db_dump_dev load database my_db from db_dump_dev
Backup Server session id is: 19. Use this value when executing Backup Server session id is: 19. Use this value when executing
the 'sp_volchanged' system stored procedure after the 'sp_volchanged' system stored procedure after
fulfilling any volume change request from the Backup Server. fulfilling any volume change request from the Backup Server.
Backup Server: 6.28.1.1: Dumpfile name 'my_db052821179A ' section Backup Server: 6.28.1.1: Dumpfile name 'my_db052821179A ' section
number 1 mounted on disk file number 1 mounted on disk file
'/home/usr/u/dub101/sa/db_dump_dev.dat' '/home/usr/u/dub101/sa/db_dump_dev.dat'
Backup Server: 4.188.1.1: Database my_db: 5256 kilobytes (85%) Backup Server: 4.188.1.1: Database my_db: 5256 kilobytes (85%)
LOADed. LOADed.
Backup Server: 4.188.1.1: Database my_db: 6150 kilobytes (100%) Backup Server: 4.188.1.1: Database my_db: 6150 kilobytes (100%)
LOADed. LOADed.
Backup Server: 4.188.1.1: Database my_db: 6160 kilobytes (100%) Backup Server: 4.188.1.1: Database my_db: 6160 kilobytes (100%)
LOADed. LOADed.
Backup Server: 3.42.1.1: LOAD is complete (database my_db). Backup Server: 3.42.1.1: LOAD is complete (database my_db).
Started estimating recovery log boundaries for database 'my_db'. Started estimating recovery log boundaries for database 'my_db'.
Database 'my_db', checkpoint=(2184, 29), first=(2184, 29), Database 'my_db', checkpoint=(2184, 29), first=(2184, 29),
last=(2185, 8). last=(2185, 8).
Completed estimating recovery log boundaries for database 'my_db'. Completed estimating recovery log boundaries for database 'my_db'.
Started ANALYSIS pass for database 'my_db'. Started ANALYSIS pass for database 'my_db'.
Completed ANALYSIS pass for database 'my_db'. Completed ANALYSIS pass for database 'my_db'.
Started REDO pass for database 'my_db'. The total number of log Started REDO pass for database 'my_db'. The total number of log
records to process is 10. records to process is 10.
Redo pass of recovery has processed 2 committed and 0 aborted Redo pass of recovery has processed 2 committed and 0 aborted
transactions. transactions.
Completed REDO pass for database 'my_db'. Completed REDO pass for database 'my_db'.
Use the ONLINE DATABASE command to bring this database online; ASE Use the ONLINE DATABASE command to bring this database online; ASE
will not bring it online automatically. will not bring it online automatically.
c. Bring the my_db database online. c. Bring the my_db database online.
online database my_db online database my_db
Started estimating recovery log boundaries for database 'my_db'. Started estimating recovery log boundaries for database 'my_db'.
Database 'my_db', checkpoint=(2184, 29), first=(2184, 29), Database 'my_db', checkpoint=(2184, 29), first=(2184, 29),
last=(2185, 8). last=(2185, 8).
Completed estimating recovery log boundaries for database 'my_db'. Completed estimating recovery log boundaries for database 'my_db'.
Started ANALYSIS pass for database 'my_db'. Started ANALYSIS pass for database 'my_db'.
Completed ANALYSIS pass for database 'my_db'. Completed ANALYSIS pass for database 'my_db'.
Recovery of database 'my_db' will undo incomplete nested top Recovery of database 'my_db' will undo incomplete nested top
actions. actions.
Database 'my_db' is now online. Database 'my_db' is now online.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 18 - 11 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 18 - 11
d. Access the my_db database and examine the contents of the test_dump table. d. Access the my_db database and examine the contents of the test_dump table.
use my_db use my_db
i i
----------- -----------
1 1
2 2
How many rows are in the table after loading the full database How many rows are in the table after loading the full database
dump? dump?
There are two rows. There are two rows.
Can the third row be restored from the backup sequence just Can the third row be restored from the backup sequence just
completed? Explain. completed? Explain.
Yes. The first two rows were on the full database dump while Yes. The first two rows were on the full database dump while
the third row was on the transaction dump. the third row was on the transaction dump.
Note: It is not a usual practice to load a transaction log dump once a Note: It is not a usual practice to load a transaction log dump once a
database has been brought online. We are doing it here for database has been brought online. We are doing it here for
demonstration purposes. It is usually done only with the demonstration purposes. It is usually done only with the
standby_access option, and then only for read-only databases (where standby_access option, and then only for read-only databases (where
the dump is loaded - a read/write database could be copied to another the dump is loaded - a read/write database could be copied to another
server this way). It is the no chkpt on recovery option that makes it server this way). It is the no chkpt on recovery option that makes it
possible to do the transaction log load after a database is online, and possible to do the transaction log load after a database is online, and
this is not the normal running mode (again, except for a server this is not the normal running mode (again, except for a server
running read-only and receiving transaction log dumps from another running read-only and receiving transaction log dumps from another
server). Normally, all transaction log dumps are loaded, in sequence, server). Normally, all transaction log dumps are loaded, in sequence,
IMMEDIATELY after loading a database dump, and only when all IMMEDIATELY after loading a database dump, and only when all
those loads are complete is the database brought online. those loads are complete is the database brought online.
b. Load the transaction dump for the my_db database from the dump device, b. Load the transaction dump for the my_db database from the dump device,
log_dump_dev. log_dump_dev.
load tran my_db from log_dump_dev load tran my_db from log_dump_dev
Backup Server session id is: 22. Use this value when executing Backup Server session id is: 22. Use this value when executing
the 'sp_volchanged' system stored procedure after the 'sp_volchanged' system stored procedure after
fulfilling any volume change request from the Backup Server. fulfilling any volume change request from the Backup Server.
Backup Server: 6.28.1.1: Dumpfile name 'my_db05282118A2 ' section Backup Server: 6.28.1.1: Dumpfile name 'my_db05282118A2 ' section
number 1 mounted on disk file number 1 mounted on disk file
'/home/usr/u/dub101/sa/log_dump_dev.dat' '/home/usr/u/dub101/sa/log_dump_dev.dat'
Lab Solution 18 - 12 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 18 - 12 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 18: Performing a Backup Module 18: Performing a Backup
Backup Server: 4.58.1.1: Database my_db: 14 kilobytes LOADed. Backup Server: 4.58.1.1: Database my_db: 14 kilobytes LOADed.
Backup Server: 3.42.1.1: LOAD is complete (database my_db). Backup Server: 3.42.1.1: LOAD is complete (database my_db).
Started estimating recovery log boundaries for database 'my_db'. Started estimating recovery log boundaries for database 'my_db'.
Database 'my_db', checkpoint=(2184, 29), first=(2184, 29), Database 'my_db', checkpoint=(2184, 29), first=(2184, 29),
last=(2185, 13). last=(2185, 13).
Completed estimating recovery log boundaries for database 'my_db'. Completed estimating recovery log boundaries for database 'my_db'.
Started ANALYSIS pass for database 'my_db'. Started ANALYSIS pass for database 'my_db'.
Completed ANALYSIS pass for database 'my_db'. Completed ANALYSIS pass for database 'my_db'.
Started REDO pass for database 'my_db'. The total number of log Started REDO pass for database 'my_db'. The total number of log
records to process is 14. records to process is 14.
Redo pass of recovery has processed 3 committed and 0 aborted Redo pass of recovery has processed 3 committed and 0 aborted
transactions. transactions.
Completed REDO pass for database 'my_db'. Completed REDO pass for database 'my_db'.
Started filling free space info for database 'my_db'. Started filling free space info for database 'my_db'.
Completed filling free space info for database 'my_db'. Completed filling free space info for database 'my_db'.
Started cleaning up the default data cache for database 'my_db'. Started cleaning up the default data cache for database 'my_db'.
Completed cleaning up the default data cache for database 'my_db'. Completed cleaning up the default data cache for database 'my_db'.
Use the ONLINE DATABASE command to bring this database online; ASE Use the ONLINE DATABASE command to bring this database online; ASE
will not bring it online automatically. will not bring it online automatically.
c. Bring the my_db database online. c. Bring the my_db database online.
online database my_db online database my_db
Started estimating recovery log boundaries for database 'my_db'. Started estimating recovery log boundaries for database 'my_db'.
Database 'my_db', checkpoint=(2185, 13), first=(2185, 12), Database 'my_db', checkpoint=(2185, 13), first=(2185, 12),
last=(2185, 13). last=(2185, 13).
Completed estimating recovery log boundaries for database 'my_db'. Completed estimating recovery log boundaries for database 'my_db'.
Started ANALYSIS pass for database 'my_db'. Started ANALYSIS pass for database 'my_db'.
Completed ANALYSIS pass for database 'my_db'. Completed ANALYSIS pass for database 'my_db'.
Recovery of database 'my_db' will undo incomplete nested top Recovery of database 'my_db' will undo incomplete nested top
actions. actions.
Started UNDO pass for database 'my_db'. The total number of log Started UNDO pass for database 'my_db'. The total number of log
records to process is 2. records to process is 2.
Undo pass of recovery has processed 1 incomplete transactions. Undo pass of recovery has processed 1 incomplete transactions.
Completed UNDO pass for database 'my_db'. Completed UNDO pass for database 'my_db'.
Database 'my_db' is now online. Database 'my_db' is now online.
d. Access the my_db database and examine the contents of the test_dump table. d. Access the my_db database and examine the contents of the test_dump table.
use my_db use my_db
i i
----------- -----------
1 1
2 2
3 3
How many rows are in the table after loading the full database dump How many rows are in the table after loading the full database dump
AND the transaction dump? AND the transaction dump?
All three rows have been restored. All three rows have been restored.
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 18 - 13 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 18 - 13
4. Continuing in Window A as the sa, reset the database options. 4. Continuing in Window A as the sa, reset the database options.
1. turn on the database option “trunc log on chkpt” for the my_db database. 1. turn on the database option “trunc log on chkpt” for the my_db database.
2. turn off the database option “no chkpt on recovery” for the my_db database. 2. turn off the database option “no chkpt on recovery” for the my_db database.
use master use master
exec sp_dboption my_db, "trunc log on chkpt", true exec sp_dboption my_db, "trunc log on chkpt", true
exec sp_dboption my_db, "no chkpt on recovery", false exec sp_dboption my_db, "no chkpt on recovery", false
Database option 'trunc log on chkpt' turned ON for database Database option 'trunc log on chkpt' turned ON for database
'my_db'. 'my_db'.
Running CHECKPOINT on database 'my_db' for option 'trunc log on Running CHECKPOINT on database 'my_db' for option 'trunc log on
chkpt' to take effect. chkpt' to take effect.
(return status = 0) (return status = 0)
Database option 'no chkpt on recovery' turned OFF for database Database option 'no chkpt on recovery' turned OFF for database
'my_db'. 'my_db'.
Running CHECKPOINT on database 'my_db' for option 'no chkpt on Running CHECKPOINT on database 'my_db' for option 'no chkpt on
recovery' to take effect. recovery' to take effect.
(return status = 0) (return status = 0)
Lab Solution 18 - 14 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 18 - 14 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 18: Performing a Backup Module 18: Performing a Backup
Task 4: Analyzing the Effects of Dump Compression Task 4: Analyzing the Effects of Dump Compression
Description In this task, you will analyze the effects of dump compression. Description In this task, you will analyze the effects of dump compression.
Procedure 1. Perform full database dumps for the my_db database with various compression values. Procedure 1. Perform full database dumps for the my_db database with various compression values.
In this section you will perform several database dumps for the same In this section you will perform several database dumps for the same
database using different levels of compression. database using different levels of compression.
Do not use the dump devices created earlier in this lab when Do not use the dump devices created earlier in this lab when
performing the dumps. performing the dumps.
Instead, create distinct physical dump files in the $HOME/sa Instead, create distinct physical dump files in the $HOME/sa
directory. Perform the following types of dumps using the associated directory. Perform the following types of dumps using the associated
file names: file names:
no compression: dump_my_db.no_compress no compression: dump_my_db.no_compress
default compression: dump_my_db.default_compress default compression: dump_my_db.default_compress
level 0 compression: dump_my_db.level0_compress level 0 compression: dump_my_db.level0_compress
level 1 compression: dump_my_db.level1_compress level 1 compression: dump_my_db.level1_compress
level 6 compression: dump_my_db.level6_compress level 6 compression: dump_my_db.level6_compress
level 9 compression: dump_my_db.level9_compress level 9 compression: dump_my_db.level9_compress
a. No compression - use the dump file name: dump_my_db.no_compress: a. No compression - use the dump file name: dump_my_db.no_compress:
dump database my_db to dump database my_db to
"/home/usr/u/dub101/sa/dump_my_db.no_compress" "/home/usr/u/dub101/sa/dump_my_db.no_compress"
Backup Server session id is: 25. Use this value when executing Backup Server session id is: 25. Use this value when executing
the 'sp_volchanged' system stored procedure after the 'sp_volchanged' system stored procedure after
fulfilling any volume change request from the Backup Server. fulfilling any volume change request from the Backup Server.
Backup Server: 4.41.1.1: Creating new disk file Backup Server: 4.41.1.1: Creating new disk file
/home/usr/u/dub101/sa/dump_my_db.no_compress. /home/usr/u/dub101/sa/dump_my_db.no_compress.
Backup Server: 6.28.1.1: Dumpfile name 'my_db0528211F27 ' section Backup Server: 6.28.1.1: Dumpfile name 'my_db0528211F27 ' section
number 1 mounted on disk file number 1 mounted on disk file
'/home/usr/u/dub101/sa/dump_my_db.no_compress' '/home/usr/u/dub101/sa/dump_my_db.no_compress'
Backup Server: 4.188.1.1: Database my_db: 2372 kilobytes (100%) Backup Server: 4.188.1.1: Database my_db: 2372 kilobytes (100%)
DUMPed. DUMPed.
Backup Server: 3.43.1.1: Dump phase number 1 completed. Backup Server: 3.43.1.1: Dump phase number 1 completed.
Backup Server: 3.43.1.1: Dump phase number 2 completed. Backup Server: 3.43.1.1: Dump phase number 2 completed.
Backup Server: 3.43.1.1: Dump phase number 3 completed. Backup Server: 3.43.1.1: Dump phase number 3 completed.
Backup Server: 4.188.1.1: Database my_db: 2384 kilobytes (100%) Backup Server: 4.188.1.1: Database my_db: 2384 kilobytes (100%)
DUMPed. DUMPed.
Backup Server: 3.42.1.1: DUMP is complete (database my_db). Backup Server: 3.42.1.1: DUMP is complete (database my_db).
b. Default compression - use the dump file name: dump_my_db.default_compress: b. Default compression - use the dump file name: dump_my_db.default_compress:
dump database my_db to dump database my_db to
"compress::/home/usr/u/dub101/sa/dump_my_db.default_compress" "compress::/home/usr/u/dub101/sa/dump_my_db.default_compress"
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 18 - 15 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 18 - 15
Backup Server session id is: 28. Use this value when executing Backup Server session id is: 28. Use this value when executing
the 'sp_volchanged' system stored procedure after the 'sp_volchanged' system stored procedure after
fulfilling any volume change request from the Backup Server. fulfilling any volume change request from the Backup Server.
Backup Server: 4.132.1.1: Attempting to open byte stream device: Backup Server: 4.132.1.1: Attempting to open byte stream device:
'compress::/home/usr/u/dub101/sa/dump_my_db.default_compress::00' 'compress::/home/usr/u/dub101/sa/dump_my_db.default_compress::00'
Backup Server: 6.28.1.1: Dumpfile name 'my_db0528211F5B ' section Backup Server: 6.28.1.1: Dumpfile name 'my_db0528211F5B ' section
number 1 mounted on byte stream number 1 mounted on byte stream
'compress::/home/usr/u/dub101/sa/dump_my_db.default_compress::00' 'compress::/home/usr/u/dub101/sa/dump_my_db.default_compress::00'
Backup Server: 4.188.1.1: Database my_db: 2372 kilobytes (100%) Backup Server: 4.188.1.1: Database my_db: 2372 kilobytes (100%)
DUMPed. DUMPed.
Backup Server: 3.43.1.1: Dump phase number 1 completed. Backup Server: 3.43.1.1: Dump phase number 1 completed.
Backup Server: 3.43.1.1: Dump phase number 2 completed. Backup Server: 3.43.1.1: Dump phase number 2 completed.
Backup Server: 3.43.1.1: Dump phase number 3 completed. Backup Server: 3.43.1.1: Dump phase number 3 completed.
Backup Server: 4.188.1.1: Database my_db: 2384 kilobytes (100%) Backup Server: 4.188.1.1: Database my_db: 2384 kilobytes (100%)
DUMPed. DUMPed.
Backup Server: 3.42.1.1: DUMP is complete (database my_db). Backup Server: 3.42.1.1: DUMP is complete (database my_db).
c. Level 0 compression - use the dump file name: dump_my_db.level0_compress: c. Level 0 compression - use the dump file name: dump_my_db.level0_compress:
dump database my_db to dump database my_db to
"compress::0::/home/usr/u/dub101/sa/dump_my_db.level0_compress" "compress::0::/home/usr/u/dub101/sa/dump_my_db.level0_compress"
Backup Server session id is: 31. Use this value when executing Backup Server session id is: 31. Use this value when executing
the 'sp_volchanged' system stored procedure after the 'sp_volchanged' system stored procedure after
fulfilling any volume change request from the Backup Server. fulfilling any volume change request from the Backup Server.
Backup Server: 4.132.1.1: Attempting to open byte stream device: Backup Server: 4.132.1.1: Attempting to open byte stream device:
'compress::0::/home/usr/u/dub101/sa/dump_my_db.level0_compress::00' 'compress::0::/home/usr/u/dub101/sa/dump_my_db.level0_compress::00'
Backup Server: 6.28.1.1: Dumpfile name 'my_db0528211F90 ' section Backup Server: 6.28.1.1: Dumpfile name 'my_db0528211F90 ' section
number 1 mounted on byte stream number 1 mounted on byte stream
'compress::0::/home/usr/u/dub101/sa/dump_my_db.level0_compress::00' 'compress::0::/home/usr/u/dub101/sa/dump_my_db.level0_compress::00'
Backup Server: 4.188.1.1: Database my_db: 2372 kilobytes (100%) Backup Server: 4.188.1.1: Database my_db: 2372 kilobytes (100%)
DUMPed. DUMPed.
Backup Server: 3.43.1.1: Dump phase number 1 completed. Backup Server: 3.43.1.1: Dump phase number 1 completed.
Backup Server: 3.43.1.1: Dump phase number 2 completed. Backup Server: 3.43.1.1: Dump phase number 2 completed.
Backup Server: 3.43.1.1: Dump phase number 3 completed. Backup Server: 3.43.1.1: Dump phase number 3 completed.
Backup Server: 4.188.1.1: Database my_db: 2384 kilobytes (100%) Backup Server: 4.188.1.1: Database my_db: 2384 kilobytes (100%)
DUMPed. DUMPed.
Backup Server: 3.42.1.1: DUMP is complete (database my_db). Backup Server: 3.42.1.1: DUMP is complete (database my_db).
d. Level 1 compression - use the dump file name: dump_my_db.level1_compress: d. Level 1 compression - use the dump file name: dump_my_db.level1_compress:
dump database my_db to dump database my_db to
"/home/usr/u/dub101/sa/dump_my_db.level1_compress" "/home/usr/u/dub101/sa/dump_my_db.level1_compress"
with compression = “1” with compression = “1”
Backup Server session id is: 34. Use this value when executing Backup Server session id is: 34. Use this value when executing
the 'sp_volchanged' system stored procedure after the 'sp_volchanged' system stored procedure after
fulfilling any volume change request from the Backup Server. fulfilling any volume change request from the Backup Server.
Backup Server: 4.132.1.1: Attempting to open byte stream device: Backup Server: 4.132.1.1: Attempting to open byte stream device:
'/home/usr/u/dub101/sa/dump_my_db.level1_compress::00' '/home/usr/u/dub101/sa/dump_my_db.level1_compress::00'
Backup Server: 6.28.1.1: Dumpfile name 'my_db0528211FB6 ' section Backup Server: 6.28.1.1: Dumpfile name 'my_db0528211FB6 ' section
number 1 mounted on byte stream number 1 mounted on byte stream
'compress::1::/home/usr/u/dub101/sa/dump_my_db.level1_compress' 'compress::1::/home/usr/u/dub101/sa/dump_my_db.level1_compress'
Backup Server: 4.188.1.1: Database my_db: 2372 kilobytes (100%) Backup Server: 4.188.1.1: Database my_db: 2372 kilobytes (100%)
DUMPed. DUMPed.
Backup Server: 3.43.1.1: Dump phase number 1 completed. Backup Server: 3.43.1.1: Dump phase number 1 completed.
Backup Server: 3.43.1.1: Dump phase number 2 completed. Backup Server: 3.43.1.1: Dump phase number 2 completed.
Backup Server: 3.43.1.1: Dump phase number 3 completed. Backup Server: 3.43.1.1: Dump phase number 3 completed.
Backup Server: 4.188.1.1: Database my_db: 2384 kilobytes (100%) Backup Server: 4.188.1.1: Database my_db: 2384 kilobytes (100%)
DUMPed. DUMPed.
Backup Server: 3.42.1.1: DUMP is complete (database my_db). Backup Server: 3.42.1.1: DUMP is complete (database my_db).
Lab Solution 18 - 16 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 18 - 16 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 18: Performing a Backup Module 18: Performing a Backup
e. Level 6 compression - use the dump file name: dump_my_db.level6_compress: e. Level 6 compression - use the dump file name: dump_my_db.level6_compress:
dump database my_db to dump database my_db to
"/home/usr/u/dub101/sa/dump_my_db.level6_compress" "/home/usr/u/dub101/sa/dump_my_db.level6_compress"
with compression = “6” with compression = “6”
Backup Server session id is: 37. Use this value when executing Backup Server session id is: 37. Use this value when executing
the 'sp_volchanged' system stored procedure after the 'sp_volchanged' system stored procedure after
fulfilling any volume change request from the Backup Server. fulfilling any volume change request from the Backup Server.
Backup Server: 4.132.1.1: Attempting to open byte stream device: Backup Server: 4.132.1.1: Attempting to open byte stream device:
'/home/usr/u/dub101/sa/dump_my_db.level6_compress' '/home/usr/u/dub101/sa/dump_my_db.level6_compress'
Backup Server: 6.28.1.1: Dumpfile name 'my_db0528211FDE ' section Backup Server: 6.28.1.1: Dumpfile name 'my_db0528211FDE ' section
number 1 mounted on byte stream number 1 mounted on byte stream
'/home/usr/u/dub101/sa/dump_my_db.level6_compress' '/home/usr/u/dub101/sa/dump_my_db.level6_compress'
Backup Server: 4.188.1.1: Database my_db: 2372 kilobytes (100%) Backup Server: 4.188.1.1: Database my_db: 2372 kilobytes (100%)
DUMPed. DUMPed.
Backup Server: 3.43.1.1: Dump phase number 1 completed. Backup Server: 3.43.1.1: Dump phase number 1 completed.
Backup Server: 3.43.1.1: Dump phase number 2 completed. Backup Server: 3.43.1.1: Dump phase number 2 completed.
Backup Server: 3.43.1.1: Dump phase number 3 completed. Backup Server: 3.43.1.1: Dump phase number 3 completed.
Backup Server: 4.188.1.1: Database my_db: 2384 kilobytes (100%) Backup Server: 4.188.1.1: Database my_db: 2384 kilobytes (100%)
DUMPed. DUMPed.
Backup Server: 3.42.1.1: DUMP is complete (database my_db). Backup Server: 3.42.1.1: DUMP is complete (database my_db).
f. Level 9 compression - use the dump file name: dump_my_db.level9_compress: f. Level 9 compression - use the dump file name: dump_my_db.level9_compress:
dump database my_db to dump database my_db to
"/home/usr/u/dub101/sa/dump_my_db.level9_compress" "/home/usr/u/dub101/sa/dump_my_db.level9_compress"
with compression = “9” with compression = “9”
Backup Server session id is: 40. Use this value when executing Backup Server session id is: 40. Use this value when executing
the 'sp_volchanged' system stored procedure after the 'sp_volchanged' system stored procedure after
fulfilling any volume change request from the Backup Server. fulfilling any volume change request from the Backup Server.
Backup Server: 4.132.1.1: Attempting to open byte stream device: Backup Server: 4.132.1.1: Attempting to open byte stream device:
'/home/usr/u/dub101/sa/dump_my_db.level9_compress' '/home/usr/u/dub101/sa/dump_my_db.level9_compress'
Backup Server: 6.28.1.1: Dumpfile name 'my_db0528212009 ' section Backup Server: 6.28.1.1: Dumpfile name 'my_db0528212009 ' section
number 1 mounted on byte stream number 1 mounted on byte stream
'/home/usr/u/dub101/sa/dump_my_db.level9_compress' '/home/usr/u/dub101/sa/dump_my_db.level9_compress'
Backup Server: 4.188.1.1: Database my_db: 2372 kilobytes (100%) Backup Server: 4.188.1.1: Database my_db: 2372 kilobytes (100%)
DUMPed. DUMPed.
Backup Server: 3.43.1.1: Dump phase number 1 completed. Backup Server: 3.43.1.1: Dump phase number 1 completed.
Backup Server: 3.43.1.1: Dump phase number 2 completed. Backup Server: 3.43.1.1: Dump phase number 2 completed.
Backup Server: 3.43.1.1: Dump phase number 3 completed. Backup Server: 3.43.1.1: Dump phase number 3 completed.
Backup Server: 4.188.1.1: Database my_db: 2384 kilobytes (100%) Backup Server: 4.188.1.1: Database my_db: 2384 kilobytes (100%)
DUMPed. DUMPed.
Backup Server: 3.42.1.1: DUMP is complete (database my_db). Backup Server: 3.42.1.1: DUMP is complete (database my_db).
2. Analyze the dump file sizes. 2. Analyze the dump file sizes.
a. In Window B, access the $HOME/sa directory. a. In Window B, access the $HOME/sa directory.
cd $HOME/sa cd $HOME/sa
b. Display a listing of the dump files just created by using the Unix ls -l command. b. Display a listing of the dump files just created by using the Unix ls -l command.
ls -l dump_my_db* ls -l dump_my_db*
-rw-r--r-- 1 dub101 260581 Oct 9 20:26 dump_my_db.default_compress -rw-r--r-- 1 dub101 260581 Oct 9 20:26 dump_my_db.default_compress
-rw-r--r-- 1 dub101 2453892 Oct 9 20:26 dump_my_db.level0_compress -rw-r--r-- 1 dub101 2453892 Oct 9 20:26 dump_my_db.level0_compress
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 18 - 17 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 18 - 17
-rw-r--r-- 1 dub101 260661 Oct 9 20:27 dump_my_db.level1_compress -rw-r--r-- 1 dub101 260661 Oct 9 20:27 dump_my_db.level1_compress
-rw-r--r-- 1 dub101 221434 Oct 9 20:28 dump_my_db.level6_compress -rw-r--r-- 1 dub101 221434 Oct 9 20:28 dump_my_db.level6_compress
-rw-r--r-- 1 dub101 219170 Oct 9 20:28 dump_my_db.level9_compress -rw-r--r-- 1 dub101 219170 Oct 9 20:28 dump_my_db.level9_compress
-rw-r--r-- 1 dub101 2453504 Oct 9 20:25 dump_my_db.no_compress -rw-r--r-- 1 dub101 2453504 Oct 9 20:25 dump_my_db.no_compress
Why are the default and level 1 compression dumps about the same Why are the default and level 1 compression dumps about the same
size? size?
Level 1 compression is the default compression level. Level 1 compression is the default compression level.
Why is the level 0 compression about the same size as the dump Why is the level 0 compression about the same size as the dump
made without compression? made without compression?
Level 0 is no compression. Level 0 is no compression.
Which compression produced the smallest dump file size? Would Which compression produced the smallest dump file size? Would
you expect to see a bigger difference for that dump file size you expect to see a bigger difference for that dump file size
(compared to the other dump files) if the database had been much (compared to the other dump files) if the database had been much
larger? larger?
Level 9 compression produces the smallest dump file size. Level 9 compression produces the smallest dump file size.
This database is relatively very tiny. You would see a much This database is relatively very tiny. You would see a much
larger difference between this dump file size as compared larger difference between this dump file size as compared
with the others had the database been of significant size. with the others had the database been of significant size.
On a heavily loaded system, why might you not want to use the best On a heavily loaded system, why might you not want to use the best
compression (level 9)? compression (level 9)?
The higher the compression level, the more CPU resources The higher the compression level, the more CPU resources
are needed to perform the compression. You have to are needed to perform the compression. You have to
carefully consider this “cost” with the I/O “benefit” that is carefully consider this “cost” with the I/O “benefit” that is
achieved. achieved.
3. Exit all client sessions with Adaptive Server. 3. Exit all client sessions with Adaptive Server.
4. Examine the following dump and load sequence and then answer the questions that 4. Examine the following dump and load sequence and then answer the questions that
follow: follow:
This is a thought exercise, you do not have to perform the following commands. This is a thought exercise, you do not have to perform the following commands.
First, a full database dump is performed with no compression as follows: First, a full database dump is performed with no compression as follows:
Then, after some data modification occurs, a transaction dump is performed with level Then, after some data modification occurs, a transaction dump is performed with level
9 compression: 9 compression:
Would the following load sequence be successful? Explain. Would the following load sequence be successful? Explain.
Lab Solution 18 - 18 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 18 - 18 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 18: Performing a Backup Module 18: Performing a Backup
This sequence would not be completely successful. The database load would This sequence would not be completely successful. The database load would
be fine but the transaction load would fail because the compression option be fine but the transaction load would fail because the compression option
used to perform the dump was not specified for the load. used to perform the dump was not specified for the load.
What would be the correct sequence to perform the load? What would be the correct sequence to perform the load?
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 18 - 19 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 18 - 19
Lab Solution 18 - 20 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 18 - 20 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 19: Practicing Advanced Backup Techniques Module 19: Practicing Advanced Backup Techniques
Module 19: Practicing Advanced Backup Techniques Module 19: Practicing Advanced Backup Techniques
Lab 19: Practicing Advanced Backup Techniques Lab 19: Practicing Advanced Backup Techniques
Lab Setup You will be using your 2K page size Adaptive Server and your Backup Server for this lab. Lab Setup You will be using your 2K page size Adaptive Server and your Backup Server for this lab.
Objectives After completing this lab, you should be able to: Objectives After completing this lab, you should be able to:
Implement a last-chance threshold procedure Implement a last-chance threshold procedure
Description In this lab, you will learn how to implement a last-chance threshold procedure and you will Description In this lab, you will learn how to implement a last-chance threshold procedure and you will
observe the effects of the quiesce database command. observe the effects of the quiesce database command.
Task Outline 1. Creating a Last-Chance Threshold Procedure Task Outline 1. Creating a Last-Chance Threshold Procedure
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 19 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 19 - 1
Note: If you have not completed the previous labs in which you Note: If you have not completed the previous labs in which you
created database devices and the my_db database then issue the created database devices and the my_db database then issue the
following commands now (substituting $SYBASE/ appropriately): following commands now (substituting $SYBASE/ appropriately):
disk init disk init
name = "data_dev", name = "data_dev",
physname = "$SYBASE/devices/data_dev.dat", physname = "$SYBASE/devices/data_dev.dat",
size = "4M" size = "4M"
go go
disk init disk init
name = "log_dev", name = "log_dev",
physname = "$SYBASE/devices/log_dev.mir", physname = "$SYBASE/devices/log_dev.mir",
size = 1024 size = 1024
go go
create database my_db on data_dev = 4 log on log_dev create database my_db on data_dev = 4 log on log_dev
= 2 = 2
go go
exec sp_addlogin tom, "friday", my_db exec sp_addlogin tom, "friday", my_db
exec sp_addlogin dick, "friday", my_db exec sp_addlogin dick, "friday", my_db
exec sp_addlogin harry, "friday", my_db exec sp_addlogin harry, "friday", my_db
go go
use my_db use my_db
go go
exec sp_adduser tom exec sp_adduser tom
exec sp_adduser dick exec sp_adduser dick
exec sp_adduser harry exec sp_adduser harry
go go
exec sp_addgroup programmers exec sp_addgroup programmers
exec sp_addgroup engineers exec sp_addgroup engineers
go go
exec sp_changegroup programmers, tom exec sp_changegroup programmers, tom
exec sp_changegroup programmers, dick exec sp_changegroup programmers, dick
exec sp_changegroup engineers, harry exec sp_changegroup engineers, harry
go go
For this lab, it would be useful to open two windows (“A” and “B”). For this lab, it would be useful to open two windows (“A” and “B”).
This allows you to have multiple client sessions with ASE This allows you to have multiple client sessions with ASE
simultaneously. simultaneously.
You should exit any active client sessions with Adaptive Server You should exit any active client sessions with Adaptive Server
before continuing. before continuing.
, ,
Lab Solution 19 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 19 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 19: Practicing Advanced Backup Techniques Module 19: Practicing Advanced Backup Techniques
Task 1: Creating a Last-chance Threshold Procedure Task 1: Creating a Last-chance Threshold Procedure
Description In this task, you will create a last-chance threshold procedure that dumps the transaction Description In this task, you will create a last-chance threshold procedure that dumps the transaction
log, prints a message to the Adaptive Server error log. You also test the last-chance log, prints a message to the Adaptive Server error log. You also test the last-chance
threshold to verify that it functions properly. threshold to verify that it functions properly.
Procedure Procedure
1. Create a last-chance threshold procedure. 1. Create a last-chance threshold procedure.
a. In Window A, connect to Adaptive Server as the sa. a. In Window A, connect to Adaptive Server as the sa.
isql -Usa -P isql -Usa -P
b. Turn off the database option “trunc log on chkpt” for the my_db database. b. Turn off the database option “trunc log on chkpt” for the my_db database.
You are going to create a last-chance threshold procedure that You are going to create a last-chance threshold procedure that
performs a transaction log dump. Therefore, the database performs a transaction log dump. Therefore, the database
option, “trunc log on chkpt”, must be off to perform a option, “trunc log on chkpt”, must be off to perform a
transaction dump. transaction dump.
use master use master
sp_dboption my_db, "trunc log on chkpt", false sp_dboption my_db, "trunc log on chkpt", false
Database option 'trunc log on chkpt' turned OFF for database Database option 'trunc log on chkpt' turned OFF for database
'my_db'. 'my_db'.
Running CHECKPOINT on database 'my_db' for option 'trunc log on Running CHECKPOINT on database 'my_db' for option 'trunc log on
chkpt' to take effect. chkpt' to take effect.
(return status = 0) (return status = 0)
c. Verify that the database option “trunc log on chkpt” is off and that “no chkpt on c. Verify that the database option “trunc log on chkpt” is off and that “no chkpt on
recovery” is on for the my_db database. recovery” is on for the my_db database.
sp_helpdb my_db sp_helpdb my_db
name db_size owner dbid created status name db_size owner dbid created status
----- ------------- ----- ------ ------------------ -------------- ----- ------------- ----- ------ ------------------ --------------
my_db 6.0 MB sa 5 Oct 04, 2005 select my_db 6.0 MB sa 5 Oct 04, 2005 select
into/bulkcopy/pllsort into/bulkcopy/pllsort
d. Continuing in the my_db database, examine the thresholds in place for the d. Continuing in the my_db database, examine the thresholds in place for the
database by using sp_helpthreshold. database by using sp_helpthreshold.
sp_helpthreshold sp_helpthreshold
segment name free pages last chance? threshold procedure segment name free pages last chance? threshold procedure
------------ ----------- ------------ ------------------- ------------ ----------- ------------ -------------------
logsegment 88 1 sp_thresholdaction logsegment 88 1 sp_thresholdaction
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 19 - 3 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 19 - 3
How many thresholds does the database have and where are How many thresholds does the database have and where are
they set? they set?
There is only one threshold and it is set at 88 free pages. There is only one threshold and it is set at 88 free pages.
What is the associated threshold procedure for the last-chance What is the associated threshold procedure for the last-chance
threshold? threshold?
sp_thresholdaction sp_thresholdaction
How can you determine whether this stored procedure exists? How can you determine whether this stored procedure exists?
Explain. Explain.
Even though Adaptive Server automatically sets up a last- Even though Adaptive Server automatically sets up a last-
chance threshold for every database, the pre-defined stored chance threshold for every database, the pre-defined stored
procedure that is associated with it, sp_thresholdaction, must procedure that is associated with it, sp_thresholdaction, must
be created. To determine whether the sp_thresholdaction be created. To determine whether the sp_thresholdaction
procedure has already been created for a target database, procedure has already been created for a target database,
you must first look for its existence in the target database. If you must first look for its existence in the target database. If
it is not there you must look for it in the sybsystemprocs it is not there you must look for it in the sybsystemprocs
database. database.
e. Create the last-chance threshold procedure, sp_thresholdaction, in the my_db e. Create the last-chance threshold procedure, sp_thresholdaction, in the my_db
database so that it performs a transaction log dump to a disk file and prints an database so that it performs a transaction log dump to a disk file and prints an
appropriate message. appropriate message.
Automatic log dumping should generate a new file name each Automatic log dumping should generate a new file name each
time as opposed to using a fixed file name or a dump device. time as opposed to using a fixed file name or a dump device.
Otherwise, each successive log dump will overwrite the previous Otherwise, each successive log dump will overwrite the previous
one! one!
For this lab you can dump to a simple file name that gets For this lab you can dump to a simple file name that gets
overwritten each time, for example: overwritten each time, for example:
dump tran @dbname to "dump_tran_my_db" dump tran @dbname to "dump_tran_my_db"
Or you can program a more sophisticated file name that is Or you can program a more sophisticated file name that is
unique for each dump, thus preserving the previous dump files. unique for each dump, thus preserving the previous dump files.
For example, your threshold procedure can create a dump file For example, your threshold procedure can create a dump file
name that is a string comprised of the database name and the name that is a string comprised of the database name and the
current system date (including a time stamp): current system date (including a time stamp):
Lab Solution 19 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 19 - 4 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 19: Practicing Advanced Backup Techniques Module 19: Practicing Advanced Backup Techniques
print "LOG DUMP: segment %1! for database %2! dumped", print "LOG DUMP: segment %1! for database %2! dumped",
@segmentname, @dbname @segmentname, @dbname
print "DUMP FILE NAME IS: %1! ", @dump_file_name print "DUMP FILE NAME IS: %1! ", @dump_file_name
2. Test the last-chance threshold procedure. 2. Test the last-chance threshold procedure.
a. Perform a full database dump for the my_db database. a. Perform a full database dump for the my_db database.
Note: If your Backup Server is not started, start it up now. Note: If your Backup Server is not started, start it up now.
Why is this step necessary for the threshold procedure that you just Why is this step necessary for the threshold procedure that you just
created? created?
Transaction log dumps cannot begin a database dump Transaction log dumps cannot begin a database dump
sequence. The sequence must start with a full database sequence. The sequence must start with a full database
dump. dump.
Backup Server session id is: 44. Use this value when executing Backup Server session id is: 44. Use this value when executing
the 'sp_volchanged' system stored procedure after the 'sp_volchanged' system stored procedure after
fulfilling any volume change request from the Backup Server. fulfilling any volume change request from the Backup Server.
Backup Server: 4.41.1.1: Creating new disk file Backup Server: 4.41.1.1: Creating new disk file
/alphadisk/home/dub101/ASE-15_0/install/full_dump_my_db. /alphadisk/home/dub101/ASE-15_0/install/full_dump_my_db.
Backup Server: 6.28.1.1: Dumpfile name 'my_db0528307EBF ' section Backup Server: 6.28.1.1: Dumpfile name 'my_db0528307EBF ' section
number 1 mounted on disk file number 1 mounted on disk file
'/alphadisk/home/dub101/ASE-15_0/install/full_dump_my_db' '/alphadisk/home/dub101/ASE-15_0/install/full_dump_my_db'
Backup Server: 4.188.1.1: Database my_db: 2372 kilobytes (100%) Backup Server: 4.188.1.1: Database my_db: 2372 kilobytes (100%)
DUMPed. DUMPed.
Backup Server: 3.43.1.1: Dump phase number 1 completed. Backup Server: 3.43.1.1: Dump phase number 1 completed.
Backup Server: 3.43.1.1: Dump phase number 2 completed. Backup Server: 3.43.1.1: Dump phase number 2 completed.
Backup Server: 3.43.1.1: Dump phase number 3 completed. Backup Server: 3.43.1.1: Dump phase number 3 completed.
Backup Server: 4.188.1.1: Database my_db: 2384 kilobytes (100%) Backup Server: 4.188.1.1: Database my_db: 2384 kilobytes (100%)
DUMPed. DUMPed.
Backup Server: 3.42.1.1: DUMP is complete (database my_db). Backup Server: 3.42.1.1: DUMP is complete (database my_db).
b. Create a simple table in the my_db database as follows: b. Create a simple table in the my_db database as follows:
create table test_lct (i int, c char(100)) create table test_lct (i int, c char(100))
c. Force the my_db database to reach the last-chance threshold by performing the c. Force the my_db database to reach the last-chance threshold by performing the
following T-SQL batch. (Note the use of set nocount on and the go 5000.) following T-SQL batch. (Note the use of set nocount on and the go 5000.)
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 19 - 5 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 19 - 5
Examine the careful construction of this batch: Examine the careful construction of this batch:
1. It uses set nocount on to eliminate the “rows affected” message 1. It uses set nocount on to eliminate the “rows affected” message
displayed by each insert and delete statement. displayed by each insert and delete statement.
2. The suggested approach is to use a delete followed by a insert so 2. The suggested approach is to use a delete followed by a insert so
that the data segment does not fill up before the log segment does. that the data segment does not fill up before the log segment does.
(No threshold procedure has been set up for the data segment.) (No threshold procedure has been set up for the data segment.)
3. The go 5000 tells Adaptive Server to repeat the batch sequence 3. The go 5000 tells Adaptive Server to repeat the batch sequence
5000 times. 5000 times.
Space available in the log segment has fallen critically low in Space available in the log segment has fallen critically low in
database 'my_db'. All future modifications to this database 'my_db'. All future modifications to this
database will be suspended until the log is successfully dumped and database will be suspended until the log is successfully dumped and
space becomes available. space becomes available.
The transaction log in database my_db is almost full. Your The transaction log in database my_db is almost full. Your
transaction is being suspended until space is made available transaction is being suspended until space is made available
in the log. in the log.
5000 xacts: 5000 xacts:
Did you see a warning message concerning the transaction log Did you see a warning message concerning the transaction log
becoming full? If yes, what happened? becoming full? If yes, what happened?
Yes, the message was displayed and the system temporarily Yes, the message was displayed and the system temporarily
waited while the threshold procedure took effect. waited while the threshold procedure took effect.
How can you tell that the batch successfully completed 5000 times? How can you tell that the batch successfully completed 5000 times?
The message “5000 xacts:” should be displayed after a The message “5000 xacts:” should be displayed after a
momentary pause while the dump is occurring. momentary pause while the dump is occurring.
Note: If the batch does not complete successfully after a few Note: If the batch does not complete successfully after a few
minutes, it’s possible that your threshold procedure is not minutes, it’s possible that your threshold procedure is not
functioning properly. You may have to open another session functioning properly. You may have to open another session
with Adaptive Server and kill the process in Window A and then with Adaptive Server and kill the process in Window A and then
manually truncate the log for the my_db database: manually truncate the log for the my_db database:
kill spid# kill spid#
go go
dump tran my_db with truncate_only dump tran my_db with truncate_only
go go
Next, if the sp_thresholdaction procedure contains logical Next, if the sp_thresholdaction procedure contains logical
programming mistakes, drop and create it again. Then start the programming mistakes, drop and create it again. Then start the
test sequence in step 2 over again. Also, make sure the Backup test sequence in step 2 over again. Also, make sure the Backup
Server is up and running. Server is up and running.
3. Verify that the threshold procedure performed as programmed. 3. Verify that the threshold procedure performed as programmed.
a. In Window B, change the directory to $SYBASE/$SYBASE_ASE/install. a. In Window B, change the directory to $SYBASE/$SYBASE_ASE/install.
cd $SYBASE/$SYBASE_ASE/install cd $SYBASE/$SYBASE_ASE/install
Lab Solution 19 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 19 - 6 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 19: Practicing Advanced Backup Techniques Module 19: Practicing Advanced Backup Techniques
b. Verify that the threshold procedure print messages were written to the Adaptive b. Verify that the threshold procedure print messages were written to the Adaptive
Server error log ($DSQUERY.log) by examining the log using any available Server error log ($DSQUERY.log) by examining the log using any available
operating system command such as tail or an editor such as vi. operating system command such as tail or an editor such as vi.
tail $DSQUERY.log tail $DSQUERY.log
00:00000:00020:2005/10/10 09:22:29.52 server background task 00:00000:00020:2005/10/10 09:22:29.52 server background task
message: LOG DUMP: segment logsegment for database my_db dum message: LOG DUMP: segment logsegment for database my_db dum
ped ped
00:00000:00020:2005/10/10 09:22:29.52 server background task 00:00000:00020:2005/10/10 09:22:29.52 server background task
message: DUMP FILE NAME IS: my_dbOct 10 2005 9:22AM message: DUMP FILE NAME IS: my_dbOct 10 2005 9:22AM
c. Examine the end of the Backup Server log (${DSQUERY}_BS.log) for messages c. Examine the end of the Backup Server log (${DSQUERY}_BS.log) for messages
concerning the dump performed by the threshold procedure, looking for the last concerning the dump performed by the threshold procedure, looking for the last
occurrence of the phrase “Dumpfile name . . . “. occurrence of the phrase “Dumpfile name . . . “.
tail ${DSQUERY}_BS.log tail ${DSQUERY}_BS.log
Oct 10 09:22:29 2005: Backup Server: 2.23.1.1: Connection from Oct 10 09:22:29 2005: Backup Server: 2.23.1.1: Connection from
Server DUB101_2K on Host with HostProcid . Server DUB101_2K on Host with HostProcid .
Oct 10 09:22:29 2005: Backup Server: 4.41.1.1: Creating new disk Oct 10 09:22:29 2005: Backup Server: 4.41.1.1: Creating new disk
file /alphadisk/home/dub101/ASE-15_0/install/my_dbOct 10 file /alphadisk/home/dub101/ASE-15_0/install/my_dbOct 10
2005 9:22AM. 2005 9:22AM.
Oct 10 09:22:29 2005: Backup Server: 6.28.1.1: Dumpfile name Oct 10 09:22:29 2005: Backup Server: 6.28.1.1: Dumpfile name
'my_db05283083D5 ' section number 1 mounted on disk file '/a 'my_db05283083D5 ' section number 1 mounted on disk file '/a
lphadisk/home/dub101/ASE-15_0/install/my_dbOct 10 2005 9:22AM' lphadisk/home/dub101/ASE-15_0/install/my_dbOct 10 2005 9:22AM'
Oct 10 09:22:29 2005: Backup Server: 4.58.1.1: Database my_db: 1866 Oct 10 09:22:29 2005: Backup Server: 4.58.1.1: Database my_db: 1866
kilobytes DUMPed. kilobytes DUMPed.
Oct 10 09:22:29 2005: Backup Server: 3.43.1.1: Dump phase number 3 Oct 10 09:22:29 2005: Backup Server: 3.43.1.1: Dump phase number 3
completed. completed.
Oct 10 09:22:29 2005: Backup Server: 4.58.1.1: Database my_db: 1874 Oct 10 09:22:29 2005: Backup Server: 4.58.1.1: Database my_db: 1874
kilobytes DUMPed. kilobytes DUMPed.
Oct 10 09:22:29 2005: Backup Server: 3.42.1.1: DUMP is complete Oct 10 09:22:29 2005: Backup Server: 3.42.1.1: DUMP is complete
(database my_db). (database my_db).
d. Verify that the transaction dump file was created by using the Unix ls command. d. Verify that the transaction dump file was created by using the Unix ls command.
ls -l my_db* ls -l my_db*
-rw-r--r-- 1 dub101 sybase 1931264 Oct 10 09:22 my_dbOct 10 -rw-r--r-- 1 dub101 sybase 1931264 Oct 10 09:22 my_dbOct 10
2005 9:22AM 2005 9:22AM
Based on you examination of the Adaptive Server and Backup Based on you examination of the Adaptive Server and Backup
Server log files, can you conclude that the threshold procedure Server log files, can you conclude that the threshold procedure
performed as programmed? performed as programmed?
Yes. The appropriate messages were generated to the log Yes. The appropriate messages were generated to the log
files and the transaction dump file appeared in the directory files and the transaction dump file appeared in the directory
listing. listing.
4. Continuing in Window A as the sa, turn on the database option “trunc log on chkpt” 4. Continuing in Window A as the sa, turn on the database option “trunc log on chkpt”
for the my_db database (to restore its state for future labs). for the my_db database (to restore its state for future labs).
use master use master
sp_dboption my_db, "trunc log on chkpt", true sp_dboption my_db, "trunc log on chkpt", true
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 19 - 7 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 19 - 7
Database option 'trunc log on chkpt' turned ON for database Database option 'trunc log on chkpt' turned ON for database
'my_db'. 'my_db'.
Running CHECKPOINT on database 'my_db' for option 'trunc log on Running CHECKPOINT on database 'my_db' for option 'trunc log on
chkpt' to take effect. chkpt' to take effect.
(return status = 0) (return status = 0)
Lab Solution 19 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 19 - 8 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 20: Sybase Central Module 20: Sybase Central
There are no labs in this module There are no labs in this module
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 20 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 20 - 1
Lab Solution 20 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 20 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Module 21: Monitoring the System Module 21: Monitoring the System
Module 21: Monitoring the System Module 21: Monitoring the System
There are no labs in this module There are no labs in this module
©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 21 - 1 ©2006 Sybase, Inc. System and Database Administration: Adaptive Server Enterprise – Version 1.1 Lab Solution 21 - 1
Lab Solution 21 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc. Lab Solution 21 - 2 System and Database Administration: Adaptive Server Enterprise – Version 1.1 ©2006 Sybase, Inc.
Internal Use Only!
Internal Use Only!
Internal Use Only!
* EDB356-90-1500-11-LWU-S * * EDB356-90-1500-11-LWU-S *
Printed In Canada Printed In Canada
EDB356-90-1500-11 Internal Use Only! EDB356-90-1500-11