背景
管理資料庫的介面工具。
開發團隊中一般有非技術背景人員,比如: 產品,功能測試人員;
對他們來說,可能安裝資料庫管理工具客戶端都很麻煩,需要一款線上的網頁工具能方便他們查閱資料。
本地docker安裝
單庫:
docker run --name myadmin -d -e PMA_HOST=lifcHost -e PMA_PORT=3306 -e PMA_USER=root -e PMA_PASSWORD=Root1234 -p 9001:80 phpmyadmin
多庫:
php初始化檔案:
<?php
$server_hosts = array(
'1' => array('server_name' => 'lifcHost', 'host' => 'lifcHost', 'port' => 3306, 'user'=>'root', 'password' => 'Root1234'),
'2' => array('server_name' => 'dev', 'host' => '10.10.1.23', 'port' => 30099,'user'=>'root', 'password' => 'Cycube123!'),
'3' => array('server_name' => 'uat', 'host' => '10.10.1.23', 'port' => 30099,'user'=>'root', 'password' => 'Cycube123!')
);
foreach($server_hosts as $key => $sh)
{
$cfg['Servers'][$key]['verbose'] = $sh['server_name'];
$cfg['Servers'][$key]['auth_type'] = 'cookie';
$cfg['Servers'][$key]['host'] = $sh['host'];
$cfg['Servers'][$key]['user'] = $sh['user'];
$cfg['Servers'][$key]['port'] = $sh['port'];
$cfg['Servers'][$key]['password'] = $sh['password'];
$cfg['Servers'][$key]['connect_type'] = 'tcp';
$cfg['Servers'][$key]['compress'] = false;
$cfg['Servers'][$key]['extension'] = 'mysqli';
$cfg['Servers'][$key]['AllowNoPassword'] = false;
}
$cfg['ServerDefault'] = 1;
docker run --name myadmin -p 9001:80 -v d:/test/phpMyAdmin/config/config.user.inc.php:/etc/phpmyadmin/config.user.inc.php -d phpmyadmin
首頁需要收入伺服器的賬號和密碼。
k8s安裝
---
apiVersion: v1
kind: ConfigMap
metadata:
name: configmap-phpmyadmin
data:
config.user.inc.php: |-
<?php
$server_hosts = array(
'1' => array('server_name' => 'prod', 'host' => 'sh-cdb-l5xxx.com', 'port' => 59153, 'user'=>'cyxxxe_read', 'password' => 'xxxxx'),
'2' => array('server_name' => 'dev', 'host' => '10.10.1.23', 'port' => 30099,'user'=>'root', 'password' => 'xxx123!')
);
foreach($server_hosts as $key => $sh)
{
$cfg['Servers'][$key]['verbose'] = $sh['server_name'];
$cfg['Servers'][$key]['auth_type'] = 'cookie';
$cfg['Servers'][$key]['host'] = $sh['host'];
$cfg['Servers'][$key]['user'] = $sh['user'];
$cfg['Servers'][$key]['port'] = $sh['port'];
$cfg['Servers'][$key]['password'] = $sh['password'];
$cfg['Servers'][$key]['connect_type'] = 'tcp';
$cfg['Servers'][$key]['compress'] = false;
$cfg['Servers'][$key]['extension'] = 'mysqli';
$cfg['Servers'][$key]['AllowNoPassword'] = false;
}
$cfg['ServerDefault'] = 1;
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: phpmyadmin
namespace: tp
labels:
cycube: phpmyadmin
spec:
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
cycube: phpmyadmin
template:
metadata:
labels:
cycube: phpmyadmin
spec:
restartPolicy: Always
schedulerName: default-scheduler
dnsPolicy: ClusterFirst
terminationGracePeriodSeconds: 120
imagePullSecrets:
- name: ali-sh2-cycube-images
containers:
- image: phpmyadmin
name: phpmyadmin
imagePullPolicy: IfNotPresent
volumeMounts:
- name: phpmyadmin-volume
mountPath: /etc/phpmyadmin/config.user.inc.php
subPath: config.user.inc.php
resources:
limits:
cpu: 250m
memory: 512Mi
requests:
cpu: 125m
memory: 256Mi
ports:
- name: http
containerPort: 80
protocol: TCP
livenessProbe:
httpGet:
path: /
port: 80
scheme: HTTP
initialDelaySeconds: 120
periodSeconds: 30
readinessProbe:
httpGet:
path: /
port: 80
scheme: HTTP
initialDelaySeconds: 90
timeoutSeconds: 15
periodSeconds: 30
successThreshold: 1
failureThreshold: 5
volumes:
- name: phpmyadmin-volume
configMap:
name: configmap-phpmyadmin
items:
- key: config.user.inc.php
path: config.user.inc.php
---
apiVersion: v1
kind: Service
metadata:
name: svc-phpmyadmin-n
spec:
ports:
- name: phpmyadmin-port
port: 80
protocol: TCP
targetPort: 80
nodePort: 30401
selector:
cycube: phpmyadmin
sessionAffinity: None
type: NodePort
執行指令:
kubectl apply -f phpadmin.yml -n tp
即可進入:
小結
替代客戶端的一個統一管理資料庫的工具。 網頁版本更清涼。
原創不易,關注誠可貴,轉發價更高!轉載請註明出處,讓我們互通有無,共同進步,歡迎溝通交流。