ACI sql 服务器容器在启动时不指向文件存储

ACI sql server container does not point to file storage at startup

我正在寻找使用 powershell 脚本在 Azure 实例容器 (ACI) 中制作具有文件存储持久性的 sql 服务器。

我执行以下步骤 1.创建资源组 2.创建文件存储 3. 创建一个使用文件存储的 sql 服务器容器。 4. 从容器中检索所有日志

我的问题是容器中的 sql 服务器无法使用文件存储中的 file/data 位置启动。

我可以看到使用 docker 参数 -v 或 -mount 被使用,但我的尝试没有成功。

因此,我们将不胜感激

谢谢你提前。

迈克尔

Powershell 脚本

param (

    # The ressource group name
    $ressourceGroup = "sql-container",

    # Location for where the instance is placed
    $location = "WestEurope",

    # Image name to download
    $imageName = "mcr.microsoft.com/mssql/server:latest-ubuntu",    

    # Dns name for this instanse
    $dnsName = "sql-test99",

    # Database instanse name
    $databaseInstanseName = "mssql-2019",

    # Database collatino type
    $databaseCollation = "Danish_Norwegian_CI_AS",

    # Database login name
    $databaseLoginName = "SA",

    # Database login name
    $databaseLoginPassword = "!thisWillMakeMyDayEveryDayIn2019",

    # Database default locations
    $databaseDefaultLocation = "/mnt/mydata/",

    # SQL server name
    $sqlServerFullName = $dnsName + "." + $location + ".azurecontainer.io",

    # Storage account name  
    $storage_account_name = "mikaelsqlstorageaccount",

    # Storage share name    
    $storage_share_name = "sqlsharestorage",

    # Storage key
    $storage_key
)

az group create --name $ressourceGroup --location $location

az Storage account create --resource-group $ressourceGroup --name $storage_account_name --location $location --sku Standard_LRS

az Storage share create --name $storage_share_name --account-name $storage_account_name

$script:storage_key=$(az Storage account keys list --resource-group $ressourceGroup --account-name $storage_account_name --query "[0].value" --output tsv)

az container create --image $imageName --name $databaseInstanseName --resource-group $ressourceGroup --cpu 1 --memory 3.5 --port 1433 --ip-address public -e ACCEPT_EULA=Y MSSQL_SA_PASSWORD=$databaseLoginPassword MSSQL_PID=Developer MSSQL_COLLATION=$databaseCollation MSSQL_ENABLE_HADR=Y MSSQL_BACKUP_DIR=$databaseDefaultLocation MSSQL_DATA_DIR=$databaseDefaultLocation MSSQL_LOG_DIR=$databaseDefaultLocation MSSQL_DUMP_DIR=$databaseDefaultLocation --location $location --dns-name-label $dnsName --azure-file-volume-account-name $storage_account_name --azure-file-volume-account-key $storage_key --azure-file-volume-share-name $storage_share_name --azure-file-volume-mount-path $databaseDefaultLocation

az container logs --resource-group $ressourceGroup --name $databaseInstanseName

SQL 容器日志

2019-10-07 08:41:08.07 Server      Logging SQL Server messages in file '/var/opt/mssql/log/errorlog'.
2019-10-07 08:41:08.07 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-10-07 08:41:19.84 spid16s      index restored for master.syspriorities.
2019-10-07 08:41:20.45 spid30s     ***Stack Dump being sent to /mnt/mydata/SQLDump0001.txt

2019-10-07 08:41:20.49 spid30s     SqlDumpExceptionHandler: Process 30 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.

根据您提供的信息,可能的原因是挂载路径应该是/mnt/mydata/。所以你需要用正确的路径格式更改变量 databaseDefaultLocation 。您还可以看到示例 here.

顺便说一下,持久卷不支持 ACI 中的 Windows 容器。所以你也需要注意一下。更多详细信息,请参阅注释 here