首页 > 编程语言 >一、源码编译安装 postgresq 14 版本

一、源码编译安装 postgresq 14 版本

时间:2022-10-22 17:31:51浏览次数:51  
标签:10 13 cdh01 14 ... pg14 源码 home postgresq

1、安装所需的依赖包

使用操作系统用户 pg14 进行编译安装,软件安装目录为/home/pg14/soft,编译安装时需要开启 ssl 的支持

[root@cdh01 ~]# yum grouplist
Loaded plugins: product-id, search-disabled-repos
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Available Environment Groups:
Minimal Install
Infrastructure Server
File and Print Server
Basic Web Server
Virtualization Host
Server with GUI
Available Groups:
Compatibility Libraries
Console Internet Tools
Development Tools
Graphical Administration Tools
Legacy UNIX Compatibility
Scientific Support
Security Tools
Smart Card Support
System Administration Tools
System Management
Done
#挂载光盘,安装依赖包
[root@cdh01 pg14]# mount /dev/cdrom /mnt/disk/

[root@cdh01 pg14]# yum install -y readline readline-devel zlib zlib-devel openssl openssl-devel

[root@cdh01 ~]# useradd -m pg14

[root@cdh01 pg14]# su - pg14

[pg14@cdh01 ~]$ cd postgresql-14.5

[pg14@cdh01 postgresql-14.5]$ ./configure --prefix=/home/pg14/soft --with-openssl
[pg14@cdh01 postgresql-14.5]$ make && make install

2、初始化数据库,启用checksum并配置免密登录

$PGDATA 目录是/home/pg14/data,PostgreSQ 数据库的超级用户是 postgres,postgres 用户的密码设置为 1qaz@WSX,并体现到.pgpass 文件中,以便postgres 免密登录,初始化时开启 checksum,监听端口号请设置为5666,然后启动数据库。

[pg14@cdh01 bin]$ ./initdb -Upostgres -W -D /home/pg14/data -k 
The files belonging to this database system will be owned by user "pg14".
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 enabled.

Enter new superuser password: 1qaz@WSX
Enter it again: 1qaz@WSX

creating directory /home/pg14/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 ... PRC
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
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:

./pg_ctl -D /home/pg14/data -l logfile start

vi /home/pg14/data/postgresql.conf

listen_addresses = '*'
port = 5666

[pg14@cdh01 ~]$ touch .pgpass
[pg14@cdh01 ~]$ vi .pgpass

localhost:5666:pg14:postgres:1qaz@WSX
[pg14@cdh01 ~]$ chmod 0600 .pgpass
#vi  .bash_profile

PATH=$PATH:$HOME/.local/bin:$HOME/bin:/home/pg14/soft/bin
PGDATA=/home/pg14/data
export PGDATA

[pg14@cdh01 ~]$ pg_ctl start -D /home/pg14/data
waiting for server to start....2022-10-10 13:14:03.579 CST [34918] LOG: starting PostgreSQL 14.5 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36), 64-bit
2022-10-10 13:14:03.580 CST [34918] LOG: listening on IPv4 address "0.0.0.0", port 5666
2022-10-10 13:14:03.580 CST [34918] LOG: listening on IPv6 address "::", port 5666
2022-10-10 13:14:03.580 CST [34918] LOG: listening on Unix socket "/tmp/.s.PGSQL.5666"
2022-10-10 13:14:03.582 CST [34919] LOG: database system was shut down at 2022-10-10 13:13:56 CST
2022-10-10 13:14:03.583 CST [34918] LOG: database system is ready to accept connections
done
server started

[pg14@cdh01 ~]$ psql -Upostgres -p5666 postgres
psql (14.5)
Type "help" for help.
postgres=#

标签:10,13,cdh01,14,...,pg14,源码,home,postgresq
From: https://blog.51cto.com/u_10930585/5786042

相关文章