1 安装python3,创建并激活虚拟环境,升级PIP
yum install python3
[root@my_ob ~]# python3 -m venv venv
[root@my_ob ~]# source venv/bin/activate
(venv) [root@my_ob ~]#
(venv) [root@my_ob ~]# pip install --upgrade pip
Collecting pip
Downloading
https://files.pythonhosted.org/packages/a4/6d/6463d49a933f547439d6b5b98b46af8742cc03ae83543e4d7688c2420f8b/pip-21.3.1-py3-none-any.whl
(1.7MB)
100% |████████████████████████████████| 1.7MB 59kB/s
Installing collected packages: pip
Found existing installation: pip 9.0.3
Uninstalling pip-9.0.3:
Successfully uninstalled pip-9.0.3
Successfully installed pip-21.3.1
You are using pip version 21.3.1, however version 22.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
2 安装PXD
(venv) [root@my_ob ~]# pip install pxd
Collecting pxd
Downloading pxd-0.3.0-py3-none-any.whl (56 kB)
|████████████████████████████████| 56 kB 237 kB/s
Collecting PyYAML==5.4.1
Downloading PyYAML-5.4.1-cp36-cp36m-manylinux1_x86_64.whl (640 kB)
|████████████████████████████████| 640 kB 33 kB/s
Collecting humanfriendly==10.0
Downloading humanfriendly-10.0-py2.py3-none-any.whl (86 kB)
|████████████████████████████████| 86 kB 50 kB/s
Collecting requests==2.26.0
Downloading requests-2.26.0-py2.py3-none-any.whl (62 kB)
|████████████████████████████████| 62 kB 24 kB/s
Collecting idna==3.2
Downloading idna-3.2-py3-none-any.whl (59 kB)
|████████████████████████████████| 59 kB 32 kB/s
Collecting urllib3==1.26.6
Downloading urllib3-1.26.6-py2.py3-none-any.whl (138 kB)
|████████████████████████████████| 138 kB 38 kB/s
Collecting retrying==1.3.3
Downloading retrying-1.3.3.tar.gz (10 kB)
Preparing metadata (setup.py) ... done
Collecting certifi==2021.5.30
Downloading certifi-2021.5.30-py2.py3-none-any.whl (145 kB)
|████████████████████████████████| 145 kB 23 kB/s
Collecting six==1.16.0
Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting click==8.0.1
Downloading click-8.0.1-py3-none-any.whl (97 kB)
|████████████████████████████████| 97 kB 41 kB/s
Collecting PyMySQL==1.0.2
Downloading PyMySQL-1.0.2-py3-none-any.whl (43 kB)
|████████████████████████████████| 43 kB 48 kB/s
Collecting websocket-client==1.2.1
Downloading websocket_client-1.2.1-py2.py3-none-any.whl (52 kB)
|████████████████████████████████| 52 kB 56 kB/s
Collecting spurplus==2.3.4
Downloading spurplus-2.3.4.tar.gz (20 kB)
Preparing metadata (setup.py) ... done
Collecting docker==5.0.0
Downloading docker-5.0.0-py2.py3-none-any.whl (146 kB)
|████████████████████████████████| 146 kB 31 kB/s
Collecting colorama==0.4.4
Downloading colorama-0.4.4-py2.py3-none-any.whl (16 kB)
Collecting charset-normalizer==2.0.4
Downloading charset_normalizer-2.0.4-py3-none-any.whl (36 kB)
Collecting pycryptodomex==3.10.1
Downloading pycryptodomex-3.10.1-cp35-abi3-manylinux2010_x86_64.whl (1.9 MB)
|████████████████████████████████| 1.9 MB 50 kB/s
Collecting importlib-metadata
Downloading importlib_metadata-4.8.3-py3-none-any.whl (17 kB)
Collecting spur==0.3.20
Downloading spur-0.3.20-py2.py3-none-any.whl (18 kB)
Collecting typing_extensions>=3.6.2.1
Downloading typing_extensions-4.1.1-py3-none-any.whl (26 kB)
Collecting icontract<3,>=2.0.1
Downloading icontract-2.6.1.tar.gz (36 kB)
Preparing metadata (setup.py) ... done
Collecting temppathlib<2,>=1.0.3
Downloading temppathlib-1.2.0.tar.gz (6.3 kB)
Preparing metadata (setup.py) ... done
Collecting paramiko<3,>=1.13.1
Downloading paramiko-2.11.0-py2.py3-none-any.whl (212 kB)
|████████████████████████████████| 212 kB 39 kB/s
Collecting asttokens<3,>=2
Downloading asttokens-2.0.5-py2.py3-none-any.whl (20 kB)
Collecting zipp>=0.5
Downloading zipp-3.6.0-py3-none-any.whl (5.3 kB)
Collecting pynacl>=1.0.1
Downloading PyNaCl-1.5.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB)
|████████████████████████████████| 1.1 MB 54 kB/s
Collecting bcrypt>=3.1.3
Downloading bcrypt-3.2.2-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (61 kB)
|████████████████████████████████| 61 kB 95 kB/s
Collecting cryptography>=2.5
Downloading cryptography-37.0.2-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.1 MB)
|████████████████████████████████| 4.1 MB 81 kB/s
Collecting cffi>=1.1
Downloading cffi-1.15.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (405 kB)
|████████████████████████████████| 405 kB 60 kB/s
Collecting pycparser
Downloading pycparser-2.21-py2.py3-none-any.whl (118 kB)
|████████████████████████████████| 118 kB 77 kB/s
Using legacy 'setup.py install' for retrying, since package 'wheel' is not installed.
Using legacy 'setup.py install' for spurplus, since package 'wheel' is not installed.
Using legacy 'setup.py install' for icontract, since package 'wheel' is not installed.
Using legacy 'setup.py install' for temppathlib, since package 'wheel' is not installed.
Installing collected packages: pycparser, cffi, six, pynacl, cryptography, bcrypt, zipp, urllib3, typing-extensions, paramiko, idna, charset-normalizer, certifi, asttokens, websocket-client, temppathlib, spur, requests, importlib-metadata, icontract, spurplus, retrying, PyYAML, PyMySQL, pycryptodomex, humanfriendly, docker, colorama, click, pxd
Running setup.py install for temppathlib ... done
Running setup.py install for icontract ... done
Running setup.py install for spurplus ... done
Running setup.py install for retrying ... done
Successfully installed PyMySQL-1.0.2 PyYAML-5.4.1 asttokens-2.0.5 bcrypt-3.2.2 certifi-2021.5.30 cffi-1.15.0 charset-normalizer-2.0.4 click-8.0.1 colorama-0.4.4 cryptography-37.0.2 docker-5.0.0 humanfriendly-10.0 icontract-2.6.1 idna-3.2 importlib-metadata-4.8.3 paramiko-2.11.0 pxd-0.3.0 pycparser-2.21 pycryptodomex-3.10.1 pynacl-1.5.0 requests-2.26.0 retrying-1.3.3 six-1.16.0 spur-0.3.20 spurplus-2.3.4 temppathlib-1.2.0 typing-extensions-4.1.1 urllib3-1.26.6 websocket-client-1.2.1 zipp-3.6.0
3 启动docker,创建集群
(venv) [root@my_ob ~]# systemctl start docker
(venv) [root@my_ob ~]#pxd tryout
Status: Downloaded newer image for docker.io/polardbx/xstore-tools:latest
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 -P4657 -upolardbx_root -prrGOnPmp
创建集群的步骤是先下载镜像,然后创建节点,最后输出连接方式及密码,密码只在这里显示一次,需要记住。
4 连接集群,检查各个节点的情况
(venv) [root@my_ob ~]# obclient -h 127.0.0.1 -P4657 -upolardbx_root -prrGOnPmp
Welcome to the OceanBase. 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.
1) 检查GMS
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.136 sec)
2)创建数据库
MySQL [(none)]> create database polarx_example partition_mode='partitioning';
Query OK, 1 row affected (0.800 sec)
MySQL [(none)]> use polarx_example;
Database changed
3) 创建表,insert数据
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 (5.720 sec)
MySQL [polarx_example]> insert into example values(null,'lily',375),(null,'lisa',400),(null,'ljh',500);
Query OK, 3 rows affected (0.139 sec)
4) 查看数据及拓扑
MySQL [polarx_example]> select * from example;
+--------+------+-------+
| id | name | score |
+--------+------+-------+
| 100001 | lily | 375 |
| 100002 | lisa | 400 |
| 100003 | ljh | 500 |
+--------+------+-------+
3 rows in set (0.078 sec)
MySQL [polarx_example]> show topology from example;
+----+-----------------------------+--------------------+----------------+
| ID | GROUP_NAME | TABLE_NAME | PARTITION_NAME |
+----+-----------------------------+--------------------+----------------+
| 0 | POLARX_EXAMPLE_P00000_GROUP | example_jVt5_00000 | p1 |
| 1 | POLARX_EXAMPLE_P00000_GROUP | example_jVt5_00001 | p2 |
| 2 | POLARX_EXAMPLE_P00000_GROUP | example_jVt5_00002 | p3 |
| 3 | POLARX_EXAMPLE_P00000_GROUP | example_jVt5_00003 | p4 |
| 4 | POLARX_EXAMPLE_P00000_GROUP | example_jVt5_00004 | p5 |
| 5 | POLARX_EXAMPLE_P00000_GROUP | example_jVt5_00005 | p6 |
| 6 | POLARX_EXAMPLE_P00000_GROUP | example_jVt5_00006 | p7 |
| 7 | POLARX_EXAMPLE_P00000_GROUP | example_jVt5_00007 | p8 |
+----+-----------------------------+--------------------+----------------+
8 rows in set (0.009 sec)
5)检查CDC
MySQL [polarx_example]> show master status ;
+---------------+----------+--------------+------------------+-------------------+
| FILE | POSITION | BINLOG_DO_DB | BINLOG_IGNORE_DB | EXECUTED_GTID_SET |
+---------------+----------+--------------+------------------+-------------------+
| binlog.000001 | 7658 | | | |
+---------------+----------+--------------+------------------+-------------------+
1 row in set (0.913 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 | 1275453311 | 123 | Server ver: 5.6.29-PXC-5.4.13-16534775, Binlog ver: 4 |
| binlog.000001 | 123 | Rows_query | 1275453311 | 206 | CTS::693756915409433401614686343691690352640000000000469718 |
| binlog.000001 | 206 | Rows_query | 1275453311 | 289 | CTS::693756915512613280014686343702847201280000000000469718 |
|
| binlog.000001 | 2032 | Rows_query | 1275453311 | 2115 | CTS::693756966040554707214686348756647976960000000000469718 |
| binlog.000001 | 2115 | Rows_query | 1275453311 | 2198 | CTS::693756966100113824014686348763149148160000000000469718 |
| binlog.000001 | 2198 | Rows_query | 1275453311 | 2281 | CTS::693756978300505299214686349982643036170000000000469718 |
| binlog.000001 | 2281 | Rows_query | 1275453311 | 2364 | CTS::693756978385649670414686349989437808640000000000469718 |
| binlog.000001 | 2364 | Rows_query | 1275453311 | 2447 | CTS::693756978450661382414686349998581391360000000000469718 |
| binlog.000001 | 2447 | Rows_query | 1275453311 | 2530 | CTS::693756978513995372814686350004830904330000000000469718 |
| binlog.000001 | 2530 | Rows_query | 1275453311 | 2613 | CTS::693756978601236896014686350011374018560000000000469718 |
| binlog.000001 | 2613 | Rows_query | 1275453311 | 2696 | CTS::693756978669184620814686350020265943040000000000469718 |
| binlog.000001 | 2696 | Query | 1275453311 | 2989 | # POLARX_ORIGIN_SQL=CREATE DATABASE polarx_example MODE 'partitioning'
# POLARX_TSO=693756986400545184014686350788788264960000000000000000
CREATE DATABASE polarx_example CHARACTER SET utf8mb4 |
| binlog.000001 | 2989 | Rows_query | 1275453311 | 3072 | CTS::693756986400545184014686350788788264960000000000000000 |
| binlog.000001 | 3072 | Rows_query | 1275453311 | 3155 | CTS::693756990871673248014686351240850350090000000000469718 |
| binlog.000001 | 3155 | Rows_query | 1275453311 | 3238 | CTS::693756990955139897614686351248777584640000000000469718 |
| binlog.000001 | 3238 | Rows_query | 1275453311 | 3321 | CTS::693756991072580409614686351259053629440000000000469718 |
| binlog.000001 | 3321 | Rows_query | 1275453311 | 3404 | CTS::693756991146819590414686351266351718400000000000469718 |
| binlog.000001 | 3902 | Query | 1275453311 | 4572 | # 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=693757008319977888014686352979305472000000000000000000
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 | 4572 | Rows_query | 1275453311 | 4655 | CTS::693757008319977888014686352979305472000000000000000000
| binlog.000001 | 5050 | Rows_query | 1275453311 | 5116 | /*DRDS /172.17.0.1/1461a428ddc01000/1// */ |
| binlog.000001 | 5116 | Table_map | 1275453311 | 5180 | table_id: 1 (polarx_example.example) |
| binlog.000001 | 5180 | Write_rows | 1275453311 | 5238 | table_id: 1 flags: STMT_END_F |
| binlog.000001 | 5238 | Xid | 1275453311 | 5269 | COMMIT /* xid=1 */ |
| binlog.000001 | 5269 | Rows_query | 1275453311 | 5352 | CTS::693757023314195257614686354485438095360000000001469718 |
| binlog.000001 | 5352 | Query | 1275453311 | 5415 | BEGIN |
| binlog.000001 | 5415 | Rows_query | 1275453311 | 5481 | /*DRDS /172.17.0.1/1461a428ddc01000/1// */ |
| binlog.000001 | 5481 | Table_map | 1275453311 | 5545 | table_id: 1 (polarx_example.example) |
| binlog.000001 | 5545 | Write_rows | 1275453311 | 5603 | table_id: 1 flags: STMT_END_F |
| binlog.000001 | 5603 | Xid | 1275453311 | 5634 | COMMIT /* xid=2 */ |
| binlog.000001 | 5634 | Rows_query | 1275453311 | 5717 | CTS::693757023363688044814686354488374108170000000001469718 |
| binlog.000001 | 5717 | Query | 1275453311 | 5780 | BEGIN |
| binlog.000001 | 5780 | Rows_query | 1275453311 | 5846 | /*DRDS /172.17.0.1/1461a428ddc01000/1// */ |
| binlog.000001 | 5846 | Table_map | 1275453311 | 5910 | table_id: 1 (polarx_example.example) |
| binlog.000001 | 5910 | Write_rows | 1275453311 | 5967 | table_id: 1 flags: STMT_END_F |
| binlog.000001 | 5967 | Xid | 1275453311 | 5998 | COMMIT /* xid=3 */ |
| binlog.000001 | 5998 | Rows_query | 1275453311 | 6081 | CTS::693757023363688044814686354488374108170000000002469718 |
| binlog.000001 | 6081 | Rows_query | 1275453311 | 6164 | CTS::693757028633411590414686355015304519680000000000469718 |
87 rows in set (0.412 sec)
6) 检查DN
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:14508 | true | MASTER | 2 | 3 | 0 | false | null | null |
| pxc-tryout-gms | 172.17.0.2:17077 | true | META_DB | 2 | 2 | 0 | false | null | null |
+-----------------+------------------+------------+-----------+----------+-------------+--------+-----------+-------+--------+
2 rows in set (0.014 sec)
7)检查CN
MySQL [polarx_example]> show mpp ;
+------------+-----------------+------+--------+
| ID | NODE | ROLE | LEADER |
+------------+-----------------+------+--------+
| pxc-tryout | 172.17.0.4:4659 | W | Y |
+------------+-----------------+------+--------+
1 row in set (0.008 sec)
8)查看语句的执行计划
MySQL [polarx_example]> explain select * from example;
+----------------------------------------------------------------------------------------------------------------------------------------+
| LOGICAL EXECUTIONPLAN |
+----------------------------------------------------------------------------------------------------------------------------------------+
| Gather(concurrent=true) |
| LogicalView(tables="example[p1,p2,p3,p4,p5,p6,p7,p8]", shardCount=8, sql="SELECT `id`, `name`, `score` FROM `example` AS `example`") |
| HitCache:true |
| Source:PLAN_CACHE |
| TemplateId: bdbc4fb8 |
+----------------------------------------------------------------------------------------------------------------------------------------+
5 rows in set (0.049 sec)
5 检查下载的映像
(venv) [root@my_ob ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/polardbx/galaxysql latest 78c86515c06f 4 days ago 948 MB
docker.io/polardbx/galaxycdc latest 943a6731feb0 12 days ago 905 MB
docker.io/polardbx/galaxyengine latest 2b35a63ba00a 5 weeks ago 2.11 GB
docker.io/polardbx/xstore-tools latest b5e066e144eb 7 weeks ago 2.69 MB
docker.io/polardbx/polardbx-init latest af4828b6797e 7 weeks ago 6.58 MB
6 检查运行的容器
(venv) [root@my_ob ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2fa39a46f4b6 polardbx/galaxycdc:latest "/bin/sh -c /home/..." 14 minutes ago Up 14 minutes pxc-tryout-cdc-LJhR
b4b29949a075 polardbx/galaxysql:latest "/home/admin/entry..." 14 minutes ago Up 14 minutes 0.0.0.0:4657->4657/tcp pxc-tryout-cn-bLzM
1bd0be8eb646 polardbx/galaxyengine:latest "bash -c '/tools/x..." 15 minutes ago Up 15 minutes 0.0.0.0:14508->14508/tcp pxc-tryout-dn-0-Cand-14508
e930288c581c polardbx/galaxyengine:latest "bash -c '/tools/x..." 17 minutes ago Up 17 minutes 0.0.0.0:17077->17077/tcp pxc-tryout-gms-Cand-17077
从名字来看,dn、cn、cdc、gms每个节点都是一个容器。