2022-08-18

phpmyadmin 5.2.0 + mariadb 10.88.0.1,檢視使用者權限時遇到"Not enough privilege to view users"(權限不足以檢視使用者)

場景:
 phpmyadmin 5.2.0
 mariadb 10.88.0.1

問題:
phpmyadmin點選使用者帳號(User accounts)頁籤時,無法顯示使用者,出現"Not enough privilege to view users"(權限不足以檢視使用者)錯誤訊息

解決方式:
執行以下語句,並重新啟動mariadb
use mysql;
INSERT INTO `tables_priv` (`Host`, `Db`, `User`, `Table_name`, `Grantor`, `Timestamp`, `Table_priv`, `Column_priv`) VALUES ('localhost','mysql','mariadb.sys','global_priv','root@localhost','0000-00-00 00:00:00','Select,Delete','');

ref:
https://stackoverflow.com/questions/60387072/not-enough-privilege-to-view-users-in-phpmyadmin

2022-04-21

tomcat 9 發生 "too many open files" (開啟太多檔案)

 前二天早上tomcat突然掛掉,log 顯示如下:

  20-Apr-2022 10:22:41.714 嚴重 [https-jsse-nio2-8443-Acceptor-0] org.apache.tomcat.util.net.Acceptor.run Socket accept failed
 java.util.concurrent.ExecutionException: java.io.IOException: 開啟太多檔案
	at sun.nio.ch.CompletedFuture.get(CompletedFuture.java:69)
	at org.apache.tomcat.util.net.Nio2Endpoint.serverSocketAccept(Nio2Endpoint.java:334)
	at org.apache.tomcat.util.net.Nio2Endpoint.serverSocketAccept(Nio2Endpoint.java:59)
	at org.apache.tomcat.util.net.Acceptor.run(Acceptor.java:95)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: 開啟太多檔案
	at sun.nio.ch.UnixAsynchronousServerSocketChannelImpl.accept0(Native Method)
	at sun.nio.ch.UnixAsynchronousServerSocketChannelImpl.accept(UnixAsynchronousServerSocketChannelImpl.java:344)
	at sun.nio.ch.UnixAsynchronousServerSocketChannelImpl.implAccept(UnixAsynchronousServerSocketChannelImpl.java:280)
	at sun.nio.ch.AsynchronousServerSocketChannelImpl.accept(AsynchronousServerSocketChannelImpl.java:125)
	... 4 more

初步調查是tomcat開啟了太多檔案,造成"too many open files" (開啟太多檔案),網路上一般說法是說要調整系統的ulimit上限才行,但想想不太對,這系統會需要同時開啟的檔案不多,而且運行了幾年也沒有發生file leak的狀況。

先找出tomcat的pid,再用 ls -al /proc/<pid>/fd | wc -l,就可以知道tomcat目前開啟多少檔案(包含unix socket file)。

後來發現是tomcat自已的bug,會一直存取tomcat-users.xml卻沒有釋放資源,解法是升級 tomcat 9 >= 9.0.14+,或修改 server.xml,加入watchSource="false":

<resource 
 auth="Container"
 description="User database that can be updated and saved"
 factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
 name="UserDatabase" pathname="conf/tomcat-users.xml"
 type="org.apache.catalina.UserDatabase"
 watchsource="false">
ref:
https://bz.apache.org/bugzilla/show_bug.cgi?id=62924#c2
https://zhuanlan.zhihu.com/p/75897823
https://www.cnblogs.com/linus-tan/p/10328801.html

2022-04-16

ubuntu/mint下chromium啟用硬體加速+解決netflix無法觀看

在ubuntu/mint下要啟用chromium的硬體加速,必須是pathced過的版本,

可以用 https://launchpad.net/~saiarcot895/+archive/ubuntu/chromium-beta 
(包含Widevine,觀看netflix等有DRM保護的串流時需要)

