环境准备
代码语言:javascript复制docker rm -f lhrmatrixdb
docker run -itd --name lhrmatrixdb -h lhrmatrixdb
-p 5432:5432 -p 8240:8240 -p 8086:8086 -p 33389:3389
-v /sys/fs/cgroup:/sys/fs/cgroup
--privileged=true lhrbest/matrixdb:5.0
/usr/sbin/init
启动
代码语言:javascript复制docker exec -it lhrmatrixdb bash
su - mxadmin
mxstart -a
示例:
代码语言:javascript复制[root@lhrdb ~]# docker run -itd --name lhrmatrixdb -h lhrmatrixdb
> -p 5432:5432 -p 8240:8240 -p 8086:8086 -p 33389:3389
> -v /sys/fs/cgroup:/sys/fs/cgroup
> --privileged=true lhrbest/matrixdb:5.0
> /usr/sbin/init
8787d19fc67bd564929b48f09899fc7ef799ebd89db537d1030e388716854ca3
[root@lhrdb ~]#
[root@lhrdb ~]# docker exec -it lhrmatrixdb bash
[root@lhrmatrixdb /]# su - mxadmin
Last login: Thu Apr 6 15:57:41 CST 2023
********** MatrixDB Administrator **********
The MatrixDB on 5432 is not running
Start the database with
mxstart -a
********************************************
[mxadmin@lhrmatrixdb ~]$ mxstart -a
2023-04-06:16:08:12.735 mxstart:mxadmin:lhrmatrixdb:000505-[INFO]:-Starting MatrixDB cluster with: [no-prompt:true].
2023-04-06:16:08:12.735 mxstart:mxadmin:lhrmatrixdb:000505-[INFO]:-Connecting to physical cluster's etcd cluster ...
2023-04-06:16:08:12.747 mxstart:mxadmin:lhrmatrixdb:000505-[INFO]:-Connected to physical cluster's etcd cluster: [http://172.71.0.2:4679].
2023-04-06:16:08:12.747 mxstart:mxadmin:lhrmatrixdb:000505-[INFO]:-Collecting database cluster ID ...
2023-04-06:16:08:12.747 mxstart:mxadmin:lhrmatrixdb:000505-[INFO]:-Collected database cluster ID: K5wAqr8EDiRFPT8Dhbi9ew
2023-04-06:16:08:12.754 mxstart:mxadmin:lhrmatrixdb:000505-[INFO]:-Collecting cluster info ...
2023-04-06:16:08:12.756 mxstart:mxadmin:lhrmatrixdb:000505-[INFO]:----------------------------
2023-04-06:16:08:12.756 mxstart:mxadmin:lhrmatrixdb:000505-[INFO]:-Master instance parameters
2023-04-06:16:08:12.756 mxstart:mxadmin:lhrmatrixdb:000505-[INFO]:----------------------------
2023-04-06:16:08:12.756 mxstart:mxadmin:lhrmatrixdb:000505-[INFO]:-Master Host = lhrmatrixdb
2023-04-06:16:08:12.756 mxstart:mxadmin:lhrmatrixdb:000505-[INFO]:-Master Port = 5432
2023-04-06:16:08:12.756 mxstart:mxadmin:lhrmatrixdb:000505-[INFO]:-Master Directory = /mxdata_20230406130924/master/mxseg-1
2023-04-06:16:08:12.756 mxstart:mxadmin:lhrmatrixdb:000505-[INFO]:----------------------------------------
2023-04-06:16:08:12.756 mxstart:mxadmin:lhrmatrixdb:000505-[INFO]:-Segment instances that will be started
2023-04-06:16:08:12.756 mxstart:mxadmin:lhrmatrixdb:000505-[INFO]:----------------------------------------
2023-04-06:16:08:12.756 mxstart:mxadmin:lhrmatrixdb:000505-[INFO]:-Host Port DataDir Role
2023-04-06:16:08:12.756 mxstart:mxadmin:lhrmatrixdb:000505-[INFO]:-lhrmatrixdb 6000 /mxdata_20230406130924/primary/mxseg0 PRIMARY
2023-04-06:16:08:12.756 mxstart:mxadmin:lhrmatrixdb:000505-[INFO]:-lhrmatrixdb 6001 /mxdata_20230406130924/primary/mxseg1 PRIMARY
2023-04-06:16:08:12.756 mxstart:mxadmin:lhrmatrixdb:000505-[INFO]:-lhrmatrixdb 6002 /mxdata_20230406130924/primary/mxseg2 PRIMARY
2023-04-06:16:08:12.756 mxstart:mxadmin:lhrmatrixdb:000505-[INFO]:-lhrmatrixdb 6003 /mxdata_20230406130924/primary/mxseg3 PRIMARY
2023-04-06:16:08:12.756 mxstart:mxadmin:lhrmatrixdb:000505-[INFO]:-Commencing parallel primary and mirror segment instance startup, please wait ...
2023-04-06:16:08:12.763 mxstart:mxadmin:lhrmatrixdb:000505-[INFO]:-Send start to cluster service
2023-04-06:16:08:16.319 mxstart:mxadmin:lhrmatrixdb:000505-[INFO]:-DB instances process started. Waiting for status in-sync ...
2023-04-06:16:08:17.328 mxstart:mxadmin:lhrmatrixdb:000505-[INFO]:-Database instance started and status is in sync.
2023-04-06:16:08:17.346 mxstart:mxadmin:lhrmatrixdb:000505-[INFO]:-Send reload request to cluster service
2023-04-06:16:08:18.410 mxstart:mxadmin:lhrmatrixdb:000505-[INFO]:-Cluster GUC reloaded.
2023-04-06:16:08:18.416 mxstart:mxadmin:lhrmatrixdb:000505-[INFO]:-MatrixDB cluster successfully started.
[mxadmin@lhrmatrixdb ~]$
[mxadmin@lhrmatrixdb ~]$ psql -d postgres
psql (12)
Type "help" for help.
postgres=#
远程访问
代码语言:javascript复制[root@lhrdb ~]# psql -U mxadmin -h 192.18.0.14 -p5432 -d postgres
Password for user mxadmin:
psql (14.7, server 12)
Type "help" for help.
postgres=# l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
----------- --------- ---------- ------------ ------------ ---------------------
matrixmgr | mxadmin | UTF8 | en_US.utf8 | en_US.utf8 |
postgres | mxadmin | UTF8 | en_US.utf8 | en_US.utf8 |
template0 | mxadmin | UTF8 | en_US.utf8 | en_US.utf8 | =c/mxadmin
| | | | | mxadmin=CTc/mxadmin
template1 | mxadmin | UTF8 | en_US.utf8 | en_US.utf8 | =c/mxadmin
| | | | | mxadmin=CTc/mxadmin
(4 rows)
postgres=# select version();
version
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
PostgreSQL 12 (MatrixDB 5.0.0 community) (Greenplum Database 7.0.0 dev.20476.g346be35d90 build commit:346be35d90d3b69877dc6262b163f68bd08b902c) on x86_64-pc-linux-gnu, compiled by gcc (GCC) 11.2.1 20220127 (Red Hat 11.2.1-9), 64-bit compiled on Mar 31 2023 08:22:55
(1 row)
postgres=#
postgres=# select * from gp_segment_configuration ;
dbid | content | role | preferred_role | mode | status | port | hostname | address | datadir
------ --------- ------ ---------------- ------ -------- ------ ------------- ------------- ---------------------------------------
1 | -1 | p | p | n | u | 5432 | lhrmatrixdb | lhrmatrixdb | /mxdata_20230406130924/master/mxseg-1
2 | 0 | p | p | n | u | 6000 | lhrmatrixdb | lhrmatrixdb | /mxdata_20230406130924/primary/mxseg0
5 | 3 | p | p | n | u | 6003 | lhrmatrixdb | lhrmatrixdb | /mxdata_20230406130924/primary/mxseg3
3 | 1 | p | p | n | u | 6001 | lhrmatrixdb | lhrmatrixdb | /mxdata_20230406130924/primary/mxseg1
4 | 2 | p | p | n | u | 6002 | lhrmatrixdb | lhrmatrixdb | /mxdata_20230406130924/primary/mxseg2
(5 rows)
postgres=#
web界面管理
http://192.18.0.14:8240 密码:lhr
数据库管理
SSH 登陆到服务器,切换到 YMatrix 管理员用户 mxadmin:
代码语言:javascript复制su - mxadmin
YMatrix 的启动、停止、重启、状态查看可以通过下述命令分别完成:
代码语言:javascript复制mxstart -a
mxstop -af
mxstop -arf
mxstate -s # YMatrix 5 开始的数据库新架构适用
命令 | 用途 |
---|---|
mxstop -a | 停止集群。(此模式下,如果有会话链接,关闭数据库会卡住) |
mxstop -af | 快速关闭集群 |
mxstop -ar | 重启集群。等待当前正在执行的 SQL 语句结束(此模式下,如果有会话链接,关闭数据库会卡住) |
mxstate -s | 查看集群状态 |
监控检查
参考
https://ymatrix.cn/doc/5.0/get-started
https://www.xmmup.com/ymatrixshujukuxunjianjiaoben.html