File tree 1 file changed +85
-0
lines changed
1 file changed +85
-0
lines changed Original file line number Diff line number Diff line change
1
+ # How to compile Postgres on Ubuntu 22.04
2
+
3
+ > 我每天都会发布一篇新的 PostgreSQL "howto" 文章。加入我的旅程吧 — 订阅、提供反馈、分享!
4
+
5
+ 本文介绍了如何快速在 Ubuntu 22.04 上编译 Postgres。
6
+
7
+ [ 官方文档] ( https://postgresql.org/docs/current/installation.html ) 提供了非常详细的信息,作为参考非常有用,但你不会找到针对特定操作系统版本的具体步骤,比如 Ubuntu。
8
+
9
+ 本文提供的指南足够让你从 ` master ` 分支构建 Postgres 并开始使用。如果需要,可以根据实际需求扩展这些基本步骤。
10
+
11
+ 几点说明:
12
+
13
+ - 当前 (截至 2023 年,PG16) 文档中提到了一种新的 Postgres 构建方法 — [ Meson] ( https://mesonbuild.com/ ) — 但它仍被认为是实验性的,因此本文不会使用。
14
+ - 此处使用的二进制文件和 ` PGDATA ` 路径仅作为示例 (适用于"快速而粗糙"的设置来测试,例如,来自 ` pgsql-hackers ` 邮件列表的新补丁)。
15
+
16
+ 1 . 安装必需的软件
17
+ 2 . 获取源代码
18
+ 3 . 配置
19
+ 4 . 编译和安装
20
+ 5 . 创建集群并开始使用
21
+
22
+ ### 1) 安装必需的软件
23
+
24
+ ``` bash
25
+ sudo apt update
26
+
27
+ sudo apt install -y \
28
+ build-essential libreadline-dev \
29
+ zlib1g-dev flex bison libxml2-dev \
30
+ libxslt-dev libssl-dev libxml2-utils \
31
+ xsltproc ccache
32
+ ```
33
+
34
+ ### 2) 获取源代码
35
+
36
+ ``` bash
37
+ git clone https://gitlab.com/postgres/postgres.git
38
+ cd ./postgres
39
+ ```
40
+
41
+ ### 3) 配置
42
+
43
+ ``` bash
44
+ mkdir ~ /pg16 # consider changing it!
45
+
46
+ ./configure \
47
+ --prefix=$( echo ~ /pg16) \
48
+ --with-ssl=openssl \
49
+ --with-python \
50
+ --enable-depend \
51
+ --enable-cassert
52
+ ```
53
+
54
+ (查看可选项列表)
55
+
56
+ ### 4) 编译和安装
57
+
58
+ ``` bash
59
+ make -j$( grep -c processor /proc/cpuinfo)
60
+ make install
61
+ ```
62
+
63
+ ### 5) 创建集群并开始使用
64
+
65
+ ``` bash
66
+ ~ /pg16/bin/initdb \
67
+ -D ~ /pgdata \
68
+ --data-checksums \
69
+ --locale-provider=icu \
70
+ --icu-locale=en
71
+
72
+ ~ /pg16/bin/pg_ctl \
73
+ -D ~ /pgdata \
74
+ -l pg.log start
75
+ ```
76
+
77
+ 现在,进行检查:
78
+
79
+ ``` bash
80
+ $ ~ /pg16/bin/psql postgres -c ' show server_version'
81
+ server_version
82
+ ----------------
83
+ 17devel
84
+ (1 row)
85
+ ```
You can’t perform that action at this time.
0 commit comments