2009. 8. 13. 18:41

T-SQL::Total Disk Size 얻기 (OLE 사용)

디스크의 남은 용량은 xp_fixeddrives 를 이용해서 구할 수 있지만 디스크 전체 사이즈를 쉽게 얻기는 쉽지 않다.

여러 방법이 있었는데 그중 OLE 사용하는 방법이다.

 

이 방법을 사용하기 위해서는 기능 영역에 OLE 자동화 사용이 활성화 되어 있어야 한다.

서비스 되고 있는 DB 장비는 이 기능을 ON 해 놓지 않기에 평범하게 사용할 수는 없다.

 

(클릭해서 크게 보세요)

 

CREATE PROCEDURE sp_diskspace
AS
/*
   Displays the free space,free space percentage
   plus total drive size for a server
*/
SET NOCOUNT ON

DECLARE @hr int
DECLARE @fso int
DECLARE @drive char(1)
DECLARE @odrive int
DECLARE @TotalSize varchar(20)
DECLARE @MB bigint ; SET @MB = 1048576

CREATE TABLE #drives (drive char(1) PRIMARY KEY,
                      FreeSpace int NULL,
                      TotalSize int NULL)

INSERT #drives(drive,FreeSpace)
EXEC master.dbo.xp_fixeddrives

EXEC @hr=sp_OACreate 'Scripting.FileSystemObject',@fso OUT
IF @hr <> 0 EXEC sp_OAGetErrorInfo @fso

DECLARE dcur CURSOR LOCAL FAST_FORWARD
FOR SELECT drive from #drives
ORDER by drive

OPEN dcur

FETCH NEXT FROM dcur INTO @drive

WHILE @@FETCH_STATUS=0
BEGIN

        EXEC @hr = sp_OAMethod @fso,'GetDrive', @odrive OUT, @drive
        IF @hr <> 0 EXEC sp_OAGetErrorInfo @fso
       
        EXEC @hr = sp_OAGetProperty @odrive,'TotalSize', @TotalSize OUT
        IF @hr <> 0 EXEC sp_OAGetErrorInfo @odrive
                       
        UPDATE #drives
        SET TotalSize=@TotalSize/@MB
        WHERE drive=@drive
       
        FETCH NEXT FROM dcur INTO @drive

END

CLOSE dcur
DEALLOCATE dcur

EXEC @hr=sp_OADestroy @fso
IF @hr <> 0 EXEC sp_OAGetErrorInfo @fso

SELECT drive,
       FreeSpace as 'Free(MB)',
       TotalSize as 'Total(MB)',
       CAST((FreeSpace/(TotalSize*1.0))*100.0 as int) as 'Free(%)'
FROM #drives
ORDER BY drive

DROP TABLE #drives

RETURN
go

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

T-SQL::Attach  (1) 2009.12.01
T-SQL::테이블 ROWCOUNT, 사이즈  (0) 2009.11.27
T-SQL::Index Script  (1) 2009.11.19
T-SQL::List all indexes in database  (0) 2009.11.19
2009. 8. 4. 16:21

공유 데이터 원본 Overwrite

Reporting Sevice 개발시 공유데이터 연결을 사용하여 배포할 경우 이미 있는 공유데이터 원본이 계속 재 배포 됨으로써 자격증명이 초기화 되어 연결이 되지 않는 현상이 발생하였다.

 

원하는 것은 보고서만 배포되기를 바라는데..

왜 일까??

 

아주 간단했음.

프로젝트의 속성 페이지에서

배포 옵션에 OverwriteDataSources : False로 해야함 이미 원본이 서버에 있는 경우 원본을 덮어쓰지 않고 사용할 수 있었음.

 

 

'Reporting Service' 카테고리의 다른 글

배포 메일링 주소 변경  (0) 2014.09.02
시작시 늦어지는 경우 (Slow StartUP)  (1) 2012.10.09
2009. 7. 27. 10:57

SSIS::Foreach 이용한 장비별 동일 로직 반복 - ADO 열거자

DBA 작업을 하면서 장비별 동일 정보를 관리용으로 수집하고 싶은 경우가 종종 있게 된다.

연결 정보만 틀리고 동일한 로직을 호출하면 되는데 여러개의 데이터 흐름 작업을 만들고, 여러 연결 관리자를 만들게 되면 관리상의 이슈로 힘들어 지게 된다.

 

