Microsoft MVP성태의 닷넷 이야기
개발 환경 구성: 35. SQL Express 버전과 User Instance 옵션 [링크 복사], [링크+제목 복사],
조회: 24050
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 
(연관된 글이 4개 있습니다.)

SQL Express 버전과 User Instance 옵션


SQL Server 2005 Express Edition Technical Articles - SQL Server 2005 Express Edition User Instances
; https://docs.microsoft.com/en-us/previous-versions/sql/sql-server-2005/express-administrator/bb264564(v=sql.90)

와... ^^ SQL Express 버전에 "User Instance"라는 재미있는 옵션이 있네요. Oxite 설치를 하면서 web.config의 DB 연결문자열을 보았는데 다음과 같았습니다.

<connectionStrings>
    <add name="ApplicationServices" 
    connectionString="Data Source=.\SQLEXPRESS2008;AttachDBFileName=|DataDirectory|Oxite.Database.mdf;
    Integrated Security=true;User Instance=true;"/> 
</connectionStrings>

그 동안의 깜냥으로, User Instance라는 것이 SQL Instance가 사용자마다 생성된다는 것을 짐작할 수 있게 하는데요. 실제로 연결 과정을 보면 더 재미있습니다. 일단, 새로운 SQL Instance를 생성해야 하는데 이를 위해서 master, msdb, tempdb와 같은 시스템 DB를 아래의 사용자 폴더로 복사합니다.

비스타의 경우
C:\Users\[계정명]\AppData\Local\Microsoft\Microsoft SQL Server Data\[SQL Express인스턴스 이름]

그리고는 AttachDBFileName 경로에 지정된 DB를 해당 SQL Instance에 연결합니다. 이 때문에, 작업 관리자로 보면 다음과 같이 sqlservr.exe가 2개가 나옵니다.

[그림 1: 작업관리자 - sqlservr.exe]
sql_express_user_instance_1.PNG

AttachDBFileName 옵션으로 인해 개발자가 mdb 파일을 굳이 SQL 서버에 등록하지 않고도 사용할 수 있게 하는 편리함이 있는데, 이에 더해서 User Instance 옵션은 관리자 계정이 아닌 상태에서도 SQL DB를 사용할 수 있게 해준다는 것입니다. (즉, UAC에서도 잘 된다는 것이지요.)

SQL 인스턴스가 동적으로 생성되었으니, 이것 역시 "SQL Server Management Studio"로도 연결이 되겠지요. 그럴려면 허용된 Named Pipe 이름을 알아야 하는데 이는 "Process Explorer"로 sqlservr.exe를 살펴보면 알아낼 수 있습니다.

[그림 2: Process Explorer로 확인한 Named Pipe 이름]
sql_express_user_instance_2.PNG

"C:\...\MSSQL\Binn\sqlservr.exe" 
    -U"C:\...\MSSQL\Template Data" 
    -d"C:\Users\...\SQLEXPRESS2008"\master.mdf 
    -l"C:\Users\...\SQLEXPRESS2008"\mastlog.ldf 
    -e"C:\Users\...\SQLEXPRESS2008"\error.log 
    -c 
    -SSQLEXPRESS2008 
    -s1BBB3E46-938C-4E 
    -w60 

이 중에서 -s 스위치로 시작한 것이 Named Pipe의 이름이며 이를 이용해서 다음과 같이 인스턴스 명을 구성해 주면 연결이 가능합니다.

연결 문자열 형식
np:\\.\pipe\[Named Pipe이름]\tsql\query

이번 경우에는 "np:\\.\pipe\1BBB3E46-938C-4E\tsql\query"가 되겠고, 다음 그림에서 보는 것처럼 연결 대화창에서 지정하면,

[그림 3: Named Pipe 연결 문자열 지정]
sql_express_user_instance_3.PNG

성공한 경우, 아래와 같은 관리 화면을 볼 수 있습니다.

[그림 4: SQL Server Management Studio 화면]
sql_express_user_instance_5.PNG

만약, 이 과정에서 다음과 같은 오류가 발생한다면, "SQL Server Configuration Manager"를 실행시켜서 "SQL Server Network Configuration"에서 "Named Pipes" 프로토콜을 "Enabled" 상태로 변경해 주면 됩니다.

[그림 5: Named Pipe 연결 오류]
sql_express_user_instance_4.PNG

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 2)