或 https://github.com/Eloston/ungoogled-chromium#downloads 
(不包含Widevine)

先裝好對應各顯卡的VA-API driver,啟動chromium時加上以下參數:

chromium-browser --use-gl=desktop --enable-features=VaapiVideoDecoder --disable-features=UseChromeOSDirectVideoDecoder
(chromium 98開始需加上 --disable-features=UseChromeOSDirectVideoDecoder)

====2024.09更新(在128的版本實測有效):==========

https://ubuntuhandbook.org/index.php/2024/01/chromium-va-api-wayland/
https://debugpointnews.com/va-api-chromium-wayland/

chromium 121以後的版本,可以不用再找有va-api patched過的版本,直接使用以下參數開啟硬體加速:

On X11:
chromium-browser --enable-features=VaapiVideoDecodeLinuxGL --use-gl=angle --use-angle=gl --ozone-platform=x11

On Wayland:
chromium-browser --enable-features=VaapiVideoDecodeLinuxGL --use-gl=angle --use-angle=gl --ozone-platform=wayland

=====================================

用ungoogled-chromium又想加上Widevine DRM支援時,
可先下載對應版本的Chrome DEB安裝檔(stable, unstable),
解開後,把 ./opt/google/chrome/WidevineCdm 複製到
 /usr/lib/chromium/WidevineCd 或 ~/.local/lib/WidevineCdm

ref:
https://wiki.archlinux.org/title/Chromium#Hardware_video_acceleration
https://www.linuxuprising.com/2018/08/how-to-enable-hardware-accelerated.html
https://ungoogled-software.github.io/ungoogled-chromium-wiki/faq#linux

2022-02-12

Acer SPIN 5 (SP513-55N, SP513-41N)安裝Ubuntu/Linux MINT Cinnamon 20.3

想要支援平版型筆電, MINT裝Cinnamon版本會友善一點,MATE/XFCE的支援度差一點,但後面會講解法。 

1.開機時按F2進BIOS,
在Main頁面按ctrl+s呼叫出隱藏選項,
將SATA Mode=> AHCI, trackpad => PS2(待會會再改回來),
在Security將TPM關閉,
在Boot頁面將Secure Boot關閉(要先在Security頁面設Supervisor Password才能改),
Boot priority order 設為要用來安裝Ubuntu/Mint的USB。

2.開始安裝Mint,安裝時個人是分成三個分割區:
EFI => 550mb (UEFI開機載入需要此分割區)
SWAP=> 5120mb
剩下的都格式化為ext4並 mount 給 /

3.裝完後,修改 /etc/default/grub:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash pci=nocrs" #加入pci=nocrs
GRUB_SAVEDEFAULT=true
GRUB_DEFAULT=saved
GRUB_TIMEOUT=3

修改完執行 sudo update-grub

3.打開更新管理員執行更新,若是intel版本,AX210網卡需5.10+ kernel,AX200需5.1+ kernel。若是amd版本,附的應該是都MT7921聯發科網卡,需要5.12+ kernel,但我建議把聯發科卡換成intel網卡,就算弄到能上網一樣是真心爛(掉包降速斷線等)。

重開機,進BIOS把trackpad改回IC2,開機時在選單選擇用最新的kernel開機。

4.調整自動旋轉
= 若是Cinnamon =:
進 管理/顯示器/設定,選擇Hi-DPI啟用fractional scaling,fractional scaling選150%
安裝touchscreen旋轉時的xinput修正:
sudo apt-get install x11-touchscreen-calibrator

Cinnamon其中有一個"自動螢幕旋轉",請保持停用狀態,不然啟用的話,螢幕設定不知怎的都無法正常保存。

= 若是MATE/XFCE =:
桌面設定一樣改 Hi-DPI
sudo apt-get install x11-touchscreen-calibrator
xrandr --output eDP --scale 1.5x1.5
sudo apt install autorandr
autorandr --save work

