database administration ecs release 5 training. 625-cd-511-001 2 objectives create new database...
TRANSCRIPT
DATABASE ADMINISTRATION
ECS Release 5 Training
625-CD-511-001
2
Objectives
• Create new database devices
• Allocate disk space
• Maintain database segments
• Maintain transaction logs, error logs
• Maintain the interfaces file (Configure SQL Server)
• Startup and shutdown SQL servers
• Startup and shutdown Back Server
• Startup and shutdown Monitor Server
• Security and monitoring
• Product Installation and Disk Storage Management
• Backup and recovery
• Configuring, tuning, and monitoring
625-CD-511-001
3
DBA Tasks and Functions
• Perform database backup, transaction log maintenance, and database recovery.
• Monitor and tune the physical allocation of database resources.
• Maintain user accounts.
• Create user registration and account access control permissions in the security database.
• Work with data specialists on DB design, data sets, and metadata management.
625-CD-511-001
4
Sybase Directory Structure
Directory Contains
$SYBASE/bin Utilities necessary to load, run, and accessthe server
$SYBASE /install Files used to start dataservers,backupserver and to record servermessages (errorlogs)
$SYBASE /scripts Root directory for all script files executedon the server
$SYBASE/scripts/ mk_DB_database.sql (e.g. database = SubServer)
SQL script files used to create databaseson the server
$SYBASE/scripts/ add_devices.sql SQL script file (disk init) used to mapphysical storage to a logical name.
$SYBASE/scripts/ alter_DB_tempdb.sql
SQL script file used to alter the database.
$SYBASE /scripts/ del_user Script file used to delete logins andremove them from the users database.
backup directory:$SYBASE/sybase.dumps
Root directory that contains all backupsubdirectories. It is recommended, but notrequired, that this directory be on aseparate physical disk
625-CD-511-001
5
Version 2.0 SQL Servers
Database Content
g0acg01_srvr Data Subsystem Server (Science Dataserver and StorageManagement)
g0acg01_backup
g0ins01_srvr Subscription Server
g0ins01_backup
g0mss21_srvr Management Subsystem Server (ACL and MSS Databases)
g0mss21_backup
g0ins02_srvr Data Management Server (Advertising and Data Dictionary)
g0ins02_backup
g0pls02_srvr Planning and Data Processing Server (Autosys)
g0pls02_backup
g0icg01_srvr Ingest Server
g0icg01_backup
625-CD-511-001
6
Version 2.0 Production Databases
Database Content
Ingest DB File types to be ingested, status of ingest production requests,historical summary.
Planning & Data ProcessingSystem (PDPS)
PGE information to plan production.
Metadata Collection, granule, document, producer, and other descriptiveinformation about science data.
MSS Management DB System and application performance information, user profiles, andorder tracking information.
Storage Management PullMonitor
Staging disk usage, tape drives available, requests needing resources.
Data Dictionary User descriptions of attributes and other terms in system
Document Database (WEB-based search only)
ECS-related science documents.
ASTER Lookup Table (LUT) Atmospheric correction parameters
CSS Persistent Access ControlList (ACL)
List of principals who can access components.
Advertising Database Holdings and services available to users.
Subscription Database Principals (users or servers) to be notified when a specified eventoccurs.
625-CD-511-001
7
Version 2.0 System ManagementDatabases
Application Tool Server
Network Management HP OpenView MSS
System Performance Management Tivoli TME/Sentry MSS
Extensible SNMP Agent Peer Networks Optima All platforms
Trouble Ticketing Remedy Corporation ARS MSS
Physical Configuration Management Accugraph Corporation (PNM) MSS
Security/DCE Management HAL DCE Cell Manager CSS
Software Change Management Clearcase CM
Change Request Management DDTS CM
Baseline Manager HTG XRP CM
625-CD-511-001
8
Naming Conventions
• The file name should indicate the function and/or content of the object regardless of the length of the file name.
• Only easily understandable abbreviations should be used.
• Parts of names are separated by the underscore character(_).
• Only one optional suffix is permitted and is appended to the file name by a period (.).
• The full path of the object is considered to be part of the name.
625-CD-511-001
9
Version 2.0 Databases
Production Databases
System Management Databases
Version 2.0 databases are divided into two categories:
625-CD-511-001
10
B.0 Databases
ICLHWIngest
ICLHWIngest
DMGHWAdvertising
DMGHWAdvertising
ACMHWStorage Management Pull Monitor
Metadata
ACMHWStorage Management Pull Monitor
Metadata
PLNHWPlanning and Data Processing Subsystem
PLNHWPlanning and Data Processing Subsystem
ASTER LUTAster Lookup Table
(EDC only)
ASTER LUTAster Lookup Table
(EDC only)
625-CD-511-001
11
SQL Server
SQL Server Executable (shared)
Operating System
Procedure Cache
Locks
Pending I/O queue
OtherMemory
Shared Memory
CPUs DisksNetwork
Engine 0
NetworkI/O
Running
RegistersFile Descriptors
Engine 1
NetworkI/O
Running
RegistersFile Descriptors
Engine N
NetworkI/O
Running
RegistersFile Descriptors
Data Caches
625-CD-511-001
12
What is a Transaction Log?
• Automatically records every transaction issued by each user of the DB.
• Keeps track of all changes to the database.
• Each database has its own transaction log.
• Cannot be turned off.
• Write-ahead file. Changes are reversed if transaction fails to complete.
• Receive a dump transactions in seconds.
625-CD-511-001
13
Transaction Log Backup
• Transaction Log - an expanding file that records all database transactions.
• Used for complete recovery of DB if media fails.
• Maintained on a different device than DB
• Backed up with regular system backups, but non-scheduled backups can be performed with permission.
625-CD-511-001
14
Maintaining the Interfaces file
• Adding an entry to the interfaces file (When a new SQL Server is created)
• Modifying an existing entry in the interface file (When the machine that has the SQL Server is running gets moved)
625-CD-511-001
15
Start & Stop SQL Server
STOP! BACKUP and MONITOR Server must be
STOPPED before STOPPING SQL Server
START the SQL Serverafter installation, system
outageor maintenance
625-CD-511-001
16
Start & Stop SQL Backup Server
STOP the BACKUP Server before STOPPING SQL
Server
SQL Server must be Up and Running in order to
START the BACKUP Server
625-CD-511-001
17
Start & Stop SQL Monitor Server
STOP the MONITOR Server before stopping SQL Server
SQL Server mustbe up and running in order
to START the MONITOR Server
625-CD-511-001
18
Database Device
• Stores objects that make up databases
• May be:
– a distinct physical device
– a disk partition
– a file
• Must be initialized first
625-CD-511-001
19
Initializing a Database DeviceCommand Script Template
/******************************************/ /* name: [add_devices.sql] */ /* purpose: */ /* written: */ /* revised: */ /* reason: */ /******************************************/ disk init name = [device name], physname = "/dev/[device name]", vdevno = [#], size = [size] go sp_helpdevice [device name} go
625-CD-511-001
20
Completed database device creation script
/**************************************************/ /* name: test_dev.sql */ /* purpose: allocate 3Mb device for testing */ /* written: 12/18/97 */ /* revised: */ /* reason: */ /**************************************************/ disk init name = test_dev, physname =
“/usr/ecs/REL_A/COTS/sybase/studentdevices/test_dev.dat”, vdevno = 15, size = 1536 go sp_helpdevice test_dev go
625-CD-511-001
21
Create New DatabaseCommand Script Template
/*******************************************/ /* name: [database name].sql */ /* purpose: */ /* written: */ /* revised: */ /* reason: */ /******************************************/ create database [database name] on [data device name] = [#] /* size in Mb */ go sp_helpdb [database name] go
625-CD-511-001
22
Completed Create DatabaseScript
/************************************/ /* name: test_db.sql */ /* purpose: create a database for */ /* testing */ /* written: 12/19/97 */ /* revised: */ /* reason: */ /************************************/ create database test_db on test_dev = 3 go sp_helpdb test_db go
625-CD-511-001
23
User Database Request Form
User Database Request Form
REQUESTER INFORMATION:Name: ______________________________________________________________________Office Phone Number: __________________________________________________________E-Mail Address: ______________________________ Office Location: ___________________
DATABASE(S) TO BE CREATED:_______________________________________________________________________________________________________________________________________________________________________________________________________________________________________
JUSTIFICATION: _____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Date of Request: ________________________ Date Required: ________________________
Supervisor Approval: __________________________________________ Date: ____________Ops Supervisor Approval: ______________________________________ Date: ____________
User Database Request Form
REQUESTER INFORMATION:Name: ______________________________________________________________________Office Phone Number: __________________________________________________________E-Mail Address: ______________________________ Office Location: ___________________
DATABASE(S) TO BE CREATED:_______________________________________________________________________________________________________________________________________________________________________________________________________________________________________
JUSTIFICATION: _____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Date of Request: ________________________ Date Required: ________________________
Supervisor Approval: __________________________________________ Date: ____________Ops Supervisor Approval: ______________________________________ Date: ____________
625-CD-511-001
24
Renaming DatabaseCommand Sample
/* Rename database Old-database-name to New-database-name */
sp_dboption Old-database-name, "single user", truegouse Old-database-namegocheckpointgouse mastergosp_renamedb Old-database-name, New-database-namegosp_dboption New-database-name, "single user", falsegouse New-database-namegocheckpointgouse mastergo
625-CD-511-001
25
T1INS01
• t1ins01_srvr• t1ins01_mon_srvr• t1ins01_syb_backup
T1MSS07
• t1mss06_srvr• t1mss06_mon_srvr• t1mss06_syb_backup
T1INS02
• t1ins02_srvr• t1ins02_mon_srvr• t1ins02_syb_backup
T1PLS01
• t1pls01_srvr• t1pls01_mon_srvr• t1pls01_syb_backup
T1ICG01
• t1icg01_srvr• t1icg01_sqs222_srvr• t1icg01_mon_srvr• t1icg01_syb_backup
T1MSS06
• t1mss06_srvr• t1mss06_mon_srvr• t1mss06_syb_backup
T1ICG03
• t1icg03_srvr• t1icg03_sqs222_srvr• t1icg03_mon_srvr• t1icg03_syb_backup
T1MSH01
• t1msh01_srvr• t1msh01_mon_srvr• t1msh01_syb_backup
T1ACG01
• t1acg01_srvr• t1acg01_sqs222_srvr• t1acg01_mon_srvr• t1acg01_syb_backup
T1SPS02
• t1sps02_srvr• t1sps02_mon_srvr• t1sps02_syb_backup
Servers Name:(Sybase & SQS)
625-CD-511-001
26
Changing PasswordCommand Sample
sp_password old-password, new-password, user-name
625-CD-511-001
27
Database Segments
• Collection of database devices or fragments available to a particular database
• Can have tables and indexes assigned to it
• Can span a set of physical devices
• Created when the database is created or when DBA deems necessary or as part of the database recovery procedure
625-CD-511-001
28
Why Database Segments?
• Reduces read/write access time
• Increases SQL Server performance
• Added administrative control over placement, size, and space usage of specific database objects
625-CD-511-001
29
Database Segments Template File
/******************************************//* name: [segment.sql] *//* purpose: *//* written: *//* revised: *//* reason: *//******************************************/
sp_addsegment [seg_name], [DBname], [Device Name]gogo[DBDevice]
625-CD-511-001
30
Sample template.sql file for creation of a database table
/************************************/ /* name: [table name].sql */ /* purpose: */ /* written: */ /* revised: */ /* reason: */ /************************************/ use [database name] go create table [table name] ( [column 1] [datatype] [null | not null] [column 2] [datatype] [null | not null] ) go sp_help [table name] go /* for any other objects consult */
/* appropriate documentation */
625-CD-511-001
31
Completed Create Table Script
/******************************************/ /* name: test_table.sql */ /* purpose: create a database table for */
/* testing */ /* written: 12/19/97 */ /* revised: */ /* reason: */ /******************************************/ use [database name] go create table test_table ( last_name varchar(30) not null, first_name varchar(30) not null, ) go sp_helpdb test_table go
625-CD-511-001
32
Backup and Recovery
625-CD-511-001
33
Database Data Backup
• Databases data are backed daily
• Can be requested at any time
• Need to know the following:– Name of DB to be backed up
– Name of the server on which the DB resides
– Name of the backup volume
– Name of the dump file on the backup volume
• Run daily by a UNIX Cron Job
625-CD-511-001
34
Database Recovery/Database Device Restoration
• Device Failure verified by SA
• SA requests a restoration from the DBA
• Transaction log for each DB on the failed device is backed up
• DBA examines space usage of each DB on failed device.
• DB(s) on the failed device are deleted; then device is deleted
• DBA initializes new DB device
• DBA recreates each user DB on the new device
• Each DB is restored from DB backups and transaction logs
• DBA notifies SA when restoration is complete.
625-CD-511-001
35
Sample template.sql file for new database user login
/******************************************/ /* name: [template.sql] */ /* purpose: */ /* written: */ /* revised: */ /* reason: */ /******************************************/
sp_addlogin [login name], [password], [defaultdatabase]
gouse [default database]gosp_adduser [login name]go/* the following is optional, by database */sp_changegroup [group name], [login name]gosp_helpuser
go
625-CD-511-001
36
dbcc memusage Sample Output
Meg. 2K Blks Bytes
Configured Memory: 400.0000 204800 419430400
Code size: 3.4259 1755 3592296Kernel Structures: 5.9769 3061 6267212Server Structures: 13.9494 7143 14627040Cache Memory: 357.0625 182816 374407168Proc Buffers: 0.6974 358 731272Proc Headers: 18.8848 9669 19802112
625-CD-511-001
37
Configure SQL Server
• Customization
• Fine Tuning
• Optimize memory allocation or performance
• Configuration Variables:– allow/deny updates
– audit queue size
– password expiration interval
– remote access
• Some values take effect immediately, others require a server reboot.
– When in doubt, reboot!
625-CD-511-001
38
I provide M
ister Quester w
ith a
password for th
e SQL Server,
Then I send e-m
ail to everyone
to confirm th
e new account.
SQL Server Login Approval Process
I complete theSQL Server Login
Request Form and
send it to mySupervisor.
Looks okay to me!I’ll send it to the
Database Administrator.
R. E. Quester
If the form is complete, I’ll
approve it andsend it on to the
Operations Supervisor.
625-CD-511-001
39
SQL Server Login AccountRequest Form
SQL Server Login Account Request
REQUESTER INFORMATION:Name: ______________________________________________________________________UNIX ID: _______________________________ Group: _______________________________Office Phone Number: __________________________________________________________E-Mail Address: ______________________________ Office Location: ___________________
Database(s) to be accessed: _____________________________________________________________________________________________________________________________________________________________________________________________________________Permissions required for database objects:_______________________________________________________________________________________________________________________Justification: __________________________________________________________________________________________________________________________________________________________________________________________________________________________
Date of Request: ________________________ Date Required: ________________________
Supervisor Approval: __________________________________________ Date: ____________Ops Supervisor Approval: ______________________________________ Date: ____________
625-CD-511-001
40
Database Access Privileges
Assign a user to a group that hasspecific access
privileges.
Assign a userobject permissions.
Assign a user command
permissions.
625-CD-511-001
41
Database Tuning andPerformance Monitoring
• Use sp_config to determine current configuration parameters and set future run values.
• Use dbcc memusage to determine current memory usage.
• Use sp_spaceused to determine how much space has been used on the device.
• Running two event processors
625-CD-511-001
42
sp_config Sample Output>sp_configure>go name minimum maximum config_value run_value ---------------------------- ----------- ----------- ------------ ----------- recovery interval 1 32767 0 5 allow updates 0 1 0 0 user connections 5 2147483647 0 25 memory 3850 2147483647 0 5120 open databases 5 2147483647 0 12 locks 5000 2147483647 0 5000 open objects 100 2147483647 0 500 procedure cache 1 99 0 20 fill factor 0 100 0 0 time slice 50 1000 0 100 database size 2 10000 0 2 tape retention 0 365 0 0 recovery flags 0 1 0 0 nested triggers 0 1 1 1 devices 4 256 0 10 remote access 0 1 1 1 remote logins 0 2147483647 0 20 remote sites 0 2147483647 0 10 remote connections 0 2147483647 0 20 pre-read packets 0 2147483647 0 3 upgrade version 0 2147483647 1002 1002 default sortorder id 0 255 50 50 default language 0 2147483647 0 0 language in cache 3 100 3 3 max online engines 1 32 1 1 min online engines 1 32 1 1 engine adjust interval 1 32 0 0 cpu flush 1 2147483647 200 200 i/o flush 1 2147483647 1000 1000 default character set id 0 255 1 1 stack size 20480 2147483647 0 28672 password expiration interval 0 32767 0 0 audit queue size 1 65535 100 100 additional netmem 0 2147483647 0 0 default network packet size 512 524288 0 512 maximum network packet size 512 524288 0 512 extent i/o buffers 0 2147483647 0 0 identity burning set factor 1 9999999 5000 5000 allow sendmsg 0 1 0 0 sendmsg starting port number 0 65535 0 0
(40 rows affected, return status = 0)
625-CD-511-001
43
Physical MemoryUtilization Scheme
Operating System Kerneland Other Applications
SQLServer
Executable
SQLServerKernel
SQLServerInternal
Structures
Procedure Data
Configurable
SQL Server Cache
625-CD-511-001
44
Topology for Running Two Event Processors
EventServe
r#1
EventServe
r
reads&
writes
reads&
writes
writes
PrimaryProcesso
r
ShadowProcessor
Run Job
RemoteAgent
UserCommand
PING
StartJob
MACHINE
MACHINE B (PLS)MACHINE A (SPS)Remote
Third
#1 #2
625-CD-511-001
45
Sybase Security (Auditing)
1) Run sybinit and install auditing.2) Add a login for auditing: sp_addlogin ssa, ssa_password, sybsecurity use sybsecurity sp_changedbowner ssa sp_role "grant", sso_role, ssa3) Enable auditing: sp_auditoption "enable auditing", "on" sp_auditlogin loginname, "cmdtext", "on"4) To Test: create a table in a database with one field grant all on the table for the loginname log into isql using the loginname insert a record into the table log into isql as ssa select * from sysaudits where loginname = "loginname"
625-CD-511-001
46
Integrity Monitoring
Database Consistency Checker
dbcc: is a set of utility commands for checking the logical and physical consistency of a database