특이한 면이 있지요! Named Pipe 프로토콜 지원 여부에 관계없이 User Instance 옵션으로 생성된 SQL 인스턴스는, 프로그램 코드에서 연결문자열을 User Instance 옵션을 직접 지정한 클라이언트에게는 무조건 Named Pipe 연결을 지원하는 반면, 정작 Management Studio에서 연결하려면 프로토콜 지원을 추가해야 하니 말이죠. 아무튼, SQL 서비스가 "인스턴스"라는 개념을 통해서 하나의 PC에서 다중으로 설치될 수 있다는 점이, 결국 User Instance라는 편리한 개발환경으로 이어지고 있습니다.




[이 토픽에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]

[연관 글]






[최초 등록일: ]
[최종 수정일: 6/27/2021]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




... 46  47  [48]  49  50  51  52  53  54  55  56  57  58  59  60  ...
NoWriterDateCnt.TitleFile(s)
12434정성태11/30/202010849Windows: 180. C# - dynamicport 값의 범위를 알아내는 방법
12433정성태11/29/20209918Windows: 179. 윈도우 환경에서 클라이언트 소켓의 최대 접속 수 (3) - SO_PORT_SCALABILITY파일 다운로드1
12432정성태11/29/202011279Windows: 178. 윈도우 환경에서 클라이언트 소켓의 최대 접속 수 (2) - SO_REUSEADDR [1]파일 다운로드1
12431정성태11/27/20209203.NET Framework: 976. UnmanagedCallersOnly + C# 9.0 함수 포인터 사용 시 x86 빌드에서 오동작하는 문제파일 다운로드1
12430정성태11/27/20209921오류 유형: 686. Ubuntu - E: The repository 'cdrom://...' does not have a Release file.
12429정성태11/25/202010023디버깅 기술: 175. windbg - 특정 Win32 API에서 BP가 안 걸리는 경우
12428정성태11/25/20208969VS.NET IDE: 154. Visual Studio - .NET Core App 실행 시 dotnet.exe 실행 화면만 나오는 문제
12427정성태11/24/202010105.NET Framework: 975. .NET Core를 직접 호스팅해 (runtimeconfig.json 없이) EXE만 배포해 실행파일 다운로드1
12426정성태11/24/20208717오류 유형: 685. WinDbg Preview - error InitTypeRead
12425정성태11/24/20209770VC++: 141. Visual C++ - "Treat Warnings As Errors" 옵션이 꺼져 있는데도 일부 경고가 에러 처리되는 경우
12424정성태11/24/202010199VC++: 140. C++의 연산자 동의어(operator synonyms), 대체 토큰 [1]
12423정성태11/22/202011100.NET Framework: 974. C# 9.0 - (16) 제약 조건이 없는 형식 매개변수 주석(Unconstrained type parameter annotations)파일 다운로드1
12422정성태11/21/20208907.NET Framework: 973. .NET 5, .NET Framework에서만 허용하는 UnmanagedCallersOnly 사용예파일 다운로드1
12421정성태11/19/20208651.NET Framework: 972. DNNE가 출력한 NE DLL을 직접 생성하는 방법파일 다운로드1
12420정성태11/19/20207816오류 유형: 684. Visual C++ - MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance
12419정성태11/19/20209033VC++: 139. Visual C++ - .NET Core의 nethost.lib와 정적 링크파일 다운로드1
12418정성태11/19/202011124오류 유형: 683. Visual C++ - error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MDd_DynamicDebug'파일 다운로드1
12417정성태11/19/20208517오류 유형: 682. Visual C++ - warning LNK4099: PDB '...pdb' was not found with '...lib(pch.obj)' or at '...pdb'; linking object as if no debug info
12416정성태11/19/20209795오류 유형: 681. Visual C++ - error LNK2001: unresolved external symbol _CrtDbgReport
12415정성태11/18/20209847.NET Framework: 971. UnmanagedCallersOnly 특성과 DNNE 사용파일 다운로드1
12414정성태11/18/202010907VC++: 138. x64 빌드에서 extern "C"가 아닌 경우 ___cdecl name mangling 적용 [4]파일 다운로드1
12413정성태11/17/202010618.NET Framework: 970. .NET 5 / .NET Core - UnmanagedCallersOnly 특성을 사용한 함수 내보내기파일 다운로드1
12412정성태11/16/202012856.NET Framework: 969. .NET Framework 및 .NET 5 - UnmanagedCallersOnly 특성 사용파일 다운로드1
12411정성태11/12/20209808오류 유형: 680. C# 9.0 - Error CS8889 The target runtime doesn't support extensible or runtime-environment default calling conventions.
12410정성태11/12/20209757디버깅 기술: 174. windbg - System.TypeLoadException 예외 분석 사례
12409정성태11/12/202011165.NET Framework: 968. C# 9.0의 Function pointer를 이용한 함수 주소 구하는 방법파일 다운로드1
... 46  47  [48]  49  50  51  52  53  54  55  56  57  58  59  60  ...