Which MogDB version and OS version was supported?

[root@localhost ~]# ptk candidate mogdb-server
  software   | version  
---------------+----------
MogDB-Server | 3.0.0    
              | 2.1.1    
              | 2.0.3    
              | 2.0.1    
              | 2.0.0    
[root@localhost ~]# ptk candidate os
software |           version              
-----------+---------------------------------
OS       | UOS 20 (arm64)                  
          | UOS 20 (x86_64)                
          | CentOS 8 (arm64)                
          | CentOS 7 (x86_64)              
          | CentOS 8 (x86_64)              
          | EulerOS 2 (arm64)              
          | EulerOS 2 (x86_64)                            
          | Kylin V10 (arm64)              
          | Kylin V10 (x86_64)              
          | Oracle Linux Server 7 (x86_64)  
          | Oracle Linux Server 8 (x86_64)  
          | openEuler 20 (arm64)            
          | openEuler 22 (arm64)            
          | openEuler 20 (x86_64)          
          | openEuler 22 (x86_64)          
          | RedHat 7 (x86_64)              
          | Rocky Linux 7 (x86_64)          
          | Rocky Linux 8 (x86_64)          
          | SLES 12 (arm64)                
          | Ubuntu 18 (x86_64)            

Which OS version is using?

[root@localhost ~]# cat /etc/os-release 
NAME="Oracle Linux Server"
VERSION="8.6"
ID="ol"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="8.6"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Oracle Linux Server 8.6"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:oracle:linux:8:6:server"
HOME_URL="https://linux.oracle.com/"
BUG_REPORT_URL="https://bugzilla.oracle.com/"

ORACLE_BUGZILLA_PRODUCT="Oracle Linux 8"
ORACLE_BUGZILLA_PRODUCT_VERSION=8.6
ORACLE_SUPPORT_PRODUCT="Oracle Linux"
ORACLE_SUPPORT_PRODUCT_VERSION=8.6

Install PTK

[root@localhost ~]# curl --proto '=https' --tlsv1.2 -sSf https://cdn-mogdb.enmotech.com/ptk/install.sh | sh
info: downloading ptk package
Detected shell: bash
Shell profile: /root/.bash_profile
ptk has been added to PATH in /root/.bash_profile
open a new terminal or source /root/.bash_profile to active it
Installed path: /root/.ptk/bin/ptk
[root@localhost ~]# source /root/.bash_profile

Check OS

Make sure has no “Abnormal” items, all the “WARNING” items can be ignored in testing environment.

Check.

[root@localhost ~]# ptk checkos
INFO[2022-07-04T06:51:04.120] local ip: 192.168.122.21                    
[host 192.168.122.21]: not found package: numactl
Please installed the above missing packages first before do other operations
[PTK-4010] the system does not meet installation requirements

Install numactl.

[root@localhost ~]# dnf install numactl
Oracle Linux 8 BaseOS Latest (x86_64)                                                                                           22 MB/s | 47 MB     00:02    
Oracle Linux 8 Application Stream (x86_64)                                                                                       24 MB/s | 37 MB     00:01    
Latest Unbreakable Enterprise Kernel Release 6 for Oracle Linux 8 (x86_64)                                                       20 MB/s | 50 MB     00:02    
Last metadata expiration check: 0:00:09 ago on Mon 04 Jul 2022 06:52:47 AM EDT.
Dependencies resolved.
================================================================================================================================================================
Package                           Architecture                     Version                                   Repository                                   Size
================================================================================================================================================================
Installing:
numactl                           x86_64                           2.0.12-13.el8                             ol8_baseos_latest                           76 k

Transaction Summary
================================================================================================================================================================
Install 1 Package

Total download size: 76 k
Installed size: 161 k
Is this ok [y/N]: y
Downloading Packages:
numactl-2.0.12-13.el8.x86_64.rpm                                                                                               637 kB/s | 76 kB     00:00    
----------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                           624 kB/s | 76 kB     00:00    
Oracle Linux 8 BaseOS Latest (x86_64)                                                                                           3.0 MB/s | 3.1 kB     00:00    
Importing GPG key 0xAD986DA3:
Userid     : "Oracle OSS group (Open Source Software group) <build@oss.oracle.com>"
Fingerprint: 76FD 3DB1 3AB6 7410 B89D B10E 8256 2EA9 AD98 6DA3
From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing       :                                                                                                                                       1/1
Installing       : numactl-2.0.12-13.el8.x86_64                                                                                                           1/1
Running scriptlet: numactl-2.0.12-13.el8.x86_64                                                                                                           1/1
Verifying       : numactl-2.0.12-13.el8.x86_64                                                                                                           1/1

Installed:
numactl-2.0.12-13.el8.x86_64                                                                                                                                  

Complete!

Check again.

