Microsoft MVP성태의 닷넷 이야기
개발 환경 구성: 475. docker - SQL Server 2019 컨테이너 실행 [링크 복사], [링크+제목 복사]
조회: 10968
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 
(연관된 글이 5개 있습니다.)

docker - SQL Server 2019 컨테이너 실행

SQL Server 2019 컨테이너의 경우,

Quickstart: Run SQL Server container images with Docker
; https://learn.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker

그냥 설치/실행하면 이런 메시지를 보게 되고,

c:\temp> docker run -it mcr.microsoft.com/mssql/server:2019-GA-ubuntu-16.04
Unable to find image 'mcr.microsoft.com/mssql/server:2019-GA-ubuntu-16.04' locally
2019-GA-ubuntu-16.04: Pulling from mssql/server
59ab41dd721a: Pull complete
57da90bec92c: Pull complete
06fe57530625: Pull complete
5a6315cba1ff: Pull complete
739f58768b3f: Pull complete
fd449e8d7345: Pull complete
51d0933375e5: Pull complete
64f21ba81504: Pull complete
55b6919c0cc6: Pull complete
Digest: sha256:c8fa22553ce421b0482febcafa712b29cbb933b0d97a8671686797b31cf157a9
Status: Downloaded newer image for mcr.microsoft.com/mssql/server:2019-GA-ubuntu-16.04
SQL Server 2019 will run as non-root by default.
This container is running as user mssql.
To learn more visit https://go.microsoft.com/fwlink/?linkid=2099216.
The SQL Server End-User License Agreement (EULA) must be accepted before SQL
Server can start. The license terms for this product can be downloaded from
http://go.microsoft.com/fwlink/?LinkId=746388.

You can accept the EULA by specifying the --accept-eula command line option,
setting the ACCEPT_EULA environment variable, or using the mssql-conf tool.

Entrypoint: opt/mssql/bin/permissions_check.sh

실행이 곧바로 종료됩니다. 메시지에 따라 (그리고 편의상 SA_PASSWORD 환경 변수까지 포함해) 다음과 같이 2개의 환경 변수를 설정해 실행해야만 합니다.

// https://hub.docker.com/_/microsoft-mssql-server 문서 참고
// 

c:\temp> docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=test_1234" -p 1433:1433 --name sql1 -d mcr.microsoft.com/mssql/server:2019-GA-ubuntu-16.04

c:\temp> docker ps | findstr mssql
7bd3e7787b5e        mcr.microsoft.com/mssql/server:2019-GA-ubuntu-16.04   "/opt/mssql/bin/pe..."   11 minutes ago      Up 11 minutes       0.0.0.0:1433->1433/tcp   sql1

컨테이너가 실행이 되면 얼마 간의 초기화 작업을 거친 후에야 SQL Server Management Studio와 같은 도구를 이용해 접속/관리를 시작할 수 있습니다.




컨테이너 내부에서 sqlcmd를 실행해 볼까요? 일단, 컨테이너 내부로 shell을 실행시켜,

c:\temp> docker exec -it 7bd3e7787b5e /bin/bash

sqlcmd를 찾은 후,

$ find / -name sqlcmd -o -path "/proc" -prune
find: '/var/cache/apt/archives/partial': Permission denied
find: '/var/cache/ldconfig': Permission denied
find: '/root': Permission denied
find: '/etc/ssl/private': Permission denied
/opt/mssql-tools/bin/sqlcmd
/proc

윈도우의 sqlcmd.exe와 유사한 옵션으로 지정해 실행하면 됩니다.

$  /opt/mssql-tools/bin/sqlcmd -U sa -P $SA_PASSWORD
1>

참고로, mcr.microsoft.com/mssql/server 환경은 기본적으로 "non-root" 권한으로 실행되기 때문에 관리자 권한이 필요한 프로그램을 수행하고 싶다면 "docker exec" 단계에서부터 "u" 옵션을 지정해 실행해야 합니다.

docker - container에서 root 권한 명령어 실행(sudo)
; https://www.sysnet.pe.kr/2/0/12172




