2010. 4. 4. 23:48

Suspect 상태 해결 - SQL 2000

SQL 2000

Suspect 상태 해결 방법

상태를 변경

Problem
I have a SQL Server 2000 database that has the wrong database status.  For some reason it is in the 'Suspect\Offline' mode.  I just need to correct the problem quickly and get my database back online.  How can I do so?   Once the status is correct, do I need to take any further steps?

Solution
To cut to the chase, the script below can be used to correct the SQL Server 2000 database status, but in reality this is only a third of the equation.  We also need to correct any sort of corruption and understand why this occurred in the first place.

Database Status Correction Script

The script below will change the database to be in simple recovery mode, which may or may not be the needed configuration for your database.  As such, it is necessary to review your database configurations once this script has been executed.  In addition, it is necessary to change the 'YourDatabaseName' to your database name in single quotes.

USE Master
GO

-- Determine the original database status
SELECT [Name], DBID, Status
FROM master.dbo.sysdatabases
GO

-- Enable system changes
sp_configure 'allow updates',1
GO
RECONFIGURE WITH OVERRIDE
GO

-- Update the database status
UPDATE master.dbo.sysdatabases
SET Status = 24
WHERE [Name] = 'YourDatabaseName'
GO

-- Disable system changes
sp_configure 'allow updates',0
GO
RECONFIGURE WITH OVERRIDE
GO

-- Determine the final database status
SELECT [Name], DBID, Status
FROM master.dbo.sysdatabases
GO

Check for Corruption

The next step in this process is very key.  It is necessary to determine if the database has any corruption and ensure that the database will be able to support the users.  If the database has corruption, you may be exposing yourself to more issues by just changing the database status without correcting the underlying issue.  To identify the underlying issue, execute the following commands:

  • DBCC CHECKDB - Validate the overall database integrity
  • DBCC CHECKCATALOG - Validate the system catalog integrity
  • DBCC CHECKTABLE - Validate the integrity for a single table

To resolve the issue, you may need to do one or more of the following:

  • Drop and Recreate Index(es)
  • Move the recoverable data from an existing table to a new table
  • Update statistics
  • DBCC UPDATEUSAGE
  • sp_recompile

To ensure the issue is corrected, it is a good idea to re-run the identification commands listed above and validate that they do not have any issues.

To address these items, check out the following MSSQLTips.com:

Determine the Root Cause

In the long term, it is imperative to understand what caused the suspect/offline database.  At a minimum the following questions should be addressed:

  • What has recently changed in your environment?
  • Review your SQL Server logs to see if you can determine when the error occurred.
  • Talk to your team members to ask them what changes have been made.
  • Review your change management and auditing processes to see what has changed in SQL Server or at a systems level.
  • See if the issue has occurred on any other databases in your environment

MS 자료

ByPass 모드

시작하기에 앞서...
매우 죄송한 말이지만 여기서 실험한 것은 로그파일이 깨진 경우입니다.
데이터 파일도 수정해서 사용해봤지만 전적은 12전 12패... -_-;
참담함 그 자체입니다.
혹시 데이터 파일을 아작내서도 성공하신 분은 제게 메일을 날려주시면 매우 감사...

그리고 사용한 방법은 정원혁님이 기술하신 Bypass모드 사용방법을 사용했습니다.
음... 이런 좋은방법 써주신 정원혁님께 감사의 마음을 드리면서...
시작하지요...
우선 MSSQL Server 서비스를 중지시킵니다.
그리고 메모장으로 Pubs 데이터베이스의 로그파일인 Pubs_log.ldf 파일을 끄적거렸습니다.
다시 MSSQL Server 서비스를 실행시키고 나서 EM으로 가서보면?
Pubs 데이터베이스에 Suspect 상태가 생겼습니다.
여기서 시스템 테이블을 직접 수정할수 있도록 옵션을 설정합니다.
EM에서도 할 수 있지요...
Server behavior에서 첫번째 Allow modifications~에 체크해주시면 됩니다.
이제 바이패스 모드로 실행을 하겠습니다.
우선 MSSQL Server 서비스를 중지해 주시고 도스 명령창에서 다음과 같이 합니다.
sqlservr.exe -T3608 이란 명령어를 실행시킵니다.
(저는 어디서 3608이란게 튀어나오는지... -_-;
추적 플래그를 뒤져보아도 3608이란 숫자가 뭘 지정하는지는 모르겠습니다.)
그럼 다운된것처럼 커서만 껌벅 거리는데 닫지 마시고 최소화시켜 놓습니다.
또 다른 도스명령창을 열어서 isql을 실행시킵니다.
... -_-... 보안상 패스워드는 지웠슴다...
Master 데이터베이스로 가서 sysdatabases를 수정합니다.
pubs 데이터베이스를 Emergency Mode로 변경합니다.
여기서 정원혁님이 쓰신말...
'1 row affected가 아닌 에러가 난다면 말짱헛거' ... 라는데 저는 한번도 에러가 나지 않았네요...
Commit하고 나갑니다.

바이패스 모드로 시작한 창으로 가서 Ctrl+C키를 누르고 Y를 눌러서 서비스를 중지시킵니다.
이제 다시 정상적으로 MSSQL Server 서비스를 실행시킵니다.
EM에 가서 확인한 광경입니다.

검색이 됩니다!
이제 어여 자료들을 다 빼야지요...
그리고 나서 Suspect 상태의 데이터베이스는 삭제시킵니다.
EM에서 삭제시 뭐라고 에러가 뜨는데 굴하지 말고 계속 OK누르면 결국 지워집니다.
이제 데이터 파일과 로그 파일만 지워주면 깨끗하게 해결된겁니다.
마지막으로 이 상황은 로그파일이 깨진지 모르는 상황에서 사용하는 것이고...
만약 로그파일이 깨져서 Suspect 상태인것을 안 상태라면?
굳이 이런 방법 쓰지 않아도 됩니다.
간단히 sp_detach_db 하여 데이터베이스를 떼어내고 mdf 파일만 이용하여 붙이면 만사OK입니다.
Suspect 상태의 DB에서도 sp_detach_db는 말을 듣는 답니다.
물론 데이터 파일이 깨졌을 경우는 떼어냈다가 붙일 방법이 없겠지요... ^^


제 생각이지만 역시 백업을 잘해놓아야 합니다.
재수없다면 디스크 스크래치 한방에 이런 불상사가 생기니 말입니다.
그리고 제가 이런 상황에 처했다면 아마 바로 리스토어 풀어버릴겁니다.
이 방법이 제대로 된다는 보장도 없고 아직까지 제가 데이터 파일을 건들여서 성공한 적이 없어서요... -_-;
그럼~ Zzz~


2010. 4. 4. 23:47

Admin::DBA Check List

SQL Server DBA Checklist

 Problem
I am looking for items that I should address on a daily basis on my SQL Servers.  As such, what are the critical aspects of SQL Server that should I check on a daily basis?  Should I perform additional checks on a weekly, monthly or yearly basis?  How can I automate some of these tasks so I do not spend my whole day reviewing SQL Servers rather working on the latest and greatest technologies?

Solution
Depending on your environment dictates all of the items that should be reviewed on a daily basis as well as their criticality in your specific organization.  Based on your environment, customize the list below to ensure it meets your needs:

Daily Checklist

  • Backups - Check your backups to validate that they were successfully created per your process.
  • Nightly Processing - Review the nightly or early morning processes.
  • SQL Server Error Log - Review the SQL Server error log for any errors or security issues (successful or failed logins) that are unexpected.
  • Windows Event Log - Review the Application Event Log at a minimum to find out if any Windows or hardware related errors or warnings are being written.
    • Some of the hardware vendors write warnings to the Windows Event Log when they anticipate an error is going to occur, so this gives you the opportunity to be proactive and correct the problem during a scheduled down time, rather than having a mid day emergency.
    • SQL Server 2005 Exposed - Log File Viewer
  • SQL Server Agent Jobs - Review for failed SQL Server Agent Jobs.
  • HA or DR Logs - Check your high availability and/or disaster recovery process logs.  Depending on the solution (Log Shipping, Clustering, Replication, Database Mirroring, CDP, etc.) that you are using dictates what needs to be checked.
  • Performance Logs - Review the performance metrics to determine if your baseline was exceeded or if you had slow points during the day that need to be reviewed.
  • Security Logs - Review the security logs from a third party solution or from the SQL Server Error Logs to determine if you had a breach or a violation in one of your policies.
  • Centralized error handling - If you have an application, per SQL Server or enterprise level logging, then review those logs for any unexpected errors.
  • Storage - Validate you have sufficient storage on your drives to support your databases, backups, batch processes, etc. in the short term.
  • Service Broker - Check the transmission and user defined queues to make sure data is properly being processed in your applications.
  • Corrective Actions - Take corrective actions based on the issues and/or errors that you found.
  • Improvements - Look for opportunities to improve your environment based on the review and analysis you have performed.
  • Learn something new - Although this review and correction process could be time consuming, take some time every day to learn something new to improve your knowledge of the technology you work on every day.

Weekly or Monthly Checklist

  • Backup Verification (Comprehensive)- Verify your backups and test on a regular basis to ensure the overall process works as expected.  What is meant by this is to:
    • Contact your off site tape vendor to obtain a tape
    • Validate that the tape goes to the correct office
    • Validate that the vendor delivers the correct tape
    • Validate that the vendor delivers the tape in the correct time period
    • Validate that the software version you use to perform the restore is compatible with the version from the tape
    • Validate that the tape does not have any restore errors
    • Validate that sufficient storage is available to move the backup to the needed SQL Server
    • Validate that the SQL Server versions are compatible to restore the database
    • Validate that no error messages are generated during the restore process
    • Validate that the database is accurately restored and the application will function properly
  • Backup Verification (Simple) - Verify your backups on a regular basis.
  • Windows, SQL Server or Application Updates - Check for service packs/patches that need to be installed on your SQL Server from either a hardware, OS, DBMS or application perspective
  • Capacity Planning - Perform capacity planning to ensure you will have sufficient storage for a specific period of time such as for 6, 12 or 18 months.
  • Fragmentation - Review the fragmentation for your databases to determine if you particular indexes must be rebuilt based on analysis from a backup SQL Server.
  • Maintenance - Perform database maintenance on a weekly or monthly basis.
  • Security - Remove unneeded logins and users for individuals that have left the organization, had a change in position, etc.
  • Shrink databases - If databases or transaction logs are larger, than necessary shrink those files to free up disk space.

Opportunities for Automation

  • Setup alerts for specific error levels or error messages that impact your SQL Servers in order to be notified automatically.
  • Setup Jobs to query for specific conditions in your tables to validate data was loaded or data is being added to specific tables based on your business processes throughout the day.
  • Setup notification on Job success, failure or completion.
    • One word of warning is to check your business critical Jobs on a regular basis just to be sure they are working properly.  Nothing is worse than finding out a key process has been failing for days, weeks or months and the reason notifications have not been sent are due to an incorrect configuration, full mailbox, etc.  It may be 30 minutes on a weekly basis that is time well spent.
  • Setup centralized error handling on a per SQL Server, application or enterprise basis then determine the business rules for specific error conditions.
2010. 4. 4. 23:46

Admin::DBA Technical Interview

Survive A SQL Server DBA Technical Interview

by Jeffrey Yao, 2006/07/10

 

Introduction

How to make a successful interview is always an interesting topic. A successful interview, in and of itself, needs attention from many perspectives, including behavioral, psychological, technical and even dressing details,  But in this article, I will focus on the technical part of a SQL Server DBA interview, using my personal experiences in the last 10 years, from small companies to big ones such as Microsoft, and IBM. I will only discuss preparation for technical interviews, which are usually held by your project manager or senior technical peers.

The article is mainly for a DBA with a few years' experience and will discuss the three phases of an interview, i.e. Preparation, Presentation, and Post-cleanup, which I call 3P phases.

About DBA type

Knowing what type of DBA your potential employer is looking for will better guide you to the right direction for preparation. Generally, DBAs are categorized into three types (of course, there are lots of overlaps between each other)