[root@localhost ~]# ptk checkos
INFO[2022-07-04T06:53:27.021] local ip: 192.168.122.21                    
INFO[2022-07-04T06:53:36.264] platform: ol_8.6_64bit                       host=192.168.122.21
INFO[2022-07-04T06:53:36.268] kernel version: 5.4.17-2136.307.3.1.el8uek.x86_64 host=192.168.122.21
INFO[2022-07-04T06:53:36.359] locale: LANG=en_US.UTF-8                     host=192.168.122.21
INFO[2022-07-04T06:53:36.364] timezone: -0400                               host=192.168.122.21
INFO[2022-07-04T06:53:36.368] swap memory 2154492kB, total memory 1734880kB host=192.168.122.21
WARN[2022-07-04T06:53:36.382] net.ipv4.tcp_tw_reuse=2, expect 1             host=192.168.122.21
WARN[2022-07-04T06:53:36.389] net.ipv4.tcp_retries1=3, expect 5             host=192.168.122.21
WARN[2022-07-04T06:53:36.394] net.ipv4.tcp_max_syn_backlog=128, expect 65535 host=192.168.122.21
WARN[2022-07-04T06:53:36.398] net.ipv4.tcp_syn_retries=6, expect 5         host=192.168.122.21
WARN[2022-07-04T06:53:36.402] net.core.wmem_max=212992, expect 21299200     host=192.168.122.21
WARN[2022-07-04T06:53:36.406] net.core.wmem_default=212992, expect 21299200 host=192.168.122.21
WARN[2022-07-04T06:53:36.410] net.ipv4.tcp_max_tw_buckets=8192, expect 10000 host=192.168.122.21
WARN[2022-07-04T06:53:36.414] net.core.rmem_default=212992, expect 21299200 host=192.168.122.21
WARN[2022-07-04T06:53:36.418] kernel.sem=32000 1024000000 500 32000, expect 250 6400000 1000 25600 host=192.168.122.21
WARN[2022-07-04T06:53:36.435] net.core.netdev_max_backlog=1000, expect 65535 host=192.168.122.21
WARN[2022-07-04T06:53:36.438] net.core.rmem_max=212992, expect 21299200     host=192.168.122.21
WARN[2022-07-04T06:53:36.448] vm.min_free_kbytes=45056, expect 86744       host=192.168.122.21
WARN[2022-07-04T06:53:36.457] net.ipv4.tcp_keepalive_intvl=75, expect 30   host=192.168.122.21
WARN[2022-07-04T06:53:36.461] net.ipv4.tcp_rmem=4096 131072 6291456, expect 8192 250000 16777216 host=192.168.122.21
WARN[2022-07-04T06:53:36.473] net.core.somaxconn=4096, expect 65535         host=192.168.122.21
WARN[2022-07-04T06:53:36.478] net.ipv4.tcp_keepalive_time=7200, expect 30   host=192.168.122.21
WARN[2022-07-04T06:53:36.481] net.ipv4.tcp_retries2=15, expect 12           host=192.168.122.21
WARN[2022-07-04T06:53:36.490] net.ipv4.tcp_wmem=4096 16384 4194304, expect 8192 250000 16777216 host=192.168.122.21
WARN[2022-07-04T06:53:36.637] device(/dev/vda) readahead value=8192, expect 16384. host=192.168.122.21
WARN[2022-07-04T06:53:36.661] device(sr0) 'IO Request'=64, expect 512       host=192.168.122.21
WARN[2022-07-04T06:53:36.661] device(vda) 'IO Request'=256, expect 512     host=192.168.122.21
WARN[2022-07-04T06:53:36.661] device(dm-0) 'IO Request'=128, expect 512     host=192.168.122.21
WARN[2022-07-04T06:53:36.661] device(dm-1) 'IO Request'=128, expect 512     host=192.168.122.21
WARN[2022-07-04T06:53:36.669] device(vda) 'IO scheduler'='none', expect 'mq-deadline' host=192.168.122.21
WARN[2022-07-04T06:53:36.681] not found network conf file for enp1s0 in dir /etc/sysconfig/network, skip check bonding host=192.168.122.21
WARN[2022-07-04T06:53:36.710] network card(enp1s0): mtu=1500, expect 8192   host=192.168.122.21
ERRO[2022-07-04T06:53:36.721] transparent_hugepage status is 'always', expect 'never' host=192.168.122.21
INFO[2022-07-04T06:53:45.839] write fix os script to root_fix_os.sh successfully
INFO[2022-07-04T06:53:45.839] all checkers finished                        
# Check Results
              Item               | Level    
------------------------------------+-----------
A1.Check_OS_Version               | OK        
A2.Check_Kernel_Version           | OK        
A3.Check_Unicode                 | OK        
A4.Check_TimeZone                 | OK        
A5.Check_Swap_Memory_Configure   | Warning  
A6.Check_SysCtl_Parameter         | Warning  
A7.Check_FileSystem_Configure     | OK        
A8.Check_Disk_Configure           | OK        
A9.Check_BlockDev_Configure       | Warning  
A9.Check_Logical_Block           | OK        
A10.Check_IO_Configure           | Warning  
A10.Check_IO_Request             | Warning  
A10.Check_Asynchronous_IO_Request | OK        
A11.Check_Network_Configure       | Warning  
A12.Check_Time_Consistency       | OK        
A13.Check_Firewall_Service       | OK        
A14.Check_THP_Service             | Abnormal  
A15.Check_Dependent_Package       | Warning  
A16.Check_CPU_Instruction_Set     | OK        
Total count 19, abnormal count 1, warning count 7

Failed to check os, can’t perform installation unless fix all the abnormal items
You can use 'ptk checkos -i ITEM --detail' to see detail message
Please check root_fix_os.sh for commands to resolve.

Disable TPH. the command can be find in root_fix_os.sh generated by PTK.

[root@localhost ~]# [ -f /sys/kernel/mm/transparent_hugepage/enabled ] && echo 'never' | sudo tee /sys/kernel/mm/transparent_hugepage/enabled
never

Check again.

[root@localhost ~]# ptk checkos
INFO[2022-07-04T06:57:55.973] local ip: 192.168.122.21                    
INFO[2022-07-04T06:58:05.230] platform: ol_8.6_64bit                       host=192.168.122.21
INFO[2022-07-04T06:58:05.234] kernel version: 5.4.17-2136.307.3.1.el8uek.x86_64 host=192.168.122.21
INFO[2022-07-04T06:58:05.324] locale: LANG=en_US.UTF-8                     host=192.168.122.21
INFO[2022-07-04T06:58:05.329] timezone: -0400                               host=192.168.122.21
INFO[2022-07-04T06:58:05.333] swap memory 2154492kB, total memory 1734880kB host=192.168.122.21
WARN[2022-07-04T06:58:05.338] net.core.wmem_max=212992, expect 21299200     host=192.168.122.21
WARN[2022-07-04T06:58:05.342] net.ipv4.tcp_max_tw_buckets=8192, expect 10000 host=192.168.122.21
WARN[2022-07-04T06:58:05.355] net.core.netdev_max_backlog=1000, expect 65535 host=192.168.122.21
WARN[2022-07-04T06:58:05.359] net.ipv4.tcp_retries1=3, expect 5             host=192.168.122.21
WARN[2022-07-04T06:58:05.362] net.ipv4.tcp_wmem=4096 16384 4194304, expect 8192 250000 16777216 host=192.168.122.21
WARN[2022-07-04T06:58:05.366] net.core.wmem_default=212992, expect 21299200 host=192.168.122.21
WARN[2022-07-04T06:58:05.378] kernel.sem=32000 1024000000 500 32000, expect 250 6400000 1000 25600 host=192.168.122.21
WARN[2022-07-04T06:58:05.382] net.ipv4.tcp_max_syn_backlog=128, expect 65535 host=192.168.122.21
WARN[2022-07-04T06:58:05.392] net.core.somaxconn=4096, expect 65535         host=192.168.122.21
WARN[2022-07-04T06:58:05.396] net.core.rmem_max=212992, expect 21299200     host=192.168.122.21
WARN[2022-07-04T06:58:05.399] net.core.rmem_default=212992, expect 21299200 host=192.168.122.21
WARN[2022-07-04T06:58:05.408] net.ipv4.tcp_tw_reuse=2, expect 1             host=192.168.122.21
WARN[2022-07-04T06:58:05.412] net.ipv4.tcp_keepalive_time=7200, expect 30   host=192.168.122.21
WARN[2022-07-04T06:58:05.416] net.ipv4.tcp_rmem=4096 131072 6291456, expect 8192 250000 16777216 host=192.168.122.21
WARN[2022-07-04T06:58:05.420] net.ipv4.tcp_syn_retries=6, expect 5         host=192.168.122.21
WARN[2022-07-04T06:58:05.432] net.ipv4.tcp_keepalive_intvl=75, expect 30   host=192.168.122.21
WARN[2022-07-04T06:58:05.437] net.ipv4.tcp_retries2=15, expect 12           host=192.168.122.21
WARN[2022-07-04T06:58:05.452] vm.min_free_kbytes=45056, expect 86744       host=192.168.122.21
WARN[2022-07-04T06:58:05.586] device(/dev/vda) readahead value=8192, expect 16384. host=192.168.122.21
WARN[2022-07-04T06:58:05.609] device(dm-0) 'IO Request'=128, expect 512     host=192.168.122.21
WARN[2022-07-04T06:58:05.609] device(dm-1) 'IO Request'=128, expect 512     host=192.168.122.21
WARN[2022-07-04T06:58:05.609] device(sr0) 'IO Request'=64, expect 512       host=192.168.122.21
WARN[2022-07-04T06:58:05.609] device(vda) 'IO Request'=256, expect 512     host=192.168.122.21
WARN[2022-07-04T06:58:05.616] device(vda) 'IO scheduler'='none', expect 'mq-deadline' host=192.168.122.21
WARN[2022-07-04T06:58:05.627] not found network conf file for enp1s0 in dir /etc/sysconfig/network, skip check bonding host=192.168.122.21
WARN[2022-07-04T06:58:05.653] network card(enp1s0): mtu=1500, expect 8192   host=192.168.122.21
INFO[2022-07-04T06:58:14.838] write fix os script to root_fix_os.sh successfully
INFO[2022-07-04T06:58:14.839] all checkers finished                        
# Check Results
              Item               | Level  
