2011. 3. 11. 16:06

Server Broker Error Case

Output Queue

A service uses Service Broker to send a message to another service. Service

Broker does this by putting the message into an output queue and

then sending it, possibly at a later time, to the queue for the other service.

A number of messages may build up in the output queue, waiting to be

sent, but they will eventually be sent and sent in the order in which they

were put into the queue.

The advantage of this extra layer of queuing is that the service sending

the message never waits for anything. But the extra layer also introduces

extra overhead. Service Broker will skip the output queue when both services

are on the same instance of SQL Server. In this case, it will put the

message directly into the queue from which the receiving service gets its

messages. Figure 15-3 shows how Service Broker efficiently sends a message

from one service to another



Error Case

1. Broker이 되게 DB가 셋팅 되어 있지 않을 때
  • is_broker_enabled, is_trustworthy_on 이 setting 되어 있지 않음.
  • 메세지를 전달 하면, Broker 비활성화 되었다고 하고, 받는 쪽 큐에는 대화가 전달되지 않는다.
  •  큐의 데이터 전달은 sys.transmission_queue 에 insert 된 후 타켓 큐에 전달 된다.


  • 해결
  • ALTER DATABASE DBA SET TRUSTWORTHY , ENABLE_BROKER ON

    /* 전송큐에대한메세지행포함*/

    select conversation_handle, to_service_name, from_service_name,enqueue_time,

        message_sequence_number,message_type_name,

        is_conversation_error, is_end_of_dialog, message_body ,transmission_status

     from sys.transmission_queue

    2.Broker 셋팅 되어질 DB가 master의 owner와 다를 경우

    An exception occurred while enqueueing a message in the target queue.

    Error: 33009, State: 2.

    The database owner SID recorded in the master database differs from the database owner SID recorded in database 'DB명'.

    You should correct this situation by resetting the owner of database 'DB명' using the ALTER AUTHORIZATION statement.


    해결
    sp_changedbowner 변경

    3. 상대 큐가 서로 비활 성화 되었을 경우
    로직 적으로 문제가 되서 대화의 시도가 기본값 5 이상 실패하면 큐는 잠기게 된다.

    One or more messages could not be delivered to the local service targeted by this dialog.


    해결
    ALTER QUEUE 큐명 with status = ON;

'Error Case' 카테고리의 다른 글

‘A time-out occurred while waiting for buffer latch’  (0) 2017.07.12
에러::SSIS 연결끊기는 현상  (1) 2010.06.03
에러::Agent  (1) 2010.06.03
에러::64bit 버퍼 풀 페이징  (0) 2010.06.03
2011. 1. 30. 17:10

Admin::Tempdb 의 작업, 모니터링

1.tempdb의 사용

- 지역/전역 임시 테이블과 인덱스, 임시 저장프로시저, 테이블 변수, 커서
- 해시 조인, 집계, 커서, order by , group by , union 쿼리 등과 같이 다양한 작업을 수행하면서 발생되는 중간 결과를 저장하기 위한 임시 테이블
- after트리거, instead of 트리거를 이용할 때 사용되는 개체들 저장
- 대형 xml 개체 저장
- sql server 버전 저장소
- DBCC checkdb 명령을 사용하는 동안에 중간 결과를 정렬 작업을 저장
- 서비스 브로커의 임시 개체를 저장

2. tempdb의 공간 사용

- 내부 개체
- 버전 저장소
- 사용자 개체

3. 최적화 방법

- tempdb의 사용량이 증가할 경우 다른 데이터베이스들의 성능 저하
- tempdb의 사용의 최소화 ( 1번 내용에 해당되는 것들)
- tempdb의 공간을 미리 할당함으로써 자동 증가 옵션 사용을 피함
- 필요하지 않은 경우는 tempdb를 축소하지 말자,  현재 작게 사용하고 있다고 항상 작은 사이즈를 사용하고 있는 것은 아니다. batch 작업이 시작될때는 지금 사용 사이즈 보다 훨씬 많이 사용할 수도 있다. 
- tempdb 데이터 베이스를 물리적 파일로 분리하자, (전형적으로 cpu 코어수 만큼 분리)
- 고속 I/O 하위 시스템에 tempdb를 생성하자  ( RAID 5로는 설정해서는 안된다.: 속도가 느리다.  적어도 RAID 1 또는 RAID10 으로 설정된 I/O 하위 시스템에 생성하는 것을 권장한다.)
- tempdb는 별도의 디스크 드라이브를 가지고 있는 별도의 LUN (논리 단위 번호)에 생성하는 것이 좋다. 
- SQL 2008의 TDE(투명한 데이터 암호화) 사용시 고려해야 한다. tempdb역시 암호화 되기 때문에 디스크 사이를 이동할 때마다 암호화 하고 복호화 하는 작업이 일어난다. 
- 통계 자동 작성, 자동 업데이트 옵션은 활성화 된 상태로 두자
- SQL 2008에서는 CEECKSUM 옵션을 확인하자, SQL 2005에서 업그레이드 되었을 경우에는 비활성화 되어 있다. 꼭 활성화 시키자  - tempdb의 무결성을 보장 할 수 있다. 

4. 모니터링

