2009. 11. 4. 13:37

Admin::Allocate Extent, 익스텐드 할당&공간관리

SQL Server의 데이터베이스는 데이터 파일과 로그 파일로 구성됨.

로그 파일은 앞에서 설명한 VLF로 구성된다.

반면, 데이터 파일의 가장 작은 단위는 페이지이다.

연속적인  8개의 페이지로 extent가 구성된다.

 

extents는 'single-extent' (균일 익스텐트), 'mixed extent'(혼합 익스텐트) 로 나뉜다.

균일 익스텐트는 하나의 개체가 8개의 페이지를 모두 사용 하며, 혼합 익스텐트는 하나의 익스텐트에 여러 개체가 들어간다.

1 extents = 8 page = 1 page *  8kb = 64kb

 

테이블을 만들때는 익스텐트 단위로 일어나는데 SQL은 처음 테이블을 만들때는 항상 혼합 익스텐트 내에서 생성한다.

테이블이 커져가서 8 개의 page를 채훈 후 부터 균일 인스텐트를 할당한다.

 

* GAM, SGAM

SQL Server는 전역 할당 맵(GAM) 과 공유 전역 할당 맵(SGAM) 이라는 두가지 할당 맵을 사용하여 익스텐트, GAM, SGAM은 각 1bit로 하나의 익스텐트를 관리함으로 총 6400 익세텐트를 관리 (4GB)

 

GAM : 어떤 익스텐트가 할당되었는지 관리

SGAM : 어떤 익스텐트가 현재 혼합 익스텐트로 사용되는지, 빈 페이지를 가지는지 여부 관리

 GAM비트   SGAM비트  해당 익스텐트의 상태
 1  0  비어있음, 사용중이지 않음
 0  0  균일 익스텐트 또는 환전 혼합 익스텐트
 0  1  빈 페이지가 있는 혼합 익스텐트

1. 신규 테이블 생성시 :  0:1 이 있는것에 할당함. 즉, SGAM이 1인것을 할당

SGAM : 1인것이 존재 하지 않으면, 1:0 인것을 찾아서 할당하고 비트 패턴을 0:1 로 변경한다.

 

2. GAM과 SGAM은 데이터 파일 하나씩 있으므로 해당 DB의 파일 개수를 늘려주면 SGAM에 대한 요구가 분산되어 보다 좋은 성능을 낼 수 잇다.

임시테이블은 모두 tempdb에서 처리됨으로 tempdb의 데이터 파일을 여러개로 분리하는 것이 많은 수의 임시 테이블 요구에 대한 할당 잠금 측면에서 유리하다.

 

* PFS (Page Free Space)

힙, ntext, text, image 컬럼의 페이지가 할당되었는지 여부와 각 페이지의 빈 공간 크기를 기록한다.

하나의 PFS 페이지는 약 8000 page = 1000 익스텐트 관리하며, 파일이 커지면 연결 리스트 구조로 새로운 PFS 페이지가 추가된다.

 

* BCM (Bulked Change Map)

마지막 Backup log 문 이후 대량 기록 작업에 의해 수정된 익스텐트를 관리, 대량 로그 복구 모델일 때 사용됨

 

* DCM

마지막 bakcup dataase (full backup) 이후에 변경된 익스텐트를 관리하는 페이지이며, 차등 백업의 대상 익스텐트를 찾기 위해 사용,

BCM, DCM도 1bit로 하나의 익스텐트를 관리함으로 총6400 익스텐트 관리하게 된다.

 

* IAM (Index Allocation Map)

개체가 사용하는 데이터베이스 파일의 익스텐트를 매핑한다.

 


 

 

 

2009. 10. 11. 14:12

SQL Server DBA Checklist

 

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.
2009. 7. 24. 14:01

[TechNet세미나] Windows Server 2003 ClusterService Troubleshooting

http://www.microsoft.com/korea/eseminar/Seminar_player7.aspx?number=1316&asf=300K

 

온라인 등록하고 들으면 들을 수 있습니다.

 

2009. 7. 20. 17:32

SQL Server 2000 vs SQL Server 2005 Startup Parameters

출처 http://www.mssqltips.com/tip.asp?tip=960

 

비교적 쉬운 영어길래 그대로 가져옵니다.

 

Problem
SQL Server offers the ability to use startup parameters when your SQL Server instance starts. The default items include:

  • location of  master database data file (-d)
  • location of  master database log file (-l)
  • location of  SQL server error logs (-e)

In addition, you can set startup parameters for trace flags, starting your instance in single user mode, etc...here is a link to startup options for SQL Server 2005 which is pretty similar to options for SQL Server 2000.

With SQL Server 2000 the startup parameters are available right from Enterprise Manager, but not so with SQL Server 2005.  So how do you set the startup parameters for SQL Server 2005?