First type: Operation DBA. The major responsibility for this type of DBA is to ensure the high-availability of a system, to monitor and keep the well-being of the system, and to do daily DBA routine work, such as adding logins, database backup / restore, on-going database maintenance (reindex / db size adjustments / file defragmentation etc), performance tuning, database implementation and other ad-hoc requirements.

Skill requirements: Familiar with various performance counters (both system and SQL Server related) and their implications, security / performance related T-SQL statements, including DBCC statements, how to create / grant login, network protocol configuration, backup / restore T-SQLs and sufficient knowledge about log-shipping, replication, disaster recovery methodology etc.

Second type: Development DBA. The major responsibility for this type is to translate user requirements into database model, which takes into consideration entity relationship, data integrity, business rule conformation, and efficiency for the whole system (mainly index/view design). The DBA is also involved in the following tasks:

  • developing exemplary code templates that embed "best practice" in terms of security, performance, and maintenance consideration.
  • examining / performance-tuning other developers' code
  • final database deployment

Skill requirements: familiar with at least one data modeling tool (ERWin, Visio or PowerDesigner etc), understanding index architecture, experts knowledge about T-SQL and SQL Profile tool, sufficient knowledge about SQL Server best practices.

Third type: Hybrid  DBA, who are required to be capable of every respect of database administration, but may not necessarily be an expert on everything. (Actually, I do not think one can be an expert on everything about database administration).

Skill requirements: broad understanding of SQL Server system, and strong capability to tackle any issues with independent research.

Preparation

The best approach to prepare for an interview is to treat the everyday work / study as if you would be asked a related question next day in an interview. For example, when you are restoring a database, try to understand the related restore statements, i.e. "restore filelistonly ", "restore headeronly", "restore verifyonly", and when/how these statements are used. Never take anything for granted, just act as if you were a kid, who dare to ask any question, to yourself. The advantage of this approach is you learn more effectively while you are working, with no pressure but sense of achievement every time you learn something that you know you will give "perfect" answers in your next interview.

Another practical approach is to act if you will be an interviewer who will ask a candidate SQL Server questions next day. The benefit here, is that this will no doubt drive you to pay more attentions to details. According to my experience, it is much harder to ask excellent questions than to answer them, esp. if the questions are targeted towards senior DBA level. For example, assuming you are a project manager and are responsible to design an SQL Server exam paper, people who pass the exam paper will work with you as your DBA, and your DBA's technical skills will finally decide the fate of your project. In this scenario, how to make out the exam paper is definitely no small task to you as a PM.

My final suggested approach, though a little bit  luxury but  really effective, is to get a senior DBA to be your mentor, and do a few rehearsals before the interview. Working together with the mentor, you can better understand your weakness through frank and honest opinions, thus improve your weakness quickly and efficiently..

Presentation

Treat an interview as an opportunity to present your technical capability and your affections for your profession. For senior position hiring opportunity, we will often be asked some open question, such as "what is your database admin strategy to ensure the high availability of your system?", "how do you troubleshoot a slow system, which originally run very well?"  and "how are you going to solve our discussed problem ? " etc. There is no right or wrong answer to this type of question, but there is definitely good or bad answer here in terms of logic, soundness, achievability and also the most important part, i.e. your vision and passion and ambition.

For development-oriented DBAs, the presentation should be centered around how you can make the data-driven solutions to solve / benefit the company's projects. Here data model technique, application layer methodology, DMO, XML or other data-related terms should appear at high frequency in your language. The point here is to convince the interviewer that you can contribute a lot with the technology you have talked about.

For operation-oriented DBAs, the presentation needs to be about security, performance, high-availability, efficiency and scalability, Demonstration of your proficiency of various management tools, deep understanding of the SQL Server architecture and innovative ideas in managing SQL Server system will prove your value. Personally, I believe operation-oriented DBAs need to be very strong in T-SQL and better in one of Window scripts (VBScript or JScript) to take advantage of DMO (SMO in SQL2K5) because without programming, you can hardly make an automated administration system, and thus you can hardly have any innovation in managing multiple SQL Server systems. If you can do jobs of two or three regular DBAs work, an employer will no doubt see the great value you can make.

For hybrid-type DBAs, the presentation is more about your knowledge base in various fields, and your capability in solving problems by research and learning. My personal suggestion here is to publish some articles, or to get some certifications to prove your capability and the broadness of your interests.

Post-fix

In this stage, the target is to give the interviewer/s the final pitch about your value. Sometime, if you cannot answer the question in the interview, it is still worthwhile to answer it in your "post-interview" time. This at least demonstrates your integrity and your keen interests in the interview.

I remember in one interview I did not do very well in a T-SQL question (a very complex query, and I used up my allowed time), the interviewer gave me the answer finally. But after I reviewed it, I decided this is not the one I pursued, but I cannot think out of the query immediately at the time. So after interview when I arrived home, I worked on the query again, and finally got what I wanted. I later sent to my interviewer the result, which I guess impressed him, because I got the offer letter the next day.

Another time, I believe I answered very well in the interview. So after interview, I sent a thank-you email, in which I commented about the technical interview questions, stating which question is a good one and why, and which is not because of what.

Summary

This article aims to provide some high-level guidelines to survive SQL Server DBA technical interview. Of the three (3P) stages, I'd say Preparation is the foundation stone that gives you strength to go to Presentation stage, while Presentation stage is when you will shine, and the Post-fix stage is the last try to solidify your value into the impression of your interviewers.

References

http://www.computerweekly.com/Article42138.htm

http://www.dyessconsulting.com/E-Books/InterviewBook/home.html

'Common Admin' 카테고리의 다른 글

Suspect 상태 해결 - SQL 2000  (1) 2010.04.04
Admin::DBA Check List  (0) 2010.04.04
Admin::Hardware 101 for DBA  (2) 2010.04.04
Admin::VLDB성능관리#2  (0) 2010.04.04
2010. 4. 4. 23:46

Admin::Hardware 101 for DBA

Problem
I am a SQL Server DBA and I am very comfortable with the design and development side of SQL Server.  I have been complimented by my own team on many of my database designs as well as on much of the behind the scenes development that I have done in SQL Server.  Unfortunately, the tides have turned a little bit at work and we now have a stronger focus on the infrastructure components with some new people on the team.  I know the basics about hardware, but I get lost on some of the newer terms that some of the new folks bring up.  Can you help define some of the key hardware related items and the significance in SQL Server?

Solution
Let's try to break down some of the recent hardware trends that might be brought up related to SQL Server and outline some of the impacts to the SQL Server environment.  We have only a handful of topics in this tip and with the hardware markets changing so rapidly, do not be surprised that what is new today is old tomorrow.  Just the fact of life with processing power doubling every 1 to 2 years, the hardware technology changes rapidly and get rolled into environments at a rapid pace.

Platform Technologies

  • 32 Bit vs. 64 Bit - The biggest over arching platform aspect is the 64 bit technology.  The predecessor was the 32 bit platform that was able to scale but had some inherent limitations, whereas with the 64 bit architecture the natively addressed resources well exceed the practical limit of most applications depending on the hardware platform and Windows version selected.  If you have an application that needs to scale, start with the 64 bit platform.  Your application and most notably your users will have met their match.
  • Blade Servers - A low profile or thin server that resides in a blade enclosure with 1 or more CPUs, 1 or more GB of memory,  controller cards, NICs and either has 1 or 2 local disks or is connected to a SAN or NAS device to store the SQL Server databases.

Central Processing Unit (CPU)

  • Hyper Threaded CPUs - Two simultaneous threads on the CPU which Windows logically recognizes as 2 CPUs.  The advantage in using hyper threading is that multiple threads run simultaneously which improve the CPU response time and minimize idle time.
  • Socket - The device that connects the physical CPU to the mother board.  The reason the socket has become important is primarily related to licensing for particular products including SQL Server.  Not too long ago all licensing was based on a per CPU paradigm.  Now that a CPU can have multiple threads (see Hyper Threaded CPUs) or cores, the logical CPUs compared to the physical CPUs can become confusing.  As such, with some vendors the CPU sockets are used to determine licensing as compared to the cores.  When it comes down to licensing, make sure you know the number of sockets and cores per CPU as well as if the CPUs are hyper threaded, to make sure you have appropriate licensing.
  • Dual Core CPUs - On a single socket, two independent microprocessors exist which gives the machine the power of 2 CPUs on a single socket.  This is also another example of where SQL Server shows two logical CPUs in the machine as compared to one physical socket.
  • Multi Core CPUs - As an example, Intel and AMD recently released a 4 core CPU which means that a single sockets has 4 microprocessors as the next step up from the Dual Core CPUs.

Disk Drives

  • External Chassis - An external device with one or more cages that stores disk drives which can be access by one or more machines directly as local disk drives.
  • Storage Area Network (SAN) - Centralized storage (disk drives) that can be vertically or horizontally partitioned and presented to a finite number of machines (i.e. SQL Servers).  Some of the SAN technologies have front end cache on the SAN to improve the data access by retrieving a cached value (memory) of the data as opposed to retrieving the data from the physical hard drives.  Disk drives can also be added to the SAN and then presented to the SQL Servers which streamlines the process to add storage for specific machines across the enterprise.  In many circumstances, the NAS (Network Attached Storage) devices are blurring across vendors, but historically the NAS devices were intended for file level access similar to a file server.
  • Redundant Array of Inexpensive Disks (RAID) - Although this technology and some of the others in this tip have been around for a while, people still seem to want to know the differences among the RAID sets.  In general the RAID set provides redundancy so that N number of disks can fail, but the RAID set remains functional and can process user requests with or without degradation depending on the hardware or software solution.  Although, I have seen most RAID configurations managed by a hardware device, software versions are available as well, but are typically considered less optimal as compared to the corresponding hardware version.  So let's take a look at each RAID definition and some additional key points:
    • RAID 0
      • General - Disk striping without parity
      • Minimum number of disks - 0
      • Maximum number of disks - Many, but the limitation is ultimately based on the vendor's specifications i.e. cage, rack, closet, SAN, etc.
      • Redundancy - None - If 1 disk drive fails, the entire array fails
      • Purpose in SQL Server - Backups, batch file processing, etc.
    • RAID 1
      • General - Disk mirroring
      • Minimum number of disks - 2
      • Maximum number of disks - 2
      • Redundancy - Ability to lose a single disk and continue operations, but will need to replace the failed disk and rebuild the parity between the new set of disks
      • Purpose in SQL Server - Since a RAID 1 set is the most basic form of data protection, with the least amount of disk drives, at times all SQL Server functions are supported.  When it comes to performance, RAID 1 sets are ideal for transaction log processing because the processing is primarily sequential.  In addition, if a SQL Server instance has intense TempDB processing, in some circumstances TempDB is moved to a separate RAID 1 set, but that is to isolate the processing, even though the TempDB processing is typically more random then sequential.
    • RAID 10
      • General - Disk mirroring in a disk stripped set
        • Depending on the vendor, RAID 10 could be implemented and named as RAID 1 + 0 or RAID 0 + 1, so the general premise may be the same as RAID 10, but some of the underlying implementation details may be different, so check with the hardware vendor for the exact details.
      • Minimum number of disks -  2 or 4
      • Maximum number of disks - Many, in multiples of 2, but ultimately based on the hardware vendor's specifications.  I know most vendors can at least support a RAID 10 set of 4 or 8 disks.  Beyond that number it really boils down to the hardware device used.
      • Redundancy - As long as 1 disk remains functional in each mirrored set, the array is operational.
      • Purpose in SQL Server - Performance.  If a user defined database has intense processing demands, in general the best performance would be from the RAID 10 set.
    • RAID 5
      • General - Disk stripping with parity
      • Minimum number of disks - 3
      • Maximum number of disks - Many, but either in an odd or even number, but ultimately based on the hardware vendor's specifications.  I know most vendors can at least support a RAID 5 set of 10+ disks.  Beyond that number it really boils down to the hardware device used.
      • Redundancy - Ability to lose a single disk and continue operations, but 2 disks result in an array failure.
      • Purpose in SQL Server - Ideal for supporting user defined databases that are read intensive applications, which most are.
    • RAID - As a note, some hardware vendors also have other RAID configurations, so please contact them for the details or share them with us and we will update the tip.
    • Additional information about RAID:
  • Hot Spare - A disk drive in the chassis that can move to an online state in case of a failure in any of the arrays (RAID sets).
  • Parity - Means of providing fault tolerance between the disk drives to ensure a single disk failure does not yield an inaccessible drive and/or data.
  • 10K vs. 15K RPM - The drive speed for the disk drives with the general premise that the faster the better, but at a higher cost.
  • iSCSI - Considered slower and much lower cheaper than Fibre Channel connectivity, iSCSI (Internet Small Computer System Interface) is a protocol used with SAN and NAS devices.  This protocol uses TCP\IP for sending and receiving the IO requests to the disk subsystem.
  • Fibre Channel - Considered the high speed connectivity between a SQL Server machine and a SAN storage device.  Connectivity from the SQL Server to the SAN is via a HBA, cabling (fiber-optic or copper) to a switch and then to the SAN.  In many circumstances, there is redundancy between the SQL Server and SAN to ensure no single point of failure.
  • HBA - Host Bus Adapter which is a device installed in the SQL Server to communicate with a SAN or NAS device.  The HBA acts as interface to manage the IO requests from the SQL Server and responses from the SAN or NAS device.
  • SATA - Serial ATA (Advanced Technology Attachment ) which is a standard to read and write to local disks (internal cages) or direct attached storage devices (DAS\DASD).

