pxd 0.7.1
This is a tool to download and install PolarDB-X

# What is pxd?

pxd(polardbx-deployer) is a tool to deploy [PolarDB-X](https://help.aliyun.com/product/29657.html).

# Install

Run command:

```
pip install pxd
```

More details see: [Quick Start](https://github.com/ApsaraDB/galaxysql/blob/main/docs/en/quickstart.md)

# Usage

## Create PolarDB-X for tryout

Create a default cluster(1 GMS, 1 DN, 1 CN, 1 CDC) for tryout on your local machine:

```
pxd tryout
```
You can specify cn and dn version using the following options:

```
Options:
  -name TEXT            PolarDB-X Cluster name, default: pxc-tryout
  -cn_replica INTEGER   cn node count
  -cn_version TEXT      cn node version
  -dn_replica INTEGER   dn node count
  -dn_version TEXT      dn node version
  -cdc_replica INTEGER  cdc node count
  -cdc_version TEXT     cdc node version
  -leader_only BOOLEAN  create gms and dn with single node by default,
                        otherwise a x-paxos cluster

  --help                Show this message and exit.
```

If you want to create gms and dn with a x-paxos cluster, using the following command:

```
pxd tryout -leader_only false
```

## Create PolarDB-X for cluster mode

```
pxd create -file cluster.yaml
```

Following is an example of cluster.yaml

```
version: v1
type: polardbx
cluster:
  name: pxc_test
  gms:
    image: polardbx/galaxyengine:latest
    host_group: [10.168.0.37]
    resources:
      mem_limit: 2G
  cn:
    image: polardbx/galaxysql:latest
    replica: 3
    nodes:
      - host: 10.168.0.37
      - host: 10.168.0.38
      - host: 10.168.0.39
    resources:
      mem_limit: 4G
  dn:
    image: polardbx/galaxyengine:latest
    replica: 2
    nodes:
      - host_group: [10.168.0.38]
      - host_group: [10.168.0.39]
    resources:
      mem_limit: 4G
  cdc:
    image: polardbx/galaxycdc:latest
    replica: 3
    nodes:
      - host: 10.168.0.37
      - host: 10.168.0.38
      - host: 10.168.0.39
    resources:
      mem_limit: 4G
```

* version: topology version, default v1
* type: cluster type, polardbx
* cluster.name：The name of PolarDB-X cluster
* cluster.gms.image: docker image of gms, default is the latest
* cluster.gms.host_group: gms ip list. If set three ips, it will create a x-paxos cluster
* cluster.cn
    * image: docker image of cn, default is the latest
    * replica: cn node count
    * nodes: list, cn node hosts
    * resources: 
        * mem_limit: memory limit，default 1G
* cluster.dn
    * image: docker image of dn, default is the latest
    * replica: dn node count
    * nodes: dn host group list. If set three ips, it will create a x-paxos cluster
    * resources: 
        * mem_limit: memory limit，default 1G
* cluster.cdc
    * image: docker image of cdc, default is the latest
    * replica: cdc node count
    * nodes: cdc node ip list
    * resources: 
        * mem_limit: memory limit，default 1G

## List existing clusters

```
pxd list
```
It will show all PolarDB-X clusters.

## Delete Cluster

Delete a specific PolarDB-X cluster:

```
pxd delete {pxc_name}
```

Delete all PolarDB-X clusters:

```
pxd cleanup
```

More information about pxd, please run following command:

```
pxd --help
```

More information about PolarDB-X, refer to following links:

* https://help.aliyun.com/product/29657.html
* https://www.zhihu.com/org/polardb-x