ubuntu install polardb-x by deb ball
本篇文章基于上述 4 篇 文章 单机版
CentOS 7.9 环境安装 PolarDB-X 数据库: https://developer.aliyun.com/article/1704678
银河麒麟V10操作系统安装 Polardb-X 数据库: https://developer.aliyun.com/article/1704731
欧拉 openEuler 20.03 操作系统安装 Polardb-X 数据库: https://developer.aliyun.com/article/1704866
PolarDB-X 集中式三节点高可用集群部署 & Java 场景 CRUD 应用: https://developer.aliyun.com/article/1705878
下面开始编写 Ubuntu 18.04.6 操作系统安装 Polardb-X 数据库 单机版 deb 包 教程
0. env
polarx@linux:~$ cat /etc/issue
Ubuntu 18.04.6 LTS \n \l
polarx@linux:~$ arch
x86_64
polarx@linux:~$ uname -sr
Linux 5.4.0-150-generic
polarx@linux:~$
polarx@linux:~$ free -h
总计 已用 空闲 共享 缓冲/缓存 可用
内存: 7.8G 1.5G 127M 22M 6.2G 6.0G
交换: 2.0G 1.0M 2.0G
polarx@linux:~$
polarx@linux:~$ lscpu |grep "^CPU:"
CPU: 2
polarx@linux:~$
1. rpm 2 deb ball
qc@ubuntu ~/Downloads $ sudo apt install alien
qc@ubuntu ~/Downloads $
qc@ubuntu ~/Downloads $ sudo alien t-polardbx-engine-8.4.19-20250825_17558853.el7.x86_64.rpm
Warning: Skipping conversion of scripts in package t-polardbx-engine: postinst preinst
Warning: Use the --scripts parameter to include the scripts.
t-polardbx-engine_8.4.19-20250826_amd64.deb generated
qc@ubuntu ~/Downloads $
qc@ubuntu ~/Downloads $ ll t-polardbx-engine-8.4.19-20250825_17558853.el7.x86_64.rpm
-rw-rw-r-- 1 qc qc 674397380 Jan 8 11:42 t-polardbx-engine-8.4.19-20250825_17558853.el7.x86_64.rpm
qc@ubuntu ~/Downloads $
qc@ubuntu ~/Downloads $ ll t-polardbx-engine_8.4.19-20250826_amd64.deb
-rw-r--r-- 1 root root 669259014 Jan 14 08:49 t-polardbx-engine_8.4.19-20250826_amd64.deb
qc@ubuntu ~/Downloads $
2. install deb
root@linux:/home/ubuntu# ll t-polardbx-engine_8.4.19-20250826_amd64.deb
-rw-r--r-- 1 ubuntu ubuntu 669259014 1月 14 08:51 t-polardbx-engine_8.4.19-20250826_amd64.deb
root@linux:/home/ubuntu#
root@linux:/home/ubuntu# apt install ./t-polardbx-engine_8.4.19-20250826_amd64.deb
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
注意,选中 't-polardbx-engine' 而非 './t-polardbx-engine_8.4.19-20250826_amd64.deb'
下列软件包是自动安装的并且现在不需要了:
gir1.2-goa-1.0 gir1.2-snapd-1
使用'apt autoremove'来卸载它(它们)。
下列【新】软件包将被安装:
t-polardbx-engine
升级了 0 个软件包,新安装了 1 个软件包,要卸载 0 个软件包,有 3 个软件包未被升级。
需要下载 0 B/669 MB 的归档。
解压缩后会消耗 3,010 MB 的额外空间。
获取:1 /home/ubuntu/t-polardbx-engine_8.4.19-20250826_amd64.deb t-polardbx-engine amd64 8.4.19-20250826 [669 MB]
正在选中未选择的软件包 t-polardbx-engine。
(正在读取数据库 ... 系统当前共安装有 170514 个文件和目录。)
正准备解包 .../t-polardbx-engine_8.4.19-20250826_amd64.deb ...
正在解包 t-polardbx-engine (8.4.19-20250826) ...
正在设置 t-polardbx-engine (8.4.19-20250826) ...
正在处理用于 libc-bin (2.27-3ubuntu1.6) 的触发器 ...
root@linux:/home/ubuntu#
- check after install
ubuntu@linux:~$ ll /u01/
总用量 4
drwxr-xr-x 11 root root 4096 1月 14 08:52 xcluster80_20250825_current
ubuntu@linux:~$
ubuntu@linux:~$ ll /u01/xcluster80_20250825_current
总用量 732
drwxr-xr-x 2 root root 4096 1月 14 08:52 bin
drwxr-xr-x 2 root root 4096 1月 14 08:52 docs
drwxr-xr-x 3 root root 4096 1月 14 08:52 include
drwxr-xr-x 6 root root 4096 1月 14 08:52 lib
-rwxr-xr-x 1 root root 283374 8月 22 17:58 LICENSE
-rwxr-xr-x 1 root root 121462 8月 22 17:58 LICENSE.router
-rwxr-xr-x 1 root root 283374 8月 22 17:58 LICENSE-test
drwxr-xr-x 4 root root 4096 1月 14 08:51 man
-rwxr-xr-x 1 root root 1622 8月 22 17:59 mysqlrouter-log-rotate
-rwxr-xr-x 1 root root 952 8月 22 17:58 README
-rwxr-xr-x 1 root root 679 8月 22 17:58 README.router
-rwxr-xr-x 1 root root 952 8月 22 17:58 README-test
drwxr-xr-x 2 root root 4096 8月 22 18:06 run
drwxr-xr-x 28 root root 4096 1月 14 08:52 share
drwxr-xr-x 2 root root 4096 1月 14 08:52 support-files
drwxr-xr-x 3 root root 4096 1月 14 08:51 var
ubuntu@linux:~$
3. basic config
root@linux:~# cd /u01/
root@linux:/u01# ll
总用量 4
drwxr-xr-x 11 root root 4096 1月 14 08:52 xcluster80_20250825_current
root@linux:/u01# cp -a xcluster80_20250825_current xcluster80
root@linux:/u01# cp -a xcluster80_20250825_current xcluster80_20250825
root@linux:/u01# ll
总用量 12
drwxr-xr-x 11 root root 4096 1月 14 08:52 xcluster80
drwxr-xr-x 11 root root 4096 1月 14 08:52 xcluster80_20250825
drwxr-xr-x 11 root root 4096 1月 14 08:52 xcluster80_20250825_current
root@linux:/u01#
root@linux:/u01# ln -s /u01/xcluster80_20250825 /opt/polardbx_engine
root@linux:/u01# cd /opt/
root@linux:/opt# ll
总用量 0
lrwxrwxrwx 1 root root 24 1月 14 09:13 polardbx_engine -> /u01/xcluster80_20250825
root@linux:/opt#
root@linux:/opt# ll polardbx_engine/
总用量 732
drwxr-xr-x 2 root root 4096 1月 14 08:52 bin
drwxr-xr-x 2 root root 4096 1月 14 08:52 docs
drwxr-xr-x 3 root root 4096 1月 14 08:52 include
drwxr-xr-x 6 root root 4096 1月 14 08:52 lib
-rwxr-xr-x 1 root root 283374 8月 22 17:58 LICENSE
-rwxr-xr-x 1 root root 121462 8月 22 17:58 LICENSE.router
-rwxr-xr-x 1 root root 283374 8月 22 17:58 LICENSE-test
drwxr-xr-x 4 root root 4096 1月 14 08:51 man
-rwxr-xr-x 1 root root 1622 8月 22 17:59 mysqlrouter-log-rotate
-rwxr-xr-x 1 root root 952 8月 22 17:58 README
-rwxr-xr-x 1 root root 679 8月 22 17:58 README.router
-rwxr-xr-x 1 root root 952 8月 22 17:58 README-test
drwxr-xr-x 2 root root 4096 8月 22 18:06 run
drwxr-xr-x 28 root root 4096 1月 14 08:52 share
drwxr-xr-x 2 root root 4096 1月 14 08:52 support-files
drwxr-xr-x 3 root root 4096 1月 14 08:51 var
root@linux:/opt#
root@linux:/opt# ll polardbx_engine/bin/
总用量 2413804
-rwxr-xr-x 1 root root 24435360 8月 22 18:01 comp_err
-rwxr-xr-x 1 root root 28027592 8月 22 18:01 ibd2sdi
-rwxr-xr-x 1 root root 26435488 8月 22 18:01 innochecksum
-rwxr-xr-x 1 root root 35528 8月 22 18:01 kms_agent_mock
-rwxr-xr-x 1 root root 13394432 8月 22 18:01 lz4_decompress
-rwxr-xr-x 1 root root 28240512 8月 22 18:01 myisamchk
-rwxr-xr-x 1 root root 27460272 8月 22 18:01 myisam_ftdump
-rwxr-xr-x 1 root root 15588128 8月 22 18:01 myisamlog
-rwxr-xr-x 1 root root 27618104 8月 22 18:01 myisampack
-rwxr-xr-x 1 root root 24023384 8月 22 18:01 my_print_defaults
-rwxr-xr-x 1 root root 41704352 8月 22 18:01 mysql
-rwxr-xr-x 1 root root 39626072 8月 22 18:01 mysqladmin
-rwxr-xr-x 1 root root 47954480 8月 22 18:01 mysqlbinlog
-rwxr-xr-x 1 root root 39976112 8月 22 18:01 mysqlcheck
-rwxr-xr-x 1 root root 42148976 8月 22 18:01 mysql_client_test
-rwxr-xr-x 1 root root 5153 8月 22 17:59 mysql_config
-rwxr-xr-x 1 root root 24187768 8月 22 18:01 mysql_config_editor
-rwxr-xr-x 1 root root 1319085576 8月 22 18:05 mysqld
-rwxr-xr-x 1 root root 27844 8月 22 17:59 mysqld_multi
-rwxr-xr-x 1 root root 31071 8月 22 17:59 mysqld_safe
-rwxr-xr-x 1 root root 40159344 8月 22 18:01 mysqldump
-rwxr-xr-x 1 root root 7669 8月 22 17:59 mysqldumpslow
-rwxr-xr-x 1 root root 39599520 8月 22 18:01 mysqlimport
-rwxr-xr-x 1 root root 26694136 8月 22 18:01 mysql_keyring_encryption_test
-rwxr-xr-x 1 root root 42435592 8月 22 18:01 mysql_migrate_keyring
-rwxr-xr-x 1 root root 54435744 8月 22 18:02 mysqlpump
-rwxr-xr-x 1 root root 12110840 8月 22 18:02 mysqlrouter
-rwxr-xr-x 1 root root 2256864 8月 22 18:01 mysqlrouter_keyring
-rwxr-xr-x 1 root root 1702728 8月 22 18:02 mysqlrouter_passwd
-rwxr-xr-x 1 root root 11674224 8月 22 18:01 mysqlrouter_plugin_info
-rwxr-xr-x 1 root root 39518400 8月 22 18:01 mysql_secure_installation
-rwxr-xr-x 1 root root 39571960 8月 22 18:01 mysqlshow
-rwxr-xr-x 1 root root 39689952 8月 22 18:01 mysqlslap
-rwxr-xr-x 1 root root 27724384 8月 22 18:01 mysql_ssl_rsa_setup
-rwxr-xr-x 1 root root 46477360 8月 22 18:01 mysqltest
-rwxr-xr-x 1 root root 47512 8月 22 17:59 mysqltest_safe_process
-rwxr-xr-x 1 root root 11927256 8月 22 18:01 mysql_tzinfo_to_sql
-rwxr-xr-x 1 root root 42924504 8月 22 18:01 mysql_upgrade
-rwxr-xr-x 1 root root 99186552 8月 22 18:01 mysqlxtest
-rwxr-xr-x 1 root root 24857736 8月 22 18:01 perror
-rwxr-xr-x 1 root root 86694864 8月 22 18:06 polarx_rpc_test
-rwxr-xr-x 1 root root 11929568 8月 22 18:01 zlib_decompress
root@linux:/opt#
4. create polardbx account
root@linux:~# useradd -ms /bin/bash polarx
root@linux:~#
root@linux:~# echo "polarx:polarx" | chpasswd
root@linux:~#
root@linux:~# echo "polarx ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
root@linux:~#
root@linux:~# su - polarx
polarx@linux:~$
polarx@linux:~$ mkdir -p polardbx-engine/{log,mysql,run,data,tmp}
polarx@linux:~$
polarx@linux:~$ ll
总用量 16
drwxrwxr-x 7 polarx polarx 4096 1月 14 09:17 polardbx-engine
polarx@linux:~$
polarx@linux:~$ ll polardbx-engine/
总用量 20
drwxrwxr-x 2 polarx polarx 4096 1月 14 09:17 data
drwxrwxr-x 2 polarx polarx 4096 1月 14 09:17 log
drwxrwxr-x 2 polarx polarx 4096 1月 14 09:17 mysql
drwxrwxr-x 2 polarx polarx 4096 1月 14 09:17 run
drwxrwxr-x 2 polarx polarx 4096 1月 14 09:17 tmp
polarx@linux:~$
5. my.cnf config
polarx@linux:~$ cd polardbx-engine/
polarx@linux:~/polardbx-engine$ vim my.cnf
polarx@linux:~/polardbx-engine$ cat my.cnf
[mysqld]
basedir = /opt/polardbx_engine
log_error_verbosity = 2
default_authentication_plugin = mysql_native_password
gtid_mode = ON
enforce_gtid_consistency = ON
log_bin = mysql-binlog
binlog_format = row
binlog_row_image = FULL
master_info_repository = TABLE
relay_log_info_repository = TABLE
# change me if needed
datadir = /home/polarx/polardbx-engine/data
tmpdir = /home/polarx/polardbx-engine/tmp
socket = /home/polarx/polardbx-engine/tmp.mysql.sock
log_error = /home/polarx/polardbx-engine/log/alert.log
port = 4886
cluster_id = 1234
cluster_info = 127.0.0.1:14886@1
server_id = 2712347953
[mysqld_safe]
pid_file = /home/polarx/polardbx-engine/run/mysql.pid
polarx@linux:~/polardbx-engine$
polarx@linux:~/polardbx-engine$ ll
总用量 24
drwxrwxr-x 2 polarx polarx 4096 1月 14 09:17 data
drwxrwxr-x 2 polarx polarx 4096 1月 14 09:17 log
-rw-rw-r-- 1 polarx polarx 667 1月 14 09:19 my.cnf
drwxrwxr-x 2 polarx polarx 4096 1月 14 09:17 mysql
drwxrwxr-x 2 polarx polarx 4096 1月 14 09:17 run
drwxrwxr-x 2 polarx polarx 4096 1月 14 09:17 tmp
polarx@linux:~/polardbx-engine$
6. database init
- 1st init
polarx@linux:~/polardbx-engine$ /opt/polardbx_engine/bin/mysqld --defaults-file=my.cnf --initialize-insecure
/opt/polardbx_engine/bin/mysqld: error while loading shared libraries: libsnappy.so.1: cannot open shared object file: No such file or directory
polarx@linux:~/polardbx-engine$
- install libsnappy-dev
polarx@linux:~/polardbx-engine$ sudo apt install libsnappy-dev -y
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
下列软件包是自动安装的并且现在不需要了:
gir1.2-goa-1.0 gir1.2-snapd-1
使用'sudo apt autoremove'来卸载它(它们)。
将会同时安装下列软件:
libsnappy1v5
下列【新】软件包将被安装:
libsnappy-dev libsnappy1v5
升级了 0 个软件包,新安装了 2 个软件包,要卸载 0 个软件包,有 3 个软件包未被升级。
需要下载 43.2 kB 的归档。
解压缩后会消耗 156 kB 的额外空间。
获取:1 https://mirrors.aliyun.com/ubuntu bionic/main amd64 libsnappy1v5 amd64 1.1.7-1 [16.0 kB]
获取:2 https://mirrors.aliyun.com/ubuntu bionic/main amd64 libsnappy-dev amd64 1.1.7-1 [27.2 kB]
已下载 43.2 kB,耗时 0秒 (116 kB/s)
正在选中未选择的软件包 libsnappy1v5:amd64。
(正在读取数据库 ... 系统当前共安装有 170915 个文件和目录。)
正准备解包 .../libsnappy1v5_1.1.7-1_amd64.deb ...
正在解包 libsnappy1v5:amd64 (1.1.7-1) ...
正在选中未选择的软件包 libsnappy-dev:amd64。
正准备解包 .../libsnappy-dev_1.1.7-1_amd64.deb ...
正在解包 libsnappy-dev:amd64 (1.1.7-1) ...
正在设置 libsnappy1v5:amd64 (1.1.7-1) ...
正在设置 libsnappy-dev:amd64 (1.1.7-1) ...
正在处理用于 libc-bin (2.27-3ubuntu1.6) 的触发器 ...
polarx@linux:~/polardbx-engine$
- 2d init
polarx@linux:~/polardbx-engine$ /opt/polardbx_engine/bin/mysqld --defaults-file=my.cnf --initialize-insecure
/opt/polardbx_engine/bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
polarx@linux:~/polardbx-engine$
- install libaio-dev
polarx@linux:~/polardbx-engine$ sudo apt install libaio-dev -y
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
下列软件包是自动安装的并且现在不需要了:
gir1.2-goa-1.0 gir1.2-snapd-1
使用'sudo apt autoremove'来卸载它(它们)。
将会同时安装下列软件:
libaio1
下列【新】软件包将被安装:
libaio-dev libaio1
升级了 0 个软件包,新安装了 2 个软件包,要卸载 0 个软件包,有 3 个软件包未被升级。
需要下载 19.3 kB 的归档。
解压缩后会消耗 87.0 kB 的额外空间。
获取:1 https://mirrors.aliyun.com/ubuntu bionic-updates/main amd64 libaio1 amd64 0.3.110-5ubuntu0.1 [6,476 B]
获取:2 https://mirrors.aliyun.com/ubuntu bionic-updates/main amd64 libaio-dev amd64 0.3.110-5ubuntu0.1 [12.8 kB]
已下载 19.3 kB,耗时 0秒 (119 kB/s)
正在选中未选择的软件包 libaio1:amd64。
(正在读取数据库 ... 系统当前共安装有 170939 个文件和目录。)
正准备解包 .../libaio1_0.3.110-5ubuntu0.1_amd64.deb ...
正在解包 libaio1:amd64 (0.3.110-5ubuntu0.1) ...
正在选中未选择的软件包 libaio-dev:amd64。
正准备解包 .../libaio-dev_0.3.110-5ubuntu0.1_amd64.deb ...
正在解包 libaio-dev:amd64 (0.3.110-5ubuntu0.1) ...
正在设置 libaio1:amd64 (0.3.110-5ubuntu0.1) ...
正在设置 libaio-dev:amd64 (0.3.110-5ubuntu0.1) ...
正在处理用于 man-db (2.8.3-2ubuntu0.1) 的触发器 ...
正在处理用于 libc-bin (2.27-3ubuntu1.6) 的触发器 ...
polarx@linux:~/polardbx-engine$
- 3d init (SUCCESS)
polarx@linux:~/polardbx-engine$ /opt/polardbx_engine/bin/mysqld --defaults-file=my.cnf --initialize-insecure
polarx@linux:~/polardbx-engine$
7. start PolarDB-X
polarx@linux:~/polardbx-engine$ /opt/polardbx_engine/bin/mysqld_safe --defaults-file=my.cnf &
[1] 4496
polarx@linux:~/polardbx-engine$ 2026-01-14T01:31:23.881838Z mysqld_safe Logging to '/home/polarx/polardbx-engine/log/alert.log'.
2026-01-14T01:31:23.913028Z mysqld_safe Starting mysqld daemon with databases from /home/polarx/polardbx-engine/data
polarx@linux:~/polardbx-engine$
8. check port (4886)
polarx@linux:~/polardbx-engine$ netstat -antp|grep 4886
(并非所有进程都能被检测到,所有非本用户的进程信息将不会显示,如果想看到所有信息,则必须切换到 root 用户)
tcp6 0 0 :::14886 :::* LISTEN 4792/mysqld
tcp6 0 0 :::4886 :::* LISTEN 4792/mysqld
polarx@linux:~/polardbx-engine$
9. client login
polarx@linux:~/polardbx-engine$ /opt/polardbx_engine/bin/mysql -h127.0.0.1 -P4886 -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 8.0.32-X-Cluster-8.4.19-20250825 Source distribution
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select version();
+----------------------------------+
| version() |
+----------------------------------+
| 8.0.32-X-Cluster-8.4.19-20250825 |
+----------------------------------+
1 row in set (0.00 sec)
mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2026-01-14 09:32:43 |
+---------------------+
1 row in set (0.00 sec)
mysql>
10. disable firewall ufw
root@linux:~# systemctl status ufw
● ufw.service - Uncomplicated firewall
Loaded: loaded (/lib/systemd/system/ufw.service; enabled; vendor preset: enabled)
Active: active (exited) since Wed 2026-01-14 08:42:44 CST; 58min ago
Docs: man:ufw(8)
Main PID: 259 (code=exited, status=0/SUCCESS)
Tasks: 0 (limit: 4915)
CGroup: /system.slice/ufw.service
Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.
root@linux:~#
root@linux:~# systemctl stop ufw
root@linux:~#
root@linux:~# systemctl disable ufw
Synchronizing state of ufw.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install disable ufw
root@linux:~#
root@linux:~# systemctl status ufw
● ufw.service - Uncomplicated firewall
Loaded: loaded (/lib/systemd/system/ufw.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:ufw(8)
1月 14 09:41:45 linux systemd[1]: Stopping Uncomplicated firewall...
1月 14 09:41:45 linux ufw-init[4921]: Skip stopping firewall: ufw (not enabled)
1月 14 09:41:45 linux systemd[1]: Stopped Uncomplicated firewall.
root@linux:~#