不管哪個版本,自動旋轉請改用自動偵測script (https://askubuntu.com/a/1375561),可放到開機自動啟動:

sudo apt install iio-sensor-proxy inotify-tools

==================================
#!/bin/bash
# Auto rotate screen based on device orientation
monitor-sensor | \
while IFS= read -r str; do
  if [[ $str =~ orientation\ changed:\ (.*)$ ]]; then
    case "${BASH_REMATCH[1]}" in
    normal)
      xrandr --output eDP --rotate normal ;;
    bottom-up)
      xrandr --output eDP --rotate inverted ;;
    right-up)
      xrandr --output eDP --rotate right ;;
    left-up)
      xrandr --output eDP --rotate left ;;
    esac
  fi
done
=================================

5.調整firefox滑動及steam縮放,修改/etc/environment,加入:
MOZ_USE_XINPUT2=1 #firefox,並把firefox設定中的平滑捲動取消
# GDK_SCALE=2 #steam,不過建議在啟動steam時加在指令前面就好

6.調整java介面縮放,修改 ~/.profile,加入:
#java ui scale
export _JAVA_OPTIONS='-Dsun.java2d.uiScale.enabled=true  -Dsun.java2d.uiScale=2'

7.fcitx輸入文字時,候選字(preedit)視窗(fcitx-qimpanel)過小:

譬如用的是ubutnu-grey主題,那麼就修改:
sudo vi /usr/share/fcitx-qimpanel/skin/ubuntu-grey/fcitx_skin.conf

FontSize=36
CandFontSize=36

若是用default佈景,那就修改:
sudo vi /usr/share/fcitx/skin/default/fcitx_skin.conf

8.觸控板多指手勢支援:
X11(後面指令以X11為主):
https://github.com/bulletmark/libinput-gestures
https://gitlab.com/cunidev/gestures

sudo apt install python3 python3-pip python3-venv python3-gi python-gobject meson wmctrl xdotool libinput-tools gettext appstream-util

sudo gpasswd -a $USER input
git clone https://github.com/bulletmark/libinput-gestures.git
cd libinput-gestures
sudo make install (or sudo ./libinput-gestures-setup install)
cp /etc/libinput-gestures.conf ~/.config/libinput-gestures.conf
newgrp input
libinput-gestures-setup autostart start


git clone https://gitlab.com/cunidev/gestures
cd gestures
meson build --prefix=/usr
ninja -C build
sudo ninja -C build install

之後再執行gestures程式調整要的多指手勢

若display server是Wayland的話,可參考:
https://extensions.gnome.org/extension/1253/extended-gestures/

9.指紋辨識(Fingerprint Reader),因為我用不到,而且加入方式也挺麻煩,跳過。

