Download Installing SQL Server

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

DBase wikipedia , lookup

Commitment ordering wikipedia , lookup

IMDb wikipedia , lookup

Tandem Computers wikipedia , lookup

Serializability wikipedia , lookup

Entity–attribute–value model wikipedia , lookup

Oracle Database wikipedia , lookup

Microsoft Access wikipedia , lookup

Functional Database Model wikipedia , lookup

Team Foundation Server wikipedia , lookup

Btrieve wikipedia , lookup

Database wikipedia , lookup

Ingres (database) wikipedia , lookup

Extensible Storage Engine wikipedia , lookup

Concurrency control wikipedia , lookup

Microsoft Jet Database Engine wikipedia , lookup

Open Database Connectivity wikipedia , lookup

SQL wikipedia , lookup

Relational model wikipedia , lookup

Clusterpoint wikipedia , lookup

PL/SQL wikipedia , lookup

Database model wikipedia , lookup

Microsoft SQL Server wikipedia , lookup

Transcript
SQL Server 2000
Administration
John Syre
Collaborative Data Services
Fred Hutch Cancer
Research Center
CDS Brownbag Series
(In the spirit of sharing)
 This is the 12th in a series of seminars
 Materials for the series can be downloaded from
https://cds.fhcrc.org/downloads.aspx
 Sign up to be on our email list
Next Brown Bag June 6
Creating Web Apps with ASP.NET 2.0 and
Visual Studio 2005
By Paul Litwin,
12:30-1:45 p.m (refer to web site for location)
Agenda of Topics









Installing SQL Server
Designing & Implementing Databases
Creating & Managing Tables
Designing & Configuring SQL Server Security
Importing and Exporting Data
Backing Up SQL Server Databases
Restoring SQL Server Databases
Automating SQL Server Administration
Monitoring SQL Server
Installing SQL Server
 Do not install SQL Server on a system that is
also a domain controller.
 Disable SQL Server ports on your firewall
 Use the most secure file system NTFS
 If possible, put database and transaction log on
different physical disks.
 My preference is not use the SQL Server
installation directory for database files and
backups.
Typical Raid Installation
Better
for writes
Put on different drives
for better performance
Non-RAID with Separate
Disks
 If your configuration allows then each of the
following should be put on different disks to
optimize performance
 Databases
 Transaction Logs
 tempdb
System Databases Created
Databases created during an installation
 Master

The master database records all of the system level information
for a SQL Server system.
 Msdb

The msdb database is used by SQL Server Agent for scheduling
alerts and jobs, and recording operators.
 Model

The model database is used as the template for all databases
created on a system.
 Tempdb

Holds all temporary tables and temporary stored procedures.
Note order by creates a temporary table in tempdb.
Create Database using
Enterprise Manager
Using tools in Enterprise Manager
 Select the Run a Wizard from the Tool Bar


From the dialog select Database->Create Database Wizard
This provides a step by step process. Defaults are presented
where available.
 Right click on databases in the left explorer window and
select New Database


Under the 3 tabs General, Data Files and Transaction Logs
specify the database name, location, and other properties.
You will have to enter the correct values for locations, etc.
Set database Properties
Databases Properties
 If you want to see details
about an existing
database right click on
the database in the
explorer window select
Properties
Create Database DDL
USE master
GO
CREATE DATABASE MYDB
ON PRIMARY (NAME = 'MYDB_Data',
FILENAME ='f:\sqlserverdata\MSSQL\data\MYDB_Data.MDF',
SIZE = 5MB,
FILEGROWTH = 10%)
LOG ON (NAME = 'MYDB_Log',
FILENAME ='f:\sqlserverdata\MSSQL\data\MYDB_Data.MDF',
SIZE = 5MB,
FILEGROWTH = 10%)
GO
Create/Manage Tables with
Table Designer
 Provides graphical
interface to easily select
column data types
 When making changes
automatically handles
constraints for you
Table Designer Features
 Set properties for columns
 Create and manipulate relationships between
tables, including choosing primary and foreign
keys for the relationship
 Create and manipulate indexes, primary keys,
and unique constraints attached to a table
Indexes/Keys
 Create and manipulate check constraints
 Changes are not applied until you close the
designer
Table Creation
Recommendations
Don’t use spaces in names
Always create a primary key
Try to avoid NULLs, use default values instead
Be careful of names being too long, some tools use the
name of table in creating other entities like stored
procedures
 Take into consideration other databases you may want to
support when naming tables
 Some say always create a clustered index (only allowed
one per table). My take, “It depends on the situation.”




DDL for Creating Tables
CREATE TABLE [dbo].[Allergies] (
[PatientId] [int] NOT NULL ,
[AllergyId] [int] IDENTITY (1, 1) NOT NULL ,
[Allergen] [varchar] (50) ,
[AllergyResponse] [varchar] (50) ,
CONSTRAINT [PK_Allergies] PRIMARY KEY CLUSTERED
(
[AllergyId]
)
)
DDL for changing a Table
ALTER TABLE Alergies
ADD EnteredDate datetime NOT NULL
ALTER TABLE [dbo].[Allergies] ADD
CONSTRAINT [FK_Allergies_Patients] FOREIGN KEY
(
[PatientId]
) REFERENCES [dbo].[Patients] (
[PatientId]
) ON DELETE CASCADE ON UPDATE CASCADE
GO
 Note: can only add one column at a time. New columns are added to
the end of the table definition.
Designing & Configuring
Security
 Use the Microsoft Baseline Security Analyzer
(MBSA). Download from
http://www.microsoft.com/technet/security/tools/
mbsahome.mspx
 Install the latest service packs
 Implement good administrative and development
policies
 Limit privilege level of SQL Server Services
 Use Windows Authentication Mode for internet
 Audit connections to SQL Server