Memory

  • Hot Swappable Memory - For years, it has been possible to change a failed disk drive either as it is degrading or after failure.  Now the same concept is going to be applied to memory and processors according to this article - Microsoft demos Longhorn 'hot swap' feature In addition, Longhorn has been officially dubbed 'Windows Server 2008' in the next release of Windows.  For systems where the combination of uptime and high performance are critical, this new hardware feature should get more systems closer to the 5 nines of availability.
  • Cache - Memory for temporary storage of data that is expected to be used again in the near term.  From a hardware perspective, CPUs and hard drive controllers typically have cache to improve the overall processing.  For example, L2 or L3 cache on CPUs is between 1 to 256 MB of storage to increase the speed of the CPU processing.

Virtualization

  • Host - A single piece of hardware that typically has its own operating system and dedicated CPUs, memory, disk drives, etc. that is running a number of virtual machines.
  • VM (Virtual machine) - One host typically has multiple virtual machines.  Each virtual machine operates as a separate physical entity on the network with its own NetBIOS name, IP address, operating system, applications, etc.  From an functional perspective, the virtual machine is no different than a physical machine, they have all of the same functional components, but do not necessarily have the same functional underlying hardware components.

Next Steps

  • This tip is by no means a comprehensive list of hardware impacting a DBAs job on a daily basis.  This is only scratching the surface.  If there are other hardware related technologies that you work with on a regular basis that benefit your SQL Server environment like tape libraries, hardware encryption, etc, then shoot us an email (tips@mssqltips.com) with your input that we will share with the rest of the community.
  • If you are unsure about how a specific hardware vendor implements one of these technologies, consider reviewing their web site or contact sales\support to obtain the correct understanding for that vendor's implementation of the technology.
  • Depending on the size of your organization and your personal desires, hardware advancements can be very exciting or just a box that you know exists and not much else.  Regardless, knowing the basic building blocks and their impact to SQL Server is a valuable set of baseline knowledge.

'Common Admin' 카테고리의 다른 글

Admin::DBA Check List  (0) 2010.04.04
Admin::DBA Technical Interview  (1) 2010.04.04
Admin::VLDB성능관리#2  (0) 2010.04.04
Admin::VLDB성능관리#1  (0) 2010.04.04
2010. 4. 4. 23:45

Admin::VLDB성능관리#2

대용량 VLDB의 성능관리
- VLDB와의 소리 없는 전쟁(2) -

 

대용량 VLDB의 성능관리에서 자주 마주치는 문제가 바로 응답 속도 저하현상이다. 대개 IT 사용자들이 시스템의 성능이 떨어질 때 하드웨어 탓으로 돌릴 때가 흔하다. 자신이 쓰고 있는 데이터베이스 성능을 유지하기 위해 땀을 흘려본 사람이라면, VLDB의 성능관리의 중요성을 다시 한번 되새겨보자.

 

권순용 | kwontra@hanmail.net

 

 

대개 대용량 데이터베이스인 VLDB에서 처음 접하게 되는 문제라면 아무래도 응답 속도 저하가 많다. 이는 비단 대용량 데이터베이스에 국한되는 것은 아니다. 데이터베이스를 이용하는 모든 업무에서 흔하게 발생할 수 있는 문제이기 때문이다. 하지만 VLDB는 응답 속도 저하가 더욱 심각하게 발생하게 된다. 그렇기 때문에 지금도 수많은 고객업체들이 VLDB에 대한 성능 관리를 고민하고 있다. 대부분 성능 관리의 중요성은 인지하지만, 어느 요소가 성능 관리의 중심인지를 모르는 경우가 많다. 이번 호에서는 많은 IT 사용자들이 고민도 하고 관심을 갖고 있는 대용량 VLDB의 성능 관리에 대해 살펴보자.

 

성능 관리의 중심에는 SQL이 있다

자신이 쓰고 있는 시스템에서 응답 속도 저하현상이 발생한다면 먼저 무엇을 확인해야 할까? 이럴 경우 일반적으로 해당 시스템의 관련자들이 한자리에 모이게 되는 것은 당연한 순서일 것이다. 모두 모여서 마라톤 회의도 진행되게 마련이다. 이 때 각 담당자들은 어떻게 처리해야 될지 과제 아닌 과제를 떠맡게 된다. 여기까지의 상황 설정은 성능 관리를 위한 일련의 활동이고 또 주위에서 자주 접하게 마련이다. 이럴 경우 회의에 참석해 보면 재미있는 현상이 있다.

 

개발자들은 서버의 자원이 부족하여 응답 속도가 저하되는 것이라고 이야기할 때가 많다. 또한, 현업은 서버 설정이나 또는 시스템 운영자들의 잘못된 관리에 의해 응답 속도 저하 현상이 발생하는 것이라고 의문을 가질 때가 흔하다. 여기까지는 그럴 수도 있는 일이다. 보다 중요한 것은 서버 담당자 또는 소프트웨어 담당자에게 응답 속도 저하의 원인 및 해결 방안을 도출하라고 요구하는 경우가 많다는 것이다. 하지만 운영 중이던 시스템이 갑자기 응답 속도 저하가 발생했다면 무엇이 문제였겠는가? 각 담당자들의 실수가 아니라면 서버 또는 소프트웨어에는 문제가 없다고 생각해야 하지 않을까? 이런 상황이라면 응답 속도 저하의 문제는 회의 때 어느 누구도 언급하지 않은 데이터의 증가 및 데이터베이스가 VLDB로 변하고 있기 때문에 생기는 성능 문제일 가능성이 높다. 현재 운영 중인 시스템의 응답 속도가 저하되었다면 시스템과 소프트웨어를 의심하지 말고 지금 시스템에 증가하는 데이터와 해당 데이터를 액세스하는 SQL을 확인해 보는 것이 좋다. VLDB의 성능 관리는 증가되는 데이터의 효과적인 관리와 데이터의 액세스 최적화에 의해 성공 여부가 좌우되기 때문이다.

 

어느 시스템에서 3개월 동안 CPU 사용량이 5% 가량 증가한 경우가 있었다. 이에 현업에서는 원인을 파악하려고 나섰다. 해당 시스템은 한 달에 70GB 정도의 데이터가 증가하는 시스템이었다. 결국에는 데이터의 증가와 데이터를 액세스하는 SQL의 비효율로 결론을 지었다. 하지만 현업에서는 데이터 증가에 따른 성능 저하는 이해가 안 된다고 반론을 제기하는 사람도 있었다. 그렇다면 이러한 현상이 왜 이해가 안 되는 것일까?

 

10GB의 데이터일 경우 이상이 없었던 데이터를 액세스하는 SQL이 데이터가 30GB가 되는 순간 악성 SQL로 변할 수 있는 것이 현실이다. 왜 이런 사실을 많은 사람들이 인지하지 못하는 것일까? 아직 늦지 않았다. VLDB의 성능 관리를 수립하기 위해 가장 중요한 요소가 데이터와 데이터를 액세스하는 SQL이라는 것을 이제라도 인지하고 성능 관리 체계를 수립한다면 VLDB를 현명하게 대처할 수 있을 것이다.

 

따라서, VLDB의 성능 관리는 대용량 데이터의 관리와 데이터를 엑세스하는 SQL의 관리로 구분하여 성능 관리 체계를 구축해야 할 것이다.

 

VLDB의 대용량 데이터 관리가 성능을 좌우한다

VLDB는 대용량 데이터베이스를 의미한다고 했다. 그러므로 관리해야 할 데이터는 TB 이상이 될 것이다. VLDB에서는 대용량 데이터를 효과적으로 관리하는 방안이 반드시 필요하다. 그렇다면 어떻게 대용량 데이터를 최적화하여 관리해야 하는 것일까?

 

첫 번째로 데이터를 저장하는 테이블 관리에 대한 방안이 정립되어 있어야 한다. 데이터를 저장하는 테이블에 대해 어떠한 생각 없이 생성하는 것에 익숙해져 있는 사람이 많다. 오라클 등의 데이터베이스에서 제공하는 테이블의 종류가 많다는 것을 아는가? 업무에 따라 어떤 구조의 테이블로 구성하는가에 따라 매우 효율적으로 업무를 구현할 수 있다. VLDB에는 많은 대용량 테이블들이 존재하게 된다. 이러한 대용량 데이터의 테이블들은 어떤 구조로 저장하는가에 따라 데이터 관리 및 성능에 많은 영향을 미치게 된다.

 

예를 들어, 통신회사의 통화 내역 테이블을 생각해 보자. 통화 내역 테이블의 경우에는 하루에도 엄청난 통화 내역 데이터가 발생하게 된다. 또한, 일반적으로 데이터의 보관 주기가 정해지게 된다. 보관 주기가 6개월이라고 한다면 현재로부터 6개월이 지난 데이터는 반드시 제거해야 할 것이다. 이와 같은 속성을 가지고 있는 데이터를 일반 테이블에 저장하게 되면 보관 주기 관리도 힘들며 성능도 저하될 수 밖에 없다.

 

이러한 데이터는 오라클의 경우 파티션(Partition) 테이블에 저장해야 된다. 파티션 테이블에 저장함으로써 보관 주기 관리뿐만 아니라 월별로 파티션을 구성했다면 월별 통계 작업은 엄청난 성능 향상을 기대할 수 있을 것이다. 이처럼 VLDB의 성능 관리를 수행하기 위해 대용량 데이터를 저장하는 테이블에 대한 아키텍처 관리는 반드시 수행되어야 한다.

 

두 번째로 디스크 I/O 분산 관리이다. 디스크 I/O 분산은 많은 사람들이 디스크 제조사 또는 운영체제 담당자에게 모든 것을 의지하는 경우가 많다. 물리적인 디스크 분산은 디스크 제조사 또는 운영체제 담당자가 수행할 것이다. 하지만, 데이터베이스에 저장되는 데이터를 모든 디스크로 분산하는 방법이 데이터베이스에 별도로 존재한다. 디스크 I/O의 최적화는 물리적인 디스크 I/O 분산과 그 위에 데이터들이 고르게 저장될 수 있도록 해야 한다.

 

