docker 安装sqlserver数据库

版权声明:本文为wcuu原创文章。 https://blog.csdn.net/wcuuchina/article/details/88849837

微软官网操作指南:

https://docs.microsoft.com/zh-cn/sql/linux/quickstart-install-connect-docker?view=sql-server-2017&pivots=cs1-bash

具备条件:

1.服务器需要大于2G内存。如果不够则可能无法正常启动,请看日志。

docker logs -f d9b450870984195f0d575d937d3fa82b23d3085d4ff95b49f356c782d84f260d

( This program requires a machine with at least 2000 megabytes of memory.)

本实例为 aliyun 

4G内存服务器

首先运行命令

yum update
yum install docker.x86_64

按 Y

启动docker

service docker start

获取 sqlserver镜像

docker pull mcr.microsoft.com/mssql/server:2017-latest

镜像下载成功后,运行镜像

docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=Waq48932je30.qesdW.' -p 1433:1433 --name sql1 -d mcr.microsoft.com/mssql/server:2017-latest

查看日志

docker logs -f 79e5d2a03de65634e194871906594a1273fa2b223222ca5ab602ea7f7a39a762

2019-03-27 09:24:59.92 Server      Setup step is copying system data file 'C:\templatedata\master.mdf' to '/var/opt/mssql/data/master.mdf'.
2019-03-27 09:24:59.98 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.
2019-03-27 09:24:59.98 Server      Setup step is copying system data file 'C:\templatedata\mastlog.ldf' to '/var/opt/mssql/data/mastlog.ldf'.
2019-03-27 09:24:59.99 Server      Setup step is copying system data file 'C:\templatedata\model.mdf' to '/var/opt/mssql/data/model.mdf'.
2019-03-27 09:25:00.01 Server      Setup step is copying system data file 'C:\templatedata\modellog.ldf' to '/var/opt/mssql/data/modellog.ldf'.
2019-03-27 09:25:00.03 Server      Setup step is copying system data file 'C:\templatedata\msdbdata.mdf' to '/var/opt/mssql/data/msdbdata.mdf'.
2019-03-27 09:25:00.06 Server      Setup step is copying system data file 'C:\templatedata\msdblog.ldf' to '/var/opt/mssql/data/msdblog.ldf'.
2019-03-27 09:25:00.15 Server      Microsoft SQL Server 2017 (RTM-CU14) (KB4484710) - 14.0.3076.1 (X64) 
        Mar 12 2019 19:29:19 
        Copyright (C) 2017 Microsoft Corporation
        Developer Edition (64-bit) on Linux (Ubuntu 16.04.6 LTS)