해당 컨테이너를 stop하는 것은 상관없지만, 당연히 "rm"으로 컨테이너 인스턴스 자체를 삭제해버리면 이후 다시 "docker run"을 하게 되었을 때 초기 이미지부터 SQL 서버 구성이 시작되기 때문에 기존 데이터는 모두 삭제가 됩니다. 따라서 아래의 문서에 따라,

Configure SQL Server container images on Docker - Persist your data
; https://learn.microsoft.com/en-us/sql/linux/sql-server-linux-configure-docker?view=sql-server-ver15#persist

docker run 수행 시 볼륨 매핑을 추가해야만 합니다.

-v sqlvolume:/var/opt/mssql

예) docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=test_1234" -v sqlvolume:/var/opt/mssql -p 1433:1433 --name sql1 -d mcr.microsoft.com/mssql/server:2019-GA-ubuntu-16.04

이후부터는, "docker rm ..." 후 다시 "docker run ..."을 해도 기존 구성해 놓은 docker 호스트 측 "sqlvolume" 디렉터리의 설정을 다시 로드하므로 사용자 데이터베이스가 정상적으로 보존이 됩니다. (확인 방법: DockerDesktopVM의 파일 시스템 접근 참고)




참고로, 아래의 내용은 mcr.microsoft.com/mssql/server 인스턴스화할 때 출력되는 로그입니다.

SQL Server 2019 will run as non-root by default.
This container is running as user mssql.
To learn more visit https://go.microsoft.com/fwlink/?linkid=2099216.
2020-03-07 12:42:15.14 Server      Setup step is copying system data file 'C:\templatedata\master.mdf' to '/var/opt/mssql/data/master.mdf'.
2020-03-07 12:42:15.49 Server      Did not find an existing master data file /var/opt/mssql/data/master.mdf, copying the missing default master and other system database files. If you have moved the database location, but not moved the database files, startup may fail. To repair: shutdown SQL Server, move the master database to configured location, and restart.
2020-03-07 12:42:15.50 Server      Setup step is copying system data file 'C:\templatedata\mastlog.ldf' to '/var/opt/mssql/data/mastlog.ldf'.
2020-03-07 12:42:15.55 Server      Setup step is copying system data file 'C:\templatedata\model.mdf' to '/var/opt/mssql/data/model.mdf'.
2020-03-07 12:42:15.64 Server      Setup step is copying system data file 'C:\templatedata\modellog.ldf' to '/var/opt/mssql/data/modellog.ldf'.
2020-03-07 12:42:15.72 Server      Setup step is copying system data file 'C:\templatedata\msdbdata.mdf' to '/var/opt/mssql/data/msdbdata.mdf'.
2020-03-07 12:42:15.81 Server      Setup step is copying system data file 'C:\templatedata\msdblog.ldf' to '/var/opt/mssql/data/msdblog.ldf'.
2020-03-07 12:42:15.86 Server      Setup step is copying system data file 'C:\templatedata\model_replicatedmaster.mdf' to '/var/opt/mssql/data/model_replicatedmaster.mdf'.
2020-03-07 12:42:15.95 Server      Setup step is copying system data file 'C:\templatedata\model_replicatedmaster.ldf' to '/var/opt/mssql/data/model_replicatedmaster.ldf'.
2020-03-07 12:42:16.03 Server      Setup step is copying system data file 'C:\templatedata\model_msdbdata.mdf' to '/var/opt/mssql/data/model_msdbdata.mdf'.
2020-03-07 12:42:16.16 Server      Setup step is copying system data file 'C:\templatedata\model_msdblog.ldf' to '/var/opt/mssql/data/model_msdblog.ldf'.
2020-03-07 12:42:16.61 Server      Microsoft SQL Server 2019 (RTM) - 15.0.2000.5 (X64) 
Sep 24 2019 13:48:23 
Copyright (C) 2019 Microsoft Corporation
Developer Edition (64-bit) on Linux (Ubuntu 16.04.6 LTS) <X64>
2020-03-07 12:42:16.61 Server      UTC adjustment: 0:00
2020-03-07 12:42:16.62 Server      (c) Microsoft Corporation.
2020-03-07 12:42:16.62 Server      All rights reserved.
2020-03-07 12:42:16.62 Server      Server process ID is 28.
2020-03-07 12:42:16.62 Server      Logging SQL Server messages in file '/var/opt/mssql/log/errorlog'.
2020-03-07 12:42:16.63 Server      Registry startup parameters: 
 -d /var/opt/mssql/data/master.mdf
 -l /var/opt/mssql/data/mastlog.ldf
 -e /var/opt/mssql/log/errorlog
