Kubernetes部署Wordpress时碰到的两个问题解决

文章目录

小结

在使用Kubernetes部署Wordpress时返回了两个问题:

  • Function not implemented: AH00141: Could not initialize random number generator

  • chown: changing ownership of '.': Operation not permitted

对这个两个返回错误,进行了解决。

问题1解决

Function not implemented: AH00141: Could not initialize random number generator具体返回的错误如下:

shell 复制代码
[root@Master ~]# kubectl get pods -o wide
NAME              READY     STATUS             RESTARTS   AGE       IP           NODE
mysql-d7xcd       1/1       Running            0          12h       172.17.0.3   192.168.238.135
wordpress-26lwg   0/1       CrashLoopBackOff   143        11h       172.17.0.5   192.168.238.135
wordpress-2l6v2   0/1       Error              143        11h       172.17.0.3   192.168.238.134
wordpress-9g6qp   0/1       CrashLoopBackOff   142        11h       172.17.0.4   192.168.238.135
wordpress-vz3tk   0/1       CrashLoopBackOff   143        11h       172.17.0.2   192.168.238.134
[root@Master ~]# 
[root@Master ~]# kubectl logs wordpress-vz3tk
WordPress not found in /var/www/html - copying now...
Complete! WordPress has been successfully copied to /var/www/html
No 'wp-config.php' found in /var/www/html, but 'WORDPRESS_...' variables supplied; copying 'wp-config-docker.php' (WORDPRESS_PORT WORDPRESS_PORT_80_TCP WORDPRESS_PORT_80_TCP_ADDR WORDPRESS_PORT_80_TCP_PORT WORDPRESS_PORT_80_TCP_PROTO WORDPRESS_SERVICE_HOST WORDPRESS_SERVICE_PORT)
[Sun Aug 13 03:23:30.542592 2023] [:crit] [pid 1] (38)Function not implemented: AH00141: Could not initialize random number generator
[root@Master ~]# 

查看具体原因,是因为Linux Kernel的版本太低,缺失了Apache2的一些依赖,只要升级Linux Kernel版本就可以解决问题,进行了验证,确实可以解决问题。

参考How to Upgrade Linux Kernel on CentOS ,如下步骤:

shell 复制代码
[root@Node1 ~]# yum update -y
[root@Node1 ~]# uname -r
3.10.0-514.el7.x86_64
[root@Node1 ~]# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
[root@Node1 ~]# yum install -y https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm
[root@Node1 ~]# yum --enablerepo=elrepo-kernel install -y kernel-ml
[root@Node1 ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-6.4.10-1.el7.elrepo.x86_64
Found initrd image: /boot/initramfs-6.4.10-1.el7.elrepo.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-1160.95.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1160.95.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-514.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-514.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-651a89d2f1bc4d1d890d6b935d971e00
Found initrd image: /boot/initramfs-0-rescue-651a89d2f1bc4d1d890d6b935d971e00.img
done
[root@Node1 ~]# grub2-set-default 0
[root@Node1 ~]# reboot
[root@Node1 ~]# uname -r
6.4.10-1.el7.elrepo.x86_64

重新部署wordpress docker,问题解决。

问题2解决

Wordpress共享了NFS挂载的卷,yaml文件如下:

yaml 复制代码
[root@Master ~]# vim wordpress_rc_update.yaml 


apiVersion: v1
kind: ReplicationController
metadata:
  name: wordpress
spec:
  replicas: 2
  selector:
    name: wordpress

  template:
    metadata:
      labels:
        name: wordpress
    spec:
      containers:
      - name: wordpress
        image: wordpress:v1
        ports:
        - name: web
          containerPort: 80
        env:
        - name: MYSQL_SERVICE_HOST
          value: 10.254.225.126
        volumeMounts:
        - name: data
          mountPath: /var/www/html
      volumes:
      - name: data
        hostPath:
          path: /nfs

部署时碰到以下问题:

shell 复制代码
[root@Master ~]# kubectl logs wordpress-qz6hh
chown: changing ownership of '.': Operation not permitted
[root@Master ~]# kubectl logs wordpress-v05h7
chown: changing ownership of '.': Operation not permitted

这里牵扯到权限问题,解决办法:

shell 复制代码
[root@Master ~]#  chmod o+w /nfs/
[root@Master ~]# vim /etc/exports
/nfs    *(rw,sync,no_root_squash)
[root@Master ~]# systemctl restart nfs
[root@Node1 ~]# mount Master:/nfs/ /nfs/
[root@Node1 ~]# chmod o+w /nfs/
[root@Node2 ~]#  mount Master:/nfs/ /nfs/
[root@Node2 ~]# chmod o+w /nfs/

重新部署wordpress docker,问题解决。

参考

How to Upgrade Linux Kernel on CentOS
(38)Function not implemented: AH00141: Could not initialize random number generator #1574
chown on a mounted NFS partition gives "Operation not permitted"

相关推荐
阿里云云原生12 小时前
LLM 不断提升智能下限,MCP 不断提升创意上限
云原生
阿里云云原生12 小时前
GraalVM 24 正式发布阿里巴巴贡献重要特性 —— 支持 Java Agent 插桩
云原生
云上艺旅15 小时前
K8S学习之基础七十四:部署在线书店bookinfo
学习·云原生·容器·kubernetes
c无序15 小时前
【Docker-7】Docker是什么+Docker版本+Docker架构+Docker生态
docker·容器·架构
FixBug_Nick15 小时前
使用Docker安装及使用最新版本的Jenkins
docker·容器·jenkins
ghostwritten17 小时前
Run Milvus in Kubernetes with Milvus Operator
容器·kubernetes·milvus
Zero_to_zero123417 小时前
解决docker的ubuntu系统中文乱码问题
ubuntu·docker·容器
@郭小茶17 小时前
docker-compose方式部署docker项目
运维·docker·容器
duration~19 小时前
K8S自定义CRD
容器·贪心算法·kubernetes
ghostwritten20 小时前
Docker Registry Clean
运维·docker·容器