--1. tempdb SizeSELECT name , db.log_reuse_wait_desc , ls.cntr_value  AS size_kb , lu.cntr_value AS used_kb , CAST(lu.cntr_value AS FLOAT) / CAST(ls.cntr_value AS FLOAT)    AS used_percent , CASE WHEN CAST(lu.cntr_value AS FLOAT) / CAST(ls.cntr_value AS FLOAT) > .5 THEN    CASE     /* tempdb special monitoring */     WHEN db.name = 'tempdb'       AND log_reuse_wait_desc NOT IN ('CHECKPOINT', 'NOTHING') THEN 'WARNING'      /* all other databases, monitor foor the 50% fill case */     WHEN db.name <> 'tempdb' THEN 'WARNING'     ELSE 'OK'     END   ELSE 'OK' END   AS log_status FROM sys.databases db JOIN sys.dm_os_performance_counters lu  ON db.name = lu.instance_name JOIN sys.dm_os_performance_counters ls  ON db.name = ls.instance_name WHERE lu.counter_name LIKE  'Log File(s) Used Size (KB)%' AND ls.counter_name LIKE 'Log File(s) Size (KB)%' -- 2. temdb 사용 session,taskSELECT top 5 * FROM sys.dm_db_session_space_usage  ORDER BY (user_objects_alloc_page_count + internal_objects_alloc_page_count) DESCSELECT top 5 * FROM sys.dm_db_task_space_usageORDER BY (user_objects_alloc_page_count + internal_objects_alloc_page_count) DESCSELECT t1.session_id, t1.request_id, t1.task_alloc,  t1.task_dealloc, t2.sql_handle, t2.statement_start_offset,   t2.statement_end_offset, t2.plan_handleFROM (Select session_id, request_id,    SUM(internal_objects_alloc_page_count) AS task_alloc,    SUM (internal_objects_dealloc_page_count) AS task_dealloc   FROM sys.dm_db_task_space_usage   GROUP BY session_id, request_id) AS t1,   sys.dm_exec_requests AS t2WHERE t1.session_id = t2.session_id  AND (t1.request_id = t2.request_id)ORDER BY t1.task_alloc DESC
--3. 종합
CREATE TABLE tempdb_space_usage ( -- This represents the time when the particular row was -- inserted dt datetime DEFAULT CURRENT_TIMESTAMP, -- session id of the sessions that were active at the time session_id int DEFAULT null, -- this represents the source DMV of information. It can be -- track instance, session or task based allocation information. scope char(7), -- instance level unallocated extent pages in tempdb Instance_unallocated_extent_pages bigint, -- tempdb pages allocated to verstion store version_store_pages bigint, -- tempdb pages allocated to user objects in the instance Instance_userobj_alloc_pages bigint, -- tempdb pages allocated to internal objects in the instance Instance_internalobj_alloc_pages bigint, -- tempdb pages allocated in mixed extents in the instance Instance_mixed_extent_alloc_pages bigint, -- tempdb pages allocated to user obejcts within this sesssion or task. Sess_task_userobj_alloc_pages bigint, -- tempdb user object pages deallocated within this sesssion -- or task. Sess_task_userobj_deallocated_pages bigint, -- tempdb pages allocated to internal objects within this sesssion -- or task Sess_task_internalobj_alloc_pages bigint, -- tempdb internal object pages deallocated within this sesssion or -- task Sess_task_internalobj_deallocated_pages bigint, -- query text for the active query for the task query_text nvarchar(max) )go-- Create a clustered index on time column when the data was collectedCREATE CLUSTERED INDEX cidx ON tempdb_space_usage (dt)goCREATE PROC sp_sampleTempDbSpaceUsage AS Instance level tempdb File space usage for all files within -- tempdb INSERT tempdb_space_usage ( scope, Instance_unallocated_extent_pages, version_store_pages, Instance_userobj_alloc_pages, Instance_internalobj_alloc_pages, Instance_mixed_extent_alloc_pages) SELECT 'instance', SUM(unallocated_extent_page_count), SUM(version_store_reserved_page_count), SUM(user_object_reserved_page_count), SUM(internal_object_reserved_page_count), SUM(mixed_extent_page_count) FROM sys.dm_db_file_space_usage -- 2. tempdb space usage per session -- INSERT tempdb_space_usage ( scope, session_id, Sess_task_userobj_alloc_pages, Sess_task_userobj_deallocated_pages, Sess_task_internalobj_alloc_pages, Sess_task_internalobj_deallocated_pages) SELECT 'session', session_id, user_objects_alloc_page_count, user_objects_dealloc_page_count, internal_objects_alloc_page_count, internal_objects_dealloc_page_count FROM sys.dm_db_session_space_usage WHERE session_id > 50 -- 3. tempdb space usage per active task -- INSERT tempdb_space_usage ( scope, session_id, Sess_task_userobj_alloc_pages, Sess_task_userobj_deallocated_pages, Sess_task_internalobj_alloc_pages, Sess_task_internalobj_deallocated_pages, query_text) SELECT 'task', R1.session_id, R1.user_objects_alloc_page_count, R1.user_objects_dealloc_page_count, R1.internal_objects_alloc_page_count, R1.internal_objects_dealloc_page_count, R3.text FROM sys.dm_db_task_space_usage AS R1 LEFT OUTER JOIN sys.dm_exec_requests AS R2 ON R1.session_id = R2.session_id OUTER APPLY sys.dm_exec_sql_text(R2.sql_handle) AS R3 WHERE R1.session_id > 50go
--5. 결과 쿼리 -- This query reports the maximum allocated space in tempdb over all the data points collectedSELECT CONVERT (float, (MAX(version_store_pages + Instance_userobj_alloc_pages + Instance_internalobj_alloc_pages + Instance_mixed_extent_alloc_pages)))/ 128.0 AS max_tempdb_allocation_MBFROM tempdb_space_usage WHERE scope = ‘instance’
--This query reports the average allocated space in tempdb over all the data points collectedSELECT CONVERT (float, (AVG(version_store_pages + Instance_userobj_alloc_pages + Instance_internalobj_alloc_pages + Instance_mixed_extent_alloc_pages)))/ 128.0 AS avg_tempdb_allocation_MBFROM tempdb_space_usage WHERE scope = ‘instance’
-- 버전 정보 저장 할당양SELECT MAX(version_store_pages) AS max_version_store_pages_allocated, MAX(version_store_pages/128.0) AS max_version_store_allocated_space_MBFROM tempdb_space_usage WHERE scope = ‘instance’
SELECT AVG(version_store_pages) AS max_version_store_pages_allocated, AVG(version_store_pages)/ 128.0 AS max_version_store_allocated_space_MBFROM tempdb_space_usage WHERE scope = ‘instance’
-- top 5 내부 개첵 사용하는 requestSELECT top 5 MAX ((Sess_task_internalobj_alloc_pages) - (Sess_task_internalobj_deallocated_pages)) AS Max_Sess_task_allocated_pages_delta, query_textFROM tempdb_space_usage WHERE scope = 'task' and session_id > 50GROUP BY query_textORDER BY Max_Sess_task_allocated_pages_delta DESCSELECT top 5 AVG ((Sess_task_internalobj_alloc_pages) - (Sess_task_internalobj_deallocated_pages)) AS Avg_Sess_task_allocated_pages_delta, query_textFROM tempdb_space_usage WHERE scope = 'task' and session_id > 50GROUP BY query_textORDER BY Avg_Sess_task_allocated_pages_delta DESC

