k3s 挂载本地目录到pod 报错 SQL Server 2022 will run as non-root by default. This container is running as user mssql. Your master database file is owned by mssql. To learn more visit https://go.microsoft.com/fwlink/?linkid=2099216. 2023-06-07 03:14:03.28 Server Microsoft SQL Server 2022 (RTM-CU4) (KB5026717) - 16.0.4035.4 (X64) May 1 2023 10:34:45 Copyright (C) 2022 Microsoft Corporation Developer Edition (64-bit) on Linux (Ubuntu 20.04.6 LTS) <X64> 03:14:03.29 Server UTC adjustment: 0:00 03:14:03.29 Server (c) Microsoft Corporation. 03:14:03.29 Server All rights reserved. 03:14:03.29 Server Server process ID is 396. 03:14:03.30 Server Logging SQL Server messages in file '/var/opt/mssql/log/errorlog'. 03:14:03.30 Server Registry startup parameters: -d /var/opt/mssql/data/master.mdf -l /var/opt/mssql/data/mastlog.ldf -e /var/opt/mssql/log/errorlog 03:14:03.31 Server Error: 17113, Severity: 16, State: 1. 03:14:03.31 Server Error 5(Access is denied.) occurred while opening file '/var/opt/mssql/data/master.mdf' to obtain configuration information at startup. An invalid startup option might have caused the error. Verify your startup options, and correct or remove them if necessary. 2023-06-07T03:14:03.591017773Z
时间: 2024-04-25 12:25:52 浏览: 563
k3s-selinux-1.3-1.el7.noarch.rpm
根据报错信息,看起来是因为 SQL Server 2022 默认以非 root 用户身份运行,但是你挂载的本地目录的文件所有者是 mssql 用户,导致无法访问。你可以尝试修改挂载目录的权限,使其可以被非 root 用户访问。具体操作可以参考以下步骤:
1. 在本地机器上修改挂载目录的权限:
```
sudo chmod -R 777 /path/to/local/dir
```
2. 在 k3s 集群中,将挂载目录的所有者设置为非 root 用户:
```
spec:
containers:
- name: sql-server
image: sql-server:latest
volumeMounts:
- name: data
mountPath: /var/opt/mssql/data
subPath: data
readOnly: false
securityContext:
runAsUser: 10001
runAsGroup: 10001
volumes:
- name: data
hostPath:
path: /path/to/local/dir
```
其中,`runAsUser` 和 `runAsGroup` 分别设置为非 root 用户的 UID 和 GID。这样就可以让 SQL Server 以非 root 用户身份运行,并且可以访问挂载目录了。
阅读全文