Renew Alienware Alpha R1 with Pop!_OS

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

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.

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

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.

How to find the corresponding session in MogDB/openGauss from OS thread ID

诊断需求

当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)

How to make Total Commander works with Everything and QuickLook

让Windows操作系统更好用

大多数时间我的工作是在自己的Macbook Pro里完成的,但是因为主要用于游戏的Windows配置了较大的屏幕,有时候也还是会顺手在Windows上进行工作。那么如何让Windows操作系统用起来更顺手?

Total Commander是神器

Total Commander是必装的WIndows资源管理器,从转到macOS之前,我最开始用Windows的时候就一直在用Total Commander,这个老牌的资源管理器从1996年就有了,现在已经更新到了10.0版本,软件价格不到300人民币,一次性购买终身免费升级,物超所值。
网络里有大量关于TC如何更有效率使用的文章,甚至有专门的TC学堂

Everything是神器

Everything是Windows下的搜索工具,所有使用的人都震惊于其闪电般的搜索速度,Everything on Windows的搜索效率远胜Spotlight on macOS。Everything是免费软件。

QuickLook是神器

macOS下的一大方便之处就是在Finder中选中任何文件,然后按空格键,就可以快速浏览,这个使用习惯一旦形成,当Windows没有内置这个功能的时候非常别扭。幸好,有QuickLook软件可以实现该功能。QuickLook是免费且开源的软件。

如何让Total Commander和Everything及QuickLook协同工作

现在我们要实现的是,在TC窗口里,选中文件按空格,打开QuickLook进行快速浏览;按Ctrl+F快捷键(TC默认的Ctrl+F快捷键是打开连接FTP服务器的窗口,用处不大)打开Everything搜索窗口。

  1. 在TC的配置文件目录下创建usercmd.ini文件,并且设置用户命令。
    网上的一些教程谈及在TC主目录下创建usercmd.ini,实际上是不全面的,TC会在自己的配置文件目录下寻找所有配置,而该目录可能在TC的程序安装目录下,也可能在单独的额外目录里。
    在菜单栏的帮助-关于 Total Commander页面里,可以找到设置文件路径,我的TC安装,程序文件和设置文件就是在不同的目录的。

在该路径下创建usercmd.ini,TC默认安装是没有该ini文件的,需要手工创建。
在该文件中增加如下内容。

[em_Everything]  
cmd=C:\Program Files\Everything\Everything.exe  
param="-search "%P "" 

[em_QuickLook]
cmd=D:\Tools\QuickLook\QuickLook.exe 
param="%P%N" 

其中cmd部分是填写Everything和QuickLook的安装路径,该部分需要根据自己安装路径的不同自行做修改;param就是当前的目录和文件名作为变量传入,该部分无需修改。

  1. 设置TC快捷键
    在菜单栏 配置-选项-其他页面,有“重新定义快捷键”部分。

下图是设置Ctrl+F快捷键,点击命令后面的放大镜图标,就可以找到之前在usercmd.ini中设置的em_Everything命令。

下图是设置空格快捷键,命令部分选择之前在usercmd.ini中设置的em_QuickLook命令。

One more thing

如果想要实现macOS里的Alfred快速启动的功能,推荐安装ueli,基本上可以复刻在Alfred中的体验。