필자가 어느 사이트에 지원나갔을 때의 일이다. 해당 사이트는 데이터가 특정 몇 개의 디스크로만 저장되어 있었다. 물론, 디스크 개수가 적다면 여러 디스크로 데이터가 고르게 분산되도록 하는 것이 어렵지는 않을 것이다. 하지만 VLDB라면 수천 개 또는 수 만개의 디스크에 데이터를 저장하게 된다. 디스크의 개수가 많기 때문에 전체 디스크로 데이터를 고르게 분산시키는 것이 어려울 수도 있다. 하지만, 디스크 I/O 분산의 문제를 최적화하는 것만으로도 성능은 3배~5배까지 향상되는 것을 보았다. 이 얼마나 놀라운 일인가?

 

동일한 테이블을 액세스할 경우 10개의 디스크를 액세스하는 것이 응답 속도가 빠르겠는가 아니면 1만개의 디스크를 액세스하는 것이 응답 속도가 더 빠르겠는가? 당연히 동일한 테이블을 액세스하는 경우 1만개의 디스크를 동시에 액세스하는 것이 유리할 것이다. 디스크가 1만개일지라도 10개의 디스크에 저장할 수도 있으며 1만개의 디스크로 고르게 분산하여 저장할 수도 있다. 이러한 디스크 I/O 분산 또한 성능 관리에 반드시 포함되어야 할 항목일 것이다.

 

세 번째로 데이터 모델링의 관리이다. 데이터 관리 차원에서의 데이터 모델링이라는 것은 각각의 테이블에 대한 컬럼들의 관리를 뜻한다.

 

어느 사이트에 튜닝을 지원했을 때의 이야기다. 해당 사이트는 모 카드 회사였으며 카드의 기본 정보를 저장하는 마스터 테이블이 존재하고 있었다. 거래내역을 조회하기 위해서는 고객이 소유하고 있는 모든 카드 번호를 확인한 후 거래내역 테이블과 조인을 수행하고 있었다. 해당 마스터 테이블에는 해당 카드가 사용했는지, 사용하지 않았는지를 기록하는 컬럼이 존재했다. 사용을 한번도 안 한 카드라면 해당 카드 번호로 거래내역 테이블을 액세스할 필요는 없을 것이다.

 

카드 사용 유무를 기록하는 컬럼을 이용하여 튜닝을 수행하고 난 이후 성능은 10배 정도가 향상됐다. 하지만, 실무자는 카드 사용 유무 컬럼을 사용할 수 없다는 말을 했다. 그 이유는 해당 컬럼에 어떤 가맹점은 사용 유무를 기록하지만 어떤 가맹점은 사용 유무를 기록하지 않기 때문에 카드 사용 유무 컬럼에 사용하지 않음이라고 되어 있더라도 해당 카드는 사용했을 수 있다는 것이다. 이 얼마나 어처구니 없는 일인가? 이런 사실을 실무자는 너무 자신 있게 이야기했다. 자신 있게 이야기하기 보다는 오히려 부끄러워해야 하는 것은 아닐까?

 

그런 이유에서 해당 테이블의 모든 컬럼을 확인하게 되었다. 해당 테이블에는 50개의 컬럼이 존재했지만 그 중 15개의 컬럼이 사용하기 힘든 상태였다. 이러한 컬럼을 왜 저장하고 있는지 모르겠다. 데이터의 정합성을 유지하기 힘든 컬럼들을 없앤다면 데이터는 감소한다. 이러한 컬럼들에 대해 데이터의 정합성을 맞추어 관리한다면 위와 같이 애플리케이션 성능을 향상시킬 수 있는 요소로 이용할 수 있을 것이다.

 

독자 여러분도 자신이 현재 관리하는 VLDB를 한번 확인해 보길 바란다. 진정으로 모든 테이블의 데이터를 다 사용하고 있는가? 분명 그렇지 않은 곳이 여기저기 존재할 것이다. 이는 VLDB에 대한 데이터 모델링 관리를 통한 성능 관리가 수행되지 않고 있기 때문이다.

 

대용량 데이터 관리를 위한 위의 세가지 요소는 시간과 비용이 많이 소요되는 항목들이다. 그렇기 때문에 프로젝트 초기부터 관리되어야만 VLDB의 성능 관리가 성공할 수 있다. 이러한 항목이 관리되지 않는다면 머지 않아 후회스러운 일이 발생할지도 모른다.

 

성능관리 핵심은 데이터를 엑세스하는 SQL이다

VLDB의 성능 관리는 데이터 관리와 함께 해당 데이터를 액세스하는 SQL의 관리이다. 많은 서적들을 참조해 보면 시스템을 최적화함에 있어 서버 튜닝 또는 데이터베이스 엔진 튜닝으로 얻을 수 있는 성능 향상은 전체 향상될 수 있는 부분의 10% 정도의 향상이 기대된다고 한다. 그렇다면 어떤 부분을 최적화 했을 때 나머지 90%의 효과를 얻을 수 있는 것일까? 그것은 바로 애플리케이션이다. 애플리케이션 중에서도 데이터를 액세스하는 부분인 SQL이 이에 해당된다. 애플리케이션에 사용되는 로직 또한 중요하다. 하지만 애플리케이션에 사용하는 로직이라는 것도 SQL에서 추출한 데이터를 조작하는 단계이기 때문에 여기서 말하는 데이터를 액세스하는 SQL이라는 것은 이러한 액플리케이션의 로직을 포함하는 것이다. 그렇다면 SQL의 어떤 항목을 통해 성능 관리를 수행해야 하는가?

 

첫 번째로 SQL 및 SQL의 실행 계획에 대한 계속적인 추적이 필요하다. 실행 계획이라는 것은 무엇인가? 우리가 서울역에서 분당까지 가기 위해 어떻게 가는 것이 빠른가? 여러 번의 경험이 있는 사람이라면 최적의 방법을 이용하여 목적지에 도착할 것이다. 하지만 처음 서울역에서 분당으로 가는 사람이라면 어떨까? 전철을 이용할지, 버스를 이용할 것인지 또는 버스와 전철을 동시에 이용하는 것이 적합한지 애매한 경우가 있다.

 

이러한 경우에도 서울역에서 분당까지 가고자 하는 그 사람의 의지가 중요할 것이다. SQL의 실행 계획도 이와 별반 다르지 않다. 인덱스를 이용하여 데이터를 추출할 것인지 또는 테이블을 전체 스캔하여 데이터를 추출할 것인지는 실행 계획을 생성하는 옵티마이저에 의해 결정된다. 이러한 실행 계획에 의해 동일한 데이터를 추출하는 SQL은 1분이 1시간으로 응답 속도가 저하될 수 있다. 최적화되어 수행된다면 1분이면 종료될 SQL이 악성 SQL로 수행되어 1시간이 소요된다면 이는 응답 속도의 저하뿐만 아니라 CPU 사용량도 증가시키게 된다.

 

결국, 이러한 실행 계획이 관리되지 않는다면 악성 SQL이 계속적으로 증가되어 CPU 사용량은 계속 높아만 질 것이다. 이 것이 해당 시스템의 CPU를 증설하게 되는 주범이라는 것을 눈여겨볼 필요가 있다.

 

결과적으로 VLDB의 성능 관리를 수행하기 위해서는 해당 VLDB를 액세스하는 SQL과 해당 SQL의 실행 계획을 반드시 추적하고 있어야 한다. 이와 같이 SQL과 SQL의 실행 계획을 추적해야 하는 또 하나의 이유가 존재한다. 그 이유는 SQL의 실행 계획이 변할 수 있기 때문이다. 서울역에서 분당을 갈 때 매번 버스를 이용하였지만 하루는 비가 많이 내렸다고 가정하자. 비가 많이 내린다면 버스는 일반적으로 정체 구간이 많이 발생한다.

 

그래서 이럴 경우에는 반대로 전철을 이용하여 분당에 갈수도 있을 것이다. 실행 계획 또한 이와 동일하다. 데이터베이스에 큰 변화가 발생한다면 언제든지 이러한 실행 계획은 변할 수 있다. 실행 계획이 변하면 SQL의 응답 속도가 향상될 수도 있지만 대부분 응답 속도가 저하되기 쉽다. 오라클의 경우 데이터베이스를 업그레이드 하게 되면 성능과 관련된 SQL의 실행 계획을 재점검해야 한다. 이 또한 데이터베이스의 큰 변화이므로 실행 계획이 변할 수 있기 때문이다. 급격히 데이터가 증가하는 것 또한 데이터베이스에 수많은 변화가 발생할 여지가 있게 마련이다. 이제 VLDB의 성능을 관리하고자 한다면 반드시 데이터를 액세스하는 SQL과 SQL의 실행 계획을 관리해야 한다.

 

두 번째로 SQL이 사용하는 인덱스의 관리이다. 이는 일반 데이터베이스에서도 동일하지만 VLDB에서는 매우 중요한 성능 관리 항목이다. 인덱스라는 것은 조회 성능을 향상시키기 위해 생성하게 된다. 인덱스는 데이터의 제거, 변경 및 저장에 대해서는 성능 저하를 발생시킨다. 단지, 조회를 위해 효율적으로 이용할 수 있는 것이 인덱스이다. 또 하나 고려할 것은 SQL이 인덱스를 이용했다고 해서 SQL이 최적화된 것이 절대 아니라는 것이다.

 

처리 범위를 최소화시킬 수 있는 인덱스를 이용한 것이 아니라면 해당 인덱스를 이용함으로써 응답 속도는 저하된다. 이러한 사실을 모르는 관리자 또는 개발자들이 많다는 것이 때로는 필자를 슬프게 만든다. 단지, SQL이 인덱스를 이용했다는 이유 하나만으로 최적화 되었다고 생각하지 말자. 이러한 생각은 VLDB를 최악으로 만드는 장본인이라는 것을 인지해야 할 것이다.

 

프로젝트 초기에는 인덱스의 생성 및 삭제가 가능할 수 있지만 시스템을 오픈하여 서비스를 하고 있다면 인덱스를 추가하거나 또는 삭제하는 것이 매우 힘들다. 그 이유는 인덱스를 생성하기 위해 많은 시간이 소요되고 생성하는 동안은 해당 테이블에 대해 서비스를 제공할 수 없기 때문이다. 또한 인덱스를 추가함으로써 다른 SQL에 어떤 영향을 미칠지 아무도 장담할 수 없기 때문이다. 전혀 다른 인덱스를 이용하게 됨으로써 발생하는 성능 저하는 해당 시스템을 마비시킬 수도 있다.

 

위와 같은 이유들로 VLDB의 대용량 테이블에 대해서는 프로젝트 초기부터 인덱스에 대한 전략과 운영 시 관리 방안 등이 수립되어 진행되어야만 성능 관리를 수행할 수 있다. 이러한 VLDB에서 인덱스의 관리가 수행되지 않는다면 건너서는 안 되는 강을 건너는 것과 같이 VLDB의 성능 저하에 대해 되돌릴 수 없는 상황이 된다.

 

세 번째로 VLDB에 대해 매일 또는 매주 I/O가 많은 SQL을 수집해야 한다. 이러한 일련의 활동은 VLDB의 성능 관리를 위해 반드시 필요한 단계이다. SQL은 데이터를 액세스하는 언어이며 데이터를 엑세스하기 때문에 I/O가 발생하게 된다. 이러한 I/O가 메모리에서 발생하던 또는 디스크에서 발생하던 I/O의 양이 많다면 성능은 반드시 저하된다. I/O를 많이 발생시키는 SQL의 수집은 VLDB의 성능 관리를 위한 많은 정보를 제시해 준다.

 

예를 들어, 해당 VLDB 시스템의 CPU 사용량이 갑자기 10%가 높아졌다고 가정하자. 이런 경우 서버 및 데이터베이스를 확인할 것이다. 이런 일련의 확인 작업을 수행한 후 아무런 문제가 없다면 무엇을 확인해야 하는가? 바로 I/O가 많은 SQL을 검토해야 한다. 십중팔구 데이터의 증가와 함께 I/O가 많은 SQL에 의해 이러한 CPU 사용량이 증가했을 것이다. 데이터베이스는 별도의 툴을 이용하지 않는다면 이러한 I/O가 많은 SQL을 저장하지 않게 된다. 단지, 실시간으로 I/O가 많은 SQL을 추출할 수 있다.

 

