cd/var/lib/mysql echo"Waiting for mysqld to be ready(accepting connections)" untilmysql-uroot-p${MYSQL_ROOT_PASSWORD}-h127.0.0.1-e"SELECT 1";dosleep1;done untilmysql-uroot-p${MYSQL_ROOT_PASSWORD}-h${MASTER_HOST}-e"SELECT 1";dosleep1;done
result=$(mysql-uroot-p${MYSQL_ROOT_PASSWORD}-h127.0.0.1-e"SHOW REPLICA STATUS\G") if [[ $result==*"Replica_IO_Running:Yes"* && $result == *"Replica_SQL_Running:Yes"* ]]; then echo "recoverSTARTSLAVE" else mysql -uroot -p${MYSQL_ROOT_PASSWORD} -h127.0.0.1 -e "CHANGEREPLICATIONSOURCETOSOURCE_HOST='${MASTER_HOST}',SOURCE_USER='root',SOURCE_PASSWORD='${MYSQL_ROOT_PASSWORD}',SOURCE_CONNECT_RETRY=10;START REPLICA ;" fi # 这个是为了hold这个容器的进程,如果不hold住的话,pod会重启 # 当然这里可以使用更优雅的方式,比如TTL等,这里不做探讨 while true; do sleep 3600; done volumeMounts: - name: data mountPath: /var/lib/mysql subPath: mysql - name: conf mountPath: /etc/mysql/conf.d volumes: - name: conf emptyDir: {} - name: config-map configMap: name: {{ include "ips-db.fullname" . }}-configmap volumeClaimTemplates: - metadata: name: data spec: accessModes: - ReadWriteMany storageClassName: "local" resources: requests: storage: 10000Gi
# Default values for ips-db. # This is a YAML-formatted file. # Declare variables to be passed into your templates.
replicaCount:3
image: repository:124.70.110.25:30002/docker-io/library/mysql pullPolicy:IfNotPresent # Overrides the image tag whose default is the chart appVersion. tag:""
serviceAccount: # Specifies whether a service account should be created create:false # Automatically mount a ServiceAccount's API credentials? automount:true # Annotations to add to the service account annotations: {} # The name of the service account to use. # If not set and create is true, a name is generated using the fullname template name:""
resources: {} # We usually recommend not to specify default resources and to leave this as a conscious # choice for the user. This also increases chances charts run on environments with little # resources, such as Minikube. If you do want to specify resources, uncomment the following # lines, adjust them as necessary, and remove the curly braces after 'resources:'. # limits: # cpu: 100m # memory: 128Mi # requests: # cpu: 100m # memory: 128Mi