ITPub博客

首页 > 数据库 > PostgreSQL > Linux7.8环境下的源码安装部署PG14.8

Linux7.8环境下的源码安装部署PG14.8

原创 PostgreSQL 作者:pingdanorcale 时间:2024-01-03 09:47:12 0 删除 编辑

1.建立目录
   # mkdir -p /data/pgsql
   # mkdir -p / data/pgsql/data

2.安装依赖包
   # yum install -y perl-ExtUtils-Embed readline-devel zlib-devel pam-devel libxml2-devel libxslt-devel openldap-devel  python36-devel gcc-c++ openssl-devel cmake make

3.下载安装介质

postgresql.org/ftp/source/v14.8/

  上传到 /data

5. 创建postgresql用户
    # useradd postgres

6.设置数据目录
    # chown postgres:postgres -R   /data/pgsql

7 .设置postgres用户环境变量
    # su - postgres
    $ vi .bash_profile

    export PATH

    export PGHOME=/data/pgsql

    export PGDATA=/data/pgsql/data

    xport GG_HOME=/data/ogg

    export PATH=$PGHOME/bin:$PATH:$GG_HOME/bin

8.解压 安装源包
    $  cd /data
    $  tar -xvf postgresql-14.8.tar.gz

9 .安装配置
  $  cd /data/postgresql-14.8
   ./configure --prefix=/ data/pgsql --with-wal-blocksize=8 --with-segsize=1 --with-blocksize=8

10.编译  安装
    $ make
    $ make install

11 .安装扩展
    $  export PATH= /data/pgsql/bin:$PATH
    $ cd /data/postgresql-14.8/contrib
    $ make all
    $  make install

12. 初始化数据库

postgres@pgdb bin]$ ./initdb  -D /data/pgsql/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 "zh_CN.UTF-8".

The default database encoding has accordingly been set to "UTF8".

initdb: could not find suitable text search configuration for locale "zh_CN.UTF-8"

The default text search configuration will be set to "simple".


Data page checksums are disabled.


fixing permissions on existing directory /data/pgsql/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 /data/pgsql/data/ -l logfile start

13. 修改参数

pg_hba.conf 

host      all           all              0.0.0.0/0              trust

listen_addresses = '*'          # what IP address(es) to listen on;

                                        # comma-separated list of addresses;

                                        # defaults to 'localhost'; use '*' for all

                                        # (change requires restart)

port = 5432                             # (change requires restart)

max_connections = 100                   # (change requires restart)

#superuser_reserved_connections = 3     # (change requires restart)

#unix_socket_directories = '/tmp'       # comma-separated list of directories

unix_socket_directories = '/data/pgsql/run'

                                        # (change requires restart)

#unix_socket_group = ''                 # (change requires restart)

#unix_socket_permissions = 0777         # begin with 0 to use octal notation

                                        # (change requires restart)




附:

自动启动脚本

1.

[root@pgdb system]# cat /etc/systemd/system/postgresql.service 

[Unit]

Description=PostgreSQL Database Server

After=network.target

[Service]

Type=forking

User=postgres

Group=postgres

Environment=PGPORT=5432

Environment=PGDATA=/data/pgsql/data

1OOMScoreAdjust=-1000

# 启动命令

ExecStart=/data/pgsql/bin/pg_ctl start -D ${PGDATA} -s -o "-p ${PGPORT}" -w -t 300

# 重新加载

ExecReload=/data/pgsql/bin/pg_ctl reload -D ${PGDATA} -s

# 停止程序

ExecStop=/data/pgsql/bin/pg_ctl  stop -D ${PGDATA} -s -m fast

KillMode=mixed

KillSignal=SIGINT

TimeoutSec=0

PrivateTmp=true

[Install]

WantedBy=multi-user.target

 2.重载systemctl服务

@pgdb ~]$systemctl daemon-reload 

3. 启动postgresql服务

@pgdb ~]$ sudo systemctl start postgresql.service

4.判断服务是否启动,这里提示成功启动

@pgdb ~]$ systemctl is-active postgresql.service 

active

5. 也可以通过此命令判断服务状态

@pgdb ~]$  systemctl status postgresql.service

6. 停止postgresql服务

pgdbt ~]$  systemctl stop postgresql.service

7. 如果启动配置失败,也可以通过journalctl命令查看日志查找原因

pgdb ~]$ journalctl -u postgresql.service 

设置开机自启动


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/10201716/viewspace-3002437/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2009-01-02

  • 博文量
    158
  • 访问量
    221192