Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Tandem Computers wikipedia , lookup
Extensible Storage Engine wikipedia , lookup
Microsoft Access wikipedia , lookup
Microsoft Jet Database Engine wikipedia , lookup
Database model wikipedia , lookup
Relational model wikipedia , lookup
Clusterpoint wikipedia , lookup
Team Foundation Server wikipedia , lookup
DAT340 Most Common DBA Tasks Patrick Conlan Program Manager SQL Server Microsoft Corporation Related Talks DAT302 – SQL Server Distributed Management with SQL Agent and MOM DAT342 – Microsoft SQL Server Performance & Tuning DAT380/DAT382 – Locking, Blocking and Deadlock Troubleshooting DAT 411 – Programming and Deploying SQL Server 2000 Replication:Lessons Learned TOP 90 PERCENT LIST You know you are a DBA when: 1. 2. 3. 4. 5. 6. You normalize your shopping list to save space You apply relational logic…to your relations You never need to re-index your CD collection, it’s already clustered by artist with secondary indexes on title, label & genre You wish you could ROLLBACK TRANSACTION on your partners credit card bills You wake up screaming from a dream in which your boss says “Lets build a 1TB data warehouse…using SQL Server 6.5” You spend your lunch break inventing new DBCC commands: DBCC LOSE_DATA(‘dbname’) WITH NORECOVERY 7. 8. 9. You understand the need to answer any question with another question You know where your data goes at night… …and you know that your developers mean well! Agenda The Basics Automation: Alerts Automation: Routine Tasks Securing Your Server Monitoring for Performance Data Loading demo BACKUP Demo with the UI Demo with Script Maintenance Plans Where are Errors Logged? Demo cycling the error log & Increasing the number of logs SQL Agent Log RESTORE Demo with the UI Demo with Script Log Shipping Agenda The Basics Automation: Alerts Automation: Routine Tasks Securing Your Server Monitoring for Performance Data Loading Automation is Your Friend You should automate all ordinary tasks This frees up time for you to perform “fun” tasks Serious performance analysis Capacity Planning Programming Going home early Configure SQL Server Agent Configure to run as a user Grant admin privs or lose functionality I.e. Automatic server restart, proxy jobs Configure an Operator SQL Server Agent mail is different from SQLMail (xp_sendmail) Uses a MAPI profile (Outlook) Log in to the server as the service account and configure the Outlook mail profile Automate Alerts Automatically be notified when particular conditions occur SQL Server Agent can issue alerts based on either error number or severity of error(s) Read from the Windows event log A number of alerts are pre-configured But not going anywhere without you configuring them further… Customize as appropriate for your site Create Your Own Alerts You can create application-specific alerts Run sp_addmessage to add a custom error message Run RAISERROR WITH LOG to raise the event and write a copy to the Windows application event log Otherwise SQL Agent doesn’t see your error Set up an alert to respond to your error number Run jobs as appropriate… Alerting Based on Perfmon Counters UI added in SQL Server 7.0/2000 to do this Configure through same UI as Transact-SQL generated alerts Monitor critical information not otherwise easy to get at Memory Usage Database size Tempdb usage Note that this is an expensive operation demo Setting Up Alerts Agenda The Basics Automating Alerts Automate routine tasks Secure Your Server Monitor for performance Data loading Automate Routine Tasks Get this “busy work” done automagically… If it needs to be done daily, or weekly, then automate it We’ve seen too many DBAs run everything ad-hoc This WON’T make you useless, we promise! Automate Your Backups All backups should be run automatically Backup type depends on database size and access patterns See Chapter 4 of the operations guide for details Back up system databases as well as your own application database(s) Don’t Forget to Back Up Scripts Generate full scripts of all objects you can periodically Use the generate scripts wizard May want to automate with SQL-DMO Watch for encrypted text Script out logins and custom error messages if you just script out a database Keep historical scripts and change scripts in a source control system such as Visual SourceSafe demo Set up a Backup Job A Word About Restore You can’t really automate restore… But practice, practice, practice!!! Don’t find out your backups don’t work when you really need them You can’t lose your job over many things, but this is one of them Other Maintenance… DBCC CheckDB Index Reorgs Again, details in the operations guide Check tables rather than databases on a large server Do only for peace of mind Only as needed Establish a pattern using DBCC SHOWCONTIG Depends on server usage… Statistics Updates Log File Maintenance SQL Server Error Logs SQL Server Agent Error Log Recycles after every service restart Job History Logs Configure how many you want to keep Back them up with your other scripts, etc. Sp_cycle_errorlog Agent properties, Job System tab Probably too low by default DBMaint history logs demo Database Maintenance Plans -Runs backups, integrity checks, update index/column stats… -Defrag script Agenda The Basics Automating Alerts Automate routine tasks Secure Your Server Monitor for performance Data Loading Secure Your Server Set up your server securely Use a service account with a strong password Don’t run SQL Server service as an administrator Run in integrated security mode - but still apply a strong password to “sa” Run on NTFS file system Encrypt the data files What to change/setup Use Security Auditing Set up login security auditing Not on by default Configure on the security tab of Server Properties in Enterprise Manager Enable for Failure or All View using the Windows Event Viewer SQL Server 2000 Auditing SQL Trace – the server side of profiling SQL Profiler – the UI components Auditing is performed by SQL Trace – internal to SQLServr.exe Very robust and secure SQL Trace Features File rollover So you can back up the old trace files while a new one is being populated Specify a max file size limit or an end time for a trace All audit types and data columns are selectable Get as much or as little auditing as you want/need SQL Server 2000 Audit Events We audit 19 different kinds of events: Login/logout GRD - statement perms GRD – object perms Add/drop SQL login GRD NT login rights Modify login property Password change event Add/remove from fixed server role Add/remove database user Derived Permissions Add/remove database role member Add/drop a database role Change Approle password Statement permission used Object permission used Backup/restore event DBCC command issued Audit modification event Server shutdown/pause/start SQL Server 2000 Auditing For each event, many subtypes Example - GDR object permission: Grant Deny Revoke Each event includes (at a minimum): Success or failure Server name Date/time of event Application name NT username Spid Host name Statement text How To Turn On An Audit An audit (except for C2 audit) is just a profiler trace So, turn on a profiler trace with the new profiler procedures, adding auditing events Set the trace to start with the server if you want a comprehensive audit Wrap the trace setup into a stored procedure Enable that stored procedure for autostart demo Using Profiler to Audit Use Profiler to configure an audit trace Use the scripting feature to script out the trace definition Agenda The Basics Automate : Alerts Automate : Routine Tasks Secure Your Server Monitor for Performance Data Loading Performance Monitoring Use System Monitor Counters Use SQL Server Profiler Learn what they mean by monitoring your system Monitor the overhead carefully on your system Use built-in tools Replication Monitor Current Activity Monitor Sp_who2 Ongoing Monitoring Index fragmentation May want to run well-defined queries periodically DBCC SHOWCONTIG As a “ping” to verify uptime To monitor for performance history If MSDE you may run DBCC CONCURRENCYVIOLATION to look for performance throttling issues Run Index Tuning Wizard periodically to see if indexes are still used/relevant Capacity Planning Monitor Database sizes, index sizes, filegroup usage, logfile usage, memory usage Watch for new objects if there’s more than one dbadmin (especially likely in development) Keep track of growth over time to forecast new hardware needs Very few tools to help you here Microsoft Excel is your friend! Agenda The Basics Automate : Alerts Automate : Routine Tasks Secure Your Server Monitor for Performance Data Loading Data Loading – Quick Tips Fastest way to load data is: Empty table, no indexes Use multiple Bulk Insert commands, one per processor, each with a roughly equal partition of the data. If seeking high-end performance then balance your i/o subsystem. Use the TABLOCK hint Set the ROWS_PER_BATCH to > rows in each file Switch the database to Bulk Logged Recovery Model BULK INSERT command is the fastest way to load data – runs in process with SQL Server BCP more flexible but a little slower DTS can be very fast as well but you should try to take a table lock for best load performance Watch out for concurrency issues with this technique References SQL Server Operations Guide SQL Server Resource Kit http://www.microsoft.com/technet/treevie w/default.asp?url=/technet/prodtechnol/sq l/maintain/operate/opsguide/default.asp http://www.microsoft.com/technet/treevie w/default.asp?url=/technet/prodtechnol/sq l/reskit/sql2000/sql2kres.asp SQL Server Security Whitepaper http://www.microsoft.com/sql/techinfo/ad ministration/2000/securityWP.asp Call to Action Keep an eye on the SQL web site: http://www.microsoft.com/sql Some components of SQL Server ship more frequently than the main engine: SQL Server CE Notification Services SQL XML [email protected] SOAP Interface, XML Bulk Load, XML OLEDB provider http://www.microsoft.com/sql/techinfo/xml MDAC http://www.microsoft.com/data Don’t forget to complete the on-line Session Feedback form on the Attendee Web site https://web.mseventseurope.com/teched/ © 2002 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.