MySQL Openshift 模板的版本更新错误
Error in Version Updation for MySQL Openshift Templates
我正在尝试在 Openshift Cloud Platform
上部署 MySQL 实例。
我的要求是:
- 版本 8.0.19(最新)
- 1 Master 和 2 Slave 副本集
- 持久性
我在以下位置找到了 MySQL 5.7 版的模板:
MySQL-Version5.7
经过一些更改后,我已成功地将这些模板集成到我的源代码中。
除了 MySQL 版本问题外,这些都符合我的要求。
我尝试了多种方法来使用这些模板部署 MySQL 最新版本,但在每种情况下都遇到了一些错误。
在这些模板中将版本值 5.7
更改为 latest
后,只有主副本部署错误:
Readiness probe failed: ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)
修复此错误后,又出现了一些错误,但同一模板在 5.7 版中无需任何修改即可正常工作。我一定是在模板中遗漏了一些我不知道的东西。这对我来说是强制性要求,我对此很陌生。
如何使用这些模板部署 MySQL 最新版本?
我建议使用 helm chart,而不是使用此模板。如果您是 Kubernetes 的新手,并且错误地配置了错误,可能会导致灾难。
您可以使用类似于预配置模板的 helm chart。
你可以看看这个:MySQL-Helm
我不确定您是否遇到了问题,因为 MYSQL 版本的实施发生了准备就绪和活跃度的变化。
对于 MySQL HA 配置,您可以检查一下:https://github.com/helm/charts/tree/master/incubator/mysqlha
MySQL 最新版本 8 的模板:
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql
labels:
app: mysql
spec:
replicas: 1
selector:
matchLabels:
app: mysql
template:
metadata:
labels:
app: mysql
spec:
containers:
- image: mysql:8
name: mysql
args:
- "--default-authentication-plugin=mysql_native_password"
env:
- name: MYSQL_ROOT_PASSWORD
value : password
ports:
- containerPort: 3306
name: mysql
volumeMounts:
- name: mysql-persistent-storage
mountPath: /var/lib/mysql
volumes:
- name: mysql-persistent-storage
persistentVolumeClaim:
claimName: mysql-volumeclaim
This 不是模板。如果您将版本切换到更高版本,可能会出现问题,因为这可能针对此特定 MySQL 5.7
进行了优化
如果你真的想使用一个可以一次性升级到更高版本的模板,你应该考虑@Harsh Manvar, using MySQL - Helm Chart的建议。
您提到的错误是由StatefulSet部分的这部分产生的:
readinessProbe:
exec:
# Check we can execute queries over TCP (skip-networking is off).
command: ["mysql", "-h", "127.0.0.1", "-e", "SELECT 1"]
initialDelaySeconds: 5
periodSeconds: 2
timeoutSeconds: 1
这意味着 pod
将检查它是否可以使用命令 mysql -h 127.0.0.1 -e SELECT 1
连接到数据库。 periodSeconds
字段指定 kubelet 应每 2 秒执行一次就绪探测。 initialDelaySeconds
字段告诉 kubelet 在执行第一次探测之前应该等待 5 秒。
您可以将这些值更改为更高的值以确保其有效。
如果您提供有关您预期的其他错误的模式详细信息,我们将尽力提供进一步帮助。
此外,如果您先部署了 5.7
,然后尝试仅更改版本,这可能不起作用,因为某些资源已经创建,例如 volumes
和 latest
将不起作用与以前的版本资源。您应该考虑 运行 这是一个干净的命名空间或删除以前创建的对象。
您可以关注Cleaning up:
- Cancel the
SELECT @@server_id
loop by pressing Ctrl+C in its terminal, or running the following from another terminal:
kubectl delete pod mysql-client-loop --now
- Delete the StatefulSet. This also begins terminating the Pods.
kubectl delete statefulset mysql
- Verify that the Pods disappear. They might take some time to finish terminating.
kubectl get pods -l app=mysql
You’ll know the Pods have terminated when the above returns:
No resources found.
- Delete the ConfigMap, Services, and PersistentVolumeClaims.
kubectl delete configmap,service,pvc -l app=mysql
- If you manually provisioned PersistentVolumes, you also need to manually delete them, as well as release the underlying resources. If you used a dynamic provisioner, it automatically deletes the PersistentVolumes when it sees that you deleted the PersistentVolumeClaims. Some dynamic provisioners (such as those for EBS and PD) also release the underlying resources upon deleting the PersistentVolumes.
我正在尝试在 Openshift Cloud Platform
上部署 MySQL 实例。
我的要求是:
- 版本 8.0.19(最新)
- 1 Master 和 2 Slave 副本集
- 持久性
我在以下位置找到了 MySQL 5.7 版的模板: MySQL-Version5.7
经过一些更改后,我已成功地将这些模板集成到我的源代码中。 除了 MySQL 版本问题外,这些都符合我的要求。 我尝试了多种方法来使用这些模板部署 MySQL 最新版本,但在每种情况下都遇到了一些错误。
在这些模板中将版本值 5.7
更改为 latest
后,只有主副本部署错误:
Readiness probe failed: ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)
修复此错误后,又出现了一些错误,但同一模板在 5.7 版中无需任何修改即可正常工作。我一定是在模板中遗漏了一些我不知道的东西。这对我来说是强制性要求,我对此很陌生。
如何使用这些模板部署 MySQL 最新版本?
我建议使用 helm chart,而不是使用此模板。如果您是 Kubernetes 的新手,并且错误地配置了错误,可能会导致灾难。
您可以使用类似于预配置模板的 helm chart。
你可以看看这个:MySQL-Helm
我不确定您是否遇到了问题,因为 MYSQL 版本的实施发生了准备就绪和活跃度的变化。
对于 MySQL HA 配置,您可以检查一下:https://github.com/helm/charts/tree/master/incubator/mysqlha
MySQL 最新版本 8 的模板:
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql
labels:
app: mysql
spec:
replicas: 1
selector:
matchLabels:
app: mysql
template:
metadata:
labels:
app: mysql
spec:
containers:
- image: mysql:8
name: mysql
args:
- "--default-authentication-plugin=mysql_native_password"
env:
- name: MYSQL_ROOT_PASSWORD
value : password
ports:
- containerPort: 3306
name: mysql
volumeMounts:
- name: mysql-persistent-storage
mountPath: /var/lib/mysql
volumes:
- name: mysql-persistent-storage
persistentVolumeClaim:
claimName: mysql-volumeclaim
This 不是模板。如果您将版本切换到更高版本,可能会出现问题,因为这可能针对此特定 MySQL 5.7
进行了优化如果你真的想使用一个可以一次性升级到更高版本的模板,你应该考虑@Harsh Manvar, using MySQL - Helm Chart的建议。
您提到的错误是由StatefulSet部分的这部分产生的:
readinessProbe:
exec:
# Check we can execute queries over TCP (skip-networking is off).
command: ["mysql", "-h", "127.0.0.1", "-e", "SELECT 1"]
initialDelaySeconds: 5
periodSeconds: 2
timeoutSeconds: 1
这意味着 pod
将检查它是否可以使用命令 mysql -h 127.0.0.1 -e SELECT 1
连接到数据库。 periodSeconds
字段指定 kubelet 应每 2 秒执行一次就绪探测。 initialDelaySeconds
字段告诉 kubelet 在执行第一次探测之前应该等待 5 秒。
您可以将这些值更改为更高的值以确保其有效。
如果您提供有关您预期的其他错误的模式详细信息,我们将尽力提供进一步帮助。
此外,如果您先部署了 5.7
,然后尝试仅更改版本,这可能不起作用,因为某些资源已经创建,例如 volumes
和 latest
将不起作用与以前的版本资源。您应该考虑 运行 这是一个干净的命名空间或删除以前创建的对象。
您可以关注Cleaning up:
- Cancel the
SELECT @@server_id
loop by pressing Ctrl+C in its terminal, or running the following from another terminal:kubectl delete pod mysql-client-loop --now
- Delete the StatefulSet. This also begins terminating the Pods.
kubectl delete statefulset mysql
- Verify that the Pods disappear. They might take some time to finish terminating.
kubectl get pods -l app=mysql
You’ll know the Pods have terminated when the above returns:
No resources found.
- Delete the ConfigMap, Services, and PersistentVolumeClaims.
kubectl delete configmap,service,pvc -l app=mysql
- If you manually provisioned PersistentVolumes, you also need to manually delete them, as well as release the underlying resources. If you used a dynamic provisioner, it automatically deletes the PersistentVolumes when it sees that you deleted the PersistentVolumeClaims. Some dynamic provisioners (such as those for EBS and PD) also release the underlying resources upon deleting the PersistentVolumes.