通过DOCKER运行MSSQL2017,并对外提供访问

拉取镜像,有1.35G

docker pull microsoft/mssql-server-linux:2017-latest

[root@v73 ~]# docker images
REPOSITORY                     TAG                 IMAGE ID            CREATED             SIZE
microsoft/mssql-server-linux   2017-latest         314918ddaedf        4 months ago        1.35GB

 

运行容器,并把数据文件映身到主机的/datas目录下,服务端口映射主机的1499端口提供服务,容器运行先运行一个/bin/bash,不然启动后会退出容器

docker run -it -v /datas:/var/opt/mssql -v /etc/localtime:/etc/localtime:ro -e TZ="Asia/Shanghai" -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=abcd1234!*' -p 1499:1433 -d --name=linuxmssql 314918ddaedf /bin/bash

 

进入容器手动开启SQLSERVER服务,要有2G以上的内存才跑得起来,内存不足容器会有提示

[root@v73 ~]# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                    NAMES
89e08cc9e120        314918ddaedf        "/bin/bash"         3 hours ago         Up 2 hours          0.0.0.0:1499->1433/tcp   linuxmssql

[root@v73 ~]# docker exec -it 89e08cc9e120 /bin/bash
root@89e08cc9e120:/# ls  
bin  boot  dev  etc  home  install.sh  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
root@89e08cc9e120:/# cd /opt/mssql
root@89e08cc9e120:/opt/mssql# ls
bin  lib
root@89e08cc9e120:/opt/mssql# cd bin/
root@89e08cc9e120:/opt/mssql/bin# ls
compress-dump.sh  crash-support-functions.sh  generate-sql-dump.sh  handle-crash.sh  mssql-conf  paldumper  sqlservr
root@89e08cc9e120:/opt/mssql/bin# ./sqlservr 
2019-04-26 12:26:30.68 Server      Microsoft SQL Server 2017 (RTM-CU13) (KB4466404) - 14.0.3048.4 (X64) 
        Nov 30 2018 12:57:58 
        Copyright (C) 2017 Microsoft Corporation
        Developer Edition (64-bit) on Linux (Ubuntu 16.04.5 LTS)
2019-04-26 12:26:30.69 Server      UTC adjustment: 8:00
2019-04-26 12:26:30.69 Server      (c) Microsoft Corporation.
2019-04-26 12:26:30.70 Server      All rights reserved.
2019-04-26 12:26:30.70 Server      Server process ID is 4120.
2019-04-26 12:26:30.70 Server      Logging SQL Server messages in file '/var/opt/mssql/log/errorlog'.
2019-04-26 12:26:30.71 Server      Registry startup parameters: 
         -d /var/opt/mssql/data/master.mdf
         -l /var/opt/mssql/data/mastlog.ldf
         -e /var/opt/mssql/log/errorlog