------------------------------------+----------
A1.Check_OS_Version               | OK      
A2.Check_Kernel_Version           | OK      
A3.Check_Unicode                 | OK      
A4.Check_TimeZone                 | OK      
A5.Check_Swap_Memory_Configure   | Warning  
A6.Check_SysCtl_Parameter         | Warning  
A7.Check_FileSystem_Configure     | OK      
A8.Check_Disk_Configure           | OK      
A9.Check_BlockDev_Configure       | Warning  
A9.Check_Logical_Block           | OK      
A10.Check_Asynchronous_IO_Request | OK      
A10.Check_IO_Configure           | Warning  
A10.Check_IO_Request             | Warning  
A11.Check_Network_Configure       | Warning  
A12.Check_Time_Consistency       | OK      
A13.Check_Firewall_Service       | OK      
A14.Check_THP_Service             | OK      
A15.Check_Dependent_Package       | Warning  
A16.Check_CPU_Instruction_Set     | OK      
Total count 19, abnormal count 0, warning count 7

Generate config file

If this is the newly installation in a new OS, no need to modify anything, just keep all the default settings.

[root@localhost ~]# ptk template --local > config.yaml
[root@localhost ~]# cat config.yaml
global:
# # cluster name (required)
cluster_name: "cluster_xWsybr"
# # system user for running db
user: "omm"
# # system user group, same as username if not given
group: "omm"
# # base directory for install MogDB server,
# # if any of app_dir,data_dir,log_dir and tool_dir not config,
# # PTK will create corresponding directory under base_dir
base_dir: "/opt/mogdb"

db_servers:
- host: "127.0.0.1"
  # # database port
  db_port: 26000

Install MogDB 3.0

PTK will download MogDB for openEuler image in all the Fedora like OS from version 8. Please make sure you are using the latest ptk by using ptk self upgrade. PTK is being developed very actively, Upgrading PTK every few days is recommend.

[root@localhost ~]# ptk self upgrade
INFO[2022-07-04T08:29:16.082] start download ptk_linux_x86_64.tar.gz      
> download ptk_linux_x86_64.t...: 3.93 MiB / 3.93 MiB [------------------------------------------------------------------------------] 100.00% 3.83 MiB p/s 1.2s
INFO[2022-07-04T08:29:22.006] download ptk_linux_x86_64.tar.gz successfully
INFO[2022-07-04T08:29:22.122] upgrade ptk successfully  

[root@localhost ~]# ptk -v
PTK Version: v0.2.2
Go Version: go1.17.1
Build Date: 2022-07-04T12:18:21Z
Git Hash: 5959dd0
[root@localhost ~]# ptk install -f config.yaml
Please enter db password (8~16 characters):
Retype db password:
=============================
global:
cluster_name: cluster_xWsybr
user: omm
group: omm
app_dir: /opt/mogdb/app
data_dir: /opt/mogdb/data
log_dir: /opt/mogdb/log
tool_dir: /opt/mogdb/tool
tmp_dir: /opt/mogdb/tmp
db_servers:
- host: 192.168.122.21
db_port: 26000
role: primary
az_name: AZ1
az_priority: 1

