By digoal
Reference document: https://www.polardbx.com/document
Use PXD to quickly deploy PolarDB-X on-premises instances.
PXD is a tool specifically designed for deploying Polardb-x. Currently, only machines with x86 architecture are supported. PXD relies on Python3 and Docker.
If Python3 is already installed on your machine, you can skip this step.
Check using the command: which Python3
. If there is a return, it means that Python3
is already installed. We recommend using Homebrew to install Python3. If Homebrew is not available, please refer to the official installation method provided by Homebrew.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Use Homebrew to install Python3
brew install python
Reference document: https://docs.docker.com/desktop/mac/install/
Download Docker Desktop for Mac
For example, download it to the ~/Downloads
cd ~/Downloads
sudo hdiutil attach Docker.dmg
sudo /Volumes/Docker/Docker.app/Contents/MacOS/install
sudo hdiutil detach /Volumes/Docker
Since the default memory allocation of Docker Desktop for Mac is 2 GB, it does not meet the minimum requirements for the PolarDB-X development and testing environment. You need to adjust the memory allocation to 8 GB in Docker Preferences, as shown in the figure below:
Note: After installing Docker on MacOS, you must enable and run Docker in the application (you can disable it after it has finished running) before the docker cli appears in /usr/local/bin
. This step needs to be performed every time. Otherwise, PXD will encounter an error when obtaining images.
Note: It is recommended to use a virtual environment for installing the PXD tools. All subsequent operations, including installing Polardb-x, starting, and connecting to Docker, should also be performed within the virtual environment.
python3 -m venv venv
source venv/bin/activate
Before installation, we recommend running the following command to upgrade pip
pip install --upgrade pip
Run the following command to install PXD:
pip install pxd
Note: If the speed of downloading packages from pypi is slow, you can use the following command to install pxd from Alibaba Cloud images:
pip install -i https://mirrors.aliyun.com/pypi/simple/ pxd
Running the pxd tryout
command directly creates a PolarDB-X database of the latest version, with one GMS, one CN, one DN, and one CDC:
pxd tryout
You can also specify the number and version of CN, DN, and CDC. The command is as follows:
pxd tryout -cn_replica 1 -cn_version latest -dn_replica 1 -dn_version latest -cdc_replica 1 -cdc_version latest
By default, GMSs and DNs created in tryout mode use the single-replica mode. To create a Paxos-based three-replica cluster, run the following command:
pxd tryout -leader_only false
Note: The three-replica mode requires the PXD version to be 0.3.0 or later.
Here is a record of the entire process:
pxd tryout
...
Processing [#########---------------------------] 25% create gms node
Processing [############------------------------] 33% create gms db and tables
Processing [###############---------------------] 41% create PolarDB-X root account
Processing [##################------------------] 50% create dn
Processing [#####################---------------] 58% register dn to gms
Processing [########################------------] 66% create cn
Processing [###########################---------] 75% wait cn ready
Processing [##############################------] 83% create cdc containers
Processing [#################################---] 91% wait PolarDB-X ready
Processing [####################################] 100%
PolarDB-X cluster create successfully, you can try it out now.
Connect PolarDB-X using the following command:
mysql -h127.0.0.1 -P3992 -upolardbx_root -pdbkudfhk
Note: The password of the PolarDB-X administrator account is randomly generated and occurs only once. Please save it.
Description of PolarDB-X port occupancy:
In the current local test mode, the CN, DN, and GMS nodes each occupy a port, which is randomly generated. If the PolarDB-X fails to be created due to port conflicts, run the pxd cleanup
or pxd delete {cluster name}
command to clear and recreate the cluster.
(venv) IT-C02YW2EFLVDL:~ digoal$ pxd list
/Users/digoal/venv/lib/python3.9/site-packages/deployer
NAME CN DN CDC STATUS
pxc-tryout 1 1 1 running
To connect to the PolarDB-X cluster, the MySQL client should be in the CN node. So we can use the docker command line to connect to the PolarDB-X.
(venv) IT-C02YW2EFLVDL:~ digoal$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0ca5aa5c9f79 polardbx/galaxycdc:latest "/bin/sh -c /home/ad…" 4 minutes ago Up 4 minutes pxc-tryout-cdc-xxOD
68f05f5a3a4e polardbx/galaxysql:latest "/home/admin/entrypo…" 4 minutes ago Up 4 minutes 0.0.0.0:3992->3992/tcp pxc-tryout-cn-BRjf
e5eed057b92c polardbx/galaxyengine:latest "bash -c '/tools/xst…" 5 minutes ago Up 5 minutes 0.0.0.0:15151->15151/tcp pxc-tryout-dn-0-Cand-15151
c4dabe87a6de polardbx/galaxyengine:latest "bash -c '/tools/xst…" 6 minutes ago Up 6 minutes 0.0.0.0:17479->17479/tcp pxc-tryout-gms-Cand-17479
(venv) IT-C02YW2EFLVDL:~ digoal$ docker exec -it 68f05f5a3a4e mysql -h127.0.0.1 -P3992 -upolardbx_root -pdbkudfhk
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.6.29 Tddl Server (ALIBABA)
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]> select * from information_schema.schemata;
+--------------+--------------------+----------------------------+------------------------+----------+--------------------+
| CATALOG_NAME | SCHEMA_NAME | DEFAULT_CHARACTER_SET_NAME | DEFAULT_COLLATION_NAME | SQL_PATH | DEFAULT_ENCRYPTION |
+--------------+--------------------+----------------------------+------------------------+----------+--------------------+
| def | information_schema | utf8 | UTF8_GENERAL_CI | NULL | NO |
| def | __cdc__ | utf8 | UTF8_GENERAL_CI | NULL | NO |
+--------------+--------------------+----------------------------+------------------------+----------+--------------------+
2 rows in set (0.25 sec)
MySQL [(none)]> create database polarx_example partition_mode='partitioning';
Query OK, 1 row affected (0.38 sec)
MySQL [(none)]> use polarx_example;
Database changed
MySQL [polarx_example]> create table example (
-> `id` bigint(11) auto_increment NOT NULL,
-> `name` varchar(255) DEFAULT NULL,
-> `score` bigint(11) DEFAULT NULL,
-> primary key (`id`)
-> ) engine=InnoDB default charset=utf8
-> partition by hash(id)
-> partitions 8;
Query OK, 0 rows affected (1.13 sec)
MySQL [polarx_example]> insert into example values(null,'lily',375),(null,'lisa',400),(null,'ljh',500);
Query OK, 3 rows affected (0.06 sec)
MySQL [polarx_example]> select * from example;
+--------+------+-------+
| id | name | score |
+--------+------+-------+
| 100001 | lily | 375 |
| 100002 | lisa | 400 |
| 100003 | ljh | 500 |
+--------+------+-------+
3 rows in set (0.10 sec)
MySQL [polarx_example]> show topology from example;
+----+-----------------------------+--------------------+----------------+
| ID | GROUP_NAME | TABLE_NAME | PARTITION_NAME |
+----+-----------------------------+--------------------+----------------+
| 0 | POLARX_EXAMPLE_P00000_GROUP | example_AIex_00000 | p1 |
| 1 | POLARX_EXAMPLE_P00000_GROUP | example_AIex_00001 | p2 |
| 2 | POLARX_EXAMPLE_P00000_GROUP | example_AIex_00002 | p3 |
| 3 | POLARX_EXAMPLE_P00000_GROUP | example_AIex_00003 | p4 |
| 4 | POLARX_EXAMPLE_P00000_GROUP | example_AIex_00004 | p5 |
| 5 | POLARX_EXAMPLE_P00000_GROUP | example_AIex_00005 | p6 |
| 6 | POLARX_EXAMPLE_P00000_GROUP | example_AIex_00006 | p7 |
| 7 | POLARX_EXAMPLE_P00000_GROUP | example_AIex_00007 | p8 |
+----+-----------------------------+--------------------+----------------+
8 rows in set (0.01 sec)
MySQL [polarx_example]> show master status ;
+---------------+----------+--------------+------------------+-------------------+
| FILE | POSITION | BINLOG_DO_DB | BINLOG_IGNORE_DB | EXECUTED_GTID_SET |
+---------------+----------+--------------+------------------+-------------------+
| binlog.000001 | 8900 | | | |
+---------------+----------+--------------+------------------+-------------------+
1 row in set (0.87 sec)
MySQL [polarx_example]> show binlog events in 'binlog.000001' from 4;
+---------------+------+-------------+------------+-------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| LOG_NAME | POS | EVENT_TYPE | SERVER_ID | END_LOG_POS | INFO |
+---------------+------+-------------+------------+-------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| binlog.000001 | 4 | Format_desc | 2990132244 | 123 | Server ver: 5.6.29-PXC-5.4.13-20220621, Binlog ver: 4 |
| binlog.000001 | 123 | Rows_query | 2990132244 | 206 | CTS::696305156394215020814941167793901445120000000000469718 |
| binlog.000001 | 206 | Rows_query | 2990132244 | 289 | CTS::696305156476842809614941167802248110080000000000469718 |
| binlog.000001 | 289 | Rows_query | 2990132244 | 372 | CTS::696305156560728889614941167810678661120000000000469718 |
| binlog.000001 | 372 | Rows_query | 2990132244 | 455 | CTS::696305156650906425614941167819109212160000000000469718 |
| binlog.000001 | 455 | Rows_query | 2990132244 | 538 | CTS::696305156736050796814941167827455877120000000000469718 |
| binlog.000001 | 538 | Rows_query | 2990132244 | 621 | CTS::696305168964963539214941169051269898240000000000469718 |
| binlog.000001 | 621 | Rows_query | 2990132244 | 704 | CTS::696305169049688480014941169059658506240000000000469718 |
| binlog.000001 | 704 | Rows_query | 2990132244 | 787 | CTS::696305169134832851214941169068089057280000000000469718 |
| binlog.000001 | 787 | Rows_query | 2990132244 | 870 | CTS::696305169220396652814941169076477665280000000000469718 |
| binlog.000001 | 870 | Rows_query | 2990132244 | 953 | CTS::696305169302605011214941169084866273280000000000469718 |
| binlog.000001 | 953 | Rows_query | 2990132244 | 1036 | CTS::696305181541164652814941170308680294400000000000469718 |
| binlog.000001 | 1036 | Rows_query | 2990132244 | 1119 | CTS::696305181626728454414941170317068902400000000000469718 |
| binlog.000001 | 1119 | Rows_query | 2990132244 | 1202 | CTS::696305181709356243214941170325499453440000000000469718 |
| binlog.000001 | 1202 | Rows_query | 2990132244 | 1285 | CTS::696305181791564601614941170333846118400000000000469718 |
| binlog.000001 | 1285 | Rows_query | 2990132244 | 1368 | CTS::696305181876289542414941170342234726400000000000469718 |
| binlog.000001 | 1368 | Rows_query | 2990132244 | 1451 | CTS::696305194114429753614941171566090690560000000000469718 |
| binlog.000001 | 1451 | Rows_query | 2990132244 | 1534 | CTS::696305194198735264014941171574437355520000000000469718 |
| binlog.000001 | 1534 | Rows_query | 2990132244 | 1617 | CTS::696305194279685331214941171582867906560000000000469718 |
| binlog.000001 | 1617 | Rows_query | 2990132244 | 1700 | CTS::696305194362732550414941171591298457600000000000469718 |
| binlog.000001 | 1700 | Rows_query | 2990132244 | 1783 | CTS::696305194447457491214941171599603179520000000000469718 |
| binlog.000001 | 1783 | Rows_query | 2990132244 | 1866 | CTS::696305206769903212814941172831889694730000000000469718 |
| binlog.000001 | 1866 | Rows_query | 2990132244 | 1949 | CTS::696305206860080748814941172840320245760000000000469718 |
| binlog.000001 | 1949 | Rows_query | 2990132244 | 2032 | CTS::696305206941450246414941172848708853760000000000469718 |
| binlog.000001 | 2032 | Rows_query | 2990132244 | 2115 | CTS::696305207026175187214941172857097461760000000000469718 |
| binlog.000001 | 2115 | Rows_query | 2990132244 | 2198 | CTS::696305207104608672014941172865444126730000000000469718 |
| binlog.000001 | 2198 | Rows_query | 2990132244 | 2281 | CTS::696305219347782048014941174089342033920000000000469718 |
| binlog.000001 | 2281 | Rows_query | 2990132244 | 2364 | CTS::696305219431248697614941174097772584960000000000469718 |
| binlog.000001 | 2364 | Rows_query | 2990132244 | 2447 | CTS::696305219514295916814941174106119249920000000000469718 |
| binlog.000001 | 2447 | Rows_query | 2990132244 | 2530 | CTS::696305219597343136014941174114507857920000000000469718 |
| binlog.000001 | 2530 | Rows_query | 2990132244 | 2613 | CTS::696305219681229216014941174122854522890000000000469718 |
| binlog.000001 | 2613 | Rows_query | 2990132244 | 2696 | CTS::696305231929016326414941175347591290880000000000469718 |
| binlog.000001 | 2696 | Rows_query | 2990132244 | 2779 | CTS::696305232007449811214941175355854069770000000000469718 |
| binlog.000001 | 2779 | Rows_query | 2990132244 | 2862 | CTS::696305232106015955214941175364284620800000000000469718 |
| binlog.000001 | 2862 | Rows_query | 2990132244 | 2945 | CTS::696305232177319123214941175372673228800000000000469718 |
| binlog.000001 | 2945 | Rows_query | 2990132244 | 3028 | CTS::696305232262044064014941175381103779840000000000469718 |
| binlog.000001 | 3028 | Rows_query | 2990132244 | 3111 | CTS::696305244500184275214941176604917800960000000000469718 |
| binlog.000001 | 3111 | Rows_query | 2990132244 | 3194 | CTS::696305244587845228814941176613264465920000000000469718 |
| binlog.000001 | 3194 | Rows_query | 2990132244 | 3277 | CTS::696305244668795296014941176621611130890000000000469718 |
| binlog.000001 | 3277 | Rows_query | 2990132244 | 3360 | CTS::696305244754778528014941176630083624970000000000469718 |
| binlog.000001 | 3360 | Rows_query | 2990132244 | 3443 | CTS::696305244834050873614941176638430289920000000000469718 |
| binlog.000001 | 3443 | Rows_query | 2990132244 | 3526 | CTS::696305257072191084814941177862244311040000000000469718 |
| binlog.000001 | 3526 | Rows_query | 2990132244 | 3609 | CTS::696305257159432608014941177870674862080000000000469718 |
| binlog.000001 | 3609 | Rows_query | 2990132244 | 3692 | CTS::696305257241640966414941177879021527040000000000469718 |
| binlog.000001 | 3692 | Rows_query | 2990132244 | 3775 | CTS::696305257328043628814941177887452078080000000000469718 |
| binlog.000001 | 3775 | Rows_query | 2990132244 | 3858 | CTS::696305257412768569614941177895882629120000000000469718 |
| binlog.000001 | 3858 | Rows_query | 2990132244 | 3941 | CTS::696305269646714476814941179119570821120000000000469718 |
| binlog.000001 | 3941 | Rows_query | 2990132244 | 4024 | CTS::696305269736053152014941179127959429130000000000469718 |
| binlog.000001 | 4024 | Rows_query | 2990132244 | 4107 | CTS::696305269816164358414941179136348037120000000000469718 |
| binlog.000001 | 4107 | Rows_query | 2990132244 | 4190 | CTS::696305269899631008014941179144778588160000000000469718 |
| binlog.000001 | 4190 | Rows_query | 2990132244 | 4273 | CTS::696305269984355948814941179153167196160000000000469718 |
| binlog.000001 | 4273 | Rows_query | 2990132244 | 4356 | CTS::696305282220399008014941180377023160320000000000469718 |
| binlog.000001 | 4356 | Rows_query | 2990132244 | 4439 | CTS::696305282307640531214941180385411768320000000000469718 |
| binlog.000001 | 4439 | Rows_query | 2990132244 | 4522 | CTS::696305282386074016014941180393758433280000000000469718 |
| binlog.000001 | 4522 | Rows_query | 2990132244 | 4605 | CTS::696305282469960096014941180402147041280000000000469718 |
| binlog.000001 | 4605 | Rows_query | 2990132244 | 4688 | CTS::696305282558459910414941180410577592320000000000469718 |
| binlog.000001 | 4688 | Rows_query | 2990132244 | 4771 | CTS::696305294791986387214941181634265784330000000000469718 |
| binlog.000001 | 4771 | Rows_query | 2990132244 | 4854 | CTS::696305294882163923214941181642654392330000000000469718 |
| binlog.000001 | 4854 | Rows_query | 2990132244 | 4937 | CTS::696305294963533420814941181651126886400000000000469718 |
| binlog.000001 | 4937 | Rows_query | 2990132244 | 5020 | CTS::696305295053291526414941181659431608330000000000469718 |
| binlog.000001 | 5020 | Rows_query | 2990132244 | 5103 | CTS::696305295150179948814941181667862159360000000000469718 |
| binlog.000001 | 5103 | Rows_query | 2990132244 | 5186 | CTS::696305307371962374414941182891802009600000000000469718 |
| binlog.000001 | 5186 | Rows_query | 2990132244 | 5269 | CTS::696305307456687315214941182900106731520000000000469718 |
| binlog.000001 | 5269 | Rows_query | 2990132244 | 5352 | CTS::696305307535120800014941182908453396490000000000469718 |
| binlog.000001 | 5352 | Rows_query | 2990132244 | 5435 | CTS::696305307619426310414941182916925890570000000000469718 |
| binlog.000001 | 5435 | Rows_query | 2990132244 | 5518 | CTS::696305307703312390414941182925272555520000000000469718 |
| binlog.000001 | 5518 | Rows_query | 2990132244 | 5601 | CTS::696305319940613740814941184149086576650000000000469718 |
| binlog.000001 | 5601 | Rows_query | 2990132244 | 5684 | CTS::696305320025758112014941184157517127680000000000469718 |
| binlog.000001 | 5684 | Rows_query | 2990132244 | 5767 | CTS::696305320111741344014941184165905735680000000000469718 |
| binlog.000001 | 5767 | Rows_query | 2990132244 | 5850 | CTS::696305320192691411214941184174252400650000000000469718 |
| binlog.000001 | 5850 | Rows_query | 2990132244 | 5933 | CTS::696305320278255212814941184182724894720000000000469718 |
| binlog.000001 | 5933 | Rows_query | 2990132244 | 6016 | CTS::696305332599862073614941185414885580800000000000469718 |
| binlog.000001 | 6016 | Rows_query | 2990132244 | 6099 | CTS::696305332682489862414941185423274188810000000000469718 |
| binlog.000001 | 6099 | Rows_query | 2990132244 | 6182 | CTS::696305332778119993614941185431704739840000000000469718 |
| binlog.000001 | 6182 | Rows_query | 2990132244 | 6265 | CTS::696305332849423161614941185440051404800000000000469718 |
| binlog.000001 | 6265 | Query | 2990132244 | 6558 | # POLARX_ORIGIN_SQL=CREATE DATABASE polarx_example MODE 'partitioning'
# POLARX_TSO=696305338377515833614941185991141007360000000000000000
CREATE DATABASE polarx_example CHARACTER SET utf8mb4 |
| binlog.000001 | 6558 | Rows_query | 2990132244 | 6641 | CTS::696305338377515833614941185991141007360000000000000000 |
| binlog.000001 | 6641 | Query | 2990132244 | 7311 | # POLARX_ORIGIN_SQL=CREATE TABLE example ( `id` bigint(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) DEFAULT NULL, `score` bigint(11) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8 PARTITION BY HASH (id) PARTITIONS 8
# POLARX_TSO=696305344376628844814941186592688087040000000000000000
create table example ( `id` bigint(11) not null auto_increment, `name` varchar(255) default null, `score` bigint(11) default null, primary key (`id`) ) engine = innodb default charset = utf8 default character set = utf8 default collate = utf8_general_ci |
| binlog.000001 | 7311 | Rows_query | 2990132244 | 7394 | CTS::696305344376628844814941186592688087040000000000000000 |
| binlog.000001 | 7394 | Rows_query | 2990132244 | 7477 | CTS::696305345174804896014941186672254033920000000000469718 |
| binlog.000001 | 7477 | Rows_query | 2990132244 | 7560 | CTS::696305345260368697614941186680642641920000000000469718 |
| binlog.000001 | 7560 | Rows_query | 2990132244 | 7643 | CTS::696305345340060473614941186688989306880000000000469718 |
| binlog.000001 | 7643 | Rows_query | 2990132244 | 7726 | CTS::696305345428560288014941186697419857920000000000469718 |
| binlog.000001 | 7726 | Rows_query | 2990132244 | 7809 | CTS::696305345511188076814941186705850408960000000000469718 |
| binlog.000001 | 7809 | Query | 2990132244 | 7872 | BEGIN |
| binlog.000001 | 7872 | Rows_query | 2990132244 | 7937 | /*DRDS /127.0.0.1/14bc2d04ff401000/1// */ |
| binlog.000001 | 7937 | Table_map | 2990132244 | 8001 | table_id: 1 (polarx_example.example) |
| binlog.000001 | 8001 | Write_rows | 2990132244 | 8059 | table_id: 1 flags: STMT_END_F |
| binlog.000001 | 8059 | Xid | 2990132244 | 8090 | COMMIT /* xid=1 */ |
| binlog.000001 | 8090 | Rows_query | 2990132244 | 8173 | CTS::696305346014085126414941186756140113920000000001469718 |
| binlog.000001 | 8173 | Query | 2990132244 | 8236 | BEGIN |
| binlog.000001 | 8236 | Rows_query | 2990132244 | 8301 | /*DRDS /127.0.0.1/14bc2d04ff401000/1// */ |
| binlog.000001 | 8301 | Table_map | 2990132244 | 8365 | table_id: 1 (polarx_example.example) |
| binlog.000001 | 8365 | Write_rows | 2990132244 | 8423 | table_id: 1 flags: STMT_END_F |
| binlog.000001 | 8423 | Xid | 2990132244 | 8454 | COMMIT /* xid=2 */ |
| binlog.000001 | 8454 | Rows_query | 2990132244 | 8537 | CTS::696305346014085126414941186756140113920000000002469718 |
| binlog.000001 | 8537 | Query | 2990132244 | 8600 | BEGIN |
| binlog.000001 | 8600 | Rows_query | 2990132244 | 8665 | /*DRDS /127.0.0.1/14bc2d04ff401000/1// */ |
| binlog.000001 | 8665 | Table_map | 2990132244 | 8729 | table_id: 1 (polarx_example.example) |
| binlog.000001 | 8729 | Write_rows | 2990132244 | 8786 | table_id: 1 flags: STMT_END_F |
| binlog.000001 | 8786 | Xid | 2990132244 | 8817 | COMMIT /* xid=3 */ |
| binlog.000001 | 8817 | Rows_query | 2990132244 | 8900 | CTS::696305346014085126414941186756140113920000000003469718 |
+---------------+------+-------------+------------+-------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
102 rows in set (0.44 sec)
MySQL [polarx_example]> show storage ;
+-----------------+------------------+------------+-----------+----------+-------------+--------+-----------+-------+--------+
| STORAGE_INST_ID | LEADER_NODE | IS_HEALTHY | INST_KIND | DB_COUNT | GROUP_COUNT | STATUS | DELETABLE | DELAY | ACTIVE |
+-----------------+------------------+------------+-----------+----------+-------------+--------+-----------+-------+--------+
| pxc-tryout-dn-0 | 172.17.0.3:15151 | true | MASTER | 2 | 3 | 0 | false | null | null |
| pxc-tryout-gms | 172.17.0.2:17479 | true | META_DB | 2 | 2 | 0 | false | null | null |
+-----------------+------------------+------------+-----------+----------+-------------+--------+-----------+-------+--------+
2 rows in set (0.01 sec)
MySQL [polarx_example]> show mpp ;
+------------+-----------------+------+--------+
| ID | NODE | ROLE | LEADER |
+------------+-----------------+------+--------+
| pxc-tryout | 172.17.0.4:3994 | W | Y |
+------------+-----------------+------+--------+
1 row in set (0.00 sec)
Instructions:
# Check GMS
select * from information_schema.schemata;
# Create a partitioned table
create database polarx_example partition_mode='partitioning';
use polarx_example;
create table example (
`id` bigint(11) auto_increment NOT NULL,
`name` varchar(255) DEFAULT NULL,
`score` bigint(11) DEFAULT NULL,
primary key (`id`)
) engine=InnoDB default charset=utf8
partition by hash(id)
partitions 8;
insert into example values(null,'lily',375),(null,'lisa',400),(null,'ljh',500);
select * from example;
show topology from example;
# Check CDC
show master status ;
show binlog events in 'binlog.000001' from 4;
# Check DN and CN
show storage ;
show mpp ;
Run the following command to view the list of PolarDB-X in the current environment:
pxd list
Run the following command to clean up all PolarDB-X in the local environment:
pxd cleanup
Run the following command to view more instructions and usage of PXD:
pxd --help
Use Docker to connect to the container and view the logs of the corresponding service.
(venv) IT-C02YW2EFLVDL:~ digoal$ docker exec -it 53ef61b59653 bash
[admin@53ef61b59653 ~]$
[admin@53ef61b59653 ~]$ ls
bin drds-server entrypoint.sh tools
[admin@53ef61b59653 ~]$ cd drds-server/
[admin@53ef61b59653 drds-server]$ ls
bin conf lib logs spill
[admin@53ef61b59653 drds-server]$ cd logs
[admin@53ef61b59653 logs]$ ls
__cdc__ polardbx tddl
[admin@53ef61b59653 logs]$ cd tddl
[admin@53ef61b59653 tddl]$ ls
check-ha.log ddl-meta.log event.log gc.log.0 gc.log.2 gc.log.4 rpc.log tddl-console.log tddl-executor.log tddl-sequence.log trans.log XPerf.log
ddl.log ddl-stats.log gc.log gc.log.1 gc.log.3 meta-db.log start-up.log tddl-dynamic.log tddl.log tddl-stat.log XLog.log XRequest.log
You can also use configuration files to deploy PolarDB-X.
vi ~/px.yaml
version: v1
type: polardbx
cluster:
name: pxc_test
gms:
image: polardbx/galaxyengine:latest
host_group: [127.0.0.1]
cn:
image: polardbx/galaxysql:latest
replica: 1
nodes:
- host: 127.0.0.1
resources:
mem_limit: 2G
dn:
image: polardbx/galaxyengine:latest
replica: 1
nodes:
- host_group: [127.0.0.1]
resources:
mem_limit: 2G
cdc:
image: polardbx/galaxycdc:latest
replica: 1
nodes:
- host: 127.0.0.1
resources:
mem_limit: 2G
pxd cleanup
pxd create -file ~/px.yaml
Stop containers
docker stop 70a7c08f943a e39532b652bc 9cad34440635 572f97117552
Start the containers in the reverse order of creation: DSM, DN, CN, CDC. Additionally, please note that the IP of the local container will change, but following the specified order will ensure that the IP remains unchanged.
(venv) IT-C02YW2EFLVDL:~ digoal$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8de91f7d2adc polardbx/galaxycdc:latest "/bin/sh -c /home/ad…" 4 seconds ago Up 3 seconds pxc_test-cdc-lboQ
3e606d60db97 polardbx/galaxysql:latest "/home/admin/entrypo…" 4 seconds ago Up 3 seconds 0.0.0.0:5425->5425/tcp pxc_test-cn-Fach
51c4fe463fa2 polardbx/galaxyengine:latest "bash -c '/tools/xst…" 47 seconds ago Up 46 seconds 0.0.0.0:15321->15321/tcp pxc_test-dn-0-Cand-15321
af6766bcc723 polardbx/galaxyengine:latest "bash -c '/tools/xst…" About a minute ago Up About a minute 0.0.0.0:14376->14376/tcp pxc_test-gms-Cand-14376
(venv) IT-C02YW2EFLVDL:~ digoal$ docker inspect af6766bcc723|grep IPAddre
"SecondaryIPAddresses": null,
"IPAddress": "172.17.0.2",
"IPAddress": "172.17.0.2",
(venv) IT-C02YW2EFLVDL:~ digoal$ docker inspect 51c4fe463fa2|grep IPAddre
"SecondaryIPAddresses": null,
"IPAddress": "172.17.0.3",
"IPAddress": "172.17.0.3",
(venv) IT-C02YW2EFLVDL:~ digoal$ docker inspect 3e606d60db97|grep IPAddre
"SecondaryIPAddresses": null,
"IPAddress": "172.17.0.4",
"IPAddress": "172.17.0.4",
(venv) IT-C02YW2EFLVDL:~ digoal$ docker inspect 8de91f7d2adc|grep IPAddre
"SecondaryIPAddresses": null,
"IPAddress": "172.17.0.5",
"IPAddress": "172.17.0.5",
docker start af6766bcc723
docker start 51c4fe463fa2
docker start 3e606d60db97
docker start 8de91f7d2adc
Check again after startup to see if the IP is the same as when it was created.
(venv) IT-C02YW2EFLVDL:~ digoal$ docker inspect af6766bcc723|grep IPAddre
"SecondaryIPAddresses": null,
"IPAddress": "172.17.0.2",
"IPAddress": "172.17.0.2",
(venv) IT-C02YW2EFLVDL:~ digoal$ docker inspect 51c4fe463fa2|grep IPAddre
"SecondaryIPAddresses": null,
"IPAddress": "172.17.0.3",
"IPAddress": "172.17.0.3",
(venv) IT-C02YW2EFLVDL:~ digoal$ docker inspect 3e606d60db97|grep IPAddre
"SecondaryIPAddresses": null,
"IPAddress": "172.17.0.4",
"IPAddress": "172.17.0.4",
(venv) IT-C02YW2EFLVDL:~ digoal$ docker inspect 8de91f7d2adc|grep IPAddre
"SecondaryIPAddresses": null,
"IPAddress": "172.17.0.5",
"IPAddress": "172.17.0.5",
View container configurations
docker inspect e39532b652bc
Enter the container command line environment
docker exec -it e39532b652bc bash
View container running logs
docker logs -t --since 30m e39532b652bc
Command syntax:
$ docker logs [OPTIONS] CONTAINER
Options:
--details Show more information.
-f, --follow Trace real-time logs.
--since string Display the logs that are generated since a timestamp, or a relative time, such as 42m (42 minutes).
--tail string Display the number of lines of a log from the end of the log. The default value is all.
-t, --timestamps Display the timestamp.
--until string Display the logs that are generated before a timestamp, or a relative time, such as 42m (42 minutes)
Sample:
View logs after a specified time, showing only the last 100 lines:
$ docker logs -f -t --since="2018-02-08" --tail=100 CONTAINER_ID
View logs for the last 30 minutes:
$ docker logs --since 30m CONTAINER_ID
View logs after a certain time:
$ docker logs -t --since="2018-02-08T13:23:37" CONTAINER_ID
View logs of a specified time period:
$ docker logs -t --since="2018-02-08T13:23:37" --until "2018-02-09T12:23:37" CONTAINER_ID
Using PostgreSQL Recursive SQL and the PL/pgSQL Function to Draw Fractal Graphs
ApsaraDB - December 21, 2022
ApsaraDB - June 19, 2024
digoal - October 10, 2023
ApsaraDB - January 3, 2024
ApsaraDB - June 19, 2024
ApsaraDB - March 27, 2024
Alibaba Cloud PolarDB for PostgreSQL is an in-house relational database service 100% compatible with PostgreSQL and highly compatible with the Oracle syntax.
Learn MoreAlibaba Cloud PolarDB for Xscale (PolarDB-X) is a cloud-native high-performance distributed database service independently developed by Alibaba Cloud.
Learn MoreAn online MPP warehousing service based on the Greenplum Database open source program
Learn MoreAccelerate software development and delivery by integrating DevOps with the cloud
Learn MoreMore Posts by digoal