2019-03-27 09:25:00.15 Server      UTC adjustment: 0:00
2019-03-27 09:25:00.15 Server      (c) Microsoft Corporation.
2019-03-27 09:25:00.15 Server      All rights reserved.
2019-03-27 09:25:00.15 Server      Server process ID is 28.
2019-03-27 09:25:00.15 Server      Logging SQL Server messages in file '/var/opt/mssql/log/errorlog'.
2019-03-27 09:25:00.15 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-03-27 09:25:00.16 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.
2019-03-27 09:25:00.16 Server      SQL Server is starting at normal priority base (=7). This is an informational message only. No user action is required.
2019-03-27 09:25:00.17 Server      Detected 3032 MB of RAM. This is an informational message; no user action is required.
2019-03-27 09:25:00.17 Server      Using conventional memory in the memory manager.
2019-03-27 09:25:00.37 Server      Buffer pool extension is already disabled. No action is necessary. 
2019-03-27 09:25:00.53 Server      InitializeExternalUserGroupSid failed. Implied authentication will be disabled.
2019-03-27 09:25:00.53 Server      Implied authentication manager initialization failed. Implied authentication will be disabled.
2019-03-27 09:25:00.53 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-03-27 09:25:00.58 Server      The maximum number of dedicated administrator connections for this instance is '1'
2019-03-27 09:25:00.58 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-03-27 09:25:00.59 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-03-27 09:25:00.60 Server      In-Memory OLTP initialized on lowend machine.
2019-03-27 09:25:00.64 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-03-27 09:25:00.65 Server      Query Store settings initialized with enabled = 1, 
2019-03-27 09:25:00.66 Server      Software Usage Metrics is disabled.
2019-03-27 09:25:00.66 spid7s      Starting up database 'master'.
ForceFlush feature is enabled for log durability.
2019-03-27 09:25:00.83 spid7s      The tail of the log for database master is being rewritten to match the new sector size of 4096 bytes.  3072 bytes at offset 418816 in file /var/opt/mssql/data/mastlog.ldf will be written.
2019-03-27 09:25:01.02 spid7s      Converting database 'master' from version 862 to the current version 869.
2019-03-27 09:25:01.02 spid7s      Database 'master' running the upgrade step from version 862 to version 863.
2019-03-27 09:25:01.08 spid7s      Database 'master' running the upgrade step from version 863 to version 864.
2019-03-27 09:25:01.12 spid7s      Database 'master' running the upgrade step from version 864 to version 865.
2019-03-27 09:25:01.13 spid7s      Database 'master' running the upgrade step from version 865 to version 866.
2019-03-27 09:25:01.14 spid7s      Database 'master' running the upgrade step from version 866 to version 867.
2019-03-27 09:25:01.15 spid7s      Database 'master' running the upgrade step from version 867 to version 868.
2019-03-27 09:25:01.16 spid7s      Database 'master' running the upgrade step from version 868 to version 869.
2019-03-27 09:25:01.35 Server      Failed to verify the Authenticode signature of 'C:\binn\secforwarder.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.
2019-03-27 09:25:01.83 spid7s      Resource governor reconfiguration succeeded.
2019-03-27 09:25:01.84 spid7s      SQL Server Audit is starting the audits. This is an informational message. No user action is required.
2019-03-27 09:25:01.84 spid7s      SQL Server Audit has started the audits. This is an informational message. No user action is required.
2019-03-27 09:25:01.89 spid7s      SQL Trace ID 1 was started by login "sa".
2019-03-27 09:25:01.91 spid19s     Password policy update was successful.
2019-03-27 09:25:01.92 spid7s      Server name is '79e5d2a03de6'. This is an informational message only. No user action is required.
2019-03-27 09:25:01.96 spid22s     Always On: The availability replica manager is starting. This is an informational message only. No user action is required.
2019-03-27 09:25:01.96 spid22s     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-03-27 09:25:01.96 spid7s      Starting up database 'msdb'.
2019-03-27 09:25:01.97 spid10s     Starting up database 'mssqlsystemresource'.
2019-03-27 09:25:01.98 spid10s     The resource database build version is 14.00.3076. This is an informational message only. No user action is required.
2019-03-27 09:25:02.00 spid10s     Starting up database 'model'.
2019-03-27 09:25:02.21 spid7s      The tail of the log for database msdb is being rewritten to match the new sector size of 4096 bytes.  512 bytes at offset 306688 in file /var/opt/mssql/data/MSDBLog.ldf will be written.
2019-03-27 09:25:02.22 spid10s     The tail of the log for database model is being rewritten to match the new sector size of 4096 bytes.  2048 bytes at offset 75776 in file /var/opt/mssql/data/modellog.ldf will be written.
2019-03-27 09:25:02.26 spid19s     A self-generated certificate was successfully loaded for encryption.
2019-03-27 09:25:02.27 spid19s     Server is listening on [ 'any' <ipv6> 1433].
2019-03-27 09:25:02.27 spid19s     Server is listening on [ 'any' <ipv4> 1433].
2019-03-27 09:25:02.28 Server      Server is listening on [ ::1 <ipv6> 1434].
2019-03-27 09:25:02.28 Server      Server is listening on [ 127.0.0.1 <ipv4> 1434].
2019-03-27 09:25:02.28 Server      Dedicated admin connection support was established for listening locally on port 1434.
2019-03-27 09:25:02.28 spid19s     SQL Server is now ready for client connections. This is an informational message; no user action is required.
2019-03-27 09:25:02.28 spid7s      Converting database 'msdb' from version 862 to the current version 869.
2019-03-27 09:25:02.29 spid7s      Database 'msdb' running the upgrade step from version 862 to version 863.
2019-03-27 09:25:02.30 spid10s     Converting database 'model' from version 862 to the current version 869.
2019-03-27 09:25:02.30 spid10s     Database 'model' running the upgrade step from version 862 to version 863.
2019-03-27 09:25:02.43 spid10s     Database 'model' running the upgrade step from version 863 to version 864.
2019-03-27 09:25:02.43 spid7s      Database 'msdb' running the upgrade step from version 863 to version 864.
2019-03-27 09:25:02.45 spid10s     Database 'model' running the upgrade step from version 864 to version 865.
2019-03-27 09:25:02.46 spid7s      Database 'msdb' running the upgrade step from version 864 to version 865.
2019-03-27 09:25:02.46 spid10s     Database 'model' running the upgrade step from version 865 to version 866.
2019-03-27 09:25:02.47 spid7s      Database 'msdb' running the upgrade step from version 865 to version 866.
2019-03-27 09:25:02.48 spid10s     Database 'model' running the upgrade step from version 866 to version 867.
2019-03-27 09:25:02.49 spid7s      Database 'msdb' running the upgrade step from version 866 to version 867.
2019-03-27 09:25:02.50 spid10s     Database 'model' running the upgrade step from version 867 to version 868.
2019-03-27 09:25:02.51 spid7s      Database 'msdb' running the upgrade step from version 867 to version 868.
2019-03-27 09:25:02.52 spid10s     Database 'model' running the upgrade step from version 868 to version 869.
2019-03-27 09:25:02.52 spid7s      Database 'msdb' running the upgrade step from version 868 to version 869.
2019-03-27 09:25:02.65 spid10s     Polybase feature disabled.
2019-03-27 09:25:02.65 spid10s     Clearing tempdb database.
2019-03-27 09:25:03.07 spid10s     Starting up database 'tempdb'.
2019-03-27 09:25:03.33 spid10s     The tempdb database has 1 data file(s).
2019-03-27 09:25:03.33 spid22s     The Service Broker endpoint is in disabled or stopped state.
2019-03-27 09:25:03.33 spid22s     The Database Mirroring endpoint is in disabled or stopped state.
2019-03-27 09:25:03.35 spid22s     Service Broker manager has started.
2019-03-27 09:25:03.44 spid7s      Recovery is complete. This is an informational message only. No user action is required.
2019-03-27 09:25:03.47 spid24s     The default language (LCID 0) has been set for engine and full-text services.

链接sqlserver

docker exec -it sql1
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P password

执行命令

SELECT Name from sys.Databases
GO

返回

Name                                                                                                                            
--------------------------------------------------------------------------------------------------------------------------------
master                                                                                                                          
tempdb                                                                                                                          
model                                                                                                                           
msdb                                                                                                                            

(4 rows affected)
1> select 1 from dual
2> GO
Msg 208, Level 16, State 1, Server 79e5d2a03de6, Line 1
Invalid object name 'dual'.
1> SELECT Name from sys.Databases
2> Go
Name                                                                                                                            
--------------------------------------------------------------------------------------------------------------------------------
master                                                                                                                          
tempdb                                                                                                                          
model                                                                                                                           
msdb                                                                                                                            

(4 rows affected)
1> 

完毕!!!

猜你喜欢

转载自blog.csdn.net/wcuuchina/article/details/88849837