=============================
Is cluster topo correct?[Y|Yes](default=N) Y
INFO[2022-07-04T08:32:54.640] no package specified, use online package: https://cdn-mogdb.enmotech.com/mogdb-media/3.0.0/MogDB-3.0.0-openEuler-x86_64.tar.gz
INFO[2022-07-04T08:32:54.641] downloading package...                      
> download MogDB-3.0.0-openEu...: 134.20 MiB / 134.20 MiB [---------------------------------------------------------------------------] 100.00% 9.02 MiB p/s 15s
INFO[2022-07-04T08:33:13.597] download package successfully                
WARN[2022-07-04T08:33:14.463] vendor does not provide sha256 file for MogDB-3.0.0-openEuler-64bit-Libpq, skip validate
WARN[2022-07-04T08:33:14.529] vendor does not provide sha256 file for MogDB-3.0.0-openEuler-64bit-tools, skip validate
INFO[2022-07-04T08:33:14.871] the installation package files are safe      
INFO[2022-07-04T08:33:14.871] parse version.cfg from MogDB-3.0.0-openEuler-64bit.tar.gz
INFO[2022-07-04T08:33:17.386] detected db version: MogDB-3.0.0, number: 92.605, commit_id: 62408a0f
WARN[2022-07-04T08:33:17.394] the number of instances is less than 3, CM will not be installed
INFO[2022-07-04T08:33:17.394] start check operating system                
INFO[2022-07-04T08:33:17.394] local ip: 192.168.122.21                    
INFO[2022-07-04T08:33:26.605] platform: ol_8.6_64bit                       host=192.168.122.21
INFO[2022-07-04T08:33:26.610] kernel version: 5.4.17-2136.307.3.1.el8uek.x86_64 host=192.168.122.21
INFO[2022-07-04T08:33:26.702] locale: LANG=en_US.UTF-8                     host=192.168.122.21
INFO[2022-07-04T08:33:26.708] timezone: -0400                               host=192.168.122.21
INFO[2022-07-04T08:33:26.714] swap memory 2154492kB, total memory 1734880kB host=192.168.122.21
WARN[2022-07-04T08:33:26.724] net.ipv4.tcp_syn_retries=6, expect 5         host=192.168.122.21
WARN[2022-07-04T08:33:26.735] net.ipv4.tcp_rmem=4096 131072 6291456, expect 8192 250000 16777216 host=192.168.122.21
WARN[2022-07-04T08:33:26.744] net.ipv4.tcp_max_syn_backlog=128, expect 65535 host=192.168.122.21
WARN[2022-07-04T08:33:26.754] net.core.rmem_max=212992, expect 21299200     host=192.168.122.21
WARN[2022-07-04T08:33:26.759] net.core.wmem_default=212992, expect 21299200 host=192.168.122.21
WARN[2022-07-04T08:33:26.764] net.core.rmem_default=212992, expect 21299200 host=192.168.122.21
WARN[2022-07-04T08:33:26.776] vm.min_free_kbytes=45056, expect 86744       host=192.168.122.21
WARN[2022-07-04T08:33:26.790] net.ipv4.tcp_keepalive_intvl=75, expect 30   host=192.168.122.21
WARN[2022-07-04T08:33:26.800] net.ipv4.tcp_retries2=15, expect 12           host=192.168.122.21
WARN[2022-07-04T08:33:26.804] net.core.wmem_max=212992, expect 21299200     host=192.168.122.21
WARN[2022-07-04T08:33:26.809] net.ipv4.tcp_keepalive_time=7200, expect 30   host=192.168.122.21
WARN[2022-07-04T08:33:26.813] net.ipv4.tcp_retries1=3, expect 5             host=192.168.122.21
WARN[2022-07-04T08:33:26.818] net.ipv4.tcp_wmem=4096 16384 4194304, expect 8192 250000 16777216 host=192.168.122.21
WARN[2022-07-04T08:33:26.823] net.core.somaxconn=4096, expect 65535         host=192.168.122.21
WARN[2022-07-04T08:33:26.832] net.ipv4.tcp_max_tw_buckets=8192, expect 10000 host=192.168.122.21
WARN[2022-07-04T08:33:26.844] net.core.netdev_max_backlog=1000, expect 65535 host=192.168.122.21
WARN[2022-07-04T08:33:26.848] kernel.sem=32000 1024000000 500 32000, expect 250 6400000 1000 25600 host=192.168.122.21
WARN[2022-07-04T08:33:26.857] net.ipv4.tcp_tw_reuse=2, expect 1             host=192.168.122.21
WARN[2022-07-04T08:33:26.993] device(/dev/vda) readahead value=8192, expect 16384. host=192.168.122.21
WARN[2022-07-04T08:33:27.018] device(vda) 'IO Request'=256, expect 512     host=192.168.122.21
WARN[2022-07-04T08:33:27.018] device(dm-0) 'IO Request'=128, expect 512     host=192.168.122.21
WARN[2022-07-04T08:33:27.018] device(dm-1) 'IO Request'=128, expect 512     host=192.168.122.21
WARN[2022-07-04T08:33:27.018] device(sr0) 'IO Request'=64, expect 512       host=192.168.122.21
WARN[2022-07-04T08:33:27.026] device(vda) 'IO scheduler'='none', expect 'mq-deadline' host=192.168.122.21
WARN[2022-07-04T08:33:27.082] network card(enp1s0): mtu=1500, expect 8192   host=192.168.122.21
WARN[2022-07-04T08:33:27.102] the firewall service status='enabled', expect 'disabled'. host=192.168.122.21
INFO[2022-07-04T08:33:36.128] [stage=precheck]: start                       host=192.168.122.21
INFO[2022-07-04T08:33:36.128] check core pattern value                     host=192.168.122.21
INFO[2022-07-04T08:33:36.136] check RemoveIPC value                         host=192.168.122.21
INFO[2022-07-04T08:33:36.142] check user 'omm'                             host=192.168.122.21
INFO[2022-07-04T08:33:36.151] check port 26000                             host=192.168.122.21
INFO[2022-07-04T08:33:36.211] port 26000 is free                           host=192.168.122.21
INFO[2022-07-04T08:33:36.212] [stage=precheck]: successful                 host=192.168.122.21
INFO[2022-07-04T08:33:36.212] scp file from /root/.ptk/cache/MogDB-3.0.0-openEuler-x86_64.tar.gz to 192.168.122.21:/tmp/MogDB-3.0.0-openEuler-x86_64.tar.gz host=192.168.122.21
INFO[2022-07-04T08:33:36.316] [stage=initial]: start                       host=192.168.122.21
INFO[2022-07-04T08:33:36.323] total memory(1GB) is less then 4GB, use default guc config host=192.168.122.21
INFO[2022-07-04T08:33:36.323] create os user omm, group omm                 host=192.168.122.21
INFO[2022-07-04T08:33:37.440] set ulimits                                   host=192.168.122.21
INFO[2022-07-04T08:33:37.444] set user omm profiles                         host=192.168.122.21
INFO[2022-07-04T08:33:37.611] add c library /usr/local/lib to /etc/ld.so.conf.d/libc.conf host=192.168.122.21
INFO[2022-07-04T08:33:37.616] mkdir /opt/mogdb/tool                         host=192.168.122.21
INFO[2022-07-04T08:33:37.774] decompress MogDB-3.0.0-openEuler-x86_64.tar.gz to dir /opt/mogdb/tool host=192.168.122.21
INFO[2022-07-04T08:33:38.809] remove files /tmp/MogDB-3.0.0-openEuler-x86_64.tar.gz host=192.168.122.21
INFO[2022-07-04T08:33:38.826] decompress *-om.tar.gz to dir /opt/mogdb/tool host=192.168.122.21
INFO[2022-07-04T08:33:39.228] change /opt/mogdb/tool owner to omm           host=192.168.122.21
INFO[2022-07-04T08:33:39.239] mkdir /opt/mogdb/app                         host=192.168.122.21
INFO[2022-07-04T08:33:39.384] decompress MogDB-3.0.0-openEuler-64bit.tar.gz to dir /opt/mogdb/app host=192.168.122.21
INFO[2022-07-04T08:33:42.089] change /opt/mogdb/app owner to omm           host=192.168.122.21
INFO[2022-07-04T08:33:42.101] mkdir /opt/mogdb/log/gs_profile,/opt/mogdb/log/pg_log,/opt/mogdb/log/pg_audit,/opt/mogdb/log/bin,/opt/mogdb/log/pg_log/dn_6001,/opt/mogdb/log/pg_audit/dn_6001 host=192.168.122.21
INFO[2022-07-04T08:33:43.382] mkdir /opt/mogdb/tmp                         host=192.168.122.21
INFO[2022-07-04T08:33:43.523] save version to /opt/mogdb/app/bin/upgrade_version host=192.168.122.21
INFO[2022-07-04T08:33:43.595] create cluster_manual_start file             host=192.168.122.21
INFO[2022-07-04T08:33:43.660] generate static config to /opt/mogdb/app/bin/cluster_static_config host=192.168.122.21
INFO[2022-07-04T08:33:43.668] change /opt/mogdb/app/bin/cluster_static_config owner to omm host=192.168.122.21
INFO[2022-07-04T08:33:43.672] mkdir /opt/mogdb/data                         host=192.168.122.21
INFO[2022-07-04T08:33:43.812] change /opt/mogdb/data owner to omm           host=192.168.122.21
INFO[2022-07-04T08:33:43.816] initial database                             host=192.168.122.21
INFO[2022-07-04T08:33:59.488] set 192.168.122.21 postgresql.conf           host=192.168.122.21
INFO[2022-07-04T08:33:59.603] set 192.168.122.21 hba config                 host=192.168.122.21
INFO[2022-07-04T08:33:59.684] [stage=initial]: successful                   host=192.168.122.21
INFO[2022-07-04T08:33:59.684] [stage=launch]: start                         host=192.168.122.21
INFO[2022-07-04T08:33:59.684] start 192.168.122.21 database by gs_ctl       host=192.168.122.21
INFO[2022-07-04T08:34:00.805] alter initial user password                   host=192.168.122.21
INFO[2022-07-04T08:34:00.981] [stage=launch]: successful                   host=192.168.122.21
      host     | stage |   status     | message  