10. 修正外接麥克風(內建麥克風正常)無法收音問題:
修改 /etc/modprobe.d/alsa-base.conf
加入:
options snd-hda-intel model=alc255-acer,dell-headset-multi
(https://askubuntu.com/a/1307107)

11.取消進入休眠HIBERNATE (按F1似乎還是會進待機SUSPEND,但不會叫不醒了,也行…)
修改 /etc/systemd/logind.conf:
HandleSuspendKey=ignore

ref:
https://sciactive.com/2020/12/04/how-to-install-ubuntu-on-acer-spin-5-sp513-54n-for-the-perfect-linux-2-in-1/
https://wiki.archlinux.org/title/HiDPI

2021-10-03

安裝 jetbrains projector 並以 user systemd 方式啟動

 安裝很簡單,直接參考github官方網站:
https://github.com/JetBrains/projector-installer

設定:
projector config list
projector config  edit <APP_NAME>

憑證:
若有用let's encrypt,可直接用如下指令安裝,記得憑證過期一樣要再重安裝一次
(APP_NAME可能為IntelliJ或DataGrip,可參照 ~/.projector/configs):

projector install-certificate <APP_NAME> --certificate /etc/letsencrypt/live/<change.to.your.site.com>/fullchain.pem --key /etc/letsencrypt/live/<change.to.your.site.com>/privkey.pem;

以下補充如何以user systemd的方式自啟動,這樣ide點擊exit或reload時就會重新啟動,也不用登入tty,以下以新增 IntelliJ IDEA為例:
mkdir -p ~/.config/systemd/user/
vi ~/.config/systemd/user/idea.service
加入:
======================
[Unit]
Description=Jetbrains Projector - IDEA

[Service]
Type=simple
#注意這裡要改為用 run.sh 執行
ExecStart=%h/.projector/configs/IntelliJ/run.sh
Restart=always

[Install]
WantedBy=default.target
======================
再執行(以一般使用者身份執行即可)
systemctl --user start idea
systemctl --user status idea
systemctl --user enable idea
#不用tty登入也可reboot時自啟動
loginctl enable-linger <username> 

ref:
https://youtrack.jetbrains.com/issue/PRJ-298
https://wiki.archlinux.org/title/systemd/User#Automatic_start-up_of_systemd_user_instances

2021-09-16

WIN7的XP Mode導出vhd檔案並在VirtualBox(或VMware) 執行

 一、先確認你記得XP Mode的XMPUser密碼(先登出再登入試試),不然就是改為無密碼登入

二、確認將XP Mode關機(ctrl + alt +del 並選關機),確保不是在儲存狀態下

三、到XP Mode設定的硬碟一(Hard Disk 1)點選「修改(Modify)」並選「合併(Merge)」映像檔,此時會產出一個vhd檔案 

四、到VirtualBox(或VMware) 新建XP虛擬機,並指定剛剛產生的vhd檔

五、此時很可能會顯示「需啟動Windows XP」而鬼打牆無法登入,即使輸入key也一樣,先重開虛擬機並按F8進入安全模式

六、下載https://t.me/joinchat/JtV8PRmFFTeDZ_PHNVtC3g 此 tg群組內的 sp3 檔案(MEGA備份),解壓縮並放到虛擬機桌面

七、把剛解壓縮的system32資料夾內的檔案覆蓋到 C:\WINDOWS\system32,並再執行資料夾內的XP_Pro_SP3_OEM_to_VLK.reg,再重開機

八、此時很可能還會要您啟動,隨便找個VLK KEY輸入即可。
HCQ9D-TVCWX-X9QRG-J4B2Y-GR2TT

九、有些MIDI軟體在Virtualbox播放時聲音會產生嚴重卡頓,不管怎麼改設定都沒用,因此後來改用VMWare完全沒問題。

ref:
https://www.hanselman.com/blog/transferringmoving-a-vhd-from-windows-virtual-pc-windows-xp-mode-to-another-computer
https://hibest.tw/oem-to-vlk-windowsxp/

2021-09-13

老筆電X61出現Possible missing firmware...訊息

由於 linux-firmware 套件缺少了i915晶片一些韌體,導致每次更新kernel就會出現下列訊息:

update-initramfs: Generating /boot/initrd.img-5.4.0-84-generic
W: Possible missing firmware /lib/firmware/i915/tgl_dmc_ver2_04.bin for module i915
W: Possible missing firmware /lib/firmware/i915/skl_guc_33.0.0.bin for module i915
W: Possible missing firmware /lib/firmware/i915/bxt_guc_33.0.0.bin for module i915
W: Possible missing firmware /lib/firmware/i915/kbl_guc_33.0.0.bin for module i915
W: Possible missing firmware /lib/firmware/i915/glk_guc_33.0.0.bin for module i915
W: Possible missing firmware /lib/firmware/i915/kbl_guc_33.0.0.bin for module i915
W: Possible missing firmware /lib/firmware/i915/icl_guc_33.0.0.bin for module i915

缺韌體問題,就來這個網址下載這一包找找:
https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/

果然找到,補到 /lib/firmware/i915/ 內就 ok 了!

ref: