Deploy MatrixDB Docker on Windows

This article contains the main steps to run MatrixDB through Docker Desktop and Hyper-V deployment in Windows 10, and the entire installation process may require a system restart twice.

1. Enable Hyper-V:

1.1 Enable Hyper-V in command line

Right-click the Start menu and run PowerShell as an administrator, and execute the command:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All

1.2 Enable Hyper-V in the graphical interface

Open Windows settings and click to enter "Apps" 1

Click the relevant settings "Programs and Functions" on the right side of the "Applications and Functions" window to click on the relevant settings "Programs and Functions" 2

Click "Start or turn off Windows features" 3

Check to enable Hyper -V

4

Click the OK button, wait for the Windows update to complete, and restart the computer 5

2. Install Docker Desktop

Docker Desktop official download address: https://hub.docker.com/editions/community/docker-ce-desktop-windows

(Note: This version is only available for Windows 10 operating system Professional, Enterprise, Education, and some home versions.)

2.1 Installation

All the way Next, click Finish to complete the installation 6 7 8

If you encounter the following problems during the process, please click the link in the prompt box 9

Follow the prompts on the page, click the link (yellow part) in the figure below to download and install the linux kernel update package for wsl2, and restart the computer as prompted. 10

2.2 Start Docker Desktop

If you see the following interface, the installation starts successfully. 11

In addition, you can also see "Docker Desktop Service" in the Windows service list 12

3. Deploy MatrixDB Docker

3.1 Confirm the docker installation is successful

Run PowerShell or CMD as an administrator in Windows, execute docker --version to confirm that the docker command can run normally.

13

3.2 Pulling MatrixDB docker image

Execute in PowerShell or CMD command line:

docker pull matrixdb/centos7_demo

14

3.3 Run containers

docker run -it -p 5432:5432 --name mxdemo matrixdb/centos7_demo

Main parameters description:

  • -i: Run containers in interactive mode, usually used at the same time as -t;
  • -t: Reassign a pseudo-input terminal to the container, usually used at the same time as -i;
  • -p: Specify port mapping, format: host (host) port: container port;
  • -d: Run the container in the background and return the container ID;
  • --name: Specify a name for the container

3.4 Modify the authorization file

Modify the pg_hba.conf configuration file to allow access to the database from outside through the username and password.

vi /home/mxadmin/data/master/gpseg-1/pg_hba.conf

Add to the last line:

host    all     all     0.0.0.0/0       md5

15

Reload pg_hba.conf to make it effective.

gpstop -u

3.5 Modify password and create test library

[mxadmin@2e807ee654a2 ~]$ psql -d postgres
psql (12)
Type "help" for help.
postgres=# alter role mxadmin with password 'mxadmin';
ALTER ROLE
postgres=# create database testdb;
CREATE DATABASE

3.6 Exit the docker container

Because the current session is a session when creating a container, directly entering exit to exit the container command line will cause the running docker container to stop.

The correct way is to use the CTRL+D command to exit, or directly close the PowerShell window.

4. Common operations to access Docker/MatrixDB

4.1 Start the created docker container

Use the docker start command to add CONTAINERID to start the container. Note that CONTAINERID only writes the first 4 characters.

Use the docker ps command to view CONTAINERID and start:

PS C:\Users\PaulWang> docker ps -a
CONTAINER ID   IMAGE                   COMMAND                  CREATED          STATUS                     PORTS     NAMES
2e807ee654a2   matrixdb/centos7_demo   "/home/mxadmin/entry…"   33 minutes ago   Exited (0) 2 minutes ago             mxdemo
PS C:\Users\PaulWang> docker start 2e80
2e80

You can also click the start button in the Docker Desktop graphical interface to start the container. 16

4.2 Enter the container

Log in with root account:

docker exec -it 2e87 /bin/bash

Log in with mxadmin account:

docker exec -it -u mxadmin 2e87 /bin/bash

4.3 Manage database

The following management commands are used to manage the database (note: use the mxadmin account):

  • gpstate: Check the status of the current database
  • gpstart -a: start the database
  • gpstop -a: Stop the database
  • gpstop -a -M fast: Quickly stop the database

4.4 Use psql to access the database in the container

[mxadmin@2e807ee654a2 /]$ psql -d testdb
psql (12)
Type "help" for help.
testdb=# create table tb1(id int,name varchar(20)) distributed by(id);
CREATE TABLE

4.5 Stop running container

Use the docker stop plus the CONTAINERID command to stop the running container:

PS C:\Users\PaulWang> docker stop 2e80
2e80

You can also click the stop button to stop the docker container in the graphical interface of docker desktop. 17

5. Access MatrixDB using client tools

This article demonstrates how to access MatrixDB using DBeaver. First download the community version from [official website] (https://dbeaver.io/).

5.1 Create a new connection

Select "PostgreSQL" for connection type: 18

5.2 Fill in the connection information

Fill in the database connection information, including username and password. (Note that in this case, the port of the Docker container has been mapped to the Windows server, so the IP address here can be directly filled in localhost) 19

On the PostgreSQL tab, check "Show non-default databases". 20

Click "Test Connection", or "OK" to complete the connection configuration.