赞
踩
目录
官网 PostgreSQL: The world's most advanced open source database
源码下载地址 PostgreSQL: File Browser
有多个版本可以选择,我选择的是10.23
点击下载即可
我下载好之后把他上传到了我的gitcode上,接下来我们直接下载gitcode上的脚本代码和程序进行编译安装
下载脚本代码 https://gitcode.net/zenglg/postgresql.git
git clone https://gitcode.net/zenglg/postgresql.git
后面我们会附上脚本代码
代码结构如下
目录 | 说明 |
depends | 编译postgresql相关的依赖离线安装包 |
lib-site-packages | python离线依赖 |
lib64-site-packages | python离线依赖 |
local-lib-site-packages | python离线依赖 |
local-lib64-site-packages | python离线依赖 |
python3 | python3离线安装包 |
脚本文件 | 说明 |
ky10_pgadmin_python3_install.sh | pgadmin 在线安装脚本 |
ky10_pgadmin_python3_offline_install | pgadmin 离线安装脚本 |
ky10_postgresql_install.sh | postgresql在线安装脚本 |
ky10_postgresql_offline_compile_install.sh | postgresql离线编译安装脚本 |
ky10_postgresql_offline_install.sh | postgresql离线安装脚本 |
文件说明 | 说明 |
pgadmin4-6.21.tar.gz | pgadmin4-6.21源码包 |
postgresql-10.5-22.ky10.x86_64.rpm | postgresql 离线安装包 |
postgresql-server-10.5-22.ky10.x86_64.rpm | postgresql 离线安装包 |
postgresql-10.23.tar.gz | postgresql-10.23源码包 |
postgresql-12.14.tar.gz | postgresql-12.14源码包 |
ky10_postgresql_offline_compile_install.sh
-
- version=10.23
- server_ip=192.168.4.131
-
- # 下载依赖
- # yum install yum-utils -y
- # yumdownloader --destdir=/root/depends --resolve readline readline-devel zlib zlib-devel flex bison uuid-devel
-
- # 在线安装依赖
- # yum install readline
- # yum install readline-devel
- # yum install zlib
- # yum install zlib-devel
-
- cd depends
- # 离线安装依赖
- rpm -Uvh --force --nodeps *.rpm
- cd ..
-
- tar xvf postgresql-10.23.tar.gz
- cd postgresql-10.23
-
- # https://blog.csdn.net/u010430832/article/details/60142824
- ./configure --with-libxml --with-ossp-uuid --with-libs=/opt/postgresql/10.23/lib --with-includes=/opt/postgresql/10.23/include
-
- make
- make install
-
-
- # https://blog.frognew.com/2021/11/install-postgresql-from-source-code.html
-
- # 创建用户
- useradd postgres
- # 创建postgresql相关目录:
- mkdir /home/postgres/data
- mkdir /home/postgres/init
- chown -R postgres:postgres /home/postgres
-
-
- touch /etc/systemd/system/pgserver.service
- cat >/etc/systemd/system/pgserver.service<< EOF
- [Unit]
- Description=PostgreSQL database server
- [Service]
- User=postgres
- ExecStart=/usr/local/pgsql/bin/postgres -D /home/postgres/data
- ExecReload=/bin/kill -HUP $MAINPID
- PrivateTmp=true
- TimeoutStartSec=0
- KillMode=none
- [Install]
- WantedBy=multi-user.target
- EOF
-
- # 执行下面的命令对数据库进行初始化,数据库的初始化需要切换到postgres用户:
- # 以postgres用户执行程序
- rm -rf /home/postgres/data
- sudo -u postgres /usr/local/pgsql/bin/initdb -D /home/postgres/data
-
-
- # 修改 postgresql.conf
- sed -i '63s/#port = 5432/port = 5432/' /home/postgres/data/postgresql.conf
- sed -i '59s/#listen_addresses/listen_addresses/' /home/postgres/data/postgresql.conf
- sed -i '59s/localhost/*/' /home/postgres/data/postgresql.conf
- sed -i '88s/#password_encryption/password_encryption/' /home/postgres/data/postgresql.conf
-
- # 修改pg_hba.conf
- sed -i '86s/127.0.0.1/0.0.0.0/' /home/postgres/data/pg_hba.conf
- sed -i '86s/32/0/' /home/postgres/data/pg_hba.conf
- # 密码md5加密
- sed -i '86s/ident/md5/' /home/postgres/data/pg_hba.conf
-
-
- cd contrib/uuid-ossp
- make
- make install
-
-
- # mv uuidossp--1.1.sql uuid-ossp--1.1.sql
- # mv uuidossp--unpackaged--1.0.sql uuid-ossp--unpackaged--1.0.sql
- # mv uuidossp--1.0--1.1.sql uuid-ossp--1.0--1.1.sql
- # mv uuidossp.control uuid-ossp.control
-
- cd /usr/local/pgsql/share/extension/
- mv uuid-ossp--1.1.sql uuidossp--1.1.sql
- mv uuid-ossp--unpackaged--1.0.sql uuidossp--unpackaged--1.0.sql
- mv uuid-ossp--1.0--1.1.sql uuidossp--1.0--1.1.sql
- mv uuid-ossp.control uuidossp.control
-
-
- # 关闭防火墙
- systemctl stop firewalld.service
- systemctl disable firewalld.service
-
-
- # 配置开机启动并启动PostgreSQL:
- systemctl enable pgserver.service
- systemctl start pgserver.service
-
- # 修改postgres用户的密码
- sudo -u postgres /usr/local/pgsql/bin/psql -U postgres -d postgres -c "alter user postgres with password '123456';"
-
- sudo /usr/local/pgsql/bin/psql -U postgres -d postgres -c 'create extension "uuidossp";'
-
-
-
-
- # systemctl status pgserver
-
- # 重启服务,配置之后需要重启服务才能生效
- systemctl restart pgserver.service
-
-
- # 修改密码的shell脚本
- # sudo -u postgres psql -U postgres -d postgres -c "alter user postgres with password '123456';"
- # sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '123456';"
-
- # # 启动自动生成的密码是随机的,我们可以通过下面的命令修改
- # # 进入psql
- # sudo -u postgres psql
- # # 123456 为修改之后的密码
- # ALTER USER postgres WITH PASSWORD '123456';
- # # 退回到命令行
- # \q
-
-

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。