集群中数据连接数的调整
postgres
数据库中连接数的查询
1 2 3 4 5
   | # 查询当前连接数: select count(1) from pg_stat_activity;
  # 查询最大连接数 show max_connections;
   | 
 
修改容器参数
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
   | apiVersion: extensions/v1beta1 kind: Deployment metadata:   labels:     application: route-pg     cluster: admin   name: route-pg   namespace: admin spec:   replicas: 1   selector:     matchLabels:       application: route-pg       cluster: admin   template:     metadata:       labels:         application: route-pg         cluster: admin     spec:       containers:              - args:         - -cmax_connections=500         env:         - name: POSTGRES_DB           value: 数据库名称         - name: POSTGRES_USER           value: 数据库用户         - name: POSTGRES_PASSWORD           value: 数据库密码         image: postgres:9.6.9         imagePullPolicy: IfNotPresent         name: routes-pg         ports:         - containerPort: 5432           protocol: TCP         resources:           limits:             cpu: 500m             memory: 1Gi         volumeMounts:         - mountPath: /var/lib/postgresql/data           name: routes-pg       dnsPolicy: ClusterFirst       nodeSelector:         cluster: admin       restartPolicy: Always       volumes:       - name: routes-pg         persistentVolumeClaim:           claimName: routes-pg
 
   | 
 
mysql
数据库中连接数的查询
1 2 3 4 5 6 7 8 9 10 11
   | # 查询所有连接数 show FULL PROCESSLIST
  # 查询使用的最大连接数 show global status like 'Max_used_connections'
  # 查询设置的最大连接数 show variables like '%max_connections%'
  # 查询数据库当前的连接状态 show status like 'Threads%'
   | 
 
修改容器参数
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
   | apiVersion: extensions/v1beta1 kind: Deployment metadata:   labels:     application: zxy-mysql     cluster: admin     env: pro   name: zxy-mysql   namespace: admin spec:   replicas: 1   selector:     matchLabels:       application: zxy-mysql       cluster: admin   template:     metadata:       labels:         application: zxy-mysql         cluster: admin     spec:       containers:              - args:         - --max-connections=510         env:         - name: MYSQL_ROOT_PASSWORD           value: 数据库root密码         image: mysql:5.7         imagePullPolicy: IfNotPresent         name: zxy-mysql         ports:         - containerPort: 3306           protocol: TCP         resources:           limits:             cpu: "1"             memory: 2Gi         volumeMounts:         - mountPath: /var/lib/mysql           name: zxy-mysql-storage       dnsPolicy: ClusterFirst       nodeSelector:         cluster: admin       restartPolicy: Always       volumes:       - name: zxy-mysql-storage         persistentVolumeClaim:           claimName: zxy-mysql-storage
   | 
 
挂载自定义的my.cnf文件
在自定义的my.cnf文件中的服务端参数加入max_connections=510
再通过挂载的方法把自定义的配置文件挂载到数据库的容器中,重启数据库即完成修改