따라서, I/O가 많은 SQL에 대해서는 반드시 수집하는 스크립트 등을 작성하여 정해진 시간에 수행되게 해야 할 것이다. 이것이 VLDB의 성능 관리의 중요한 요소이자 또한 장애 관리에도 많은 도움이 될 것이다. 성능과 장애는 분리할 수 없는 관계에 있다. 이러한 I/O가 많은 SQL이 성능을 저하시키고 이것은 장애로 연결되기 때문이다.

 

앞에서 확인한 것과 같이 VLDB에서 SQL에 대한 관리는 성능 관리에 있어 중요한 요소가 된다. 그러므로 데이터를 액세스하는 SQL, SQL의 실행 계획 및 인덱스에 대한 관리 방안이 반드시 필요하다. 또한, I/O가 많은 SQL의 수집은 성능 관리를 하기 위한 기본이 될 것이다. 수집된 데이터를 바탕으로 분석을 수행하여 성능 관리를 수행해야 할 것이다.

 

성능 관리는 데이터 수집, 분석 반복되어야

VLDB의 성능 관리는 데이터 관리 및 데이터를 액세스하는 SQL의 관리에 대한 정확한 방안이 수립되어야 한다. 성능 관리는 성능 데이터의 수집부터 시작하게 된다. 성능 데이터가 수집된다면 내용을 분석하여 튜닝을 수행하게 된다. 정확한 분석을 통해 튜닝을 수행한다면 해당 VLDB는 성능 관리를 위한 1사이클(Cycle)이 종료될 것이다. VLDB의 성능 관리는 여기서 끝이 아니다. 이러한 사이클이 반복해서 수행되어야 한다는 것이다. 1년간 이러한 성능 관리 활동을 수행했다고 VLDB가 계속 최적화된다는 보장은 없다. 해당 시스템이 업무를 종료하는 그 날까지 성능 관리는 매일 수행되어야 한다. 이 것이 VLDB의 운명은 아닐까?

 

VLDB의 성능 관리에서 또 하나의 중요한 항목은 사람이다. 성능 데이터 수집은 방안만 수립된다면 간단한 작업일 것이다. 하지만 이러한 성능 데이터 수집 방안을 수립하고 추출된 성능 데이터를 분석하기 위해서는 많은 부분에서 사람이 관여할 수 밖에 없다. 사람이 관여해야 하기 때문에 중요하다는 것은 아니다.

 

다른 분야도 그렇겠지만 VLDB의 성능 관리는 담당자의 실력에 의해서 성공과 실패가 좌우된다. 이제라도 VLDB를 위한 성능 관리 전문가를 육성해야 할 시기라는 것을 이해하길 바란다.

 

 

필자소개
SKC&C에서 DBA를 수행하면서 여러 프로젝트에서 DB 아키텍처, 모델링, 튜닝을 담당하고 있다. 특히 DB 성능관리 문제가 발생하는 프로젝트를 처리하는 데 역점을 두고 있다. 저서로는 <Perfect 오라클 실전 튜닝>과 <초보자를 위한 오라클10g>가 있다.

 

 

제공 : DB포탈사이트 DBguide.net

'Common Admin' 카테고리의 다른 글

Admin::DBA Technical Interview  (1) 2010.04.04
Admin::Hardware 101 for DBA  (2) 2010.04.04
Admin::VLDB성능관리#1  (0) 2010.04.04
Admin::SQL Server wait types  (0) 2010.03.28
2010. 4. 4. 23:44

Admin::VLDB성능관리#1

 VLDB성능관리#2

VLDB와의 소리 없는 전쟁
- 대용량 DB의 개념 및 발생 환경 -

 

VLDB는 Very Large Database의 약자이다. 결국, VLDB는 매우 큰 데이터베이스를 뜻하며 이는 대용량 데이터베이스를 의미한다. 대용량 데이터베이스라는 말은 1990년대부터 나왔던 용어이다. 그 당시는 100GB 정도의 데이터만 되어도 대용량 데이터베이스라고 했었다. 하지만 이제는 100GB 정도의 데이터베이스를 대용량 데이터베이스라고 부르는 사람은 한 명도 없을 것이다.

 

글 _ 권순용|kwontra@hanmail.net

 

 

IT시장도 세월이 흐르면서 대용량 데이터베이스에 대한 기준이 바뀌고 있다. 객관적인 기준은 없지만 필자는 대용량 데이터베이스를 GB 단위의 데이터베이스가 아닌 TB 단위의 데이터베이스라고 정의하고 싶다. 이번 호에서는 VLDB의 개념과 VLDB에서 발생하는 현상에 대해 알아 보도록 하겠다.

 

 

21세기 IT의 재앙은 VLDB인가?

언론에서 작년 말에 모 통신 회사의 가입 고객이 2,000만 명을 넘어섰다고 발표했다. 그것은 무엇을 의미하는 것일까? 이런 내용을 언론을 통해 알고 나면 습관처럼 계산하는 것이 하나 있다. 바로 데이터의 크기에 대한 계산이다. 2,000만 명이 하루에 다섯 통화씩 한다고 가정하면 하루 1억 건의 통화 데이터가 발생하게 되며 한 달에 30억 건의 데이터가 쌓이게 된다.

 

통화 데이터는 법적으로 보관해야 하는 개월 수가 정해져 있기 때문에 6개월을 보관한다고 가정하면 180억 건의 데이터가 쌓이는 대용량 테이블이 될 것이다. 이렇다면 해당 시스템은 누구나 VLDB라고 부르게 될 것이다. 또 하나의 예를 들어보자. 어느 카드 회사의 고객이 1,000만 고객이라고 가정하자. 카드 고객이 하루에 한번씩 사용한다고 가정하면 하루 발생 데이터는 1,000만 건이 된다. 한 달이면 3억 건의 데이터가 된다. 이 또한 어느 누가 VLDB라고 부르지 않겠는가?

 

예전에는 상상할 수 없었던 이러한 VLDB들이 현재는 흔하게 생겨나고 있다. 특히, 회사들의 DW 시스템은 해당 회사에서 발생하는 대부분의 데이터를 취합하기 때문에 거의 대부분 VLDB가 된다. 시대가 변화면서 우리 일상에는 많은 변화가 발생했다. 우리의 눈에는 보이지 않지만 시대가 변함으로써 변경된 것 중에 하나가 VLDB의 탄생이다.

 

데이터베이스가 VLDB로 다시 태어나는 순간 우리에게는 예상치 못한 일들이 발생하게 된다. 응답 속도 저하, 장애 증가, 백업과 복구 시간의 증가, 비용 증가 및 일반 작업 시간 증가 등의 현상이 발생하게 된다. 발생하는 현상들을 보면 데이터베이스가 VLDB로 변경되는 순간 악영향만 있을 뿐 좋아지는 현상은 없다. 데이터의 증가는 시스템적인 면에서는 어떠한 장점도 제공하지 않게 된다. 단지, 데이터의 증가에 의한 VLDB는 우리에게 해결해야만 하는 쉽지않은 과제만을 남기게 되었다.

 

수많은 회사들이 지금 VLDB에 대한 고민을 하고 있다. 해결 방안을 찾으려고 갖은 노력들을 하고 있는 것을 지켜보기도 했다. 하지만 데이터와 데이터베이스의 이해도가 부족한 사람들이 VLDB의 해결 방안을 찾고 있었다면 과연 VLDB의 해결 방안을 찾을 수 있을까? 필자는 데이터와 데이터베이스를 이해하는 사람이 그러한 방안을 찾아야 한다고 생각한다.

 

이러한 VLDB의 문제점에 대한 해결 방안을 찾지 못한다면 몇 년이 지나지 않아서 큰 문제를 발생시킬 것이다. 최악의 경우에는 해당 회사의 존재 유무에 영향을 줄 수 있을 것이다. 그렇게 된다면 이것이 21세기 IT의 재앙이 아니고 무엇이겠는가? VLDB가 발생시킬 수 있는 재앙에 대해 미리 준비하고 최적화해야 할 시간이 별로 많이 남아 있지 않다. VLDB의 재앙을 극복하는 회사가 결국 사업을 영속적으로 이끌어 갈수 있으리라 생각한다.

 

 

데이터는 운영 데이터와 이력 데이터로 구분된다

VLDB를 이해하기 위해서는 데이터베이스에 존재하는 데이터의 속성을 이해해야 한다. 데이터의 속성을 이해해야 VLDB에서 관리해야 할 데이터를 이해할 수 있을 것이다. 운영 중인 데이터베이스의 데이터는 운영 데이터와 이력 데이터로 구분할 수 있다.

 

운영 데이터는 실제 운영에 필요한 메타 데이터에 해당된다. 예를 들어, 카드 회사의 카드 마스터 테이블이라는 것이 존재한다고 가정하자. 신규 카드를 만들게 되면 해당 테이블에 한 건씩 데이터가 저장된다. 이렇다면 결국 해당 테이블의 총건수는 카드 회사에서 발급한 카드의 건수와 동일할 것이다. 어느 카드 회사가 1,000만 고객이라고 한다면 해당 테이블은 1,000만 건이 될 것이다.

 

그럼 카드 회사의 카드 마스터 테이블이 급격하게 증가할 수 있는가? 일반적으로 하루에 몇 천만 건씩 증가하지는 않을 것이다. 몇 천만 건이 아니라 몇 만 건도 증가 하지 않을 것이다. 통신 회사의 예를 들어 보자. 통신 회사에서 가입 고객의 수가 하루에 얼마나 늘어날까? 통계에 따르면 통신사별로 순수 증가 가입자가 한달 평균 10만 명 정도인 것으로 나타나고 있다. 한 달에 10만 건의 데이터가 발생하는 것은 그렇게 많은 데이터는 아닐 것이다. 카드 회사의 카드 마스터 테이블 또는 통신 회사의 가입 고객 테이블은 운영을 위한 기초 데이터를 가지고 있다.

 

논리 모델링시 키 엔티티(Key Entity)로 도출되는 테이블들이 운영 데이터의 역할을 수행하게 된다. 논리 모델링시 도출되는 운영 데이터를 보관하는 키 엔티티는 데이터베이스를 VLDB로 만드는 어느 정도의 역할은 수행하더라도 데이터베이스를 VLDB로 변경하는 근본적인 역할은 수행하지 않게 된다.

 

이력 데이터는 키 엔티티에 의해 발생하는 데이터에 해당될 것이다. 이를 논리적 모델링에서는 액션 엔티티(Action Entity)라고 한다. 예를 들어 카드 회사의 거래내역 테이블을 생각해보자. 거래내역 테이블의 데이터는 앞서 언급한 카드 마스터에 있는 각각의 카드에 의해서 만들어 지는 데이터이다. 거래 내역 테이블에는 각 카드가 사용한 데이터가 저장되며 하나의 카드는 하루에 여러 건의 데이터를 만들어낼 수 있다.

 

따라서 카드 회사의 거래내역 테이블은 대용량 테이블로 만들어질 것이다. 어디 이 뿐인가? 일반적인 거래내역 테이블은 일정 기간의 거래 내역을 보여주기 위해 과거의 데이터도 보관하고 있다는 것이다. 따라서 거래 내역 테이블의 크기는 상상을 초월하는 크기가 될 것이다. 이러한 카드회사의 거래 내역 테이블 뿐만 아니라 통신회사의 통화 내역 테이블도 동일하다. 통화 내역 테이블 역시 가입 고객에 의해 발생하는 논리 모델링에서 액션 엔티티에 해당된다.

 

통화 내역 테이블에는 가입 고객이 사용한 하나의 통화에 대해 하나의 데이터가 저장된다. 또한 통화 내역 테이블은 이력을 관리해야 하기 때문에 대용량 테이블로 탄생할 것은 명백한 사실일 것이다. 결국, 논리적 모델링에서 액션 엔티티로 표현되며 이력 데이터를 저장하는 테이블들이 데이터베이스를 VLDB로 만드는 주범일 것이다.

 

데이터의 증가와 응답 속도는 반비례 관계인가?

