当前位置:   article > 正文

银河麒麟服务器ky10 sp3 x86编译安装postgresql(包含uuid)_麒麟v10 sp3部署postgres

麒麟v10 sp3部署postgres

目录

下载

编译安装

 目录说明 

脚本文件说明

压缩包说明 

脚本代码


下载

 官网 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-packagespython离线依赖
lib64-site-packagespython离线依赖
local-lib-site-packagespython离线依赖
local-lib64-site-packagespython离线依赖
python3python3离线安装包

脚本文件说明

脚本文件说明
ky10_pgadmin_python3_install.shpgadmin 在线安装脚本
ky10_pgadmin_python3_offline_installpgadmin 离线安装脚本
ky10_postgresql_install.shpostgresql在线安装脚本
ky10_postgresql_offline_compile_install.shpostgresql离线编译安装脚本
ky10_postgresql_offline_install.shpostgresql离线安装脚本

压缩包说明 

文件说明  说明
pgadmin4-6.21.tar.gzpgadmin4-6.21源码包
postgresql-10.5-22.ky10.x86_64.rpmpostgresql 离线安装包
postgresql-server-10.5-22.ky10.x86_64.rpmpostgresql 离线安装包
postgresql-10.23.tar.gzpostgresql-10.23源码包
postgresql-12.14.tar.gzpostgresql-12.14源码包

脚本代码

ky10_postgresql_offline_compile_install.sh

  1. version=10.23
  2. server_ip=192.168.4.131
  3. # 下载依赖
  4. # yum install yum-utils -y
  5. # yumdownloader --destdir=/root/depends --resolve readline readline-devel zlib zlib-devel flex bison uuid-devel
  6. # 在线安装依赖
  7. # yum install readline
  8. # yum install readline-devel
  9. # yum install zlib
  10. # yum install zlib-devel
  11. cd depends
  12. # 离线安装依赖
  13. rpm -Uvh --force --nodeps *.rpm
  14. cd ..
  15. tar xvf postgresql-10.23.tar.gz
  16. cd postgresql-10.23
  17. # https://blog.csdn.net/u010430832/article/details/60142824
  18. ./configure --with-libxml --with-ossp-uuid --with-libs=/opt/postgresql/10.23/lib --with-includes=/opt/postgresql/10.23/include
  19. make
  20. make install
  21. # https://blog.frognew.com/2021/11/install-postgresql-from-source-code.html
  22. # 创建用户
  23. useradd postgres
  24. # 创建postgresql相关目录:
  25. mkdir /home/postgres/data
  26. mkdir /home/postgres/init
  27. chown -R postgres:postgres /home/postgres
  28. touch /etc/systemd/system/pgserver.service
  29. cat >/etc/systemd/system/pgserver.service<< EOF
  30. [Unit]
  31. Description=PostgreSQL database server
  32. [Service]
  33. User=postgres
  34. ExecStart=/usr/local/pgsql/bin/postgres -D /home/postgres/data
  35. ExecReload=/bin/kill -HUP $MAINPID
  36. PrivateTmp=true
  37. TimeoutStartSec=0
  38. KillMode=none
  39. [Install]
  40. WantedBy=multi-user.target
  41. EOF
  42. # 执行下面的命令对数据库进行初始化,数据库的初始化需要切换到postgres用户:
  43. # 以postgres用户执行程序
  44. rm -rf /home/postgres/data
  45. sudo -u postgres /usr/local/pgsql/bin/initdb -D /home/postgres/data
  46. # 修改 postgresql.conf
  47. sed -i '63s/#port = 5432/port = 5432/' /home/postgres/data/postgresql.conf
  48. sed -i '59s/#listen_addresses/listen_addresses/' /home/postgres/data/postgresql.conf
  49. sed -i '59s/localhost/*/' /home/postgres/data/postgresql.conf
  50. sed -i '88s/#password_encryption/password_encryption/' /home/postgres/data/postgresql.conf
  51. # 修改pg_hba.conf
  52. sed -i '86s/127.0.0.1/0.0.0.0/' /home/postgres/data/pg_hba.conf
  53. sed -i '86s/32/0/' /home/postgres/data/pg_hba.conf
  54. # 密码md5加密
  55. sed -i '86s/ident/md5/' /home/postgres/data/pg_hba.conf
  56. cd contrib/uuid-ossp
  57. make
  58. make install
  59. # mv uuidossp--1.1.sql uuid-ossp--1.1.sql
  60. # mv uuidossp--unpackaged--1.0.sql uuid-ossp--unpackaged--1.0.sql
  61. # mv uuidossp--1.0--1.1.sql uuid-ossp--1.0--1.1.sql
  62. # mv uuidossp.control uuid-ossp.control
  63. cd /usr/local/pgsql/share/extension/
  64. mv uuid-ossp--1.1.sql uuidossp--1.1.sql
  65. mv uuid-ossp--unpackaged--1.0.sql uuidossp--unpackaged--1.0.sql
  66. mv uuid-ossp--1.0--1.1.sql uuidossp--1.0--1.1.sql
  67. mv uuid-ossp.control uuidossp.control
  68. # 关闭防火墙
  69. systemctl stop firewalld.service
  70. systemctl disable firewalld.service
  71. # 配置开机启动并启动PostgreSQL:
  72. systemctl enable pgserver.service
  73. systemctl start pgserver.service
  74. # 修改postgres用户的密码
  75. sudo -u postgres /usr/local/pgsql/bin/psql -U postgres -d postgres -c "alter user postgres with password '123456';"
  76. sudo /usr/local/pgsql/bin/psql -U postgres -d postgres -c 'create extension "uuidossp";'
  77. # systemctl status pgserver
  78. # 重启服务,配置之后需要重启服务才能生效
  79. systemctl restart pgserver.service
  80. # 修改密码的shell脚本
  81. # sudo -u postgres psql -U postgres -d postgres -c "alter user postgres with password '123456';"
  82. # sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '123456';"
  83. # # 启动自动生成的密码是随机的,我们可以通过下面的命令修改
  84. # # 进入psql
  85. # sudo -u postgres psql
  86. # # 123456 为修改之后的密码
  87. # ALTER USER postgres WITH PASSWORD '123456';
  88. # # 退回到命令行
  89. # \q

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/木道寻08/article/detail/906548
推荐阅读
相关标签
  

闽ICP备14008679号