代码拉取完成,页面将自动刷新
在Docker环境中运行MySQL Shell for GreatSQL 8.0.32-25,无需额外安装,更方便省事。
备选阿里云 ACR 资源地址:registry.cn-beijing.aliyuncs.com/greatsql/greatsql_shell,支持tag
创建一个MySQL Shell for GreatSQL新容器:
$ docker run -itd --hostname greatsqlsh --name greatsqlsh greatsql/greatsql_shell bash
通过tcp/ip方式连接GreatSQL
$ docker exec -it greatsqlsh bash -c "mysqlsh --uri GreatSQL@172.17.140.123"
Please provide the password for 'GreatSQL@172.17.140.123': *************
MySQL Shell 8.0.32
...
Your MySQL connection id is 14891 (X protocol)
Server version: 8.0.32-25 GreatSQL, Release 25, Revision db07cc5cb73
No default schema selected; type \use <schema> to set one.
# 获取当前MGR状态信息
MySQL 172.17.140.123:33060+ ssl JS > c=dba.getCluster()
MySQL 172.17.140.123:33060+ ssl JS > c.status()
{
"clusterName": "mgr803225",
"defaultReplicaSet": {
"name": "default",
"primary": "172.17.136.59:3306",
"ssl": "REQUIRED",
"status": "OK_NO_TOLERANCE",
"statusText": "Cluster is NOT tolerant to any failures.",
"topology": {
"172.17.136.59:3306": {
"address": "172.17.136.59:3306",
"memberRole": "PRIMARY",
"mode": "R/W",
"readReplicas": {},
"replicationLag": "applier_queue_applied",
"role": "HA",
"status": "ONLINE",
"version": "8.0.32"
},
"172.17.140.123:3306": {
"address": "172.17.140.123:3306",
"memberRole": "SECONDARY",
"mode": "R/O",
"readReplicas": {},
"replicationLag": "applier_queue_applied",
"role": "HA",
"status": "ONLINE",
"version": "8.0.32"
}
},
"topologyMode": "Single-Primary"
},
"groupInformationSourceMember": "172.17.136.59:3306"
}
MySQL 172.17.140.123:33060+ ssl JS >
# 切换到SQL命令行模式下,并查看连接列表
MySQL 172.17.140.123:33060+ ssl JS > \sql
Switching to SQL mode... Commands end with ;
Fetching global names for auto-completion... Press ^C to stop.
MySQL 172.17.140.123:33060+ ssl SQL > show processlist;
+-------+-------------+----------------------+------+---------+---------+----------------------------------------------------------+----------------------------------+------------+-----------+---------------+
| Id | User | Host | db | Command | Time | State | Info | Time_ms | Rows_sent | Rows_examined |
+-------+-------------+----------------------+------+---------+---------+----------------------------------------------------------+----------------------------------+------------+-----------+---------------+
| 12 | system user | | NULL | Connect | 1200070 | waiting for handler commit | Group replication applier module | 1200070613 | 0 | 0 |
...
| 14883 | GreatSQL | 172.17.134.224:35392 | NULL | Query | 0 | init | PLUGIN: show processlist | 0 | 0 | 0 |
+-------+-------------+----------------------+------+---------+---------+----------------------------------------------------------+----------------------------------+------------+-----------+---------------+
7 rows in set (0.0028 sec)
或者创建一个像这样的新容器,并挂载mysql.sock文件
$ docker run -itd --hostname greatsqlsh --name greatsqlsh -v /data/GreatSQL/mysql.sock:/tmp/mysql.sock greatsql/greatsql_shell bash
通过socket方式连接GreatSQL
$ docker exec -it greatsqlsh bash -c "mysqlsh -S/tmp/mysql.sock"
Please provide the password for 'root@/tmp%2Fmysql.sock':
MySQL Shell 8.0.32
...
Fetching schema names for auto-completion... Press ^C to stop.
Your MySQL connection id is 178
Server version: 8.0.32-25 GreatSQL, Release 25, Revision db07cc5cb73
No default schema selected; type \use <schema> to set one.
MySQL localhost Py > \sql
Switching to SQL mode... Commands end with ;
Fetching global names for auto-completion... Press ^C to stop.
MySQL localhost SQL > show processlist;
+-----+-------------+-----------------+----------+---------+------+----------------------------------------------------------+----------------------------------+---------+-----------+---------------+
| Id | User | Host | db | Command | Time | State | Info | Time_ms | Rows_sent | Rows_examined |
+-----+-------------+-----------------+----------+---------+------+----------------------------------------------------------+----------------------------------+---------+-----------+---------------+
| 42 | GreatSQL | 127.0.0.1:41682 | NULL | Sleep | 2469 | | NULL | 2468667 | 0 | 0 |
| 57 | root | localhost | greatsql | Sleep | 2000 | | NULL | 2000318 | 8 | 33 |
...
| 178 | root | localhost | NULL | Query | 0 | init | show processlist | 0 | 0 | 0 |
+-----+-------------+-----------------+----------+---------+------+----------------------------------------------------------+----------------------------------+---------+-----------+---------------+
9 rows in set (0.0002 sec)
如上所示,这就可以在Docker环境中运行MySQL Shell for GreatSQL 8.0.32-25,用它来管理GreatSQL MGR更方便省事。
扫码关注微信公众号
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。