-----------------+--------+---------------+----------
192.168.122.21 | launch | start_success | success  
[root@localhost ~]# ptk ls
  cluster_name |     instances       | user |   data_dir     | db_version  
-----------------+----------------------+------+-----------------+--------------
cluster_xWsybr | 192.168.122.21:26000 | omm | /opt/mogdb/data | MogDB-3.0.0  
[root@localhost ~]# ptk cluster status -n cluster_xWsybr

[   Cluster State   ]

database_version : MogDB-3.0.0
cluster_name : cluster_xWsybr
cluster_state   : Normal
current_az     : AZ_ALL

[ Datanode State   ]

  id |       ip       | port | user | instance | db_role | state  
-------+----------------+-------+------+----------+---------+---------
6001 | 192.168.122.21 | 26000 | omm | dn_6001 | Normal | Normal  

Install and use mogila sample database

It maybe takes more than 1 minute to complete the entire data manipulation works depending on the system configuration.

[root@localhost ~]# su - omm
[omm@localhost ~]$ git clone https://gitee.com/enmotech/mogila.git
Cloning into 'mogila'...
remote: Enumerating objects: 145, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 145 (delta 0), reused 0 (delta 0), pack-reused 142
Receiving objects: 100% (145/145), 4.25 MiB | 1.88 MiB/s, done.
Resolving deltas: 100% (73/73), done.
[omm@localhost ~]$ cd mogila/
[omm@localhost mogila]$ gsql -d postgres -p 26000 -c "create database mogila DBCOMPATIBILITY='PG'"
CREATE DATABASE
[omm@localhost mogila]$ gsql -d postgres -p 26000 -c "create user mogdb password 'Enmo@123'"
CREATE ROLE
[omm@localhost mogila]$ gsql -d postgres -p 26000 -c "alter user mogdb with sysadmin"
ALTER ROLE
[omm@localhost mogila]$ gsql -d mogila -p 26000 -f mogila-insert-data.sql
total time: 89570 ms
[omm@localhost mogila]$
[omm@localhost mogila]$ gsql -d mogila -p 26000 -U mogdb -W Enmo@123 -r
gsql ((MogDB 3.0.0 build 62408a0f) compiled at 2022-06-30 14:21:32 commit 0 last mr )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

mogila=> select version();
                                                                    version                                                                      
--------------------------------------------------------------------------------------------------------------------------------------------------
(MogDB 3.0.0 build 62408a0f) compiled at 2022-06-30 14:21:32 commit 0 last mr   on x86_64-unknown-linux-gnu, compiled by g++ (GCC) 7.3.0, 64-bit
(1 row)

Install compat-tools to get more Oracle database compatibilities

[omm@localhost ~]$ cd
[omm@localhost ~]$ git clone https://gitee.com/enmotech/compat-tools.git
Cloning into 'compat-tools'...
remote: Enumerating objects: 1100, done.
remote: Counting objects: 100% (208/208), done.
remote: Compressing objects: 100% (190/190), done.
remote: Total 1100 (delta 138), reused 35 (delta 18), pack-reused 892
Receiving objects: 100% (1100/1100), 1.45 MiB | 1.95 MiB/s, done.
Resolving deltas: 100% (698/698), done.

[omm@localhost ~]$ cd compat-tools/
[omm@localhost compat-tools]$ gsql -d mogila -p 26000 -f runMe.sql
gsql:runMe.sql:152: NOTICE:  
gsql:runMe.sql:152: NOTICE: -- =====================================================================
gsql:runMe.sql:152: NOTICE: -- Test Summary:
gsql:runMe.sql:152: NOTICE: -- =====================================================================
gsql:runMe.sql:152: NOTICE:     | result_type | case_count | start_time         | complete_time       |
gsql:runMe.sql:152: NOTICE:     |-------------|------------|---------------------|---------------------|
gsql:runMe.sql:152: NOTICE:     | PASSED     |       521 | 2022-07-04 13:10:49 | 2022-07-04 13:10:52 |
gsql:runMe.sql:152: NOTICE:  
gsql:runMe.sql:152: NOTICE: -- =====================================================================
gsql:runMe.sql:152: NOTICE: -- Test Detail (Failed or Null):
gsql:runMe.sql:152: NOTICE: -- =====================================================================
gsql:runMe.sql:152: NOTICE: -- <<< ALL SUCCEED >>>
ANONYMOUS BLOCK EXECUTE
total time: 4461 ms