Audit connections to SQL Server
Steps required
1. Expand a server group.
2. Right-click a server, and then click Properties.
3. On the Security tab, under Audit Level, click
Failure.
You must stop and restart the server for this setting
to take effect.
Security Checklist







Too many members of the sysadmin fixed server role.
Blank or trivial passwords.
Weak authentication mode.
Excessive rights granted to the Administrators group.
Incorrect access control lists (ACLs) on SQL Server data directories.
Plaintext sa password in setup files.
Excessive rights granted to the guest account (If you don’t need it,
best to delete it).
 Improper configuration of the Everyone group, providing access to
certain registry keys.
 Improper configuration of SQL Server service accounts.
 Missing service packs and security updates.
Limit privilege level of SQL
Server Services.
 SQL Server Engine/MSSQLServer

Run as a Windows domain user account with regular
user privileges.
 SQL Server Agent Service/SQLServerAgent

Run as a Windows domain user account with regular
user privileges. Note may not be able to if VBScripts
need special privileges.
Importing & Exporting
Tables
 DTS (Data Transformation Services)
Preferred method of handling data
 Most flexible of the methods

 BCP (Bulk CoPy)
Command line utility (import & export)
 Faster method than DTS for large data
sets

 Bulk Insert (import only)
DTS Overview
 Provides a set of tools that lets you extract,
transform, and consolidate data from disparate
sources into single or multiple destinations
 Can use graphical DTS Package Designer to
build transformations or can program command
line executable packages using DTS object
model.
DTS Designer
Types of Backups
 Simple (does not allow transaction log backups)
Operations that are not logged
 Bulk load operations
 Select Into
 Create Index
 Text/image operations
 Full(allows transaction log backups)

All operations fully logged.
 Bulk Logged (allows transaction log backups)
Operations that are not logged
 Same as Simple mode
Use Simple when
 Your data is not critical.
 Losing all transactions since the last full or
differential backup is not an issue.
 Data is derived from other data sources and is
easily recreated.
 Data is static and does not change often.
 Space is limited to log transactions. (This may
be a short-term reason, but not a good long-term
reason.)
Use Bulk Logged
 Data is critical, but logging large data loads bogs
down the system.
 Most bulk operations are done off hours and do
not interfere with normal transaction processing.
 You need to be able to recover to a point in time.
Use Full when
 Data is critical and no data can be lost.
 You always need the ability to do a point-in-time
recovery (transaction logs must also be backed
up).
 Bulk-logged activities are intermixed with normal
transaction processing.
 You are using replication and need the ability to
resynchronize all databases involved in
replication to a specific point in time.
Switching between modes
What if you want to have Full mode backups
but you have a large bulk load data
operation??
 Use the following command

ALTER DATABASE Northwind SET RECOVERY
BULK LOGGED
 Or use Enterprise Manager
When to Backup the
master database





ALTER DATABASE
CREATE DATABASE
sp_addlogin
sp_droplogin
Modified system configuration parameters
Creating a Backup Plan
 Enterprise Manager
select the “Run a Wizard”
tool. Expand
Management select
Database Maintenace
Plan Wizard
Selecting Databases
 Select the databases you
want to backup from the
list
Set Options
 Select options
 Specify time interval
Checking database integrity
 You can optionally check
the integrity before
backing up the database
 Additional dialog windows
for specifying Tranaction
Log backups and
historical logs
Recovering Databases
Timeline showing
database usage and
backup strategy
1. First recover the
database backup
2. Apply Transaction Log
from 12:00 noon
3. Next apply Transaction
Log from 6:00 PM
4. Have to again modify 10
records
Restore Database Tool
 From Enterprise
Manager, select from the
Main menu
Tools ->Restore Database
 Select the database to
restore to (Note: you can
can pick a different
database name to restore
to)
Restore Options
 Select additional options
as needed
 If loading a database
backup created on
another system may need
to modify path locations
SQL Server won’t Start!!
master database corrupted
 May have a bad master
database to recover
 Execute rebuildm.exe shown
on right to rebuild master
database. Located in
(installdir)\Microsoft SQL
Server\80\Tools\Binn
 Restore last backup of master
 Re-attach databases: right
click on Databases then All
Tasks->Attach Databases…
Automating SQL Server
Administration
ALERTS (configured in SQL Agent)
 Examples of event alerts:




Database out of space
SQL Server was abnormally terminated
Database is corrupted
Table is corrupted
 Examples of performance condition alerts:


Transaction log almost full
Number of merge conflicts exceeds an user-defined threshold
 Examples of custom alerts:


Low inventory
Aborted download
SQL Agent
 Installed with SQL Server it is a task scheduler
and alert manager.
 Features:capability to email or page an operator
when an event occurs
 Provides history logs of scheduled jobs
 Runs as a separate windows service
SQLServerAgent
 Make sure it is set to autostart
Automating SQL Server
Administration
ALERTS (configured in SQL Agent)
 Following are examples of event alerts:




Database out of space
SQL Server was abnormally terminated
Database is corrupted
Table is corrupted
 Following are examples of performance condition alerts:


Transaction log almost full
Number of merge conflicts exceeds an user-defined threshold
 Following are examples of custom alerts:


Low inventory
Aborted download
Monitoring SQL Server
 SQL Profiler
 System Monitor
 SQL Server Enterprise Manager
 Error Logs
 Transact-SQL Statements
tempdb log full!!
Error: The log file for database 'tempdb' is full.
 If you have a development SQL Server life is
easy, just re-start SQL Server. The tempdb is
rebuilt on start up.
 If a production server, then much more painful.

Refer to http://www.aspfaq.com/show.asp?id=2446 for
steps to correct.