ふたりで

centos7+docker+MSSQL setup & config Ing~ 본문

docker

centos7+docker+MSSQL setup & config Ing~

graykang 2022. 9. 8. 18:01
728x90
반응형
SMALL

#환경:

- VirtualBox(OS): CentOS7

- docker: Server Version: 20.10.17

- mssql: mcr.microsoft.com/mssql/server:2019-latest

 

1. mssql 이미지 파일 다운로드 및 확인.

[root@localhost ]# docker pull mcr.microsoft.com/mssql/server:2019-latest
2019-latest: Pulling from mssql/server
87fe25d61c01: Pull complete
209c3118dbee: Pull complete
9d2f7158599c: Pull complete
Digest: sha256:f54a84b8a802afdfa91a954e8ddfcec9973447ce8efec519adf593b54d49bedf
Status: Downloaded newer image for mcr.microsoft.com/mssql/server:2019-latest
mcr.microsoft.com/mssql/server:2019-latest
##다운로드(pull)된 이미지 리스트 확인.
[root@localhost ]# docker image ls
REPOSITORY                       TAG           IMAGE ID       CREATED       SIZE
mariadb                          latest        01d138caf7d0   2 weeks ago   384MB
mcr.microsoft.com/mssql/server   2019-latest   e3afdc6d8e5c   6 weeks ago   1.47GB
[root@localhost ]#

2. 다운로드된 이미지 설치(실행) 및 확인. 포트지정은 알아서 변경 필요. 나의 경우 14xxx:1433으로...

[root@localhost ]# docker run --restart always -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=xxx@xx@xx' -e 'MSSQL_PID=Express' -e 'MSSQL_COLLATION=korean_Wansung_CI_AS' -p 14XXX:1433 --name MSSQL2019E -d mcr.microsoft.com/mssql/server:2019-latest
6311716521c852ea9902b7c4ac4802f71ecb82c88bb0d80407074762258f8892
##실행중인 컨테이너 확인.
[root@localhost ]# docker ps
CONTAINER ID   IMAGE                                        COMMAND                  CREATED         STATUS                        PORTS                                       NAMES
6311716521c8   mcr.microsoft.com/mssql/server:2019-latest   "/opt/mssql/bin/perm…"   8 seconds ago   Restarting (1) 1 second ago                                               MSSQL2019E
6bc569c015b8   mariadb                                      "docker-entrypoint.s…"   13 days ago     Up 55 minutes                 0.0.0.0:33xx->3306/tcp, :::33xx->3306/tcp   mariadb
[root@localhost ]#

# 어...그런데 상태를 보니 오류가 난것 같음....아래 명령어로 MSSQL2019E 컨테이너의 로그를 확인...

[root@localhost ]# docker logs --tail 50 --follow --timestamps MSSQL2019E
2022-09-13T01:41:23.129175426Z /opt/mssql/bin/sqlservr: This program requires a machine with at least 2000 megabytes of memory.
2022-09-13T01:41:23.129182904Z
2022-09-13T01:41:27.064843886Z SQL Server 2019 will run as non-root by default.
2022-09-13T01:41:27.064872128Z This container is running as user mssql.
2022-09-13T01:41:27.064879272Z To learn more visit https://go.microsoft.com/fwlink/?linkid=2099216.
2022-09-13T01:41:27.208157547Z sqlservr: This program requires a machine with at least 2000 megabytes of memory.
2022-09-13T01:41:27.208199278Z /opt/mssql/bin/sqlservr: This program requires a machine with at least 2000 megabytes of memory.
2022-09-13T01:41:27.208210911Z
[root@localhost ]#

머라머라 하는데 번역해보니 대충 MSSQL2019Server 권장 사양을 충족 하지못해 발생 하는걸로 확인됨.

흠...버츄얼 박스 메모리만 2G 이상으로 설정 하고 다시시도....

 

3. VirtualBox 메모리를 3G로 설정하여 다시시도함.

[root@localhost ]# systemctl start docker
[root@localhost dbkang]# docker ps
CONTAINER ID   IMAGE                                        COMMAND                  CREATED       STATUS         PORTS                                       NAMES
6311716521c8   mcr.microsoft.com/mssql/server:2019-latest   "/opt/mssql/bin/perm…"   4 days ago    Up 8 seconds   0.0.0.0:14xxx->1433/tcp, :::14xxx->1433/tcp   MSSQL2019E
6bc569c015b8   mariadb                                      "docker-entrypoint.s…"   2 weeks ago   Up 7 seconds   0.0.0.0:33xx->3306/tcp, :::33xx->3306/tcp   mariadb
[root@localhost ]#

훗...정상적으로 실행이 되었군...

 

4. MSSQL2019E 컨테이너에 접속방법.

[root@localhost ]# docker exec -it MSSQL2019E bash
mssql@6311716521c8:/$ ls
bin  boot  dev  etc  home  lib  lib32  lib64  libx32  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
mssql@6311716521c8:/$

5. sqlcmd를 사용하여 MSSQL DB에 접속 방법.

mssql@6311716521c8:/$ /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'xxxxxxxxx'
1>

# 컨테이너에 접속 함과 동시에 sqlcmd로 mssql에 접속 방법.

[root@localhost ]# docker exec -it MSSQL2019E /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P '1577@4550'
1>

 

## DB생성, 계정생성, 외부에서 접속은 추후 다시 정리를 해야겠다...

728x90
반응형
LIST
Comments