[omm@localhost compat-tools]$ gsql -d mogila -p 26000 -U mogdb -W Enmo@123 -r
gsql ((MogDB 3.0.0 build 62408a0f) compiled at 2022-06-30 14:21:32 commit 0 last mr )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

mogila=> select * from v$version;
                    banner                      
-------------------------------------------------
MogDB 3.0.0 build 62408a0f
compiled at 2022-06-30 14:21:32
Platform architecture: x86_64-unknown-linux-gnu
(3 rows)

mogila=> select table_name,num_rows,partitioned from user_tables;
table_name   | num_rows | partitioned
---------------+----------+-------------
ACTOR         |     200 | NO
CATEGORY     |       16 | NO
CUSTOMER     |     599 | NO
CITY         |     600 | NO
COUNTRY       |     109 | NO
LANGUAGE     |       6 | NO
FILM_ACTOR   |     5462 | NO
FILM_CATEGORY |     1000 | NO
FILM         |     1000 | NO
PAYMENT       |   16049 | YES
INVENTORY     |     4581 | NO
RENTAL       |   16044 | NO
STAFF         |       2 | NO
ADDRESS       |     603 | NO
STORE         |       2 | NO
(15 rows)

mogila=> select dbms_random.value(100,1000) from dual;
    value      
------------------
891.160552715883
(1 row)

mogila-> \q
[omm@localhost compat-tools]$

Install Pop!_OS

Go to Pop!_OS website, download Pop!_OS ISO Image (NVIDIA), burn into a live USB stick. Currently the latest version is Pop!_OS 22.04 LTS. You have to use a USB keyboard, press F12 when start the computer, then install Pop!_OS.

The installation process is smooth forward without a single issue.

Change mouse to natural scrolling

In settings -> Mouse & Touchpad, check on Natural Scrolling. Yes, I’m a heavy macOS user.

Pasted image 20220605221345

Install Chrome and make it default browser

Open Pop!Shop, search “Chrome” and install it.

Then, change Default Application of Web to “Google Chrome”.

Pasted image 20220606012006

Install 1Password

1Password is a great app for store all the passwords and secrets, it can be run in macOS, Windows, Linux and Web Browser, really convenience.

Get 1Password for Linux of Ubuntu, download the .deb file, and just double click to install.

Activate online account and sync cloud drive

I linked Microsoft account to Pop OS, but One Drive is not there, have to install it seperatly.

Install rclone, rclone can sync plenty of cloud storage with local drive, including One Drive.

curl https://rclone.org/install.sh | sudo bash
rclone config
mkdir /home/kamus/OneDrive
rclone --vfs-cache-mode writes mount my-onedrive:/ /home/kamus/OneDrive/ --daemon

If you want to mount the cloud drive automatically with the system startup, create a systemd config file as /etc/systemd/system/rclonemount.service.

[Unit]  
Description=OneDrive(rclone)  
AssertPathIsDirectory=/home/kamus/OneDrive/  
After=network-online.target

[Service]  
Type=simple  
User=kamus  
Group=kamus  
ExecStart=/usr/bin/rclone --vfs-cache-mode writes mount my-onedrive:/ /home/kamus/OneDrive/ --config /home/kamus/.config/rclone/rclone.conf  
ExecStop=/usr/bin/fusermount -u /home/kamus/OneDrive/  
Restart=always  
RestartSec=10

[Install]  
WantedBy=default.target

Enable the service with systemctl.

sudo systemctl enable rclonemount.service

Now rclone will mount the drive automatically when system startup.

rclone is super powerful, please read manual for more options.

Install Chinese input method – Sogou or RIME

This is the most important and complicated job has to be done, I always envy the native English language user, they don’t have to do such things.

At first, should install fcitx input method system.

sudo apt-get install fcitx

Then from the language settings, change input method system to Fcitx.

Pasted image 20220605231555

Since Pop OS makes ibus as the default input method system, you have to remove this config file, just move it to any other directory.

sudo mv /etc/profile.d/pop-im-ibus.sh ~/

Restart the compuer, let fcitx loaded.

Downlaod the sogou input app from sogou website.

sudo dpkg -i sogoupinyin_4.0.1.2123_amd64.deb

Logout system and login again, done. The default hotkey of change input method is “Ctrl+Space”, that is great, the same as I used in macOS and Windows.

所以,现在我们可以使用中文输入法了。

There is another great Chinese input method – RIME, which is running on iBus framework, can be checked from here to learn how to install and use it.

Install Typora and Obsidian

Both are great apps, I use Typora as the default markdown file viewer, and write all the markdown files in Obsidian. I love both of them.

Obsidian is a free app can be installed from Pop!Shop.

The latest version of Typora is not free anymore, but absolutely deserve the price, it can also be installed from Pop!Shop, then open it and input your serial code.

After install Typora, you can install image uploader service – PicGo-Core just from Typora settings.

image-20220609034826011

Install Flameshot and set global hotkey

The oroginal screen capture of Pop OS sucks, Flameshot is a good choice to do the perfect job. To be sure installing flameshot by .deb format instead of flatpack in Pop!Shop.

I usally use Cmd+Shift+4 to capture screen in macOS, so I decide to set the same in Pop OS. By Settings > Keyboard > View and Customize Shortcuts > Custom shortcuts, add a new shortcuts as below.

Pasted image 20220605235747

Install WPS Office

WPS office is more comfotable than LibreOffice if you are familiar with Microsoft Office. Just install it from Pop!Shop.

image-20220609041204009

Beautify Terminal and fix openSSH issue

Change default shell to zsh.

$ sudo apt install zsh
$ chsh -s `which zsh`

Install zsh4humans to get a beautiful terminal expierience.

image-20220609181022408

Please check out this article I wrote to see the detail configuration steps, make sure you download the font with “Mono”, Pop OS terminal’s custom font setting will only show the fonts that is mono: Make a perfect terminal experience from zero in 3 steps

If you ssh to a remote server, got error as below.

❯ ssh -i /home/kamus/Downloads/id_rsa_mogdb_ecs_jumper -p 2222 kamus@121.36.15.2
Unable to negotiate with 121.36.15.2 port 2222: no matching host key type found. Their offer: ssh-rsa

You should add some lines into /etc/ssh/ssh_config files.

Host 121.36.15.2
HostKeyAlgorithms +ssh-rsa
PubkeyAcceptedKeyTypes +ssh-rsa