데이터베이스가 VLDB로 변하면서 발생할 수 있는 첫 번째 영향이 응답 속도이다. 일반적으로 데이터가 증가하면 응답 속도는 저하되기 쉽다. 이력 데이터가 1억 건이였을 경우 조회 쿼리의 응답속도가 1초였다고 가정하자.
이러한 이력 데이터가 2억 건이 된다면 이전 응답 속도인 1초 만에 해당 쿼리가 수행되기에는 힘들 것이다. 쿼리의 응답 속도는 디스크 블록 엑세스의 양과 밀접한 관계를 가진다.

 

디스크 블록 엑세스가 적다면 전체 데이터가 몇 건인가에 관계 없이 응답 속도를 보장 받을 수 있다. 하지만 데이터가 증가한다는 것은 엑세스해야 하는 디스크 블록의 증가를 암시하고 있다. 따라서 데이터 증가와 응답 속도 저하는 완전한 반비례 관계는 아니지만 VLDB에 대한 준비가 없다면 데이터 증가에 따라 응답 속도는 반비례 관계로 저하될 것이다.

 

예를 들어, 어느 통신회사의 통화 내역 테이블을 보자. 시대의 흐름에 따라 개인마다 한 대 이상의 휴대폰을 소지하면서 가입자가 증가하게 되었다. 가입자들은 개인적인 일뿐만 아니라 회사일 때문에도 많은 통화를 하게 된다. 이러한 한 통화 한 통화가 해당 통신 회사의 통화 내역 테이블에 저장된다. 통신 회사 가입 회원이 1,000만 명이라고 가정하자. 한 사람이 하루에 다섯 통화만 하게 되면 하루 데이터 량은 5,000만 건에 육박하게 된다. 또한 최근 6개월 전 통화 내역까지 고객에게 조회 가능하게 한다고 가정하자. 그렇다면 대용량의 통화 데이터가 생성될 것이다. 초기에는 특정 번호로 통화 내역 데이터를 엑세스하면 1초가 소요되었다고 가정하자.

 

그러나 계속적으로 가입자가 증가하게 되면 가입자들에 의해 발생하는 통화 데이터는 기하급수적으로 증가될 수 있다. 그렇다면 기존 쿼리의 응답 시간이 데이터의 증가에도 불구하고 1초가 유지될 것인가? 정답은 VLDB에 대한 최적화된 준비가 되어 있지 않다면 응답 속도는 저하된다는 것이다.

 

데이터의 증가는 증가된 데이터와 관련된 프로그램의 응답 속도를 저하시키는 것은 당연할 수 있다. 증가하는 데이터에 대해 어떠한 고려도 없다면 해당 시스템의 프로그램들은 점차 응답 속도가 저하되게 된다. 이를 해결하기 위해서는 기존 VLDB에 대한 성능 관리 고도화 및 새로 탄생하는 VLDB에 대한 최적화된 관리 방안 수립이 필요할 것이다.

 

VLDB에서 비용 증가는 왜 계속 되는가?

대부분의 회사에서는 매년 말 또는 매년 초 관리하고 있는 시스템에 대한 용량 증설을 계획한다. 용량 증설에는 보통의 경우 CPU, 메모리 및 디스크가 대상이 된다. 이러한 용량 증설을 위해 과연 무엇을 검토하는가? 용량 증설을 하기 위해서는 많은 데이터를 기초 데이터로 하여 용량 증설을 하게 된다.

 

CPU 용량 증설에 대한 기준은 보통의 경우 CPU 사용률이 된다. 디스크의 용량 증설의 기준은 현재 디스크 사용률과 데이터 증가량이다. 마지막으로 메모리 증설의 경우는 CPU 증설에 따라 결정되는 것이 보편적인 방법일 것이다.

 

필자가 지원했던 곳 중에 VLDB에 대해 매년 용량 증설로 10억 원 이상의 비용이 소요되고 있는 곳이 있었다. 그렇다면 막대한 비용이 매년 소요되는 용량 증설은 어쩔 수 없는 현상인가? 필자는 이 질문에 대해 아니라고 말하고 싶다. 이러한 비용이 적절하게 사용되는 부분도 있겠지만 어느 정도는 잘못 투자되는 부분도 존재한다고 생각한다.

 

CPU 사용률에 의해 CPU와 메모리가 증설된다. 중요한 점은 CPU 사용량만 보고 증설을 한다는 것이다. CPU 사용률이라는 것이 무엇인가? VLDB에서는 악성 SQL이 하나 수행되면 CPU 사용률은 많이 높아지게 된다. 그런 악성 SQL이 몇 개 수행된다면 해당 시스템은 용량 증설 대상이 될 것이다. 이런 이유에서 CPU 사용률이 높아진 시스템이 CPU 증설 대상이 되어야 하는 것인가? 시스템 관리자도 이러한 사실을 잘 인지하지 않고 있는 현실이 필자로서는 너무 아쉽다.

 

이런 악성 SQL을 최적화한다면 해당 VLDB 시스템은 CPU 사용량이 감소하게 된다. 그렇다면 CPU 또는 메모리 증설 비용이 추가되지 않을 수도 있을 것이다. 또한 배치 작업을 최적화하고 디스크 I/O 분산을 최적화한다면 이 또한 CPU 사용량이 감소하게 된다. 왜 이런 근본적인 문제를 해결하려 하지 않고 CPU와 메모리를 추가하려 하는가? 이와 같이 CPU 사용량만 보고 용량 증설을 한 시스템은 매년 이유도 모르고 용량 증설을 계속하게 마련이다.
이 얼마나 무서운 일인가? 필요한 용량 증설에는 비용을 투자해야 하는 것이 맞다. 하지만 VLDB에서 종종 발생하고 있는 잘못된 용량 증설에 의한 비용은 회사의 발전을 위해 사용해야 하는 비용을 엉뚱한 곳에 사용하고 있는 셈이다.

 

디스크 증설은 디스크 사용률과 데이터 증가량에 의해 결정된다. VLDB는 보통의 경우 대용량 이력 데이터의 증가로 용량을 증설하게 된다. 이러한 디스크 용량 증설이 반드시 필요한 것일까? 필요할 수도 있고 아닐 수도 있다. 집의 평수가 10평일지라도 이를 30평처럼 효과적으로 사용하는 사람이 있는가 하면, 30평에 살고 있어도 거의 10평 남짓한 집처럼 사용하는 사람이 있다.

 

VLDB의 디스크도 이와 별반 다르지 않다. 10TB의 VLDB가 진정한 10TB의 VLDB인지는 아무도 모른다.

 

요즘은 대부분의 데이터베이스 업체에서 데이터 압축 기술을 제공하고 있다. 이를 잘 이용한다면 10TB의 데이터가 5TB의 데이터로 변할 수 있는 것이 현실이다. 또한 데이터베이스의 특성 때문에 잘못 이용하여 불필요하게 낭비되는 공간도 있을 수 있다. 중요한 점은 논리적 모델링에서 정규화가 잘못되면 데이터는 기하급수적으로 증가하게 되며 인덱스 선정을 잘못하면 응답 속도 저하뿐만 아니라 엄청난 디스크를 사용하게 된다.

 

데이터베이스를 잘못 구성하고서 디스크가 부족하다는 이유로 디스크를 증설하는 것이 옳은 일인가? 이런 잘못된 데이터베이스 아키텍쳐와 논리적 모델링을 최적화하지 않는 한 해당 VLDB는 매년 대규모의 디스크를 증설해야 할 것이다.

 

VLDB에 대해 용량 증설을 하는 과정을 보면 필요한 부분에 대한 용량 증설을 하는 경우도 많지만 주먹 구구식으로 용량 증설을 하는 경우도 흔하다. 이런 경우 필자가 보기에는 귀찮아서가 아니라 VLDB에 대한 이해가 부족하기 때문에 발생하는 현상인 것 같다. 더 이상 VLDB를 간과할 수 없는 것이 대다수 기업의 현실이다. 체계적인 용량 증설에 대한 이해가 없다면 VLDB에 대한 용량 증설은 그 회사의 비용을 계속적으로 발생시키게 된다.

 

VLDB의 데이터 백업과 복구는 불가능 한가?

VLDB에 대해 데이터베이스가 너무 크기 때문에 백업 시간이 많이 소요되므로 업무에 지장을 초래한다는 얘기가 있다. 이는 백 번 맞는 말이다. 왜냐하면 백업을 수행하는 동안은 데이터베이스의 성능이 저하되기 때문이다. 그렇다고 VLDB여서 백업을 수행하지 못한다는 것은 이해되지 않는 말이다.

 

또한 VLDB는 장애 시 복구가 힘들 수 있지만 복구를 못하는 것은 아니다. 그렇다면 이러한 VLDB에 대한 백업과 복구에 대한 전략은 누가 수립해야 하는가?

 

어느 회사를 지원했을 때 필자가 경험했던 일이다. 그 회사는 시스템 관리자와 DBA 및 백업 관리자가 분리되어 있었다. VLDB에 대한 백업과 복구에 대한 전략을 개발자 또는 시스템 관리자가 수립하지는 않을 것이다. 그렇다면 백업 관리자인가? 이 또한 아닐 것이다. VLDB에 대한 백업과 복구에 대한 전략은 반드시 데이터베이스와 데이터를 이해하는 담당자가 계획하고 수행해야 한다는 사실이다. 데이터베이스의 아키텍쳐와 데이터의 구조를 모르는 백업 관리자가 어떻게 백업과 복구에 대해 전략을 세울 것인가? 필자가 지원했던 그 회사는 데이터베이스와 데이터를 이해하지 못하는 백업 관리자가 VLDB에 대한 백업과 복구의 모든 전략 및 계획을 수립했기 때문에 힘들어 하지 않았나 생각한다.

 

데이터베이스는 여러 가지 방법으로 데이터 백업을 지원한다. 어떤 데이터베이스는 데이터 증감 분에 대해 백업을 수행할 수 있게 해준다. 어떤 데이터베이스는 변경 작업이 발생하지 않는 데이터에 대해서는 한번 백업을 수행한 백업 본으로 언제든 복구를 수행할 수 있게 기능을 제공한다.

 

또 어떤 데이터베이스는 단순 파일 복사로만 백업을 대신할 수도 있다. 그리고 대부분의 데이터베이스는 데이터를 저장하고 있는 테이블 단위로 백업을 수행할 수 있게끔 기능을 제공하고 있다.

 

이렇게 다양한 방법의 백업방법이 제공되고 있지만, 이러한 방법을 효과적으로 이용하지 않고 전체 데이터에 대해 백업을 수행하는 경우를 자주 보아 왔다. 이렇게 전체 데이터를 매일 백업 받기 때문에 백업 시간이 많이 소요되고 이에 따라 시스템 성능 저하가 발생하게 되므로 백업을 수행하지 못한다는 얘기를 들을 때가 있다. 이 어찌 백업을 못 받는 것인가? 백업을 안 받는 거라고 해야 되지 않을까?

 

전체 데이터를 백업 받은 것으로 복구를 수행하는 경우는 그리 흔한 일은 아니다. 하지만 전체 데이터를 복구할 수 있는 백업은 반드시 백업 전략에 포함되어야 한다.

 

VLDB에서 전체 데이터를 복구하는 것은 데이터가 많기 때문에 당연히 많은 시간이 소요될 것이다. 하지만 전체 데이터베이스를 복구해야 하는 상황은 거의 발생하지 않는다. 보통의 경우 테이블스페이스 단위이거나 오브젝트 단위가 흔하게 발생하게 된다. 이런 방향으로 VLDB 복구 전략이 수립되고 복구를 수행한다면 빠르게 복구를 수행할 수 있을 것이다.

 

VLDB는 백업도 어렵지만 복구도 어려운 것이 사실이다. 하지만 데이터베이스에서 제공하는 많은 기능들을 효과적으로 사용하고 데이터의 감소를 성공적으로 달성하여 최적화된 백업 및 복구 전략을 수립할 수 있다면 VLDB의 백업과 복구가 어렵지 만은 않을 것이다. 이런 준비 없이 VLDB를 운영한다면 언젠가는 눈물을 흘리는 날이 올 것이다.

 