'Monitoring' 카테고리의 다른 글

모니터링::Index 생성 & Rebuild 진행 상황  (0) 2011.12.06
T-SQL:: Default Trace로 DB 증가량 확인  (1) 2011.04.15
T_SQL::SP_WHO2 + DBCC  (0) 2010.06.03
CPU에 할당된 Task 보기  (1) 2010.03.14
2011. 1. 16. 21:44

Tuning::Top 10 SQL Server performance Tuning


SQL Server Magazine  2011.01 Cover Store
- Andrew J.Kelly

1. TIP 1: Stop Waiting Around

먼저 Waits and Queues 대해서 알아야 한다. 많이 보이는 Waits Type에 대해 알고 있어야, 튜닝을 할 수 있다.

2. TIP 2:Locate I/O Bottlenecks
 

I/O bottlenecks 에는 Performance의 중요한 key다. page_I/O_latch waits 혹은 log_write 대기가 발생하는지 살펴봐야 한다.
sys.dm_io_virtual_file_stats() 를 통해서 확인이 가능하다.
성능 counter Avg.Disk sec/Read , Avg sec/Write 카운터를 살펴본다.
OLTP 환경에서는 log file 대기는 몇 ms 초여야 한다. 적어도 10ms 이하여야 한다. 허나, 이보다 높을 경우에도 서비스에는 문제되지 않을 수 있다. 항상 자기 서버의 base line을 알아야 한다.

3. Tip 3: Root out Problem Queries

놀랍게도 서비스에 문제되는 쿼리는 8~ 10개 정도이다. 이 쿼리들이 해당 리소스를 80 ~ 90% 사용한다.
그러므로 문제되는 쿼리를 찾아서 튜닝을 해야 한다.
sys.dm_execc_query_stats, sys.dm_exec_cached_plans, sys.dm_exec_sql_text()를 이용
-> 각자에 맞는 쿼리를 만들어야 한다. 저 같은 경우도 주기적으로 쿼리하여 적재하고 모니터링 한다.

SELECT
COALESCE(DB_NAME(t.[dbid]),'Unknown') AS [DB Name],
ecp.objtype AS [Object Type],
t.[text] AS [Adhoc Batch or Object Call],
            SUBSTRING(t.[text], (qs.[statement_start_offset]/2) + 1,
            ((CASE qs.[statement_end_offset]
                        WHEN -1 THEN DATALENGTH(t.[text]) ELSE qs.[statement_end_offset] END
                                   - qs.[statement_start_offset])/2) + 1) AS [Executed Statement]
            , qs.[execution_count] AS [Counts]
            , qs.[total_worker_time] AS [Total Worker Time], (qs.[total_worker_time] /
qs.[execution_count]) AS [Avg Worker Time]
            , qs.[total_physical_reads] AS [Total Physical Reads],
(qs.[total_physical_reads] / qs.[execution_count]) AS [Avg Physical Reads]
            , qs.[total_logical_writes] AS [Total Logical Writes],
(qs.[total_logical_writes] / qs.[execution_count]) AS [Avg Logical Writes]
            , qs.[total_logical_reads] AS [Total Logical Reads],
(qs.[total_logical_reads] / qs.[execution_count]) AS [Avg Logical Reads]
            , qs.[total_clr_time] AS [Total CLR Time], (qs.[total_clr_time] /
qs.[execution_count]) AS [Avg CLR Time]
            , qs.[total_elapsed_time] AS [Total Elapsed Time], (qs.[total_elapsed_time]
/ qs.[execution_count]) AS [Avg Elapsed Time]
            , qs.[last_execution_time] AS [Last Exec Time], qs.[creation_time] AS [Creation Time]
FROM sys.dm_exec_query_stats AS qs
    JOIN sys.dm_exec_cached_plans ecp ON qs.plan_handle = ecp.plan_handle
            CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS t
--    ORDER BY [Total Worker Time] DESC
--    ORDER BY [Total Physical Reads] DESC
--    ORDER BY [Total Logical Writes] DESC
--    ORDER BY [Total Logical Reads] DESC
--    ORDER BY [Total CLR Time] DESC
--    ORDER BY [Total Elapsed Time] DESC
         ORDER BY [Counts] DESC



 4.Tip 4: Plan to Reuse

Plan을 재 사용하는지 확인 한다.

5. Tip 5: Monitor Index Usage

sys.dm_db_index_operational_stats() DMF를 이용해서 인덱스가 잘 사용되고 있는지, 어떤 정보로 사용되는지 확인한다.

6. Tip 6: Separate Datea and Log File
7. Tip 7:Use Separate Staging Database

Temp성 데이터를 exporting or importing 하는데는 많은 비용이 들어간다. 서비스되고 있는 DB는 Full 모드이라면 모든 활동을 logging 한다.
몇몇 DB는 성능 이익을 위해서 simple 모드로 해야 한다. 작은 로깅은 성능을 향상 시키고 작은 load만 있으면 된다.
Staging  Database는 Simple 모드로 하는것이 좋고 백업이 필요 없을 수도 있다.

8. Tip 8: Pay Attention to Log File

항상 Log File의 여유 공간을 확인해야 하고 증가를 주의깊게 봐야 한다. 
VLFs가 증가하면 성능은 저하된다.
http://www.sqlskills.com/BLOGS/KIMBERLY/post/Transaction-Log-VLFs-too-many-or-too-few.aspx

9. Tip 9: Minimize tempdb contention

application이 tempdb를 무겁게 사용하면 내부적으로 tempdb를 할당하기 위해 contention이 발생한다.
tempdb contention은 최소화 해야 한다.
Workign with tempdb in SQL Server 2005 : http://technet.microsoft.com/en-us/library/cc966545.aspx