Use Mogeaver to access MogDB remotely

Mogeaver is the database GUI developer tool based on dbeaver, added MogDB compatible functions.

Mogeaver can be used on macOS, Linux and Windows, the Linux version is not including JRE runtime, so we have to install JRE manually before we can use Mogeaver.

$ sudo apt install default-jre
$ java -version
openjdk version "11.0.15" 2022-04-19
OpenJDK Runtime Environment (build 11.0.15+10-Ubuntu-0ubuntu0.22.04.1)
OpenJDK 64-Bit Server VM (build 11.0.15+10-Ubuntu-0ubuntu0.22.04.1, mixed mode, sharing)

Then downlaod the Mogeaver zip file, extract to any directory, double click “mogeaver” excutable file. Aha! That’s cool, right?

2022-06-09_14-22

Install wechat and wechat.work

$ wget -O- https://deepin-wine.i-m.dev/setup.sh | sh
$ sudo apt-get install com.qq.weixin.deepin
$ sudo apt-get install com.qq.weixin.work.deepin

If you want to try more wine apps made by Deepin, please check this web page.

Up to now, WeChat can run smoothly, but WeChat.work still cannot start normally. If there is a solution in the future, I will update the article.

Weixin.work needs more fix steps after installation. Please check out #277 and #205.

In summary we need to install some packages.

$ sudo apt install libjpeg62:i386 fonts-wqy-zenhei xfonts-wqy  

And modify /opt/apps/com.qq.weixin.work.deepin/files/run.sh to comment 2 lines as below.

#export WINEDLLPATH=/opt/$APPRUN_CMD/lib:/opt/$APPRUN_CMD/lib64
#export WINEPREDLL="$ARCHIVE_FILE_DIR/dlls"
image-20220610155246155

After so many years, to run WeChat and WeChat.work in Linux, still has to be running in a virtual Windows environment such as wine. I can’t help but feel resentment towards Tencent, such a huge enterprise, so many employees, they would like to create games to make money, instead of making even a little effort to create a native wechat client that supports the Linux. Please look at Slack or Discord.

Try to fix suspend issue

The default NVIDIA driver is nvidia-driver-510, when try to turn the computer into suspend mode, it will not wake up again, the fan will swing massively but the display keeps on black.

In Pop!shop – Installed tab, Install “nvidia-driver-470” and restart the machine.

Screenshot from 2022-06-05 22-07-51

But with no luck. Now this is the last unresolved issue that I met in Pop!OS.

Final

Pop!OS maybe is the best Linux desktop distro I’ve tried, compared to Ubuntu, Oracle Linux, Deepin and the popular Manjaro.

诊断需求

当MogDB数据库由于某种原因占用了较大的系统负载,比如CPU占用接近100%,那么如何知道到底是数据库里的哪个会话或者哪些会话占用了资源?
在Oracle数据库中,这样的问题诊断,通常都会关联 v$session, v$process, 以及操作系统top命令或者ps命令中查到的操作系统进程ID。
但是MogDB本身是线程模型,在操作系统上只能看到一个进程号,那么该如何定位问题?

因为MogDB使用的是线程模型,与PostgreSQL的进程模型不同,在操作系统级别如果用lsof命令查看网络端口的接入,虽然是会看到有多个用户会话接入,但是在PID列只会显示进程ID,无法对应到线程。

$ lsof -i 4 -a -p `pgrep -u omm3 mogdb`
COMMAND   PID USER   FD   TYPE   DEVICE SIZE/OFF NODE NAME
mogdb   12027 omm3    8u  IPv4 20313752      0t0  TCP *:biimenu (LISTEN)
mogdb   12027 omm3    9u  IPv4 20313753      0t0  TCP *:18001 (LISTEN)
mogdb   12027 omm3  325u  IPv4 28320946      0t0  TCP mogdb-kernel-0004:biimenu->softbank060132034173.bbtec.net:45206 (ESTABLISHED)
mogdb   12027 omm3  330u  IPv4 28316174      0t0  TCP mogdb-kernel-0004:biimenu->softbank060132034173.bbtec.net:45208 (ESTABLISHED)
mogdb   12027 omm3  336u  IPv4 28302815      0t0  TCP mogdb-kernel-0004:biimenu->softbank060132034173.bbtec.net:45210 (ESTABLISHED)
mogdb   12027 omm3  340u  IPv4 28323140      0t0  TCP mogdb-kernel-0004:biimenu->softbank060132034173.bbtec.net:45212 (ESTABLISHED)
mogdb   12027 omm3  360u  IPv4 28323141      0t0  TCP mogdb-kernel-0004:biimenu->softbank060132034173.bbtec.net:45214 (ESTABLISHED)
mogdb   12027 omm3  375u  IPv4 28305050      0t0  TCP mogdb-kernel-0004:biimenu->softbank060132034173.bbtec.net:45216 (ESTABLISHED)

如何获取线程ID

可以使用htop,打开htop界面以后,按F5进行进程树形显示,第一个PID是进程号,而树形结构下的每一行的PID都是该进程中对应的线程号。

也可以直接使用ps命令。-L参数表示显示线程,-o参数可以指定显示感兴趣的列。