데이터가 증가함에 따라 일반적인 운영에 소요되는 시간은 증가하게 된다. 운영에 소요되는 시간이 증가하는 것이 문제인 것은 아니다. 오히려 문제는 운영에 필요한 많은 작업이 서비스 정지 시간을 필요로 한다는 사실이다. 이러한 서비스 정지 시간이 필요한 운영 작업이 데이터의 증가에 따라 소요시간이 증가되므로 서비스 정지 시간도 증가하게 될 것이다.

 

대부분의 업무 관리자들은 시스템이 무정지 시스템으로 운영되길 원한다. VLDB는 이러한 무정지 시스템을 구현하기 위한 제약 조건에 해당된다. 대용량 테이블에 인덱스를 하나 생성하는 것 조차 VLDB는 힘들 수 있다. 하지만 우리가 앞서 언급한 문제점들을 제거하는 과정을 거치게 되면 데이터는 감소하게 된다. 또한 데이터베이스에서 제공하는 수 많은 VLDB에 최적화된 기능을 사용한다면 서비스 정지 시간을 없애거나 감소시킬 수 있을 것이다.

'Common Admin' 카테고리의 다른 글

Admin::Hardware 101 for DBA  (2) 2010.04.04
Admin::VLDB성능관리#2  (0) 2010.04.04
Admin::SQL Server wait types  (0) 2010.03.28
Admin::DB 주의대상 일때.  (0) 2010.03.06
2010. 3. 28. 23:52

Admin::SQL Server wait types

'Common Admin' 카테고리의 다른 글

Admin::VLDB성능관리#2  (0) 2010.04.04
Admin::VLDB성능관리#1  (0) 2010.04.04
Admin::DB 주의대상 일때.  (0) 2010.03.06
SQL 2008-변경 내용 추적  (0) 2009.12.28
2010. 3. 6. 11:14

Admin::DB 주의대상 일때.

1. dbcc checkdb 처리시 오래 걸림
ALTER DATABASE DB_Name SET EMERGENCY
go
ALTER DATABASE DB_Name SET SINGLE_USER WITH ROLLBACK IMMEDIATE
go
DBCC CHECKDB('DB_Name',REPAIR_ALLOW_DATA_LOSS)
go
ALTER DATABASE DB_Name SET MULTI_USER WITH ROLLBACK IMMEDIATE

'Common Admin' 카테고리의 다른 글

Admin::VLDB성능관리#1  (0) 2010.04.04
Admin::SQL Server wait types  (0) 2010.03.28
SQL 2008-변경 내용 추적  (0) 2009.12.28
sql2008::CDC(Change Data Capture)  (1) 2009.12.28
2009. 12. 28. 15:37

SQL 2008-변경 내용 추적


SQL Sever 2008 이후

MSDN에서 발췌한 내역입니다.

http://msdn.microsoft.com/ko-kr/library/bb933875.aspx

 

사용자 테이블에 대해 어떤 행이 변경되었는가?
행이 변경되었다는 사실만 필요하며, 행이 변경된 횟수 또는 중간 변경의 값은 필요하지 않습니다.
최신 데이터는 추적되는 테이블에서 직접 얻을 수 있습니다.
행이 변경되었는가?
행이 변경되었다는 사실, 그리고 이 변경에 대한 정보가 있어야 하며 동일한 트랜잭션에 변경이 수행된 시점에 이 사항이 기록되어야 합니다.


1. 변경 내용 추적 작동 방법

 

 - 변경 내용 추적이 테이블에 대해 구성되면 해당 테이블의 행에 영향을 미치는 DML 문이 수정된 각 행에 대한 변경 내용 추적을 기록합니다.

-  추적되는 테이블에서 변경 내용 정보와 함께 기록되는 유일한 정보는 기본 키 열의 값입니다. 이러한 값은 변경된 행을 식별합니다. 이러한 행에 대한 최신 데이터를 얻으려면 응용 프로그램에서는 기본 키 열 값을 사용하여 원본 테이블을 추적되는 테이블에 조인하면 됩니다.

- 각 행에 대해 수행된 변경에 대한 정보도 변경 내용 추적을 사용하여 얻을 수 있습니다.

 

ALTER DATABASE AdventureWorks
SET CHANGE_TRACKING = ON
(CHANGE_RETENTION = 2 DAYS, AUTO_CLEANUP = ON)
;

ALTER TABLE Person.Contact
ENABLE CHANGE_TRACKING
WITH (TRACK_COLUMNS_UPDATED = ON)
;

-- 해지
ALTER TABLE Person.Contact
DISABLE CHANGE_TRACKING;

ALTER DATABASE AdventureWorks
SET CHANGE_TRACKING = OFF

 

작업 변경 내용 추적이 설정된 경우

DROP TABLE

삭제된 테이블에 대한 모든 변경 내용 추적 정보가 제거됩니다.

ALTER TABLE DROP CONSTRAINT

PRIMARY KEY 제약 조건을 삭제하려는 시도가 실패합니다. 변경 내용 추적을 해제해야 PRIMARY KEY 제약 조건을 삭제할 수 있습니다.

ALTER TABLE DROP COLUMN

삭제된 열이 기본 키의 일부일 경우 변경 내용 추적과 관계없이 해당 열을 삭제할 수 없습니다.

삭제된 열이 기본 키의 일부가 아닐 경우 해당 열을 삭제할 수 있습니다. 그러나 이 데이터를 동기화하는 응용 프로그램에 미치는 영향에 대해 먼저 이해해야 합니다. 테이블에 열 변경 내용 추적이 설정되어 있을 경우 삭제된 열이 여전히 변경 내용 추적 정보의 일부로 반환될 수도 있습니다. 삭제된 열은 응용 프로그램에서 처리해야 합니다.

ALTER TABLE ADD COLUMN

변경 내용 추적이 설정된 테이블에 새 열이 추가될 경우 이 열 추가 작업은 추적되지 않습니다. 새 열에 대해 수행된 업데이트 및 변경 내용만 추적됩니다.

ALTER TABLE ALTER COLUMN

기본 키가 아닌 열의 데이터 형식 변경 내용은 추적되지 않습니다.

ALTER TABLE SWITCH

테이블 중 하나 또는 둘 모두에 변경 내용 추적이 설정된 경우 파티션 전환에 실패합니다.

DROP INDEX 또는 ALTER INDEX DISABLE

기본 키를 강제 적용하는 인덱스는 삭제 또는 해제할 수 없습니다.

TRUNCATE TABLE

테이블 잘라내기는 변경 내용 추적이 설정된 테이블에서 수행할 수 있습니다. 그러나 이 작업으로 삭제된 행은 추적되지 않으며 유효한 최소 버전이 업데이트됩니다. 응용 프로그램이 버전을 검사할 때 해당 버전이 너무 오래되어 다시 초기화해야 한다고 나타납니다. 이는 해당 테이블의 변경 내용 추적이 해제된 다음 다시 설정되는 것과 동일합니다.

 


'Common Admin' 카테고리의 다른 글

Admin::SQL Server wait types  (0) 2010.03.28
Admin::DB 주의대상 일때.  (0) 2010.03.06
sql2008::CDC(Change Data Capture)  (1) 2009.12.28
SQL2008::데이터 변경 내용 추적  (0) 2009.12.28
2009. 12. 28. 14:25

sql2008::CDC(Change Data Capture)

SQL SERVER 2008 이후


MSDN을 발췌한 내역입니다.

http://msdn.microsoft.com/ko-kr/library/cc645937.aspx

 

[기본 개요]

 

- 변경 데이터 캡처는 SQL Server 테이블에 적용되는 삽입, 업데이트 및 삭제 작업을 기록합니다

-  SQL Server Enterprise, Developer 및 Evaluation Edition에서만 사용할 수 있습니다.

-  이 기술의 대상이 될 수 있는 좋은 데이터 소비자 예로 ETL(추출, 변환 및 로드) 응용 프로그램을 들 수 있습니다. ETL 응용 프로그램은 증분식으로 SQL Server 원본 테이블의 변경 데이터를 데이터 웨어하우스 또는 데이터 마트로 로드합니다. 데이터 웨어하우스 내에서 원본 테이블의 표현은 해당 원본 테이블의 변경 내용을 반영해야 하지만 원본 복제본을 새로 고치는 종단 간 기술은 적합하지 않습니다. 대신 소비자가 다른 종류의 데이터 대상 표현에 적용할 수 있도록 구조화된 안정적인 변경 데이터 스트림이 필요합니다. SQL Server 변경 데이터 캡처가 이 기술을 제공합니다.

 

1. 기본 흐름

 

변경 데이터 원본은 SQL Server 트랜잭션 로그입니다.

 

추적된 원본 테이블에 삽입, 업데이트 및 삭제가 적용되면 이러한 변경을 설명하는 항목이 로그에 추가됩니다.

 

로그는 변경 데이터 캡처 프로세스에 대한 입력으로 사용됩니다. 이 프로세스는 로그를 읽고 변경에 대한 정보를 추적된 테이블의 관련 변경 테이블에 추가합니다.

 

지정된 범위에서 변경 테이블에 나타나는 변경을 열거하여 해당 정보를 필터링된 결과 집합의 형태로 반환하는 함수가 제공됩니다.

 

 

 

 

 

-  sys.sp_cdc_enable_db 사용하여 데이터베이스에 변경 데이터를 캡처 사용하도록 명시적 설정

- sys.sp_cdc_enable_table 사용하여 원본 테이블을 추적된 테이블로 식별할 수 있도록 명시적 설정

- 캡처 인스턴스는 변경테입르과 두개의 쿼리 함수로 구성

- cdc 스키마 , cdc 사용자, SQL Agent 작업 2개 (cdc.database.capture, cdc.database.cleanup) , 메타데이터 테이블, 변경 테이블 생성

 

- 원본 테이블에 적용되는 각 삽입 또는 삭제 작업은 변경 테이블 내에 단일 행으로 나타납니다.

- 삽입 작업의 결과로 생성되는 행의 데이터 열에는 삽입 이후의 열 값이 포함되며 삭제 작업의 결과로 생성되는 행의 데이터 열에는 삭제 이전의 열 값이 포함됩니다. 업데이트 작업의 경우 하나의 행 항목에서 업데이트 이전의 열 값을 식별하고 다른 행 항목에서 업데이트 이후의 열 값을 식별해야 합니다.

- 열 __$operation은 변경 내용과 관련된 1 = 삭제, 2 = 삽입, 3 = 업데이트(이전 이미지) 및 4 = 업데이트(이후 이미지) 작업을 기록합니다.

 

2. 데이터 베이스에 대한 변경 데이터 캡처 유효성 간격

 

-  캡처 인스턴스에 변경 데이터를 사용할 수 있는 시간입니다.

유효성 간격은 데이터베이스 테이블에 대한 첫 번째 캡처 인스턴스가 만들어질 때 시작되어 현재 시간까지 지속됩니다.

- 캡처 프로세스에서 관련 로그 항목을 처리할 때까지 변경 데이터를 사용할 수 없다는 점을 알아두는 것이 중요합니다.  (대기시간이 존재함)

 

3. 캡처 인스턴스에 대한 변경 데이터 뱁처 유효성 간격

 

- 캡처 인스턴스의 유효성 간격은 캡처 프로세스에서 캡처 인스턴스를 인식하여 해당 변경 테이블에 대한 관련 변경 내용을 기록하기 시작할 때 시작합니다. 따라서 여러 캡처 인스턴스가 서로 다른 시간에 만들어지는 경우 각 인스턴스는 처음에 서로 다른 하위 끝점을 포함하게 됩니다

- 시간이 지나도 새 캡처 인스턴스가 만들어지지 않으면 모든 개별 인스턴스에 대한 유효성 간격이 데이터베이스 유효성 간격과 일치하게 됩니다.

- sys.fn_cdc_get_min_lsn : 캡처 인스턴스의 대한 현재 최소 LSN 값을 검색

- sys.fn_cdc_get_max_lsn : 최대 LSN 값을 검색하는데 사용

- 변경 데이터를 쿼리할 때 지정 LSN 범위가 이러한 두 LSN 값 내에 포함되지 않은 경우 변경 데이터 캡처 쿼리 함수가 실패합니다.

 

4. 원본 테이블에 대한 변경 내용 처리

 

-  원본테이블의 열이 데이터 형식이 변경되면 변경테이블로 전파되어 데이터 손실이 생성되지 않는다.

- 원본 테이블열이 삭제되면, 후속 변경 항목의 열에 대해서는 NULL값이 제공된다.

- 단일 원본 테이블에 동시에 연결할 수 있는 최대 캡처 인스턴스 수는 두 개입니다.

- 기본적으로 3일 분량의 데이터가 보존 됩니다.

 

5. 데이터베이스 미러링

- 변경 데이터 갭처가 설정된 데이터베이스에 미러링 걸 수 있습니다.

 *  agent가 실행중인지 확인합니다.

 * 보안 주체가 미러로 장애 조치를 수행하면 미러에서 갭처 작업 및 정리작업을 만듭니다.

 

6. 트랜잭션 복제

 - 변경 데이터 겹처 및 트랜잭션 복제는 동일한 데이터베이스에 함께 존재할 수 있습니다.

- sp_replcmds 가 배포 데이터베이스의 테이블과 캡처에 의한 변경 테이블에 모두 값을 채웁니다. 복제가 해지되면 로그 판독기 에이전트가 제거되고 캡처 작업이 다시 만들어 집니다.

 

7. 변경 데이터 캡처가 설정된 데이터베이스 복원 또는 연결

 - 데이터베이스가 동일한 서버에 동일한 데이터베이스 이름으로 복원되는 경우 변경 데이터 캡처는 설정된 상태를 유지합니다.
 - 데이터베이스가 다른 서버로 복원되는 경우에는 기본적으로 변경 데이터 캡처가 해제되고 관련된 모든 메타데이터가 삭제됩니다. 변경 데이터 캡처를 유지하려면 데이터베이스를 복원할 때 KEEP_CDC 옵션을 사용합니다.
- 데이터베이스가 분리된 후 다시 동일한 서버 또는 다른 서버에 연결될 경우 변경 데이터 캡처는 설정된 상태를 유지합니다.

- 데이터베이스가 KEEP_CDC 옵션을 사용하여 Enterprise 이외의 다른 버전에 연결 또는 복원된 경우 변경 데이터 캡처에 SQL Server Enterprise가 필요하기 때문에 작업이 차단됩니다. 오류 메시지 932가 표시됩니다.
sys.sp_cdc_disable_db 를 사용하여 제거 할 수 있습니다.

 

 

'Common Admin' 카테고리의 다른 글

Admin::DB 주의대상 일때.  (0) 2010.03.06
SQL 2008-변경 내용 추적  (0) 2009.12.28
SQL2008::데이터 변경 내용 추적  (0) 2009.12.28
SQL 2008 개선된 기능, DBMS Trends  (0) 2009.12.24
2009. 12. 28. 11:16

SQL2008::데이터 변경 내용 추적

MSDN 자료를 발췌한 내역입니다.

http://msdn.microsoft.com/ko-kr/library/bb933994.aspx

 

일반적으로 응용 프로그램 개발자는 데이터 변경을 확인하기 위해 응용 프로그램에서 트리거, 타임스탬프, 열 및 추가 테이블의 조합으로 사용자 지정 추적 방법을 구현해야 했습니다. 이러한 응용 프로그램을 만드는 데는 일반적으로 많은 구현 작업과 스키마 업데이트가 필요했으며 성능 오버헤드도 높은 경우가 많았습니다.

SQL Server 2008은 다음과 같은 새로운 기술을 제공합니다. 응용 프로그램 개발자는 이러한 기술을 사용하여 데이터 변경을 추적하고 응용 프로그램에서 변경된 데이터만 추적하도록 할 수 있습니다.

 

1. 변경 데이터 캡처

 - DML 변경이 적용되었다는 사실과 변경된 실제 데이터 모두를 캡처하여 사용자 테이블에 대한 기록 변경 정보를 제공합니다.

- 트랜잭션 로그를 읽고 시스템에 대한 영향이 적은 비동기 프로세스를 사용합니다.

 

 

사용자 테이블에 적용된 변경은 해당 변경 테이블에서 캡처됩니다. 이러한 변경 테이블은 시간에 따라 변경을 기록하여 보여 줍니다. SQL Server에서 제공하는 변경 데이터 캡처 함수를 사용하면 변경 데이터를 쉽고 체계적으로 사용할 수 있습니다.

 

2. 변경 내용 추적

 - 변경 내역 추적은 테이블 행을 변경했다는 사실은 캡처 하지만 변경된 데이터를 캡처하지는 않습니다.

-  변경 내역을 필요로 하지 않을 경우 오버해드가 적습니다.

-  동기 추적 매터니즘을 사용하여 변경 내용을 추적합니다.


 

 

기능 변경 데이터 캡처 변경 내용 추적

추적된 변경 내용

 

 

DML 변경

추적된 정보

 

 

기록 데이터

아니요

열 변경 여부

DML 유형

 

2009. 12. 24. 16:49

SQL 2008 개선된 기능, DBMS Trends

2009. 12. 4. 13:47

Windows Aligning Disk Sectors for Optimal Performance

Microsoft Windows 2000 Server has an internal structure known as the master boot record (MBR) that limits the maximum number of hidden sectors to 63. This characteristic of the MBR causes the default starting sector for disks that report more than 63 sectors per track to be the 64th sector. Therefore, when programs transfer data to or from disks that have more than 63 sectors per track, misalignment can occur at the track level, with allocations starting at a sector other than the starting sector. This misalignment can defeat system optimizations of I/O operations that are designed to avoid crossing track boundaries.

Diskpar.exe is a command-line tool from the Windows 2000 Server Resource Kit that can explicitly set the starting offset in the MBR. By doing this, the track is aligned with the physical disk partition, which results in an improvement in disk performance. Exchange writes four kilobytes to the database and up to 32 kilobytes for the streaming data. Therefore, make sure that you set the starting offset to be a multiple of four kilobytes.

 

 

방법

http://support.microsoft.com/kb/929491/en-us

2009. 12. 3. 16:22

admin::여러 TCP 포트에서 수신하도록 데이터베이스 엔진 구성

여러 TCP 포트에서 수신하도록 데이터베이스 엔진 구성

http://msdn.microsoft.com/ko-kr/library/ms189310.aspx

 NUMA 노드에 TCP/IP 포트 매핑

http://msdn.microsoft.com/ko-kr/library/ms345346.aspx

소프트 NUMA를 사용하도록 SQL Server 구성

   http://msdn.microsoft.com/ko-kr/library/ms345357.aspx 

2009. 12. 3. 11:03

SQL Server Maximum Capacity

SQL Server Maximum Capacity

 

 

 

 

 

SQLLeader.com

 

Object

 

Maximum sizes/numbers

 

Maximum sizes/numbers

 

Maximum sizes/numbers

 

SQL Server 7 (32-bit)

 

SQL Server 2000 (32-bit)

 

SQL Server 2005 (32-bit)

 

Batch size

 

65,536 * Network Packet Size

 

65,536 * Network Packet Size

 

65,536 * Network Packet Size

 

Bytes per short string column

 

8,000

 

8,000

 

8,000

 

Bytes per text, ntext, image, varchar(max), nvarchar(max), varbinary(max), or XML column

 

231 -2 bytes

 

231 -2 bytes

 

231 -1 bytes

 

Bytes per GROUP BY, ORDER BY

 

8,060

 

8,060

 

8,060

 

Bytes per index

 

900

 

900

 

9001

 

Bytes per foreign key

 

900

 

900

 

??2

 

Bytes per primary key

 

900

 

900

 

900 - Not listed, but since this will be an index, the index guidelines should apply.

 

Bytes per row

 

8,060

 

8,060

 

8,060

 

Bytes in source text of a stored procedure

 

Lesser of batch size or 250 MB or 128MB3

 

Lesser of batch size or 250 MB or 128MB3

 

128MB

 

Clustered indexes per table

 

1

 

1

 

1

 

Columns in GROUP BY, ORDER BY

 

Limited only by number of bytes

 

Limited only by number of bytes

 

Limited only by number of bytes

 

Columns or expressions in a GROUP BY WITH CUBE or WITH ROLLUP statement

 

10

 

10

 

10

 

Columns per index

 

16

 

16

 

164 5

 

Columns per foreign key

 

16

 

16

 

164

 

Columns per primary key

 

16

 

16

 

164

 

Columns per base table

 

1,024

 

1,024

 

1,024

 

Columns per SELECT statement

 

4,096

 

4,096

 

4,096

 

Columns per INSERT statement

 

1,024

 

1,024

 

1,024

 

Connections per client

 

Maximum value of configured connections (32,767 max)

 

Maximum value of configured connections (32,767 max)

 

Maximum value of configured connections (32,767 max)

 

Database size

 

1,048,516 terabytes

 

1,048,516 terabytes

 

1,048,516 terabytes

 

Databases per instance of SQL Server

 

32,767

 

32,767

 

32,767

 

Filegroups per database

 

256

 

256

 

32,767

 

Files per database

 

32,767

 

32,767

 

32,767

 

File size (data)

 

32 terabytes

 

32 terabytes

 

32 terabytes

 

File size (log)

 

32 terabytes

 

32 terabytes

 

32 terabytes

 

Foreign key table references per table

 

253

 

253

 

253

 

Identifier length (in characters)

 

128

 

128

 

128

 

Instances per computer

 

16

 

16

 

50

 

Length of a string containing SQL statements (batch size)

 

65,536 * Network packet size

 

65,536 * Network packet size

 

65,536 * Network packet size

 

Locks per connection

 

Maximum locks per server

 

Maximum locks per server

 

Maximum locks per server

 

Locks per instance of SQL Server

 

Up to 2,147,483,647

 

Limited only by memory

 

Limited to 60% of memory

 

Nested stored procedure levels

 

32

 

32

 

32

 

Nested subqueries

 

32

 

32

 

no limit, at least according to Beta 2 BOL

 

Nested trigger levels

 

32

 

32

 

32

 

Nonclustered indexes per table

 

249

 

249

 

249

 

Objects concurrently open in an instance of SQL Server

 

2,147,483,647 per database (depending on available memory)

 

2,147,483,647 per database (depending on available memory)

 

2,147,483,647 per database (depending on available memory)

 

Objects in a database

 

2,147,483,647

 

2,147,483,647

 

2,147,483,647

 

Parameters per stored procedure

 

2,100

 

2,100

 

2,100

 

Parameters per user-defined function

 

2,100

 

2,100

 

2,100

 

REFERENCES per table

 

253

 

253

 

253

 

Rows per table

 

Limited by available storage

 

Limited by available storage

 

Limited by available storage

 

Tables per database

 

Limited by number of objects in a database

 

Limited by number of objects in a database

 

Limited by number of objects in a database

 

Tables per SELECT statement

 

256

 

256

 

256

 

Triggers per table

 

Limited by number of objects in a database

 

Limited by number of objects in a database

 

Limited by number of objects in a database

 

UNIQUE indexes or constraints per table

 

249 nonclustered and 1 clustered

 

249 nonclustered and 1 clustered

 

249 nonclustered and 1 clustered

 

 

 

Footnotes

 

 

 

 

 

 

 

1 - By including nonkey columns in the index, you can exceed the 900 byte limit as these columns (used in covering queries) are not computed as part of the 900 byte limit.

 

2 - I could not find this listed in the SQL Server 2005 Beta 2 BOL.

 

3 - The Maximum Capacity Specifications shows the less or the batch size or 250MB, however Books Online shows 128MB in the entry for

 

4 - The 16 column limit is for key columns. Additional columns can be included (as in footnote 1) beyond the 15.

 

5 - Not valid for XML indexes.