暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

PostgreSQL 16源码安装

原创 pgbase 2023-05-28
2281

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

 体验PostgreSQL 16新特性之:pg_stat_all_tables增加最后一次索引、顺序扫描时间戳

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


今天的源码安装环节就到这里,后续为大家带来新特性分享。

 

最后修改时间:2023-05-28 14:08:58
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论