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"

相关推荐
运维&陈同学38 分钟前
【Beats01】企业级日志分析系统ELK之Metricbeat与Heartbeat 监控
运维·elk·elasticsearch·云原生·kibana·heartbeat·metricbeat
AKA小徐1 小时前
Debian12使用RKE2离线部署3master2node三主两从的k8s集群详细教程
kubernetes·rancher·rke2
老大白菜8 小时前
Windows 11 安装 Dify 完整指南 非docker环境
windows·docker·容器
tntlbb12 小时前
Ubuntu20.4 VPN+Docker代理配置
运维·ubuntu·docker·容器
Gabriel_liao13 小时前
Docker安装Neo4j
docker·容器·neo4j
有一个好名字13 小时前
zookeeper分布式锁模拟12306买票
分布式·zookeeper·云原生
Anna_Tong16 小时前
云原生大数据计算服务 MaxCompute 是什么?
大数据·阿里云·云原生·maxcompute·odps
豆豆豆豆变16 小时前
Docker轻量级可视化工具Portainer
docker·容器·自动化运维
花晓木16 小时前
k8s etcd 数据损坏处理方式
容器·kubernetes·etcd
运维&陈同学16 小时前
【模块一】kubernetes容器编排进阶实战之基于velero及minio实现etcd数据备份与恢复
数据库·后端·云原生·容器·kubernetes·etcd·minio·velero