또한, 간혹 발생하게 될 장비의 IP 변경으로 인해 패키지를 다시 빌드해야 하는 단점도 발생하게 된다.

이런 점을 해결하기 위해 DB의 연결 정보를 파일로 처리하여 Foreach 루프 컨테이너의 ADO 연결자를 사용하여 장비별 동일 로직을 실행하는 예제를 만들어 본다.

 

- 한대성 님의 자료를 도움 받음 -

 

 

1. 관련 변수들을 선언한다.

object 변수와 파일에서 connection string 을 읽어올 변수는 필수이다. (obj_conn, file_conn)

 

 

 

2. conn_file01.txt 파일을 만들고  연결 스트링 정보를 입력한다.

연결정보에 관한 정보는 시스템에 맞게 입력

 

Data Source=ip 정보;User ID=;PWD=;Initial Catalog=db명;Provider=SQLOLEDB.1;Persist Security Info=True;Auto Translate=False;

 

 

 

3. 새 플랫 파일 연결관리자를 만들고 2번에서 입력한 파일을 읽을 수 있게 처리한다.

 

 

 

 

4. 플랫 파일 원본을 선택한 후 파일 연결관리자를 입력해서  connection string이 열로 출력되어 레코드 집합 대상을 만들 수 있게 처리해 준다.

 

 

5.  레코드 집한 대상에 VariableName 에 object 변수를 선택하여 파일에서 읽어온 정보가 해당 변수에 담아지도록 처리한다.

 

 

6. 파일 출력열이 맞는지 확인 한다.

 

 

 

7.  Foreach 루프 컨데이터를 이용해서 불러들인 연결 정보 만큼 동일 로직을 수행하게 작업 처리한다.

 

 

 

8.  ADO 연결자를 선택하고 원본 변수에 데이터 흐름 작업에서 connection string 정보를 담은 변수를 입력한다. 이 변수의 row 수 만큼 loop 작업이 실행되게 된다.

 

 

 

9.  ForEach 컨테이너에서 변수 매핑 을 클릭하고 출력되는 열을 변수에 담는다.

 

 

10.

담은 변수를 연결 관리자를 하나 만든다음에 실행된 DB의 커넥션 변수에 해당 변수를 매핑해 준다.

이로써 DB에 동적으로 연결 정보를 받아 작업이 실행될 수 있다.

 

 

 

 

11 SQL 실행작업을 하나 선택하고 DB를 연결관리자의 select @@servername을 실행하게 하고 출력된 결과를 스크립트 작업을 통해서 메세지 박스로 확인하는 작업이다.

 

해당 장비로 접속하여 실행되는 모습을 볼 수 있다.

 

 

'Business Inteligence (SSIS)' 카테고리의 다른 글

SQL2008에서 SQL2000 DTS열기  (0) 2010.06.07
For컨테이너-무한루프  (0) 2010.06.03
스크립트task사용  (0) 2010.06.03
Debugging and Logging in SSIS  (0) 2010.06.03
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. 20. 17:17

DeadLock 발생 원인 찾기


Deadlock 발생시 원인과 해결법.

 

1. Deadlock 이유를 알고 싶으면 trace 1204 를 켜 준다.

DBCC traceon(1204,-1)

DBCC Tracestatus(-1) -- 잘 실행되고 있는지 확인

 

2. Deadlock 발생되면 SQL의 에러로그에 로그가 남게 된다.

Deadlock encountered .... Printing deadlock information
Wait-for graph
Node:1 PAG: 9:1:18061 CleanCnt:2 Mode: SIU Flags: 0x2
Grant List 1::
Grant List 2::
Owner:0x27c007e0 Mode: S Flg:0x0 Ref:0 Life:00000001 SPID:84 ECID:0
SPID: 84 ECID: 0 Statement Type: UPDATE Line #: 11
Input Buf: RPC Event: dbo.Example_Stored_proc
Requested By: 0
ResType:LockOwner Stype:'OR' Mode: IX SPID:78 ECID:0 Ec:(0x44AA55F0) Value:0x3affcd00 Cost:(0/0)
Node:2 PAG: 9:1:18134 CleanCnt:2 Mode: SIU Flags: 0x2
Grant List 1::
Owner:0x28e6f060 Mode: S Flg:0x0 Ref:0 Life:00000001 SPID:78 ECID:0
SPID: 78 ECID: 0 Statement Type: UPDATE Line #: 11
Input Buf: RPC Event: dbo. Example_Stored_proc
Grant List 2::
Requested By:
ResType:LockOwner Stype:'OR' Mode: IX SPID:84 ECID:0 Ec:(0x239955F0) Value:0x3affc940 Cost:(0/0)
Victim Resource Owner:
ResType:LockOwner