# ps -Lp `pgrep -u omm3 mogdb` -o %cpu,tid,pid,ppid,cmd,comm
%CPU   TID   PID  PPID CMD                         COMMAND
 0.0 17847 17847     1 /opt/mogdb3/app/bin/mogdb - mogdb
 0.0 17848 17847     1 /opt/mogdb3/app/bin/mogdb - jemalloc_bg_thd
 0.0 17854 17847     1 /opt/mogdb3/app/bin/mogdb - mogdb
 0.0 17855 17847     1 /opt/mogdb3/app/bin/mogdb - syslogger
 0.0 17856 17847     1 /opt/mogdb3/app/bin/mogdb - reaper
 0.0 17857 17847     1 /opt/mogdb3/app/bin/mogdb - jemalloc_bg_thd
 0.0 17858 17847     1 /opt/mogdb3/app/bin/mogdb - jemalloc_bg_thd
 0.0 17860 17847     1 /opt/mogdb3/app/bin/mogdb - jemalloc_bg_thd
 0.0 17884 17847     1 /opt/mogdb3/app/bin/mogdb - checkpointer
 0.0 17885 17847     1 /opt/mogdb3/app/bin/mogdb - Spbgwriter
 0.1 17886 17847     1 /opt/mogdb3/app/bin/mogdb - pagewriter
 0.0 17887 17847     1 /opt/mogdb3/app/bin/mogdb - pagewriter
 0.0 17888 17847     1 /opt/mogdb3/app/bin/mogdb - pagewriter
 0.0 17889 17847     1 /opt/mogdb3/app/bin/mogdb - pagewriter
 0.0 17890 17847     1 /opt/mogdb3/app/bin/mogdb - pagewriter
 0.8 17891 17847     1 /opt/mogdb3/app/bin/mogdb - WALwriter
 0.0 17892 17847     1 /opt/mogdb3/app/bin/mogdb - WALwriteraux
 0.0 17893 17847     1 /opt/mogdb3/app/bin/mogdb - AVClauncher
 0.0 17894 17847     1 /opt/mogdb3/app/bin/mogdb - Jobscheduler
 0.0 17895 17847     1 /opt/mogdb3/app/bin/mogdb - asyncundolaunch
 0.0 17896 17847     1 /opt/mogdb3/app/bin/mogdb - globalstats
 0.0 17897 17847     1 /opt/mogdb3/app/bin/mogdb - applylauncher
 0.0 17898 17847     1 /opt/mogdb3/app/bin/mogdb - statscollector
 0.0 17899 17847     1 /opt/mogdb3/app/bin/mogdb - snapshotworker
 0.1 17900 17847     1 /opt/mogdb3/app/bin/mogdb - TrackStmtWorker
 0.0 17901 17847     1 /opt/mogdb3/app/bin/mogdb - 2pccleaner
 0.0 17902 17847     1 /opt/mogdb3/app/bin/mogdb - faultmonitor
 0.0 17904 17847     1 /opt/mogdb3/app/bin/mogdb - undorecycler
 0.0 18372 17847     1 /opt/mogdb3/app/bin/mogdb - worker
 0.0 18373 17847     1 /opt/mogdb3/app/bin/mogdb - worker
 0.0 18374 17847     1 /opt/mogdb3/app/bin/mogdb - worker
 0.0 18375 17847     1 /opt/mogdb3/app/bin/mogdb - worker
 0.0 18376 17847     1 /opt/mogdb3/app/bin/mogdb - worker
 0.0 18377 17847     1 /opt/mogdb3/app/bin/mogdb - worker
 0.0 18378 17847     1 /opt/mogdb3/app/bin/mogdb - worker
 0.0 18379 17847     1 /opt/mogdb3/app/bin/mogdb - worker
 0.0 18380 17847     1 /opt/mogdb3/app/bin/mogdb - worker
 0.0 18381 17847     1 /opt/mogdb3/app/bin/mogdb - worker
 0.0 18382 17847     1 /opt/mogdb3/app/bin/mogdb - worker
 0.0 18454 17847     1 /opt/mogdb3/app/bin/mogdb - worker
 0.0 19475 17847     1 /opt/mogdb3/app/bin/mogdb - worker
 0.0 19480 17847     1 /opt/mogdb3/app/bin/mogdb - worker
 0.0 29529 17847     1 /opt/mogdb3/app/bin/mogdb - worker
 0.0 30999 17847     1 /opt/mogdb3/app/bin/mogdb - worker

comm列中显示为woker的都是用户会话的数据库端后台进程,通常占用CPU较高的会是用户会话,因此可以用grep命令来过滤只显示用户会话。

#  ps -Lp `pgrep -u omm3 mogdb` -o %cpu,tid,pid,ppid,cmd,comm | grep -w worker
 0.0 18372 17847     1 /opt/mogdb3/app/bin/mogdb - worker
 0.0 18373 17847     1 /opt/mogdb3/app/bin/mogdb - worker
 0.0 18374 17847     1 /opt/mogdb3/app/bin/mogdb - worker
 0.0 18375 17847     1 /opt/mogdb3/app/bin/mogdb - worker
 0.0 18376 17847     1 /opt/mogdb3/app/bin/mogdb - worker
 0.0 18377 17847     1 /opt/mogdb3/app/bin/mogdb - worker
 0.0 18378 17847     1 /opt/mogdb3/app/bin/mogdb - worker
 0.0 18379 17847     1 /opt/mogdb3/app/bin/mogdb - worker
 0.0 18380 17847     1 /opt/mogdb3/app/bin/mogdb - worker
 0.0 18381 17847     1 /opt/mogdb3/app/bin/mogdb - worker
 0.0 18382 17847     1 /opt/mogdb3/app/bin/mogdb - worker
 0.0 18454 17847     1 /opt/mogdb3/app/bin/mogdb - worker
 0.0 19475 17847     1 /opt/mogdb3/app/bin/mogdb - worker
 0.0 19480 17847     1 /opt/mogdb3/app/bin/mogdb - worker
 0.0 29529 17847     1 /opt/mogdb3/app/bin/mogdb - worker
 0.0 30999 17847     1 /opt/mogdb3/app/bin/mogdb - worker

如何将操作系统线程ID跟数据库会话对应

假设在这台服务器上,线程ID=18372的线程占用了大量CPU。

在MogDB里查询pg_os_threads视图,可以获得该线程在数据库中对应的会话ID 。

MogDB=# select * from pg_os_threads where lwpid=18372;
 node_name |       pid       | lwpid | thread_name |         creation_time
-----------+-----------------+-------+-------------+-------------------------------
 dn_6001   | 140545137571584 | 18372 | dn_6001     | 2022-05-30 19:54:42.459129+08
(1 row)

pg_os_threads视图里记录了轻量级线程号和会话ID的关系,其中lwpid是操作系统线程ID,pid列是数据库会话ID。具体信息可以参考MogDB文档-PG_OS_THREADS
如果具备monadmin权限,也可以查询dbe_perf模式下的os_threads视图,信息是一样的。

找到数据库会话ID之后,就可以为所欲为了,比如可以查询dbe_perf.session_stat_activity视图来获取该会话的应用名,发起的客户端IP地址,还有该会话正在执行的SQL。

MogDB=# select application_name,client_addr,query from dbe_perf.session_stat_activity where pid=140545137571584;
 application_name | client_addr  |                          query
------------------+--------------+---------------------------------------------------------
 dn_6001          | 172.16.0.176 | SELECT cfg_value FROM bmsql_config  WHERE cfg_name = $1
(1 row)

也可以查询dbe_perf.thread_wait_status视图来获取会话的当前等待事件。BTW,实际上该视图中有lwtid字段,可以直接对应到线程ID。

MogDB=# select lwtid,wait_status,wait_event from dbe_perf.thread_wait_status where sessionid=140545137571584;
 lwtid | wait_status | wait_event
-------+-------------+------------
 18372 | wait cmd    | wait cmd
(1 row)