文章目录
小结
在使用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"