processor core 하나에 tempdb file 하나를 생성하기를 권장한다. 모든 같은 사이즈여야 한다.그렇지 않으면 이익이 없다.
임시성 테이블을 항상 drop 해줘야 한다.

10. Tip 10 : Change the Max Memory Limit

 

     

    'Peformance Tuning' 카테고리의 다른 글

    Hash Join 제약.  (0) 2011.10.10
    Join의 종류  (1) 2011.10.10
    SQL Server Best Practices Article  (0) 2011.01.16
    Storage Top 10 Best Practices  (0) 2011.01.16
    2011. 1. 16. 21:34

    SQL Server Best Practices Article

    'Peformance Tuning' 카테고리의 다른 글

    Join의 종류  (1) 2011.10.10
    Tuning::Top 10 SQL Server performance Tuning  (0) 2011.01.16
    Storage Top 10 Best Practices  (0) 2011.01.16
    RML ReadTrace 분석에 필요한 이벤트  (0) 2010.08.24
    2011. 1. 16. 21:28

    Storage Top 10 Best Practices

    2011. 1. 16. 00:40

    복제::숨겨진 저장프로시저 확인


    • 복제 관련 시스템 저장프로시저 내용을 확인해 보고 싶을 경우가 종종 있다.
    • 성능을 향상 시키고자 할 때나, 문제를 해결 하고자 할 때
    • 그런데 시스템 저장 프로시저 내용을 확인하기는 쉽지 않다.
    • 그런데 방법은 있다.
    1. DAC 기능을 활성화 한다.  혹은 sqlcmd 명영 유틸을 사용시에는 -A 옵션을 사용한다.
    exec sp_configure 'remote admin connections', 1
    go
    reconfigure
    go
    

     

     2. 저장 프로시저 내역 확인

    select object_definition (object_id('sys.sp_MSrepl_helparticlecolumns') )
    

    3. 서비스에서 작업을 진행 했다면, DAC 연결을 반드시 종료한다.

    2011. 1. 11. 07:22

    syspolicy_purge_history JOB 실패

      
    SQL Server 2008 이 후

    1. 클러스터 장비 일 경우
    -  가상 서버 이름으로 되어야 하는데 그렇지 못한 경우 서버를 찾을 수 없다는 error
    http://support.microsoft.com/kb/955726/ko

    2. PowerSheell 오류

    단계 3 실행을 시작할 수 없습니다(원인: PowerShell 하위 시스템이 로드하지 못했습니다[자세한 내용은 SQLAGENT.OUT 파일 참조]. 작업이 일시 중지되었습니다.).  단계가 실패했습니다.

     경로 확인

    SELECT * FROM msdb.dbo.syssubsystems WHERE start_entry_point ='PowerShellStart'

    agent_exe 결과 확인

    C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\SQLPS.exe

    해당 경로에 Tools\Binn 존재 하지 않습니다.

     경로 변경

    Use msdb

    go

     

    exec sp_configure 'allow updates', 1 RECONFIGURE WITH OVERRIDE

     

    UPDATE msdb.dbo.syssubsystems

    SET agent_exe='D:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\SQLPS.exe'올바르게 변경

    WHERE start_entry_point ='PowerShellStart'

    Agent Restart

    -       agent 다시 시작 하지 않으면 저 경로 인식 하지 못합니다.

    syspolicy_purge_history job 시작

     

     

    참고)

    해당 job은 한번 실행하고 나서 실패하면 다시 시작 할 수 없습니다.

    job을 다시 삭제하고 만들어 주시던가, 아님 agent를 재 시작 해주셔야 합니다.

     job을 다시 만드는 법은 아래 구문 실행 해 주세요


    DECLARE @jobId uniqueidentifier-- Obtain the current job identifier that is associated with the PurgeHistorySELECT @jobId = CAST(current_value AS uniqueidentifier)FROM msdb.dbo.syspolicy_configuration_internalWHERE name = N'PurgeHistoryJobGuid'-- Delete the job identifier association in the syspolicy configurationDELETE FROM msdb.dbo.syspolicy_configuration_internalWHERE name = N'PurgeHistoryJobGuid'-- Delete the offending jobEXEC msdb.dbo.sp_delete_job @job_id = @jobId-- Re-create the job and its association in the syspolicy configuration tableEXEC msdb.dbo.sp_syspolicy_create_purge_job
     


    'SQL Agent' 카테고리의 다른 글

    AGent::구성, 보안,Proxy  (0) 2010.06.04
    2011. 1. 10. 13:44

    Admin::Superdome VS DL580 G7


    Superdome VS DL580 G7 간단 비교 자료입니다.

     

    하드웨어 사양비교

    Model

    HP Proliant DL580 G7 Serise

    HP SUPERDOME SD32B

    Comment

    CPU

    Intel Xeon 7560  4CPU * 8Core

    Itanium2 1.60GHz 32CPU * 2Core

     

    Memory

    256GB

    512GB

     

    CPU 출시년도

    2010

    2005

     

    SQL Price

    1 2?

    4 5 ?

    정확하지 않음

    H/W Price

    4?

    5?

    정확하지 않음

    TPC-C 테스트 결과로 보는 성능비교 (참고사이트 http://www.tpc.org)

    Tpmc(transactions per minute) 순위에서 있듯이 DL580 Superdome보다 등급 위에 있는 것은 사실인 합니다.

                 Price/tpmC( 가격대비성능)DL580 G7 10배정도 좋네요

     

    'ETC' 카테고리의 다른 글

    Windbg 명령어 & 설치  (0) 2014.11.06
    Window 서비스 등록/삭제 방법  (0) 2011.10.20
    믹시 가입  (0) 2010.10.13
    네할렘 아키텍쳐  (0) 2010.06.10
    2010. 12. 28. 11:41

    Admin::Configuring Windows 2003 ( x64 ) for SQL Server


    http://sqlblogcasts.com/blogs/grumpyolddba/archive/2008/01/06/configuring-windows-2003-x64-for-sql-server.aspx


    So let’s consider memory first; x64 with 32gb ram, we can allocate 2 to 4 gb to the o/s and give the rest to SQL Server, or this is what we believe? Well not really.

     Let’s say this is a 4 way dual core box, windows will allocate 576 work threads, each of which requires 2mb of memory. In the illustration I viewed the calculations go thus:-
    • Let's leave 2GB for the OS and other applications: 2GB
    • And let's allocate 2GB for the MPA / Thread Stacks / Linked Servers etc: 2GB
    • And finally, let's reserve 3GB for all the other applications on the server (AV, backup etc): 3GB
    • So now our max server memory setting is: 32-2-2-3 = 25GB
    • Remember - this is a baseline calculation

    The average Enterprise SQL Server will likely have fibre channel HBAs, be SAN attached, probably have teamed / load balanced HBAs and NICs, will have a suite of hardware monitoring programs, will have an Antivirus, will be running a monitoring program such as Tivoli or MOM and will probably have other agents and services running as part of your standard build. You may well have IIS, reporting services, SSIS, old dts, full text. Do you really believe these can all run within 2gb – including the operating system?

    2010. 11. 23. 13:27

    Admin:: LOG Rebuild

    상황 1)
    - Data File은 이상이 없고, SQL 서버 서비스가 정상 종료 되었을 경우 처리 할 수 있다.
    - LOG 파일만 트랜잭션이 맞지 않거나 그럴 경우 문제 발생시
    - TEST DB의 DB 스토리지 copy 했는데 copy 시점에 트랜잭션이 완료 되지 않은 상태에서 시작되어 copy 되었을 경우
    - DB가 정상적으로 Detatch 될 때 사용 가능 하다.

    CREATE DATABASE TEST ON (NAME = 'TEST_DATA', FILENAME = 'F:\MSSQL\DATA\TEST _DATA.MDF')
    --,(NAME = 'SEARCHV_LOG', FILENAME = 'F:\MSSQL\LOG\SEARCHV_LOG.LDF')
    FOR ATTACH_FORCE_REBUILD_LOG
    -- 이건 기존 동일한 경로에 로그 파일을 생성합니다. 
    그러니까 기존 로그 파일을 이름 변경 해야 합니다. 
    상황 2)
    - 트랜잭션 로그 파일이 손상되었을 때
    - update, delete 작업 도중 rollback이  시도 했으나 오랜 시간이 걸려서 기다릴 수가 없을때, (서비스 open이 코 앞일때)
    - 단, 이 작업은 정합성이 유지 되지 않을 수도 있다.
     
    --1. DB를 offline 시킵니다. , 
    롤백 중이라면 offline 할때도 오래 걸립니다. 롤백이 완료 될때 까지 기다기리 때문입니다.  
    클러스터 장비로 되어 있다면 강제로 그룹 이동 시킵니다. 
    
    -- 2. log 파일 이름을 변경합니다.
    
    -- 3. DB online 합니다. 
    
    -- 4.  주의 대상으로 DB가 올라오게 됩니다. 
    ALTER DATABASE TEST SET EMERGENCY
    go
    
    -- 5. 디비가 물리적으로 문제가 있는지 확인 합니다. 해당 작업은 대용량 DB는 오래 걸립니다. 무시하시고 가셔도 됩니다. 
    -- 문제가 없으면 결과에 문제 없음으로 나옵니다. 어느 정도 문제가 있는것도 6번 단계에서 복원 될 수도 있습니다
     DBCC CHECKDB (문제DB)
    
    -- 6.  
    ALTER DATABASE TEST SET SINGLE_USER  with ROLLBACK IMMEDIATE
    go
    DBCC CHECKDB (문제DB명, REPAIR_ALLOW_DATA_LOSS)
    
    -- 7.
    ALTER DATABASE TEST SET MULTI_USER with  ROLLBACK IMMEDIATE
    
    -- 8 . LOG Rebuild 작업
    ALTER DATABASE TEST REBUILD LOG ON 
    (NAME=TEST_LOG,FILENAME='F:\MSSQL\LOG\TEST_LOG.LDF'
    , SIZE = 30720MB, file_growth = 500MB)
    
    -- 10.ONLINE 상태가 되는지 확인
    
    참고) DBCC REBUILD_LOG 상용해서도 가능합니다. 허나, 이건 단일 로그일때만 가능합니다.
    DBCC REBUILD_LOG ('db_name', 'log_file_name')
    


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

    Admin::Cache Flush 가 발생하는 경우  (0) 2011.03.30
    Admin::Configuring Windows 2003 ( x64 ) for SQL Server  (0) 2010.12.28
    waitresource 값 확인  (0) 2010.11.01
    MCITP 취득 방법  (0) 2010.10.06
    2010. 11. 1. 16:00

    waitresource 값 확인


    sysprocess, lock 정보를 봤을때 waitresoruce 값을 확인 하고 싶을 때 사용 한다.  Key: ..  형식으로 나오면 object를 찾기 쉽지만 그렇지 않은 경우 page 값으로 확인 해야 한다.

    waitresource = 11:24:3169121  -> 첫 번째 값은 DB 아이디.
    
    DBCC traceon (3604) WITH no_infomsgs         
    DBCC PAGE (11,24,3169121) with  no_infomsgs, tableresults
    
    ParentObject Object Field VALUE
    PAGE HEADER: Page @0x000000095145E000 m_objId (AllocUnitId.idObj) 16431
    PAGE HEADER: Page @0x000000095145E000 m_indexId (AllocUnitId.idInd) 256
    PAGE HEADER: Page @0x000000095145E000 Metadata: AllocUnitId 7.20576E+16
    PAGE HEADER: Page @0x000000095145E000 Metadata: PartitionId 7.20576E+16
    PAGE HEADER: Page @0x000000095145E000 Metadata: IndexId 2
    PAGE HEADER: Page @0x000000095145E000 Metadata: ObjectId 132468542



    object_id 값과 index 값을 알았으니 어느 테이블에 어느 객체인지 확인 하면 된다.

    [waiteresource 정보]
    RID. 잠금이 보유 또는 요청된 테이블 내의 단일 행을 식별합니다. RID는 RID: db_id:file_id:page_no:row_no로 표시됩니다. 예를 들면 RID: 6:1:20789:0과 같습니다.

    OBJECT. 잠금이 보유 또는 요청된 테이블을 식별합니다. OBJECT는 OBJECT: db_id:object_id로 표시됩니다. 예를 들면 TAB: 6:2009058193과 같습니다.

    KEY. 잠금이 보유 또는 요청된 인덱스 내의 키 범위를 식별합니다. KEY는 KEY: db_id:hobt_id (index key hash value)로 표시됩니다. 예를 들면 KEY: 6:72057594057457664 (350007a4d329)와 같습니다.

    PAG. 잠금이 보유 또는 요청된 페이지 리소스를 식별합니다. PAG는 PAG: db_id:file_id:page_no로 표시됩니다. 예를 들면 PAG: 6:1:20789와 같습니다.

    EXT. 익스텐트 구조를 식별합니다. EXT는 EXT: db_id:file_id:extent_no로 표시됩니다. 예를 들면 EXT: 6:1:9와 같습니다.

    DB. 데이터베이스 잠금을 식별합니다. DB는 다음 방법 중 하나로 표시됩니다.

    DB: db_id


    DB: db_id[BULK-OP-DB]. 이 방법은 백업 데이터베이스에서 수행된 데이터베이스 잠금을 식별합니다.


    DB: db_id[BULK-OP-LOG]. 이 방법은 특정 데이터베이스에 대해 백업 로그에서 수행된 잠금을 식별합니다.


    APP. 응용 프로그램 리소스에서 수행된 잠금을 식별합니다. APP는 APP: lock_resource로 표시됩니다. 예를 들면 APP: Formf370f478과 같습니다.


     

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

    Admin::Configuring Windows 2003 ( x64 ) for SQL Server  (0) 2010.12.28
    Admin:: LOG Rebuild  (0) 2010.11.23
    MCITP 취득 방법  (0) 2010.10.06
    RML Utilities for SQL Server  (0) 2010.08.23
    2010. 10. 13. 00:04

    믹시 가입

    ar8k6rNEr12FjiHOzyFXWovEUugsAIUaPEqbaiKf7TY,
    2010. 10. 6. 00:11

    MCITP 취득 방법

     

    MCITP 자격증 취득 방법

    [순서]

    431 (MCTS, 기본 조건 ) -> 443 : Designing a Database Server Infrastructure by Using Microsoft SQL Server 2005

                                          444  : Optimizing and Maintaining a Database Administration Solution by Using Microsoft SQL Server 2005  (MCITP: Database Administrator)

                                     -> 441 : Designing Database Solutions by Using Microsoft SQL Server 2005

                                         442 :Designing and Optimizing Data Access by Using Microsoft SQL Server 2005 (MCITP: Database Developer)

    http://blog.naver.com/da10316?Redirect=Log&logNo=70044945798 : 등록 방법

    http://www.microsoft.com/learning/mcp/mcts/default.mspx : E러닝 교육 과정 

    1. MCTS: SQL Server 2005

    업데이트 날짜: 2006년 5월 18일

    Technology Specialist 인증을 통해 전문가는 특정 기술을 대상으로 하고 특수 기술에 대한 깊이 있는 지식 및 전문성을 보여 줌으로써 자신의 능력을 입증할 수 있습니다.

    MCTS: SQL Server 2005(Microsoft Certified Technology Specialists in Microsoft SQL Server 2005)는 특정 명령 및 사양을 사용하여 데이터베이스를 구현 및 유지 관리합니다. 이들은 제품에 대한 해박한 지식이 있으며, 도구 및 Transact-SQL 언어 사용 방법과 사용자 인터페이스 탐색 방법을 알고 있습니다. Technology Specialist는 일반적으로 데이터베이스 관리자, 데이터베이스 개발자 또는 비즈니스 인텔리전스 개발자와 같은 직종을 선호합니다. 또한 SQL Server 작업을 매일 하지는 않지만 기술 경험의 폭을 넓히려는 사람은 개발자 및 시스템 관리자도 될 수 있습니다.

    데이터베이스 관리자, 데이터베이스 개발자 및 비즈니스 인텔리전스 개발자는 Microsoft SQL Server 2005 기술 능력 평가를 통해 시험 준비를 위한 교육 과정과 학습 리소스를 찾을 수 있습니다.

     

    MCTS: SQL Server 2005 취득 방법

    MCTS 지원자는 SQL Server 2005의 구현 및 유지 관리 능력을 검증하는 한 가지 시험을 통과해야 합니다. 관련 교육 리소스는 다음 표를 참조하십시오. 시험 날짜 및 주요 분야는 시험 준비 가이드를 참조하십시오.

    MCTS: SQL Server 2005 필수 시험(택 1) 공인 강사에 의한 강의(ILT) Microsoft E-Learning 참고 도서

    Exam 70–431 (영문): TS: Microsoft SQL Server 2005 - Implementation and Maintenance

    2779 (영문): Implementing a Microsoft SQL Server 2005 Database (3일 강의식 교육, 2006년 초부터 수강 가능)

    2780 (영문): Maintaining a Microsoft SQL Server 2005 Database (3일 강의식 교육, 2006년 초부터 수강 가능)

    2778 (영문): Writing Queries Using Microsoft SQL Server 2005 Transact–SQL(18시간, 2006년 중반부터 수강 가능)

    2936–2944: 무료* Microsoft E-Learning Series for Database Administrators, Database Developers, and Business Intelligence Developers (영문)

    MCTS Self–Paced Training Kit (Exam 70–431): Implementing and Maintaining Microsoft SQL Server 2005 (2006년 중반부터 구입 가능)

    Microsoft SQL Server 2005: Database Essentials Step by Step (영문)

    Microsoft SQL Server 2005: Applied Techniques Step by Step (영문)

    Programming Microsoft SQL Server 2005(2006년 중반부터 구입 가능)

    Microsoft SQL Server 2005 Administrator's Pocket Consultant (영문)

    Microsoft SQL Server 2005 Administrator's Companion (available mid–2006)

     

    2. MCITP: Database Developer

     

    MCITP(Microsoft Certified IT Professional): Database Developer는 데이터베이스 설계자 및 개발자를 위한 프리미어 인증입니다. 이 자격 증명은 Microsoft SQL Server 2005를 사용하여 안정적인 보안 엔터프라이즈 데이터베이스 솔루션을 설계할 수 있는 능력을 입증합니다.

    데이터베이스 개발자는 데이터베이스 저장소 개체 및 관계형 데이터베이스 모델(논리적 및 물리적)을 설계하고 구현합니다. 또한 사용자 정의 함수, 트리거, 저장 프로시저, Transact-SQL 또는 CLR을 사용하여 서버를 프로그래밍하며, SQL 쿼리를 사용하여 데이터를 검색 또는 수정하거나 쿼리를 조정 및 최적화합니다. 데이터베이스 개발자는 일반적으로 중규모 또는 대규모 조직에서 채용합니다.

     

    MCITP: Database Developer 취득 방법

    MCITP 지원자는 먼저 MCTS: SQL Server 2005 자격 증명(한 가지 시험) 요건을 갖추어야 합니다. 이 자격 증명을 취득한 후 두 가지 필수 시험을 통과하면 MCITP: Database Developer를 취득할 수 있습니다. 다음 표에서는 전체 시험 목록 및 관련 교육 리소스를 제공합니다. 시험 날짜 및 주요 분야는 시험 시행이 공지될 때 개별 시험 준비 가이드를 참조하십시오.

    MCITP: Database Developer 필수 시험(택 2) 공인 강사에 의한 강의(ILT) Microsoft E-Learning 참고 도서

    Exam 70–441 (영문): PRO: Designing Database Solutions by Using Microsoft SQL Server 2005

    2781 (영문): Designing Microsoft SQL Server 2005 Server-Side Solutions(3일 강의식 교육, 2006년 초부터 수강 가능)

    2782 (영문): Designing Microsoft SQL Server 2005 Databases (2일 강의식 교육, 2006년 초부터 수강 가능)

     

    Microsoft SQL Server 2005: Database Essentials Step by Step (영문)

    Microsoft SQL Server 2005: Applied Techniques Step by Step (영문)

    Inside Microsoft SQL Server 2005: The Storage Engine (영문)

    Inside Microsoft SQL Server 2005: T-SQL Programming (영문)

    Inside Microsoft SQL Server 2005: Query Tuning and Optimization(2007년 구입 가능)

    Programming Microsoft SQL Server 2005(2006년 중반부터 구입 가능)

    Exam 70–442 (영문): PRO: Designing and Optimizing Data Access by Using Microsoft SQL Server 2005

    2781 (영문): Designing Microsoft SQL Server 2005 Server-Side Solutions(3일 강의식 교육, 2006년 초부터 수강 가능)

    2783 (영문): Designing the Data Tier for Microsoft SQL Server 2005(1일 강의식 교육, 2006년 초부터 수강 가능)

    2784 (영문): Tuning and Optimizing Queries Using Microsoft SQL Server 2005 (3일 강의식 교육, 2006년 중반부터 수강 가능)

     

     

     

    Inside Microsoft SQL Server 2005: The Storage Engine (영문)

    Inside Microsoft SQL Server 2005: T-SQL Programming (영문)

    Inside Microsoft SQL Server 2005: Query Tuning and Optimization(2007년 구입 가능)

    Programming Microsoft SQL Server 2005(2006년 중반부터 구입 가능)

     

    3. MCITP: Database Administrator

    MCITP(Microsoft Certified IT Professional): Database Administrator는 데이터베이스 서버 관리자를 위한 프리미어 인증입니다. 이 인증은 1년 365일, 하루 24시간 동안 엔터프라이즈 비즈니스 솔루션을 유지할 수 있는 능력을 입증합니다.

    데이터베이스 관리자는 Microsoft SQL Server를 설치하거나 구성하고, 데이터베이스 또는 다차원 데이터, 사용자 계정, 데이터베이스 가용성, 복구 및 보고를 관리하거나 유지합니다. 또한 보안 또는 서버 자동화를 설계하거나 구현하고 SQL Server 동작을 모니터링하고 문제를 해결합니다. 데이터베이스 관리자는 일반적으로 중규모 또는 대규모 조직에서 채용합니다

    MCITP: Database Administrator 취득 방법

    MCITP 지원자는 먼저 MCTS: SQL Server 2005 인증(한 가지 시험) 요건을 갖추어야 합니다. 이 인증을 취득한 후 두 가지 필수 시험을 통과하면 MCITP: Database Administrator를 취득할 수 있습니다.

    MCDBA(Microsoft Certified Database Administrator)인 경우에는 두 가지 필수 시험 대신 한 가지 업그레이드 시험을 치르고 MCITP: Database Administrator 인증으로 업그레이드할 수 있습니다. 그러나 먼저 MCTS: SQL Server 2005 인증을 보유하고 있어야 합니다.

    다음 표는 전체 시험 및 관련 교육 리소스 목록입니다. 시험 날짜 및 주요 분야는 시험 시행이 공지될 때 개별 시험 준비 가이드를 참조하십시오.

    MCITP: Database Administrator 필수 시험(택 2) 공인 강사에 의한 강의(ILT) Microsoft E-Learning 참고 도서

    Exam 70–443 (영문): PRO: Designing a Database Server Infrastructure by Using Microsoft SQL Server 2005

    2786 (영문): Designing a Microsoft SQL Server 2005 Infrastructure(2일)

    2787 (영문): Designing Security for Microsoft SQL Server 2005(2일)

    2788 (영문): Designing High Availability Database Solutions Using Microsoft SQL Server 2005(3일)

    2786E (영문): Designing a Microsoft SQL Server 2005 Infrastructure(12시간; 2006 초부터 수강 가능)

    2787E (영문): Designing Security for Microsoft SQL Server 2005(12시간; 2006년 초부터 수강 가능)

    2788E: Designing High Availability Database Solutions Using Microsoft SQL Server 2005(18시간; 2006년 초부터 수강 가능)

    MCITP Self-Paced Training Kit (Exam 70-443): Designing a Microsoft SQL Server 2005 Database Server Infrastructure(2006년 중반부터 구입 가능)

    Inside Microsoft SQL Server 2005: The Storage Engine (영문)

    Inside Microsoft SQL Server 2005: T-SQL Querying (영문)

    Inside Microsoft SQL Server 2005: T-SQL Programming (영문)

    Inside Microsoft SQL Server 2005: Query Tuning and Optimization(2007년 구입 가능)

    Programming Microsoft SQL Server 2005(2006년 중반부터 구입 가능)

    Microsoft SQL Server 2005 Administrator's Pocket Consultant (영문)

    Microsoft SQL Server 2005 Administrator's Companion(2006년 중반부터 구입 가능)

    Exam 70–444 (영문): PRO: Optimizing and Maintaining a Database Administration Solution by Using Microsoft SQL Server 2005

    2787 (영문): Designing Security for Microsoft SQL Server 2005 (2일)

    2789 (영문): Administering and Automating Microsoft SQL Server 2005 Databases and Services 2005 (1일)

    2790 (영문): Troubleshooting and Optimizing Database Servers Using Microsoft SQL Server 2005 (2일)

    2787E (영문): Designing Security for Microsoft SQL Server2005(12시간; 2006년 초부터 수강 가능)

    2789E (영문): Administering and Automating Microsoft SQL Server 2005 Databases and Services(6시간, 2006년 초부터 수강 가능)

    2790E (영문): Troubleshooting and Optimizing Database Servers Using Microsoft SQL Server 2005(12시간, 2006년 중반부터 수강 가능)

    MCITP Self-Paced Training Kit (Exam 70-444): Optimizing and Maintaining a Database Administration Solution Using Microsoft SQL Server 2005(2006년 중반부터 구입 가능)

    Inside Microsoft SQL Server 2005: The Storage Engine (영문)

    Inside Microsoft SQL Server 2005: T-SQL Querying (영문)

    Inside Microsoft SQL Server 2005: T-SQL Programming (영문)

    Inside Microsoft SQL Server 2005: Query Tuning and Optimization(2007년부터 구입 가능)

    Programming Microsoft SQL Server 2005(2006년 중반부터 구입 가능)

    Microsoft SQL Server 2005 Administrator's Pocket Consultant (영문)

    Microsoft SQL Server 2005 Administrator's Companion(2006년 중반부터 구입 가능)

     

     

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

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

    Admin:: LOG Rebuild  (0) 2010.11.23
    waitresource 값 확인  (0) 2010.11.01
    RML Utilities for SQL Server  (0) 2010.08.23
    SQL 2008 -New DataType-Date  (0) 2010.06.04
    2010. 9. 6. 10:13

    DBCC ShrinkFile


    SET NOCOUNT ON
    DECLARE @shrinkUnitSize INT, @TotalSizeMB INT, @filename varchar(50), @start_time datetime, @idx int
    SET @shrinkUnitSize = 500
    SELECT @TotalSizeMB = size/128, @filename= name FROM master..sysaltfiles where dbid=db_id('dba') and fileid =1
    
    SELECT @TotalSizeMB AS CurrentSizeMB, GETDATE() AS StartTime
    
    SET @idx = 1
    WHILE (@TotalSizeMB > 300000)-- 현재사이즈가GB보다클때줄이는작업(file사이즈를GB아래로조정하는작업)
    BEGIN 
             SET @start_time = GETDATE()
             SET @TotalSizeMB = @TotalSizeMB - @shrinkUnitSize        
             DBCC SHRINKFILE (@filename, @TotalSizeMB) WITH NO_INFOMSGS 
    
    --         SELECT @idx as idx, @TotalSizeMB as TotalSizeMB, DATEDIFF(s, @start_time, getdate()) as duration
             
             PRINT 'idx = ' + CAST(@idx AS varchar(10)) + ', totalSizeMB = ' + CAST(@TotalSizeMB AS varchar(10)) + ', duration = ' + CAST(DATEDIFF(s, @start_time, getdate()) AS varchar(10))
    
                  if DATEDIFF(s, @start_time, getdate() ) < 10 -- 줄어드는시간이10초이하로떨어지면5GB단위로줄임
                        SET @shrinkUnitSize = 5000                          
                  
             SET @idx = @idx + 1
    END
    
    SELECT @TotalSizeMB AS ShrinkSizeMB, GETDATE() AS EndTime
    GO
    

    'T-SQL' 카테고리의 다른 글

    T-SQL:: TCP 포트 정보  (0) 2011.08.13
    T-SQL:: INDEX-중복인덱스 제거.  (1) 2011.08.13
    [T-SQL] JOb 수행 시간 완료 계산  (0) 2010.07.19
    Index::Defrag Script v4.0  (0) 2010.06.15
    2010. 8. 24. 10:44

    RML ReadTrace 분석에 필요한 이벤트


    ReadTrace 분석에 필요한 이벤트는 SQL2000 과  SQL2005가 다릅니다.
    SQL 2000에서는 Binary (RPC:*)  컬럼이 없어도 분석에 문제가 없었는데 SQL 2005 이상에서는 이 컬럼이 꼭 있어야 분석 레포트가 가능합니다.



    • SQL 2005 & 2008

     


    • SQL 2000용

    SQL:BatchStarting and RPC:Starting

    Required: StartTime, TextData

    Recommended: DBID

    SQL:BatchCompleted and RPC:Completed

    Required: StartTime, EndTime, TextData

    Recommended: Reads, Writes, CPU, Duration, DBID

    Audit:Logout

    Required: StartTime, EndTime

    Recommended: TextData, Reads, Writes, CPU, Duration

    Audit:Login and ExistingConnection

    Required: StartTime, EndTime

    Recommended: TextData

    SP:StmtStarting

    Required: StartTime, TextData, ObjectID, NestLevel

    Recommended: DBID

    SP:StmtCompleted

    Required: StartTime, EndTime, TextData, ObjectID, NestLevel

    Recommended: DBID, Reads, Writes, CPU, Duration, IntegerData