2019-04-26 12:26:30.78 Server      SQL Server detected 2 sockets with 1 cores per socket and 1 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.
2019-04-26 12:26:30.80 Server      SQL Server is starting at normal priority base (=7). This is an informational message only. No user action is required.
2019-04-26 12:26:30.80 Server      Detected 2268 MB of RAM. This is an informational message; no user action is required.
2019-04-26 12:26:30.81 Server      Using conventional memory in the memory manager.
2019-04-26 12:26:30.95 Server      Buffer pool extension is already disabled. No action is necessary. 
2019-04-26 12:26:31.05 Server      InitializeExternalUserGroupSid failed. Implied authentication will be disabled.
2019-04-26 12:26:31.05 Server      Implied authentication manager initialization failed. Implied authentication will be disabled.
2019-04-26 12:26:31.05 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'].
2019-04-26 12:26:31.10 Server      The maximum number of dedicated administrator connections for this instance is '1'
2019-04-26 12:26:31.10 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.
2019-04-26 12:26:31.11 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.
2019-04-26 12:26:31.12 Server      In-Memory OLTP initialized on lowend machine.
2019-04-26 12:26:31.16 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. 
2019-04-26 12:26:31.17 Server      Query Store settings initialized with enabled = 1, 
2019-04-26 12:26:31.18 spid6s      Starting up database 'master'.
2019-04-26 12:26:31.18 Server      Software Usage Metrics is disabled.
ForceFlush feature is enabled for log durability.
2019-04-26 12:26:31.92 spid6s      25 transactions rolled forward in database 'master' (1:0). This is an informational message only. No user action is required.
2019-04-26 12:26:32.70 spid6s      0 transactions rolled back in database 'master' (1:0). This is an informational message only. No user action is required.
2019-04-26 12:26:32.70 spid6s      Recovery is writing a checkpoint in database 'master' (1). This is an informational message only. No user action is required.
2019-04-26 12:26:32.72 spid6s      Recovery completed for database master (database ID 1) in 2 second(s) (analysis 112 ms, redo 277 ms, undo 491 ms.) This is an informational message only. No user action is required.
2019-04-26 12:26:33.30 spid6s      Resource governor reconfiguration succeeded.
2019-04-26 12:26:33.30 spid6s      SQL Server Audit is starting the audits. This is an informational message. No user action is required.
2019-04-26 12:26:33.33 spid6s      SQL Server Audit has started the audits. This is an informational message. No user action is required.
2019-04-26 12:26:33.43 spid6s      SQL Trace ID 1 was started by login "sa".
2019-04-26 12:26:34.05 spid6s      Server name is '89e08cc9e120'. This is an informational message only. No user action is required.
2019-04-26 12:26:34.16 spid23s     Always On: The availability replica manager is starting. This is an informational message only. No user action is required.
2019-04-26 12:26:34.16 spid6s      Starting up database 'msdb'.
2019-04-26 12:26:34.17 spid23s     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.
2019-04-26 12:26:34.17 spid9s      Starting up database 'mssqlsystemresource'.
2019-04-26 12:26:34.19 spid9s      The resource database build version is 14.00.3048. This is an informational message only. No user action is required.
2019-04-26 12:26:34.22 spid9s      Starting up database 'model'.
2019-04-26 12:26:34.23 spid20s     A self-generated certificate was successfully loaded for encryption.
2019-04-26 12:26:34.35 spid20s     Server is listening on [ 'any' <ipv4> 1433].
2019-04-26 12:26:34.36 Server      Server is listening on [ 127.0.0.1 <ipv4> 1434].
2019-04-26 12:26:34.37 Server      Dedicated admin connection support was established for listening locally on port 1434.
2019-04-26 12:26:34.65 spid6s      9 transactions rolled forward in database 'msdb' (4:0). This is an informational message only. No user action is required.
2019-04-26 12:26:34.67 spid20s     SQL Server is now ready for client connections. This is an informational message; no user action is required.
2019-04-26 12:26:34.85 spid9s      1 transactions rolled forward in database 'model' (3:0). This is an informational message only. No user action is required.
2019-04-26 12:26:35.06 spid9s      0 transactions rolled back in database 'model' (3:0). This is an informational message only. No user action is required.
2019-04-26 12:26:35.07 spid9s      Recovery is writing a checkpoint in database 'model' (3). This is an informational message only. No user action is required.
2019-04-26 12:26:35.29 spid6s      0 transactions rolled back in database 'msdb' (4:0). This is an informational message only. No user action is required.
2019-04-26 12:26:35.29 spid6s      Recovery is writing a checkpoint in database 'msdb' (4). This is an informational message only. No user action is required.
2019-04-26 12:26:35.35 spid9s      Polybase feature disabled.
2019-04-26 12:26:35.36 spid9s      Clearing tempdb database.
2019-04-26 12:26:37.34 spid9s      Starting up database 'tempdb'.
2019-04-26 12:26:38.76 spid9s      The tempdb database has 1 data file(s).
2019-04-26 12:26:38.83 spid23s     The Service Broker endpoint is in disabled or stopped state.
2019-04-26 12:26:38.83 spid23s     The Database Mirroring endpoint is in disabled or stopped state.
2019-04-26 12:26:39.21 spid23s     Service Broker manager has started.
2019-04-26 12:26:39.25 spid6s      Recovery is complete. This is an informational message only. No user action is required.
2019-04-26 12:28:16.04 spid51      Attempting to load library 'xplog70.dll' into memory. This is an informational message only. No user action is required.
2019-04-26 12:28:16.08 spid51      Using 'xplog70.dll' version '2017.140.3048' to execute extended stored procedure 'xp_msver'. This is an informational message only; no user action is required.
2019-04-26 12:28:16.45 spid51      Attempting to load library 'xpsqlbot.dll' into memory. This is an informational message only. No user action is required.
2019-04-26 12:28:16.46 spid51      Using 'xpsqlbot.dll' version '2017.140.3048' to execute extended stored procedure 'xp_qv'. This is an informational message only; no user action is required.
2019-04-26 12:28:16.73 spid54      Attempting to load library 'xpstar.dll' into memory. This is an informational message only. No user action is required.
2019-04-26 12:28:16.77 spid54      Using 'xpstar.dll' version '2017.140.3048' to execute extended stored procedure 'xp_instance_regread'. This is an informational message only; no user action is required.
2019-04-26 12:28:40.71 spid52      Starting up database 'testlinuxmssql'.
2019-04-26 12:28:40.89 spid52      Parallel redo is started for database 'testlinuxmssql' with worker pool size [1].
2019-04-26 12:28:41.02 spid52      Parallel redo is shutdown for database 'testlinuxmssql' with worker pool size [1].
2019-04-26 12:28:41.11 spid52      Setting database option COMPATIBILITY_LEVEL to 140 for database 'testlinuxmssql'.
2019-04-26 12:28:41.12 spid52      Setting database option ANSI_NULL_DEFAULT to OFF for database 'testlinuxmssql'.
2019-04-26 12:28:41.13 spid52      Setting database option ANSI_NULLS to OFF for database 'testlinuxmssql'.
2019-04-26 12:28:41.13 spid52      Setting database option ANSI_PADDING to OFF for database 'testlinuxmssql'.
2019-04-26 12:28:41.14 spid52      Setting database option ANSI_WARNINGS to OFF for database 'testlinuxmssql'.
2019-04-26 12:28:41.14 spid52      Setting database option ARITHABORT to OFF for database 'testlinuxmssql'.
2019-04-26 12:28:41.15 spid52      Setting database option AUTO_CLOSE to OFF for database 'testlinuxmssql'.
2019-04-26 12:28:41.16 spid52      Setting database option AUTO_SHRINK to OFF for database 'testlinuxmssql'.
2019-04-26 12:28:41.16 spid52      Setting database option INCREMENTAL to OFF for database 'testlinuxmssql'.
2019-04-26 12:28:41.16 spid52      Setting database option AUTO_CREATE_STATISTICS to ON for database 'testlinuxmssql'.
2019-04-26 12:28:41.17 spid52      Setting database option AUTO_UPDATE_STATISTICS to ON for database 'testlinuxmssql'.
2019-04-26 12:28:41.18 spid52      Setting database option CURSOR_CLOSE_ON_COMMIT to OFF for database 'testlinuxmssql'.
2019-04-26 12:28:41.19 spid52      Setting database option CURSOR_DEFAULT to GLOBAL for database 'testlinuxmssql'.
2019-04-26 12:28:41.19 spid52      Setting database option CONCAT_NULL_YIELDS_NULL to OFF for database 'testlinuxmssql'.
2019-04-26 12:28:41.20 spid52      Setting database option NUMERIC_ROUNDABORT to OFF for database 'testlinuxmssql'.
2019-04-26 12:28:41.21 spid52      Setting database option QUOTED_IDENTIFIER to OFF for database 'testlinuxmssql'.
2019-04-26 12:28:41.22 spid52      Setting database option RECURSIVE_TRIGGERS to OFF for database 'testlinuxmssql'.
2019-04-26 12:28:41.22 spid52      Setting database option DISABLE_BROKER to ON for database 'testlinuxmssql'.
2019-04-26 12:28:41.24 spid52      Setting database option AUTO_UPDATE_STATISTICS_ASYNC to OFF for database 'testlinuxmssql'.
2019-04-26 12:28:41.24 spid52      Setting database option DATE_CORRELATION_OPTIMIZATION to OFF for database 'testlinuxmssql'.
2019-04-26 12:28:41.24 spid52      Setting database option PARAMETERIZATION to SIMPLE for database 'testlinuxmssql'.
2019-04-26 12:28:41.25 spid52      Setting database option READ_COMMITTED_SNAPSHOT to OFF for database 'testlinuxmssql'.
2019-04-26 12:28:41.25 spid52      Setting database option READ_WRITE to ON for database 'testlinuxmssql'.
2019-04-26 12:28:41.25 spid52      Setting database option RECOVERY to FULL for database 'testlinuxmssql'.
2019-04-26 12:28:41.26 spid52      Setting database option MULTI_USER to ON for database 'testlinuxmssql'.
2019-04-26 12:28:41.26 spid52      Setting database option PAGE_VERIFY to CHECKSUM for database 'testlinuxmssql'.
2019-04-26 12:28:41.26 spid52      Setting database option target_recovery_time to 60 for database 'testlinuxmssql'.
2019-04-26 12:28:41.27 spid52      Setting database option delayed_durability to disabled for database 'testlinuxmssql'.
2019-04-26 12:31:34.28 spid55      Using 'dbghelp.dll' version '4.0.5'
 

用SQLSERVER客户端管理工具Microsoft SQL Server Management Studio 连接服务成功

 

 

数据文件都在运行容器主机映射的目录下

[root@v73 ~]# ls /datas
data  log  secrets
[root@v73 ~]# ls /datas/data/
master.mdf  mastlog.ldf  modellog.ldf  model.mdf  msdbdata.mdf  msdblog.ldf  tempdb.mdf  templog.ldf  testlinuxmssql_log.ldf  testlinuxmssql.mdf

 

已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页