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"

相关推荐
ZHOU西口39 分钟前
微服务实战系列之玩转Docker(十八)
分布式·docker·云原生·架构·数据安全·etcd·rbac
牛角上的男孩1 小时前
Istio Gateway发布服务
云原生·gateway·istio
JuiceFS3 小时前
好未来:多云环境下基于 JuiceFS 建设低运维模型仓库
运维·云原生
景天科技苑3 小时前
【云原生开发】K8S多集群资源管理平台架构设计
云原生·容器·kubernetes·k8s·云原生开发·k8s管理系统
wclass-zhengge4 小时前
K8S篇(基本介绍)
云原生·容器·kubernetes
颜淡慕潇4 小时前
【K8S问题系列 |1 】Kubernetes 中 NodePort 类型的 Service 无法访问【已解决】
后端·云原生·容器·kubernetes·问题解决
川石课堂软件测试6 小时前
性能测试|docker容器下搭建JMeter+Grafana+Influxdb监控可视化平台
运维·javascript·深度学习·jmeter·docker·容器·grafana
昌sit!12 小时前
K8S node节点没有相应的pod镜像运行故障处理办法
云原生·容器·kubernetes
A ?Charis15 小时前
Gitlab-runner running on Kubernetes - hostAliases
容器·kubernetes·gitlab
wclass-zhengge15 小时前
Docker篇(Docker Compose)
运维·docker·容器