Stype:'OR' Mode: IX SPID:84 ECID:0 Ec:(0x239955F0) Value:0x3affc940 Cost

 

3.  에러로그를 확인해 보면 'Example_stored_proc'  프로시저에서 update 시 exclusive lock  이 발생하고 있다는 것을 확인 할 수 있다.

 

4. sp_helptext 'Example_stored_proc'  를 실행하여 프로시저의 내용을 확인 한다.

 

5. 이와 관련있는 프로시저를 확인하고 deadlock 이 발생하는 page를 확인할 수 있다.

Node:1 PAG: 9:1:18061 CleanCnt:2 Mode: SIU Flags: 0x2

 

6. 해당 페이지를 조사해 본다. , DBCC Page 사용

MSDN : http://support.microsoft.com/kb/83065

 

DBCC page(9,1,18061,0)


PAGE: (1:18061)
---------------
BUFFER:
-------
BUF @0x01665900
---------------
bpage = 0x1DF58000 bhash = 0x00000000 bpageno = (1:18061)
bdbid = 9 breferences = 1 bstat = 0xb
bspin = 0 bnext = 0x00000000
PAGE HEADER:
------------
Page @0x1DF58000
----------------
m_pageId = (1:18061) m_headerVersion = 1 m_type = 1
m_typeFlagBits = 0x0 m_level = 0 m_flagBits = 0x8000
m_objId = 1013578649 m_indexId = 0 m_prevPage = (0:0)
m_nextPage = (0:0) pminlen = 52 m_slotCnt = 82
m_freeCnt = 3075 m_freeData = 5009 m_reservedCnt = 0
m_lsn = (2689:87968:2) m_xactReserved = 0 m_xdesId = (0:0)
m_ghostRecCnt = 0 m_tornBits = 0
.................

object_id를 알아 낼 수 있다.

 

7.  object 확인

 

Use DBNAME
Select object_name(OBJECT_ID)


8. 프로시저에서 해당 object를 확인하고  update 문을 찾아 그대로 update 테스트 해 본다.

이때, 해당 컬럼에 인덱스가 있는지 확인 한다. update 시 인덱스가 없으면 table scan 을 하게되고 exclusive lock 이 발생한다.

 

9. Key 되는 컬럼에 인덱스를 생성 해 준다.

 

10. 후에 다시 실행해봐서 deadlock 이 발생하는지 확인 한다.


 


 


'Monitoring' 카테고리의 다른 글

Admin::Tempdb 의 작업, 모니터링  (0) 2011.01.30
T_SQL::SP_WHO2 + DBCC  (0) 2010.06.03
CPU에 할당된 Task 보기  (1) 2010.03.14
DBCC FLUSHPROCINDB  (0) 2010.02.04
2009. 7. 17. 19:35

복제::Snaphort DB 이용한 데이터 초기화.

트랜잭션 복제, 병합복제, 스냅숏 복제에 게시를 초기화 하는 방법 중에 스냅숏 DB를 사용한 게시 초기화 방법.

  •  SQL Server 2005 Enterprise Edition 서비스 팩 2 이상 버전일 경우만 가능

 

현재 구독 초기화 방법중 알고 있는 방법은

  • 스냅숏 복제를 이용하는 방법
  • Db 백업 후 복원을 이용하는 방법
  • 게시할 테이블을 BCP 나 SSIS를 통해 데이터를 이관해 둔 상태로 처리하는 방법
  • 스냅숏 DB를 사용하는 방법

 

방법

