升級ubuntu LTS

本站原本使用ubuntu 18.04.4 LTS (Long-term support版本),最近出了ubuntu 20.04 LTS,為了資安考量,差了2年的版本總是修補了很多漏洞,比較安全一點,就升級啦。

本站跑在vmware esxi上面,升級前為了安全起見,先匯出整個VM的映像檔保存起來,如果發生意外再還原回來。

使用下面命令升級
sudo do-release-upgrade

竟然告訴我,沒有新版???
There is no development version of an LTS available.
To upgrade to the latest non-LTS develoment release
set Prompt=normal in /etc/update-manager/release-upgrades.

查了一下,原來要加參數 -d 強制,不懂為什麼
sudo do-release-upgrade -d

然後開始跑了大概40分鐘,就好了。

重開後檢查版本
$lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04 LTS
Release: 20.04
Codename: focal

$ uname -a
Linux esxi-web 5.4.0-29-generic #33-Ubuntu SMP Wed Apr 29 14:32:27 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

MariaDB裝好之後,啟動不了

在ubuntu 18.04,MariaDB 10.1.34裝好之後,啟動發生問題?真奇怪,現象是
sudo systemctl start mariadb
後,卡住,約一分鐘後mysqld process自己結束,
systemctl status mariadb
說 mariadb.service: Start operation timed out. Terminating.

用 journalctl -xe 顯示有一堆mariadb相關的mysqld apparmor=”DENIED” 訊息,例如:
Aug 18 15:14:37 G3258-H87TN kernel: [ 2336.888019] audit: type=1400 audit(1534576477.647:87): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=15348 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Aug 18 15:51:01 G3258-H87TN kernel: [ 1825.518188] audit: type=1400 audit(1534578661.329:33): apparmor="DENIED" operation="sendmsg" info="Failed name lookup - disconnected path" error=-13 profile="/usr/sbin/mysqld" name="run/systemd/notify" pid=9354 comm="mysqld" requested_mask="w" denied_mask="w" fsuid=107 ouid=0

查了一下,網上高人指出是apparmor的問題,為什麼?不知道,就目錄權限之類的問題。

解決之法是:安裝 apparmor-utils
sudo apt-get install apparmor-utils

sudo aa-complain /usr/sbin/mysqld

sudo aa-disable /usr/sbin/mysqld

Reboot之就好了。

還是怕忘記,記起來參考。

安裝MariaDB沒有問設定root密碼怎麼辦

今天把ubuntu 18.04中的mysql server 5.7移除,
sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*
裝MariaDB
sudo apt-get install mariadb-server mariadb-client
安裝MariaDB過程中沒有問root密碼要設什麼,也沒有預設密碼,那之後用什麼密碼連呢?紀錄一下,免得忘記:
用sudo使用無密碼進入mysql
sudo mysql -u root
連入後,就可以自設了
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('你要的密碼');

或者使用
sudo mysql_secure_installation
進行後續安裝。

幾個php 7跑WordPress要安裝的模組

這幾天重裝一台ubuntu server,裝了nginx、php7.0之後,要跑Wordpress或phpMyAdmin,有幾個php 7.0的模組要安裝,紀錄一下,免得忘記:
sudo apt-get install php7.0-fpm
sudo apt-get install php7.0-gd
sudo apt-get install php7.0-xml
sudo apt-get install php7.0-mbstring
sudo apt-get install php7.0-mysql