Solution
With SQL Sever 2000 access to the startup parameters is available right within Enterprise Manager.  You can get to the startup parameters by right clicking on the server name and selecting "Properties".  The following screen appears and there is a great big button "Startup Parameters..." which you can click and it will allow to see and set the startup parameters.




After clicking on "Startup Parameters" you get the following window.  From here you can click on the parameter and click "Remove" to remove it or click on "Add" to add a new parameter. It is pretty straight forward.

 

With SQL Server 2005 a lot of things have been moved to other applications and are not all available through SQL Server Management Studio.  One of these things is the startup parameters.  To find the startup parameters you need to go to the SQL Server Configuration Manager tool.  This can be found in the menus through: Microsoft SQL Server 2005 -> Configuration Tools -> SQL Server Configuration Manager.

Once the application is launched you will see the following screen.

  • select the SQL Server service that you want to set the startup parameters for such as "SQL Server (TEST1)" for our example
  • right click and select "Properties" and the following window will pop up
  • go to the "Advanced" tab

  • select "Startup Properties" and the following window will pop up

  • from here you can add, change or remove your startup properties
  • note: each startup parameter is separated by a semi colon (;)
  • once you are done click "Apply" to save your changes
2009. 7. 12. 23:27

64bit Standard 에디션 에서 "Lock Page in memory" 가능

SQL SERVER 2005 이상

좋은 소식!!

 

이제 2005, 2008의 스탠다드 에디션에서도 Locak Page Memory 사용이 가능해 졌다.

 

CU2 for SQL Server 2008 SP1 => http://support.microsoft.com/kb/970315/en-us

http://support.microsoft.com/kb/970279/ko
CU4 for SQL Server 2005 SP3 => http://support.microsoft.com/kb/970279/en-us

http://support.microsoft.com/kb/970279/ko

 

 

How to enable "Lock pages in Memory" at the Windows level:

  1. On the Start menu, click Run. In the Open box, type gpedit.msc. The Group Policy dialog box opens.
  2. On the Group Policy console, expand Computer Configuration, and then expand Windows Settings.
  3. Expand Security Settings, and then expand Local Policies.
  4. Select the User Rights Assignment folder. The policies will be displayed in the details pane.
  5. In the pane, double-click Lock pages in memory.
  6. In the Local Security Policy Setting dialog box, click Add.
  7. In the Select Users or Groups dialog box, add the account that runs the SQL Server Service.
  8. Restart the machine for these changes to take effect.

If you are running an Enterprise or Developer Edition of SQL Server 2005 or 2008, please stop here. The rest of the steps are for the Standard Edition Only.

  1. Ensure that the build of SQL Server 2008 is Cumulative Update 2 on Service Pack 1. Preferably, run the "select @@version" command against the SQL Server Instance and verify that the build is 10.00.2714.00. In case of SQL Server 2005, please verify that the build is 9.00.4226.
  2. Now  set  the  Trace  Flag  845 as a  startup trace flag. This can be done by adding
    -T845 to the startup parameters from the SQL Server Configuration Manager. Please refer to the screenshot below:

    SQLConfigManager
  3. Restart the SQL Server Service.
  4. Verify that the following message is written in the SQL Server ErrorLog file at startup:
            Using locked pages for buffer pool

Note: Enabling Locked Pages may have a negative performance impact on your system performance. Please consider all potential effects before you use this option.
Enabling this trace flag on the Enterprise Edition or the Developer Edition has no effect.

 

 

2009. 6. 23. 14:41

Admin::Started with SQL Server (서비스시작)

 SQL Server  수동 시작

  •   SQL Server 구성 관리자 :: 로컬 SQL Server 또는 SQL Server 에이전트 서비스의 인스턴스를 시작, 일시 중지, 재개 및 중지합니다.
  •  명령 프롬프트 : net start , sqlservr.exe 실행하여 SQL Server or SQL Server Agent 인스턴스 시작합니다.

    • 직접 입력한 모든 명령 프롬프트 옵션은 SQL Server 설치 동안 Windows 레지스트리에 기록된 기본 명령 프롬프트 옵션보다 우선합니다.
    • 문제 해결을 목적으로 SQL Server 를 시작하려는 경우에만 명령 프롬프트에서 sqlservr.exe를 실행하십시오.
    • Windows를 로그오프하기 전에 SQL Server 인스턴스를 종료해야 합니다.

 net 명령

  1. --  sql server 시작
  2. net start "SQL Server(MSSQLSERVER)" or net start MSSQLSERVER
  3. net start "SQL Server(instancename)" or net start MSSQL$instancename
  4.  

     

  5. -- 시작옵션
  6. net start MSSQLSERVER /f /m /T trace_flag
  7. -- 일시 중지 / 재개
  8. net pause MSSQLSQLSERVER   / net continue MSSQLSERVER
  9.  
  10. -- 서비스 중지
  11. net stop MSSQLSERVER

 