게시의 속성 중에  sync_method 옵션중에  database snapshot 가 추가 되었음 (database snaphort character : 문자모드, 사용하지 않은 것이 좋을 것 같음)
해당 옵션은 복제 마법사를 통해서 세팅이 불가능하며, 게시를 설정한 후 아래 스크립트로 변경해야 한다.

    1. 게시 DB에서 실행

    2. exec sp_helppublication;  

    3. exec sp_changepublication

          @publication = '게시 이름',

          @force_invalidate_snapshot = 1,

          @property  = 'sync_method',

          @value = 'database snapshot'  -- 5

 

결과

  •  이 방법으로 변경해서 게시를 초기화 하게 되면 게시이름_DB 이름으로 스탭숏 DB가 생성되며, 게시가 초기화 완료되면 삭제된다. 기존에 동일한 스탭숏 DB가 있다고 해도 항상 새로 생성한다. 
  • 대용량 DB일 경우 스탭숏 DB를 생성할 공간만 있다면, 이 방법을 사용했을 때 스냅숏 초기화 하는 과정 동안 서비스 DB에  테이블 lock가 걸리지 않으므로 서비스에 지장이 덜 가게 된다. 
  • 스냅숏 복제 작동 방법 : http://msdn.microsoft.com/ko-kr/library/ms151734(SQL.90).aspx

참고

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. 7. 10. 16:35

복제::article 상세 속성 정보

복제를 구성한 후 article 속성을 셋팅해서 게시 한 경우 추후 Aritical 속성을 확인할때 UI를 통한 확인도 가능하지만 부하가 있는 서버의 복제를 확인할때 UI가 응답 없음으로 될 경우가 있다.

 

sysarticles 테이블의 schema_option 값에 바이너리 값으로 속성값이 저장되며, 도움말 확인하여 연산해서 속성 확인 가능하다.

 

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

 

(트랜잭션 복제 기준)

select pub.name,art.pubid,art.artid --, art.objid
    ,art.dest_table
    ,case art.pre_creation_cmd when 0 then '없음' when 1 then 'DROP' when 2 then 'DELETE' when 3 then 'TRUNCATE' end as pre_creation_cmd
    ,case when (art.schema_option & 4) > 0 then 'TRUE' ELSE 'FALE' end as 'identity_ID열'
    ,case when (art.schema_option & 16) > 0 then 'TRUE' ELSE 'FALE' end as 'clustered'
    ,case when (art.schema_option & 32) > 0 then 'TRUE' ELSE 'FALE' end as 'UDT'
    ,case when (art.schema_option & 64) > 0 then 'TRUE' ELSE 'FALE' end as 'nonclustered'
    ,case when (art.schema_option & 128) > 0 then 'TRUE' ELSE 'FALE' end as 'PK'
    ,case when (art.schema_option & 256) > 0 then 'TRUE' ELSE 'FALE' end as 'triggers'
    ,case when (art.schema_option & 512) > 0 then 'TRUE' ELSE 'FALE' end as 'FK'
    ,case when (art.schema_option & 1024) > 0 then 'TRUE' ELSE 'FALE' end as 'check'
    ,case when (art.schema_option & 2048) > 0 then 'TRUE' ELSE 'FALE' end as 'default'
    ,case when (art.schema_option & 16384) > 0 then 'TRUE' ELSE 'FALE' end as 'unique_const'
    ,case when (art.schema_option & 134217728) > 0 then 'TRUE' ELSE 'FALE' end as 'ddl'
    ,case when (art.schema_option & 262144) > 0 then 'TRUE' ELSE 'FALE' end as 'filegroup'
    ,case when (art.schema_option & 524288) > 0 then 'TRUE' ELSE 'FALE' end as 'partition'
    ,case when (art.schema_option & 1048576) > 0 then 'TRUE' ELSE 'FALE' end as 'partition_index'
    ,case when (art.schema_option & 1073741824) > 0 then 'TRUE' ELSE 'FALE' end as 'permissions'
from sysarticles as  art
    inner join syspublications as pub  on art.pubid = pub.pubid
order by pub.pubid


 

 

2009. 7. 9. 18:27

Trouble Shooting Query Performance Issues Related to Plan Cache in SQL 2005 RTM and SP1

http://blogs.msdn.com/sqlprogrammability/archive/2007/01/20/trouble-shooting-query-performance-issues-related-to-plan-cache-in-sql-2005-rtm-and-sp1.aspx

 

 

SQL  SP3  CU4 부터 2005 X64 스탠다드 에디션에서 Lock Page in Memory 기능을 사용할 수 있게 되었음.

