centos8 安装postgre

安装依赖包 

yum install -y perl-ExtUtils-Embed readline-devel zlib-devel pam-devel libxml2-devel libxslt-devel openldap-devel  gcc-c++ openssl-devel cmake


yum search python|grep devel
上次元数据过期检查:2:24:27 前,执行于 2024年01月26日 星期五 09时14分59秒。
platform-python-devel.i686 : Libraries and header files needed for Python development
platform-python-devel.x86_64 : Libraries and header files needed for Python development
python2-devel.x86_64 : Libraries and header files needed for Python 2 development
python2-tools.x86_64 : A collection of development tools included with Python 2
python3-idle.i686 : A basic graphical development environment for Python
python3-idle.x86_64 : A basic graphical development environment for Python
python3-werkzeug.noarch : The Swiss Army knife of Python web development
python36-devel.x86_64 : Libraries and header files needed for Python development
python38-devel.x86_64 : Libraries and header files needed for Python development
python38-idle.x86_64 : A basic graphical development environment for Python
python39-devel.x86_64 : Libraries and header files needed for Python development
python39-idle.x86_64 : A basic graphical development environment for Python
python2-cairo-devel.x86_64 : Libraries and headers for py2cairo
[root@localhost ~]# yum  install python36-devel.x86_64
上次元数据过期检查:2:24:57 前,执行于 2024年01月26日 星期五 09时14分59秒。
依赖关系解决。
========================================================================================================================
 软件包                          架构            版本                                          仓库                大小
========================================================================================================================
安装:
 python36-devel                  x86_64          3.6.8-38.module_el8.5.0+895+a459eca8          AppStream           16 k
安装依赖关系:
 platform-python-devel           x86_64          3.6.8-41.el8                                  AppStream          249 k
 python3-rpm-generators          noarch          5-7.el8                                       AppStream           25 k

事务概要
========================================================================================================================
安装  3 软件包

总下载:291 k
安装大小:767 k
确定吗?[y/N]: y
下载软件包:
(1/3): python3-rpm-generators-5-7.el8.noarch.rpm                                        166 kB/s |  25 kB     00:00    
(2/3): python36-devel-3.6.8-38.module_el8.5.0+895+a459eca8.x86_64.rpm                   104 kB/s |  16 kB     00:00    
(3/3): platform-python-devel-3.6.8-41.el8.x86_64.rpm                                    881 kB/s | 249 kB     00:00    
------------------------------------------------------------------------------------------------------------------------
总计                                                                                    1.0 MB/s | 291 kB     00:00     
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
  准备中  :                                                                                                         1/1 
  安装    : python3-rpm-generators-5-7.el8.noarch                                                                   1/3 
  安装    : platform-python-devel-3.6.8-41.el8.x86_64                                                               2/3 
  安装    : python36-devel-3.6.8-38.module_el8.5.0+895+a459eca8.x86_64                                              3/3 
  运行脚本: python36-devel-3.6.8-38.module_el8.5.0+895+a459eca8.x86_64                                              3/3 
  验证    : platform-python-devel-3.6.8-41.el8.x86_64                                                               1/3 
  验证    : python3-rpm-generators-5-7.el8.noarch                                                                   2/3 
  验证    : python36-devel-3.6.8-38.module_el8.5.0+895+a459eca8.x86_64                                              3/3 

已安装:
  platform-python-devel-3.6.8-41.el8.x86_64                             python3-rpm-generators-5-7.el8.noarch           
  python36-devel-3.6.8-38.module_el8.5.0+895+a459eca8.x86_64           

完毕!
 


安装


 
 

./configure --prefix=/opt/pgsql --with-perl --with-python

make  

make install

创建目录


groupadd postgres
useradd -g postgres   postgres

id postgres

chown -R postgres:postgres  /opt/pgsql

[root@localhost pgsql]# ll
总用量 16
drwxr-xr-x. 2 postgres postgres 4096 1月  26 11:46 bin
drwxr-xr-x. 2 postgres postgres    6 1月  25 17:15 data
drwxr-xr-x. 6 postgres postgres 4096 1月  26 11:46 include
drwxr-xr-x. 4 postgres postgres 4096 1月  26 11:46 lib
drwxr-xr-x. 6 postgres postgres 4096 1月  26 11:46 share
[root@localhost pgsql]# 

配置环境变量


vi .bash_profile

export PGHOME=/opt/pgsql
 
export PGDATA=/opt/pgsql/data
 
PATH=$PATH:$HOME/bin:$PGHOME/bin

保存,退出vi。执行以下命令,使环境变量生效

  source .bash_profile 

[postgres@localhost ~]$ cat .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi


export PGHOME=/opt/pgsql

export PGDATA=/opt/pgsql/data

PATH=$PATH:$HOME/bin:$PGHOME/bin

export PATH
# User specific environment and startup programs
[postgres@localhost ~]$ 

初始化

su - postgres
 /opt/pgsql/bin/initdb -D /opt/pgsql/data -W

-W, --pwprompt          在initdb的过程中为数据库超级用户设置一个密码。

--启动数据库  

/opt/pgsql/bin/pg_ctl -D /opt/pgsql/data -l logfile start

su - postgres
 /opt/pgsql/bin/initdb -D /opt/pgsql/data -W

[root@localhost ~]# su - postgres
[postgres@localhost ~]$  /opt/pgsql/bin/initdb -D /opt/pgsql/data -W
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.

Enter new superuser password: 
Enter it again: 

fixing permissions on existing directory /opt/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 ... Asia/Shanghai
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:

    /opt/pgsql/bin/pg_ctl -D /opt/pgsql/data -l logfile start

[postgres@localhost ~]$ ^C
-----启动数据库
[postgres@localhost ~]$ /opt/pgsql/bin/pg_ctl -D /opt/pgsql/data -l logfile start
waiting for server to start.... done
server started
[postgres@localhost ~]$ 

[postgres@localhost ~]$    /opt/pgsql/bin/pg_ctl -D /opt/pgsql/data  status
pg_ctl: server is running (PID: 59362)

---创建数据库

 /opt/pgsql/bin/createdb test
 /opt/pgsql/bin/psql test


[postgres@localhost ~]$   /opt/pgsql/bin/createdb test
[postgres@localhost ~]$  /opt/pgsql/bin/psql test
psql (14.2)
Type "help" for help.

test=# 


[postgres@localhost ~]$  /opt/pgsql/bin/psql
postgres=# \l
 postgres  | postgres | UTF8     | zh_CN.UTF-8 | zh_CN.UTF-8 | 
 template0 | postgres | UTF8     | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 test      | postgres | UTF8     | zh_CN.UTF-8 | zh_CN.UTF-8 | 

  • 7
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值