sqlserver.exe

  • SQL Server를 시작할 수 있는지 테스트하는 목적 이외에는 명령줄에서 SQL Server를 실행하지 마십시오. 명령줄에서 SQL Server를 시작한 후 유지 관리 작업을 수행하면 나중에 오류가 발생할 수 있습니다. 예를 들어 관리자로 로그인하여 새 데이터베이스를 만들거나 데이터 파일의 위치를 변경하면 나중에 SQL Server 서비스의 일반 계정에서 SQL Server를 실행한 경우 해당 데이터베이스나 데이터 파일에 액세스할 수 없습니다.
  • cd \Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Binn 에 위치

     

    1. -- sql server  시작
    2. sqlservr.exe
    3. sqlservr.exe -s <instancename>
    4. -- 단일 사용자 모드로 실행
    5. sqlservr.exe -m
    6. sqlservr.exe -m -s <instancename>
    7. -- 인스턴스를 최소 구성으로 시작하려면
    8. sqlserver.exe -f
    9. -- tempdb 없이 최소 구성으로 단일 모드로
    10. sqlservr.exe -c -f -m
    11. 올리고 창하다 접속해서 tempdb 수정
     
    -- tempdb가 주의 대상일 때
    sqlservr.exe -c -T3608 -T4022


      -- 추적 플래그
    sqlserver.exe -Ttrace_flag
    -- sql server 중지
    Ctrl +Break를 누르거나 명령창을 닫습니다.

     

서비스 시작옵션 (Using the SQL Server Service Startup Options)

  • 서비스 시작되면서 필요한 추척 플래그 옵션 참고 하십시오.

    기본시작옵션 설명
     -d master_file_path

     master 데이터베이스 파일의 정규화된 경로

    C:\Program Files\Microsoft SQL Server\MSSQL.n\MSSQL\Data\master.mdf

    제공되지 않으면 기존의 레지스트리 매개 변수 사용

     -e error_log_path

     오류 로그 파일의 정규화된 경로입니다.

     C:\Program Files\Microsoft SQL Server\MSSQL.n\MSSQL\LOG\ERRORLOG

     -I master_log_path

    master 데이터베이스 로그 파일의 정규화된 경로입니다. 일반적으로

    C:\Program Files\Microsoft SQL Server\MSSQL.n\MSSQL\Data\mastlog.ldf입니다.

     -c  

     명령 프롬프트에서 SQL 을 시작할때 시간을 단축 시킵니다.

     -f   SQL Server 인스턴스를 최소 구성으로 시작합니다.  예를 들어 오버커밋 메모리 같은 구성 값의 설정 대문에 서버를 시작할 경우에 유용
     -g memory_to_reserve

     SQL Server에서 SQL Server 프로세스 내(단, SQL Server 메모리 풀 외부)의 메모리 할당에 대해 사용 가능하도록 둘 메모리를 MB 단위의 정수로 지정합니다.

    SQL Server 오류 로그에서 다음 경고가 표시되지 않으면 -g 매개 변수의 기본값을 사용해야 합니다.

    "Failed Virtual Allocate Bytes: FAIL_VIRTUAL_RESERVE <size>"
     "Failed Virtual Allocate Bytes: FAIL_VIRTUAL_COMMIT <size>"

     -h 32비트 SQL Server 2005에서 AWE가 사용된 경우 Hot Add 메모리 메타데이터에 대해 가상 주소 공간을 예약합니다. 32비트 AWE가 사용된 Hot Add 메모리에 필요하지만 가상 주소 공간에서 약 500MB를 사용하고 메모리 튜닝도 더 어렵게 만듭니다. 64비트 SQL Server에는 필요하지는 않습니다. Hot Add 메모리는 Enterprise Edition 및 Datacenter Edition에서만 사용할 수 있습니다. 또한 하드웨어 공급업체의 특수한 하드웨어 지원이 필요합니다.
     -n

     SQL Server 이벤트를 기록하는 데 Windows 응용 프로그램 로그를 사용하지 않습니다.

    -n으로 SQL Server 인스턴스를 시작하는 경우 -e 시작 옵션을 함께 사용하는 것이 좋습니다.

     -s  s 매개 변수를 설정하지 않으면 기본 인스턴스가 시작을 시도합니다.
     -T trace#  지정된 추적 플래그(trace#) 적용 시 SQL Server 인스턴스를 시작해야 함을 나타냅니다. 추적 플래그는 비표준 동작으로 서버를 시작하는 데 사용합니다.
     -x CPU 시간과 캐시 적중률 통계를 유지할 수 없도록 합니다. 최고의 성능을 허용합니다.

 

  1.  

    Sqlservr.exe c –mT3609T4022

  2.  

    3609 : SQL시작시 tempdb 생성 skip

    4022 : SQL시작시 실행되는 sp무시

     

이 글은 스프링노트에서 작성되었습니다.