1panel报错flags: 0x5000: not a directory: unknown: Are you trying to mount a directory onto a file解决

1panel安装openresty的时候报错

报错内容如下:

mount /opt/1panel/apps/openresty/openresty/conf/fastcgi-php.conf:/usr/local/openresty/nginx/conf/fastcgi-php.conf (via /proc/self/fd/6), flags: 0x5000: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type

解决办法

这是1panel的bug,新版已经修复。
1pctl restart重启1panel,卸载openresty后在应用列表界面点击刷新应用列表后重新安装就正常了,新版修复了这个问题。

探索过程

在找到解决办法前,找出错的原因

分析

这种错误一般由于主机上没有相应的文件,docker在创建的时候把文件路径当成文件夹创建导致docker挂在同步数据的时候文件夹和文件类型对应不上而报错。

所以准备修改文件映射方式

改变成我经常用的文件卷映射方式就可以了

services:
openresty:
container_name: ${CONTAINER_NAME}
deploy:
resources:
limits:
cpus: ${CPUS}
memory: ${MEMORY_LIMIT}
hostname: ${CONTAINER_NAME}
image: openresty/openresty:1.21.4.2-0-focal
labels:
createdBy: Apps
network_mode: host
restart: always
volumes:
- openrestyConf:/usr/local/openresty/nginx/conf
- openrestyLog:/var/log/nginx
- openrestyWww:/www
- openrestyHtml:/usr/share/nginx/html
- /etc/localtime:/etc/localtime
volumes:
openrestyConf: null
openrestyHtml: null
openrestyLog: null
openrestyWww: null
version: "3.7"

这种方式docker能正常拷贝文件

这种方式还是有点问题,因为毕竟对默认的方式做了修改,可能影响一些其他功能。

更新之前创建的yml是这样的

version: '3'
services:
openresty:
image: openresty/openresty:1.21.4.2-0-focal
container_name: ${CONTAINER_NAME}
restart: always
network_mode: host
volumes:
- ./conf/nginx.conf:/usr/local/openresty/nginx/conf/nginx.conf
- ./conf/fastcgi_params:/usr/local/openresty/nginx/conf/fastcgi_params
- ./conf/fastcgi-php.conf:/usr/local/openresty/nginx/conf/fastcgi-php.conf
- ./log:/var/log/nginx
- ./conf/conf.d:/usr/local/openresty/nginx/conf/conf.d/
- ./www:/www
- ./root:/usr/share/nginx/html
- /etc/localtime:/etc/localtime
labels:
createdBy: "Apps"

更新之后创建的文件是这样的


services:
openresty:
container_name: ${CONTAINER_NAME}
deploy:
resources:
limits:
cpus: ${CPUS}
memory: ${MEMORY_LIMIT}
image: openresty/openresty:1.21.4.2-0-focal
labels:
createdBy: Apps
network_mode: host
restart: always
volumes:
- ./conf/nginx.conf:/usr/local/openresty/nginx/conf/nginx.conf
- ./conf/fastcgi_params:/usr/local/openresty/nginx/conf/fastcgi_params
- ./conf/fastcgi-php.conf:/usr/local/openresty/nginx/conf/fastcgi-php.conf
- ./log:/var/log/nginx
- ./conf/conf.d:/usr/local/openresty/nginx/conf/conf.d/
- ./www:/www
<!--autointro-->

k8s部署学习

说明

下面是我学习搭建k8s的记录,并没有成功,应为我的vps配置太低了。
仅供参考学习,真正部署参考官方文档。

官方文档

https://kubernetes.io/zh-cn/docs/home/
https://github.com/guangzhengli/k8s-tutorials

安装三个组件

设置镜像库

vi /etc/yum.repos.d/kubernetes.repo
内容如下

[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg

会下载失败

kubelet-1.28.2-0.x86_64: Cannot download, all mirrors were already tried without success

修改镜像地址

[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg

安装k8s的三个工具

sudo dnf install -y kubelet kubeadm kubectl

成功,可能是国外的vps应该用国外的镜像地址
已经安装好了三个组件:kubelet kubeadm kubectl

初始化的时候报错

执行master节点初始化的时候报错,有太多不符合项目,所以用不了k8s。


[root@racknerd-d17e8e volumes]# kubeadm init
[init] Using Kubernetes version: v1.28.2
[preflight] Running pre-flight checks
[WARNING Firewalld]: firewalld is active, please ensure ports [6443 10250] are open or your cluster may not function correctly
[WARNING Swap]: swap is enabled; production deployments should disable swap unless testing the NodeSwap feature gate of the kubelet
[WARNING Service-Kubelet]: kubelet service is not enabled, please run 'systemctl enable kubelet.service'
error execution phase preflight: [preflight] Some fatal errors occurred:
[ERROR NumCPU]: the number of available CPUs 1 is less than the required 2
[ERROR Mem]: the system RAM (771 MB) is less than the minimum 1700 MB
[ERROR CRI]: container runtime is not running: output: time="2023-09-17T05:08:55-05:00" level=fatal msg="validate service connection: CRI v1 runtime API is not implemented for endpoint \"unix:///var/run/containerd/containerd.sock\": rpc error: code = Unimplemented desc = unknown service runtime.v1.RuntimeService"
, error: exit status 1
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
To see the stack trace of this <!--autointro-->

yum和dnf区别

两种不同的包管理工具,用于在Linux上安装、更新和卸载软件包。

区别:

依赖关系解决:二者dnf处理依赖关系的能力更强大
性能:dnf速度更快,dnf支持并行操作,可以同时下载多个软件包
配置文件:dnf使用以.repo为后缀的配置文件;yum使用以.repo为后缀的配置文件和/etc/yum.conf的主配置文件
用户界面:dnf输出信息更清晰明了,提供更多终端输出信息。yum输出信息较少,比较简洁

1panel使用说明

配置网站

1panel要设置网站必须先安装openresty

按照提示安装即可

查看容器运行日志

1panel的容器-编排中可以看到容器运行日志

删除已安装的应用

概览中-已安装的应用里可以删除应用

其他错误解决办法

下面这个错误是因为要用空格缩进,但是出现了tab符

错误: yaml: line 5: found a tab character that violates indentation

下面这个是因为volumes的缩进错误


services.volumes Additional property openrestyLo<!--autointro-->

1panel设置证书账户申请通配符域名

为了能够使用https访问,先开启申请证书的账户

创建Acme 账户

输入邮箱即可创建

在网站-证书中设置dns账户

我用的阿里云的dns,所以选择阿里云。
需要在阿里云控制中心创建api key

创建证书

使用DNS账号创建的好处是可以生成通配符证书

无论是dns还是http解析都会报错

服务内部错误: error: one or more domains had a problem: [panel.weiyoun.com] [panel.weiyoun.com] acme: error presenting token: API call failed: invalid character '<' looking for beginning of value [weiyoun.com] [weiyoun.com] acme: error presenting token: API call failed: invalid character '<' looking for beginning of value

找到出错的原因了

我在截图的时候,不小心把阿里云DNS变成了DNSpod,修改过来就好了。