2020-03-07 12:42:16.65 Server      SQL Server detected 1 sockets with 1 cores per socket and 2 logical processors per socket, 2 total logical processors; using 2 logical processors based on SQL Server licensing. This is an informational message; no user action is required.
2020-03-07 12:42:16.66 Server      SQL Server is starting at normal priority base (=7). This is an informational message only. No user action is required.
2020-03-07 12:42:16.66 Server      Detected 1573 MB of RAM. This is an informational message; no user action is required.
2020-03-07 12:42:16.66 Server      Using conventional memory in the memory manager.
2020-03-07 12:42:16.68 Server      Page exclusion bitmap is enabled.
2020-03-07 12:42:16.91 Server      Buffer pool extension is not supported on Linux platform.
2020-03-07 12:42:16.92 Server      Buffer Pool: Allocating 262144 bytes for 177645 hashPages.
2020-03-07 12:42:18.04 Server      Buffer pool extension is already disabled. No action is necessary.
2020-03-07 12:42:18.97 Server      Successfully initialized the TLS configuration. Allowed TLS protocol versions are ['1.0 1.1 1.2']. Allowed TLS ciphers are ['ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-ECDSA-AES128-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:!DHE-RSA-AES256-GCM-SHA384:!DHE-RSA-AES128-GCM-SHA256:!DHE-RSA-AES256-SHA:!DHE-RSA-AES128-SHA'].
2020-03-07 12:42:19.01 Server      Query Store settings initialized with enabled = 1, 
2020-03-07 12:42:19.20 Server      The maximum number of dedicated administrator connections for this instance is '1'
2020-03-07 12:42:19.22 Server      Node configuration: node 0: CPU mask: 0x0000000000000003:0 Active CPU mask: 0x0000000000000003:0. This message provides a description of the NUMA configuration for this computer. This is an informational message only. No user action is required.
2020-03-07 12:42:19.25 Server      Using dynamic lock allocation.  Initial allocation of 2500 Lock blocks and 5000 Lock Owner blocks per node.  This is an informational message only.  No user action is required.
2020-03-07 12:42:19.28 Server      In-Memory OLTP initialized on lowend machine.
2020-03-07 12:42:19.68 Server      CLR version v4.0.30319 loaded.
2020-03-07 12:42:19.79 Server      [INFO] Created Extended Events session 'hkenginexesession'
2020-03-07 12:42:19.79 Server      Database Instant File Initialization: enabled. For security and performance considerations see the topic 'Database Instant File Initialization' in SQL Server Books Online. This is an informational message only. No user action is required.
ForceFlush is enabled for this instance. 
2020-03-07 12:42:19.80 Server      Total Log Writer threads: 1. This is an informational message; no user action is required.
2020-03-07 12:42:19.82 Server      clflush is selected for pmem flush operation.
2020-03-07 12:42:19.83 Server      Software Usage Metrics is disabled.
2020-03-07 12:42:19.84 spid8s      [1]. Feature Status: PVS: 0. CTR: 0. ConcurrentPFSUpdate: 1.
2020-03-07 12:42:19.86 spid8s      Starting up database 'master'.
ForceFlush feature is enabled for log durability.
2020-03-07 12:42:20.92 spid8s      The tail of the log for database master is being rewritten to match the new sector size of 4096 bytes.  2560 bytes at offset 427520 in file /var/opt/mssql/data/mastlog.ldf will be written.
2020-03-07 12:42:21.82 spid8s      Converting database 'master' from version 897 to the current version 904.
2020-03-07 12:42:21.83 spid8s      Database 'master' running the upgrade step from version 897 to version 898.
2020-03-07 12:42:22.11 Server      Common language runtime (CLR) functionality initialized.
2020-03-07 12:42:22.47 spid8s      Database 'master' running the upgrade step from version 898 to version 899.
2020-03-07 12:42:23.15 spid8s      Database 'master' running the upgrade step from version 899 to version 900.
2020-03-07 12:42:23.50 Server      Failed to verify the Authenticode signature of 'C:\binn\msoledbsql.dll'. Signature verification of SQL Server DLLs will be skipped. Genuine copies of SQL Server are signed. Failure to verify the Authenticode signature might indicate that this is not an authentic release of SQL Server. Install a genuine copy of SQL Server or contact customer support.
2020-03-07 12:42:23.91 spid8s      Database 'master' running the upgrade step from version 900 to version 901.
2020-03-07 12:42:24.21 spid8s      Database 'master' running the upgrade step from version 901 to version 902.
2020-03-07 12:42:24.46 spid8s      Database 'master' running the upgrade step from version 902 to version 903.
2020-03-07 12:42:25.01 spid8s      Database 'master' running the upgrade step from version 903 to version 904.
2020-03-07 12:42:27.07 spid8s      Resource governor reconfiguration succeeded.
2020-03-07 12:42:27.08 spid8s      SQL Server Audit is starting the audits. This is an informational message. No user action is required.
2020-03-07 12:42:27.17 spid8s      SQL Server Audit has started the audits. This is an informational message. No user action is required.
2020-03-07 12:42:27.66 spid8s      SQL Trace ID 1 was started by login "sa".
2020-03-07 12:42:29.64 spid8s      Server name is '933f4501eb5e'. This is an informational message only. No user action is required.
2020-03-07 12:42:29.67 spid8s      [4]. Feature Status: PVS: 0. CTR: 0. ConcurrentPFSUpdate: 1.
2020-03-07 12:42:29.68 spid11s     [32767]. Feature Status: PVS: 0. CTR: 0. ConcurrentPFSUpdate: 1.
2020-03-07 12:42:29.70 spid40s     Always On: The availability replica manager is starting. This is an informational message only. No user action is required.
2020-03-07 12:42:29.70 spid40s     Always On: The availability replica manager is waiting for the instance of SQL Server to allow client connections. This is an informational message only. No user action is required.
2020-03-07 12:42:29.72 spid8s      Starting up database 'msdb'.
2020-03-07 12:42:29.72 spid11s     Starting up database 'mssqlsystemresource'.
2020-03-07 12:42:29.76 spid11s     The resource database build version is 15.00.2000. This is an informational message only. No user action is required.
2020-03-07 12:42:29.85 spid11s     [3]. Feature Status: PVS: 0. CTR: 0. ConcurrentPFSUpdate: 1.
2020-03-07 12:42:29.87 spid11s     Starting up database 'model'.
2020-03-07 12:42:30.29 spid37s     Password policy update was successful.
2020-03-07 12:42:30.96 spid37s     A self-generated certificate was successfully loaded for encryption.
2020-03-07 12:42:31.07 spid37s     Server is listening on [ 'any' <ipv6> 1433].
2020-03-07 12:42:31.08 spid37s     Server is listening on [ 'any' <ipv4> 1433].
2020-03-07 12:42:31.22 spid8s      The tail of the log for database msdb is being rewritten to match the new sector size of 4096 bytes.  3072 bytes at offset 50176 in file /var/opt/mssql/data/MSDBLog.ldf will be written.
2020-03-07 12:42:31.25 Server      Server is listening on [ ::1 <ipv6> 1434].
2020-03-07 12:42:31.26 Server      Server is listening on [ 127.0.0.1 <ipv4> 1434].
2020-03-07 12:42:31.27 Server      Dedicated admin connection support was established for listening locally on port 1434.
2020-03-07 12:42:31.28 spid37s     Error: 39002, Severity: 16, State: 1.
2020-03-07 12:42:31.28 spid37s     SQL failed to boot extensibility for error code 0x80070005.
2020-03-07 12:42:31.31 spid37s     InitializeXdbPkgLauncher failed. ErrorCode: 0x80004005.
2020-03-07 12:42:31.31 spid11s     The tail of the log for database model is being rewritten to match the new sector size of 4096 bytes.  512 bytes at offset 73216 in file /var/opt/mssql/data/modellog.ldf will be written.
2020-03-07 12:42:31.33 spid37s     SQL Server is now ready for client connections. This is an informational message; no user action is required.
2020-03-07 12:42:31.91 spid8s      Converting database 'msdb' from version 897 to the current version 904.
2020-03-07 12:42:31.91 spid8s      Database 'msdb' running the upgrade step from version 897 to version 898.
2020-03-07 12:42:32.04 spid11s     Converting database 'model' from version 897 to the current version 904.
2020-03-07 12:42:32.05 spid11s     Database 'model' running the upgrade step from version 897 to version 898.
2020-03-07 12:42:32.80 spid8s      Database 'msdb' running the upgrade step from version 898 to version 899.
2020-03-07 12:42:32.90 spid11s     Database 'model' running the upgrade step from version 898 to version 899.
2020-03-07 12:42:33.40 spid8s      Database 'msdb' running the upgrade step from version 899 to version 900.
2020-03-07 12:42:33.45 spid11s     Database 'model' running the upgrade step from version 899 to version 900.
2020-03-07 12:42:33.86 spid8s      Database 'msdb' running the upgrade step from version 900 to version 901.
2020-03-07 12:42:34.04 spid11s     Database 'model' running the upgrade step from version 900 to version 901.
2020-03-07 12:42:34.42 spid8s      Database 'msdb' running the upgrade step from version 901 to version 902.
2020-03-07 12:42:34.51 spid11s     Database 'model' running the upgrade step from version 901 to version 902.
2020-03-07 12:42:34.86 spid11s     Database 'model' running the upgrade step from version 902 to version 903.
2020-03-07 12:42:35.16 spid11s     Database 'model' running the upgrade step from version 903 to version 904.
2020-03-07 12:42:35.56 spid11s     Clearing tempdb database.
2020-03-07 12:42:37.25 spid11s     [2]. Feature Status: PVS: 0. CTR: 0. ConcurrentPFSUpdate: 1.
2020-03-07 12:42:37.26 spid11s     Starting up database 'tempdb'.
2020-03-07 12:42:37.70 spid11s     The tempdb database has 1 data file(s).
2020-03-07 12:42:37.84 spid40s     The Service Broker endpoint is in disabled or stopped state.
2020-03-07 12:42:37.85 spid40s     The Database Mirroring endpoint is in disabled or stopped state.
2020-03-07 12:42:37.97 spid40s     Service Broker manager has started.
2020-03-07 12:42:38.42 spid8s      Database 'msdb' running the upgrade step from version 902 to version 903.
2020-03-07 12:42:38.75 spid8s      Database 'msdb' running the upgrade step from version 903 to version 904.
2020-03-07 12:42:39.60 spid8s      Recovery is complete. This is an informational message only. No user action is required.
2020-03-07 12:42:40.61 spid17s     The default language (LCID 0) has been set for engine and full-text services.
2020-03-07 12:42:41.90 spid17s     The tempdb database has 2 data file(s).




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