'ETC' 카테고리의 다른 글

최상위 코어 i7 프로세서를 낳은 인텔 네할렘 아키텍처  (0) 2010.06.10
유틸::엑셀이용 데이터 입력  (1) 2010.06.03
Active Directory Management  (0) 2009.09.16
Windows용 Dr. Watson  (0) 2009.09.14
2009. 7. 8. 23:42

에러::64bit 버퍼 풀 페이징

증상

 

  • 미러링 걸려있던 DB의 로그가 90% 이상.
  • 활성 트랜잭션이 없음에도  log 백업을 해도 로그가 줄어들지 않음
  • 주 서버에서 미러가 일시 중지됨
  • 파트너 서버에 에러 로그 파일 에 아래 errorlog 발생

2009-07-05 05:39:01.050spid1sA significant part of sql server process memory has been paged out. This may result in a performance degradation. Duration: 0 seconds. Working set (KB): 263552, committed (KB): 528496, memory utilization: 49%.

2009-07-05 05:46:21.370spid1sA significant part of sql server process memory has been paged out. This may result in a performance degradation. Duration: 0 seconds. Working set (KB): 265520, committed (KB): 527400, memory utilization: 50%.


2009-07-05 07:28:27.210spid27sError: 1204, Severity: 19, State: 4.

2009-07-05 07:28:27.210spid27sThe instance of the SQL Server Database Engine cannot obtain a LOCK resource at this time.

Rerun your statement when there are fewer active users. Ask the database administrator to check the lock and memory configuration for this instance, or to check for long-running transactions.

2009-07-05 07:28:27.320spid27sError: 1454, Severity: 16, State: 1.

2009-07-05 07:28:27.320spid27sWhile acting as a mirroring partner for database 'DB명', server instance '주서버명' encountered error 1204, status 4, severity 19. Database mirroring will be suspended.  Try to resolve the error and resume mirroring.

2009-07-05 07:28:27.820spid27sDatabase mirroring is inactive for database 'DB명'. This is an informational message only. No user action is required.

 

(주서버)

2009-07-05 07:28:27.920spid34sError: 1453, Severity: 16, State: 1.

2009-07-05 07:28:27.920spid34s'TCP://정보', the remote mirroring partner for database 'DB명', encountered error 1204, status 4, severity 19. Database mirroring has been suspended.  Resolve the error on the remote server and resume mirroring, or remove mirroring and re-establish the mirror server instance.

 

원인

  • significant part of sql server process memory has been paged out. This may result in a performance degradation.
  • Windows 운영체제 페이지를 SQL Server 프로세스의 작업 집한 제한  때문에 발생합니다.
  • 데이터베이스 엔진 오류 : 1204
  • SQL Server 데이터베이스 엔진 인스턴스에서 지금 LOCK 리소스를 가져올 수 없습니다. 활성 사용자가 적을 때 문을 다시 실행하십시오. 데이터베이스 관리자에게 이 인스턴스의 잠금 및 메모리 구성이나 장기 실행 트랜잭션을 확인하도록 요청하십시오.
  • max server memory 옵션 증가시킴

select request_session_id, count(*) num_locks from sys.dm_tran_locks  group by request_session_id order by count(*) desc
  • 위는 전부 페이지 잠금 문제로 발생 했다.

 

해결

  1. 시작 을 클릭하고 실행 을 클릭합니다 gpedit.msc 를 입력한 다음 확인 을 클릭하십시오. 그룹 정책 대화 상자가 나타납니다.
  2. 확장 컴퓨터 구성 를 확장한 다음 Windows 설정 .
  3. 보안 설정 을 확장한 다음 로컬 정책 을 확장하십시오.
  4. 사용자 권한 할당 을 클릭한 다음 메모리의 페이지 잠그기 두 번 클릭하십시오.
  5. 로컬 보안 정책 설정 대화 상자에서 사용자 또는 그룹 추가 클릭합니다.
  6. 사용자 또는 그룹 선택 대화 상자에서 Sqlservr.exe 파일을 실행할 권한이 있는 계정을 추가하고 확인 을 클릭하십시오.
  7. 그룹 정책 대화 상자를 닫습니다.
  8. SQL Server 서비스를 다시 시작하십시오
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무시

     

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