2023年5月25日,PostgreSQL全球开发组织正式发布PostgreSQL 16 的第一个beta版本,广大的PGers可以下载尝鲜,下载软件点击https://www.postgresql.org/download/。
下面笔者使用源码在CentOS 7.9安装PostgreSQL
下载源码
登录PostgreSQL官网,进入下载页面https://www.postgresql.org/ftp/source/v16beta1/,下载postgresql-16beta1.tar.bz2并将文件上传到CentOS虚拟机。
解压文件
cd /opt/postgresql/postgresql-16beta1/
tar xf postgresql-version.tar.bz2
创建postgres用户
[root@node3
local]# useradd postgres
[root@node3
local]# passwd postgres
创建PostgreSQL 16安装目录:
[root@node3
local]# mkdir -p /usr/local/pgsql16beta1/
[root@node3
local]# chown postgres:postgres /usr/local/pgsql16beta1/
[root@node3
local]# mkdir -p /usr/local/pgsql16beta1/data
[root@node3 local]# chown postgres:postgres /usr/local/pgsql16beta1/data/
编译安装
su - postgres
./configure --prefix=/usr/local/pgsql16beta1/ --without-icu
make
make install
编译完成之后初始化数据库
[postgres@node3
postgresql-16beta1]$ /usr/local/pgsql16beta1/bin/initdb -D
/usr/local/pgsql16beta1/data
The files
belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database
cluster will be initialized with locale "en_US.UTF-8".
The default
database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions
on existing directory /usr/local/pgsql16beta1/data ... ok
creating
subdirectories ... ok
selecting dynamic
shared memory implementation ... posix
selecting default
max_connections ... 100
selecting default
shared_buffers ... 128MB
selecting default
time zone ... America/New_York
creating
configuration files ... ok
running bootstrap
script ... ok
performing
post-bootstrap initialization ... ok
syncing data to
disk ... ok
initdb: warning:
enabling "trust" authentication for local connections
initdb: hint: You
can change this by editing pg_hba.conf or using the option -A, or --auth-local
and --auth-host, the next time you run initdb.
Success. You can
now start the database server using:
/usr/local/pgsql16beta1/bin/pg_ctl -D
/usr/local/pgsql16beta1/data -l logfile start
[postgres@node3
postgresql-16beta1]$
[postgres@node3
postgresql-16beta1]$ /usr/local/pgsql16beta1/bin/pg_ctl -D
/usr/local/pgsql16beta1/data -l logfile start
waiting for server
to start.... done
server started
[postgres@node3
postgresql-16beta1]$ /usr/local/pgsql16beta1/bin/createdb test
[postgres@node3
postgresql-16beta1]$
登录数据库
[postgres@node3
postgresql-16beta1]$ /usr/local/pgsql16beta1/bin/psql test
psql (16beta1)
Type
"help" for help.
test=# \d
Did not find any relations.
体验PostgreSQL 16新特性之:pg_stat_io视图
test=# \d
pg_stat_io
View
"pg_catalog.pg_stat_io"
Column
| Type | Collation | Nullable | Default
----------------+--------------------------+-----------+----------+---------
backend_type
| text | | |
object
| text | | |
context
| text | | |
reads
| bigint | | |
read_time
| double precision | | |
writes
| bigint | | |
write_time
| double precision | | |
writebacks
| bigint | | |
writeback_time | double precision | | |
extends
| bigint | | |
extend_time
| double precision | | |
op_bytes
| bigint | | |
hits
| bigint | | |
evictions
| bigint | | |
reuses
| bigint | | |
fsyncs
| bigint | | |
fsync_time
| double precision | |
|
stats_reset
| timestamp with time zone |
| |
test=# \d
pg_stat_all_tables
View
"pg_catalog.pg_stat_all_tables"
Column | Type | Collation | Nullable | Default
---------------------+--------------------------+-----------+----------+---------
relid | oid | | |
schemaname | name | | |
relname | name | | |
seq_scan | bigint | | |
last_seq_scan | timestamp with time zone | | |
seq_tup_read | bigint | | |
idx_scan | bigint | | |
last_idx_scan | timestamp with time zone | | |
idx_tup_fetch | bigint | | |
n_tup_ins | bigint | | |
n_tup_upd | bigint | | |
n_tup_del | bigint | | |
n_tup_hot_upd | bigint | | |
n_tup_newpage_upd | bigint | | |
n_live_tup | bigint | | |
n_dead_tup | bigint | | |
n_mod_since_analyze | bigint | | |
n_ins_since_vacuum | bigint | | |
last_vacuum | timestamp with time zone | | |
last_autovacuum | timestamp with time zone | | |
last_analyze | timestamp with time zone | | |
last_autoanalyze | timestamp with time zone | | |
vacuum_count | bigint | | |
autovacuum_count | bigint | | |
analyze_count | bigint | | |
autoanalyze_count | bigint | | |
今天的源码安装环节就到这里,后续为大家带来新特性分享。