[연관 글]






[최초 등록일: ]
[최종 수정일: 4/28/2023]

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

비밀번호

댓글 작성자
 



2020-03-10 08시51분
Automating SQL Server 2019 Docker Deployments
; https://www.wintellect.com/automating-sql-server-2019-docker-deployments/
정성태

1  2  3  4  5  [6]  7  8  9  10  11  12  13  14  15  ...
NoWriterDateCnt.TitleFile(s)
13475정성태12/7/20232279닷넷: 2180. .NET 8 - 함수 포인터에 대한 Reflection 정보 조회파일 다운로드1
13474정성태12/6/20232133개발 환경 구성: 690. 닷넷 코어/5+ 버전의 ilasm/ildasm 실행 파일 구하는 방법 - 두 번째 이야기
13473정성태12/5/20232326닷넷: 2179. C# - 값 형식(Blittable)을 메모리 복사를 이용해 바이트 배열로 직렬화/역직렬화파일 다운로드1
13472정성태12/4/20232155C/C++: 164. Visual C++ - InterlockedCompareExchange128 사용 방법
13471정성태12/4/20232183Copilot - To enable GitHub Copilot, authorize this extension using GitHub's device flow
13470정성태12/2/20232484닷넷: 2178. C# - .NET 8부터 COM Interop에 대한 자동 소스 코드 생성 도입파일 다운로드1
13469정성태12/1/20232193닷넷: 2177. C# - (Interop DLL 없이) CoClass를 이용한 COM 개체 생성 방법파일 다운로드1
13468정성태12/1/20232176닷넷: 2176. C# - .NET Core/5+부터 달라진 RCW(Runtime Callable Wrapper) 대응 방식파일 다운로드1
13467정성태11/30/20232170오류 유형: 882. C# - Unhandled exception. System.Runtime.InteropServices.COMException (0x800080A5)파일 다운로드1
13466정성태11/29/20232376닷넷: 2175. C# - DllImport 메서드의 AOT 지원을 위한 LibraryImport 옵션
13465정성태11/28/20232111개발 환경 구성: 689. MSBuild - CopyToOutputDirectory가 "dotnet publish" 시에는 적용되지 않는 문제파일 다운로드1
13464정성태11/28/20232233닷넷: 2174. C# - .NET 7부터 UnmanagedCallersOnly 함수 export 기능을 AOT 빌드에 통합파일 다운로드1
13463정성태11/27/20232144오류 유형: 881. Visual Studio - NU1605: Warning As Error: Detected package downgrade
13462정성태11/27/20232210오류 유형: 880. Visual Studio - error CS0246: The type or namespace name '...' could not be found
13461정성태11/26/20232258닷넷: 2173. .NET Core 3/5+ 기반의 COM Server를 registry 등록 없이 사용하는 방법파일 다운로드1
13460정성태11/26/20232225닷넷: 2172. .NET 6+ 기반의 COM Server 내에 Type Library를 내장하는 방법파일 다운로드1
13459정성태11/26/20232207닷넷: 2171. .NET Core 3/5+ 기반의 COM Server를 기존의 regasm처럼 등록하는 방법파일 다운로드1
13458정성태11/26/20232212닷넷: 2170. .NET Core/5+ 기반의 COM Server를 tlb 파일을 생성하는 방법(tlbexp)
13457정성태11/25/20232164VS.NET IDE: 187. Visual Studio - 16.9 버전부터 추가된 "Display inline type hints" 옵션
13456정성태11/25/20232459닷넷: 2169. C# - OpenAI를 사용해 PDF 데이터를 대상으로 OpenAI 챗봇 작성 [1]파일 다운로드1
13455정성태11/25/20232339닷넷: 2168. C# - Azure.AI.OpenAI 패키지로 OpenAI 사용파일 다운로드1
13454정성태11/23/20232682닷넷: 2167. C# - Qdrant Vector DB를 이용한 Embedding 벡터 값 보관/조회 (Azure OpenAI) [1]파일 다운로드1
13453정성태11/23/20232218오류 유형: 879. docker desktop 설치 시 "Invalid JSON string. (Exception from HRESULT: 0x83750007)"
13452정성태11/22/20232296닷넷: 2166. C# - Azure OpenAI API를 이용해 사용자가 제공하는 정보를 대상으로 검색하는 방법파일 다운로드1
13451정성태11/21/20232431닷넷: 2165. C# - Azure OpenAI API를 이용해 ChatGPT처럼 동작하는 콘솔 응용 프로그램 제작파일 다운로드1
13450정성태11/21/20232254닷넷: 2164. C# - Octokit을 이용한 GitHub Issue 검색파일 다운로드1
1  2  3  4  5  [6]  7  8  9  10  11  12  13  14  15  ...