# phant-container **Repository Path**: MarsBighead/phant-container ## Basic Information - **Project Name**: phant-container - **Description**: OpenGauss container image with Dockerfile - **Primary Language**: Unknown - **License**: MulanPSL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 6 - **Forks**: 0 - **Created**: 2024-10-12 - **Last Updated**: 2025-06-05 ## Categories & Tags **Categories**: docker-related **Tags**: gaussdb, cncf, Docker, Kubernetes ## README # Phant Container Phant Container provides a serise tools to build optimatized OpenGauss container when compared with official project `openGauss-container`. ## Build image - Build basic OS(OpenEuler 22.03) with dependencies for OpenGauss. ```shell cd images/os; docker build -t gauss-openeuler-os:22.03 -f Dockerfile . ``` - Build OpenGauss image (version>=5.0.0) ```shell # build OpenGauss 5.0.3 with image named opengauss-lite:5.0.3 sh ci/build.sh -v 5.0.3 -i # build OpenGauss 6.0.0 with image named opengauss-lite:6.0.0 sh ci/build.sh -v 6.0.0 -i ``` *Required: to donwload install packages such as `openGauss-Lite-5.0.3-openEuler-aarch64.tar.gz` to directory `images/` in advanced.* ## Launch openGauss - Launch openGauss single instance ```shell hbu@localhost:~/dev/operator/phant-container$ docker-compose -f examples/single/docker-compose.yaml up -d Creating network "single_default" with the default driver Creating db-opengauss-patch ... done hbu@localhost:~/operator/phant-container$ docker-compose -f examples/single/docker-compose.yaml ps Name Command State Ports ------------------------------------------------------------------------------------------------ db-opengauss-patch /entrypoint.sh gaussdb Up 0.0.0.0:15432->5432/tcp,:::15432->5432/tcp hbu@localhost:~/dev/operator/phant-container$ docker exec -it db-opengauss-patch /bin/bash Welcome to 6.1.0-26-arm64 System information as of time: Sat Nov 9 15:43:43 UTC 2024 System load: 0.86 Memory used: 53.9% Swap used: 38.6% Usage On: 40% IP address: 172.21.0.2 Users online: 0 To run a command as administrator(user "root"),use "sudo ". [omm@8078308edd51 /]$ gsql -d postgres gsql ((openGauss-lite 5.0.3 build 89d144c2) compiled at 2024-07-31 21:39:16 commit 0 last mr release) Non-SSL connection (SSL connection is recommended when requiring high-security) Type "help" for help. openGauss=# \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+-------+----------+---------+---------+------------------- postgres | omm | UTF8 | C.UTF-8 | C.UTF-8 | template0 | omm | UTF8 | C.UTF-8 | C.UTF-8 | =c/omm + | | | | | omm=CTc/omm template1 | omm | UTF8 | C.UTF-8 | C.UTF-8 | =c/omm + | | | | | omm=CTc/omm (3 rows) openGauss=# \du List of roles Role name | Attributes | Member of -----------+------------------------------------------------------------------------------------------------------------------+----------- hbu | Replication, Sysadmin | {} omm | Sysadmin, Create role, Create DB, Replication, Administer audit, Monitoradmin, Operatoradmin, Policyadmin, UseFT | {} openGauss=# ``` - Launch simple openGauss primary-standby cluster ```shell hbu@localhost:~/dev/operator/phant-container$ docker-compose -f examples/master-slave/docker-compose.yaml up -d Creating network "master-slave_og-network-ps" with driver "bridge" Creating db-opengauss-ps-02 ... done Creating db-opengauss-ps-01 ... done hbu@localhost:~/dev/operator/phant-container$ docker-compose -f examples/master-slave/docker-compose.yaml ps Name Command State Ports --------------------------------------------------------------------------------------------------- db-opengauss-ps-01 /entrypoint.sh -M primary Up 0.0.0.0:25432->5432/tcp,:::25432->5432/tcp db-opengauss-ps-02 /entrypoint.sh -M standby Up 0.0.0.0:26432->5432/tcp,:::26432->5432/tcp hbu@localhost:~/dev/operator/phant-container$ docker exec -it db-opengauss-ps-01 /bin/bash Welcome to 6.1.0-26-arm64 System information as of time: Sat Nov 9 15:49:01 UTC 2024 System load: 2.21 Memory used: 53.9% Swap used: 33.2% Usage On: 39% IP address: 172.12.0.2 Users online: 0 To run a command as administrator(user "root"),use "sudo ". [omm@db-opengauss-ps-01 /]$ gsql -d postgres gsql ((openGauss-lite 5.0.3 build 89d144c2) compiled at 2024-07-31 21:39:16 commit 0 last mr release) Non-SSL connection (SSL connection is recommended when requiring high-security) Type "help" for help. openGauss=# \du List of roles Role name | Attributes | Member of -----------+------------------------------------------------------------------------------------------------------------------+----------- hbu | Replication, Sysadmin | {} omm | Sysadmin, Create role, Create DB, Replication, Administer audit, Monitoradmin, Operatoradmin, Policyadmin, UseFT | {} openGauss=# select * from PG_STAT_REPLICATION; pid | usesysid | usename | application_name | client_addr | client_hostname | client_port | backend_start | state | sender_sent_location | receiver_write_location | receiver_flush_location | receiver_replay_location | sync_priority | sync_state -----------------+----------+---------+----------------------------+-------------+-----------------+-------------+-------------------------------+-----------+ ----------------------+-------------------------+-------------------------+--------------------------+---------------+------------ 281468005308064 | 10 | omm | WalSender to Build[gs_ctl] | 172.12.0.3 | | 43369 | 2024-11-09 15:49:20.729614+00 | Streaming | 0/40000A8 | 0/40000A8 | 0/40000A8 | 0/40000A8 | 0 | Async (1 row) openGauss=# ``` - Launch openGauss cluster with 1 primary and 2 standby instances. ```shell hbu@localhost:~/dev/operator/phant-container$ docker-compose -f examples/cluster/docker-compose.yaml up -d Creating network "cluster_og-network" with driver "bridge" Creating db-opengauss-02 ... done Creating db-opengauss-01 ... done Creating db-opengauss-03 ... done hbu@localhost:~/dev/operator/phant-container$ docker exec -it db-opengauss-01 /bin/bash Welcome to 6.1.0-26-arm64 System information as of time: Sat Nov 9 15:59:03 UTC 2024 System load: 0.84 Memory used: 51.4% Swap used: 41.5% Usage On: 40% IP address: 172.11.0.2 Users online: 0 To run a command as administrator(user "root"),use "sudo ". [omm@db-opengauss-01 /]$ gsql -d postgres gsql ((openGauss-lite 5.0.3 build 89d144c2) compiled at 2024-07-31 21:39:16 commit 0 last mr release) Non-SSL connection (SSL connection is recommended when requiring high-security) Type "help" for help. openGauss=# select * from PG_STAT_REPLICATION; pid | usesysid | usename | application_name | client_addr | client_hostname | client_port | backend_start | st ate | sender_sent_location | receiver_write_location | receiver_flush_location | receiver_replay_location | sync_priority | sync_state -----------------+----------+---------+-----------------------------------+-------------+-----------------+-------------+-------------------------------+----- ------+----------------------+-------------------------+-------------------------+--------------------------+---------------+------------ 281468147979936 | 10 | omm | WalSender to Standby[walreceiver] | 172.11.0.3 | | 35657 | 2024-11-09 15:55:40.822085+00 | Stre aming | 0/40005A8 | 0/40005A8 | 0/40005A8 | 0/40005A8 | 1 | Potential 281467855296160 | 10 | omm | WalSender to Standby[walreceiver] | 172.11.0.4 | | 42781 | 2024-11-09 15:55:40.305219+00 | Stre aming | 0/40005A8 | 0/40005A8 | 0/40005A8 | 0/4000528 | 1 | Sync (2 rows) openGauss=# ``` ## Backup and Restore - Make full backups ```shell gs_probackup backup -B /home/omm/data/standby --instance standby -b full -D /opt/data/openGauss -d postgres -p 5432 ``` - Restore database from full backups ```shell gs_probackup restore -B /home/omm/data/standby --instance standby -D /home/omm/pgdata/standby gs_ctl build -D /home/omm/pgdata/standby -M standby ``` ## Features - **Containerization openGauss lite edition** Launch single and cluster openGauss instance in Docker container with lite edition. ## Limitation 1. Only supports `arm64` at present. 2. Only supports `openEuler 22.03` as basic OS for building openGauss image demo.