PTK is the optimal tool for installing the MogDB database (an enterprise-grade commercial distribution based on openGauss) or the openGauss database, offering a seamless and smooth installation experience.
To install PTK, simply run the following command:
1
curl --proto '=https' --tlsv1.2 -sSf https://cdn-mogdb.enmotech.com/ptk/install.sh | sh
This command will automatically install PTK in the user’s home directory under $HOME/.ptk. This directory will serve as the working directory for PTK, storing cache files, metadata information, cluster configuration information, backup information, and other related files. Additionally, the installation command will add the path $HOME/.ptk/bin to the PATH environment variable in the corresponding shell profile file, enabling the user to use the ptk command directly after logging into the server. In this tutorial, we installed PTK using the root user, although this is not mandatory.
For more detailed PTK installation instructions, please refer to: PTK Installation Guide.
The environment used for this series of articles is CentOS 7.6 for x86-64. MogDB must currently run on a Linux operating system. If you wish to install MogDB on macOS or Windows, you can do so using container deployment. For more information, refer to: Container-based MogDB Installation
To check your CentOS version, you can use the following command:
1 2
# cat /etc/centos-release CentOS Linux release 7.6.1810 (Core)
MogDB can also run on ARM architecture CPUs. You can list all supported CPU brands using the ptk candidate cpu command:
1 2 3 4 5 6 7 8 9 10
# ptk candidate cpu CPU Model ------------------ Cortex-ARM64 Kunpeng-ARM64 Phythium-ARM64 Hygon-x64 Intel-x64 AMD-x64 zhaoxin-x64
If PTK notifies you of a new version while running any command, you can upgrade it directly using the ptk self upgrade command.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
# ptk ls cluster_name | id | addr | user | data_dir | db_version | create_time | comment ---------------+----+------+------+----------+------------+-------------+---------- Warning: New version '1.5.0' is available, you are using ptk version '1.1.3'. You can upgrade ptk via command: 'ptk self upgrade' You can also set environment by 'export PTK_NO_CHECK_VERSION=true' to disable this warning # ptk self upgrade INFO[2024-06-06T11:59:01.105] current version: 1.1.3 release, target version: latest INFO[2024-06-06T11:59:01.105] download package from http://cdn-mogdb.enmotech.com/ptk/latest/ptk_linux_x86_64.tar.gz INFO[2024-06-06T11:59:01.105] downloading ptk_linux_x86_64.tar.gz ... > ptk_linux_x86_64.tar.gz: 17.78 MiB / 20.08 MiB [----------------------------------------------------------------------->_________] 88.52% 27.93 MiB p/s ETA 0s > ptk_linux_x86_64.tar.gz: 20.08 MiB / 20.08 MiB [---------------------------------------------------------------------------------] 100.00% 29.07 MiB p/s 900ms INFO[2024-06-06T11:59:02.956] upgrade ptk successfully [root@mogdb-kernel-0004 ~]# ptk version PTK Version: v1.5.0 release Go Version: go1.19.10 Build Date: 2024-06-04T17:16:07 Git Hash: edd5dbb0 OS/Arch: linux/amd64
Install MogDB
With PTK, you can easily create multiple MogDB instances on a single server. Each MogDB instance can be assigned to a different operating system user, allowing you to manage multiple database instances with a single PTK installation.
To quickly create a test database without any configuration, you can use the ptk demo command:
The ptk demo command accomplishes the following tasks:
Creates an operating system user named demo_user_kVP.
Creates a single-instance MogDB database of the latest version (currently 5.0.7).
Sets the database to listen on port 26000. Before running the ptk demo command, ensure that port 26000 is not occupied by other applications.
Create an initial database user with the same name as the OS user: demo_user_kVP. Also, create a monitor user named mogdb. Both users will have their initial passwords specified in the “Database Detail” section.
Creates two test databases: oracle_compatibility in Oracle-compatible mode and postgres_compatibility in PostgreSQL-compatible mode.
For the automatically created oracle_compatibility database, the following enhancements are also performed:
Installs the whale plugin, which provides extensive Oracle compatibility features. For more information on the Whale plugin, refer to: whale
Installs the compat-tools utility, which supplements the whale plugin with additional Oracle compatibility features that are not yet implemented, such as Oracle-compatible data dictionary views. For more information on compat-tools, refer to: enmotech/compat-tools
Note:compat-tools only work within a single database. This means that if you install compat-tools in the oracle_compatibility database (as is done automatically by the ptk demo command), you will only be able to query the corresponding Oracle-compatible data dictionary views when logged into that database. If you want to use these views in another database, you must install compat-tools in that database as well. For example, if you want to query Oracle-compatible data dictionary views in the postgres database, you need to download compat-tools separately from enmotech/compat-tools then run the following command:
Exploring Oracle-Compatible Data Dictionary in MogDB
Switch to the operating system user associated with the demo database. You can log in to the database using the gsql command.
Note: If you want to connect to the database remotely, you should use the mogdb user. The ptk demo command creates two users in the database. One starts with demo_user_, which is the initial user. Due to MogDB’s enhanced security features, the initial user is not allowed to connect remotely. The other user is mogdb, which can be used for remote connections. The initial password for the users is displayed at the end of the ptk demo command output. Additionally, you should modify the pg_hba.conf file to allow remote connections. For more information, refer to: Connecting to a Database Remotely.
-- sysdate function and dual table is supported oracle_compatibility=# select sysdate from dual; sysdate --------------------- 2024-06-0612:47:57 (1row)
-- V$ views are supported oracle_compatibility=# select sid,username,status,program from v$session; sid | username | status | program ----------------+---------------+--------+------------------------ 47724487509760| demo_user_kVP | active | gsql 47724085905152| demo_user_kVP | idle | WLMArbiter 47724057593600| demo_user_kVP | idle | WorkloadMonitor 47724032427776| demo_user_kVP | active | workload 47723769759488| demo_user_kVP | active | Asp 47723818518272| demo_user_kVP | idle | statement flush thread 47723696359168| demo_user_kVP | idle | CfsShrinker 47723730437888| demo_user_kVP | idle | WDRSnapshot 47723597268736| demo_user_kVP | idle | ApplyLauncher 47723658610432| demo_user_kVP | idle | TxnSnapCapturer 47723563190016| demo_user_kVP | active | JobScheduler (11rows)
-- USER_ views are supported oracle_compatibility=# select table_name,num_rows,last_analyzed from user_tables; table_name | num_rows | last_analyzed ---------------+----------+------------------------------- COUNTRY |0| CITY |600|2024-06-0612:13:24.504009+08 ACTOR |0| FILM_ACTOR |5462|2024-06-0612:13:24.518718+08 CATEGORY |0| FILM_CATEGORY |1000|2024-06-0612:13:24.531421+08 LANGUAGE|0| FILM |1000|2024-06-0612:13:24.56158+08 PAYMENT |0| CUSTOMER |0| INVENTORY |0| RENTAL |0| STAFF |0| ADDRESS |0| STORE |0| (15rows)
oracle_compatibility=# selectcount(*) from CITY; count ------- 600 (1row)
-- some short name views are supported, like IND, OBJ, COLS oracle_compatibility=# select index_name,table_owner,uniqueness,distinct_keys,partitioned from ind where table_name='CITY'; index_name | table_owner | uniqueness | distinct_keys | partitioned -------------------+-------------+------------+---------------+------------- CITY_PKEY | PUBLIC |UNIQUE|600|NO IDX_FK_COUNTRY_ID | PUBLIC | NONUNIQUE |109|NO (2rows)
Note: Due to significant differences in the underlying structure between MogDB and Oracle, these Oracle-compatible views may not include all the fields present in the corresponding Oracle database views.
To be continued:
- Exploring Oracle Compatibility in MogDB (Series II) - System Functions