银河麒麟V10——Postgres-12.5主从编译安装

奋斗吧
奋斗吧
擅长邻域:未填写

标签: 银河麒麟V10——Postgres-12.5主从编译安装 Python博客 51CTO博客

2023-05-04 18:24:10 479浏览

银河麒麟V10——Postgres-12.5主从编译安装,一、机器信息二、编译包下载链接:https://pan.baidu.com/s/1fiOmYB8uplfA1LQDy_LhqQ提取码:5y

一、机器信息

 

二、编译包下载

链接:https://pan.baidu.com/s/1fiOmYB8uplfA1LQDy_LhqQ
提取码:5yxz

三、配置免密登录

#生成私钥

[root@localhost lib]# vim /etc/profile
[root@localhost lib]# cd
[root@localhost ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa
Your public key has been saved in /root/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:lHsJtF23Wf/zZHWv4SzBR7Iml6K2Kyws/NIJHcf4IBA root@localhost.localdomain
The key's randomart image is:
+---[RSA 3072]----+
|E.      .   . . .|
|.      . + . . +.|
| .   o  = . . + +|
|  . + o. o o =  =|
|   o =  S = B o.=|
|  . . .  o = = =o|
| . + o  o   . + .|
|  + = o. .   .   |
|   +.. .o.       |
+----[SHA256]-----+#拷贝密钥到其他机器(例举一台)
[root@localhost ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub 192.168.65.132
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.65.132 (192.168.65.132)' can't be established.
ECDSA key fingerprint is SHA256:MaIR4AJ02WMecACcn4Kw8wM+oZJFTbf/zdCIkR92ez4.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed        # 试图用新的密钥登录,以过滤掉任何已经安装的密钥
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys   # 1个密钥仍待安装——如果现在提示您安装新的密钥Authorized users only. All activities may be monitored and reported.   # 仅限授权用户使用。所有活动都可以被监测和报告。
root@192.168.65.132's password:root@192.168.65.132's password: 
Connection closed by 192.168.65.132 port 22

四、解压并安装postgresql-12.5

1、#安装包

[root@localhost ~]# yum install -y openssl openssl-devel pam pam-devel libxml2 libxml2-devel libxslt libxslt-devel perl perl-devel install perl-ExtUtils-Embed readline readline-devel zlib zlib-devel gettext gettext-devel bison flex gcc gcc-c++ readline-devel
上次元数据过期检查:0:23:02 前,执行于 2023年03月03日 星期五 10时19分26秒。
软件包 openssl-1:1.1.1f-15.p06.ky10.x86_64 已安装。
软件包 openssl-devel-1:1.1.1f-15.p06.ky10.x86_64 已安装。
软件包 pam-1.4.0-8.p03.se.03.ky10.x86_64 已安装。
软件包 pam-devel-1.4.0-8.p03.se.03.ky10.x86_64 已安装。
软件包 libxml2-2.9.10-25.ky10.x86_64 已安装。
软件包 libxml2-devel-2.9.10-25.ky10.x86_64 已安装。
软件包 libxslt-1.1.34-4.ky10.x86_64 已安装。
软件包 perl-4:5.28.3-7.se.01.ky10.x86_64 已安装。
软件包 perl-devel-4:5.28.3-7.se.01.ky10.x86_64 已安装。
未找到匹配的参数: install
软件包 perl-4:5.28.3-7.se.01.ky10.x86_64 已安装。
软件包 readline-8.0-3.ky10.x86_64 已安装。
软件包 readline-devel-8.0-3.ky10.x86_64 已安装。
软件包 zlib-1.2.11-18.ky10.x86_64 已安装。
软件包 zlib-devel-1.2.11-18.ky10.x86_64 已安装。
软件包 gettext-0.21-4.ky10.x86_64 已安装。
软件包 gettext-devel-0.21-4.ky10.x86_64 已安装。
软件包 bison-3.6.4-2.ky10.x86_64 已安装。
软件包 flex-2.6.4-3.ky10.x86_64 已安装。
软件包 gcc-7.3.0-20220207.45.p01.ky10.x86_64 已安装。
软件包 gcc-c++-7.3.0-20220207.45.p01.ky10.x86_64 已安装。
错误:没有任何匹配: install

2、上传postgresql-12.5.tar.gz安装包,我的放在了/root/postgresql-12.5文件夹下

银河麒麟V10——Postgres-12.5主从编译安装_sql

3、解压

[root@localhost ~]# tar -xf postgresql-12.5.tar.gz   # 解压并得到文件夹

银河麒麟V10——Postgres-12.5主从编译安装_sql_02

4、创建文件路径,并将解压后的文件复制到该路径下

[root@localhost ~]# mkdir -p /export/servers/app/postgresql-12.5  # 创建文件路径,并将解压后的文件复制到该路径下

    [root@localhost ~]# cd postgresql-12.5

5、配置并安装make

[root@localhost postgresql-12.5]# ./configure --prefix=/export/servers/app/postgresql-12.5 &&make &&make install  # 打开并安装make

银河麒麟V10——Postgres-12.5主从编译安装_sql_03

 表示安装完成

6、添加环境变量:wq保存退出。

 [root@localhost postgresql-12.5]# vim /etc/profile

export PGHOME=/export/servers/app/postgresql-12.5
export PGDATA=/export/servers/data/pgsql/
export PATH=$PGHOME/bin:$PATH
export LANG=en_US.utf8
export LD_LIBRARY_PATH=$PGHOME/lib:$LD_LIBRARY_PATH

银河麒麟V10——Postgres-12.5主从编译安装_perl_04

#刷新并使文件生效
 [root@localhost postgresql-12.5]#  source /etc/profile

7、创建数据目录

useradd postgres
mkdir -p /export/servers/data/pgsql/
chown postgres:postgres /export/servers/data/pgsql/

银河麒麟V10——Postgres-12.5主从编译安装_postgresql_05

8、初始化数据库

[root@localhost postgresql-12.5]# su - postgres  # 切换用户
进入相应路径:
[postgres@localhost postgresql-12.5]$ cd /export/servers/app/postgresql-12.5/bin
使用initdb启动
[postgres@localhost bin]$  /export/servers/app/postgresql-12.5/bin/initdb -D /export/servers/data/pgsql/

银河麒麟V10——Postgres-12.5主从编译安装_sql_06

9、修改监听端口 

[postgres@localhost bin]$ vim /export/servers/data/pgsql/postgresql.conf
listen_addresses = '*'

银河麒麟V10——Postgres-12.5主从编译安装_perl_07

10、启动pg_ctl

[postgres@localhost bin]$ /export/servers/app/postgresql-12.5/bin/pg_ctl -D /export/servers/data/pgsql/ -l logfile start
waiting for server to start..../bin/sh: logfile: Permission denied
stopped waiting
pg_ctl: could not start server
Examine the log output.

# 启动服务

[postgres@localhost bin]$ pg_ctl start
waiting for server to start....2023-03-03 11:27:58.887 CST [41939] LOG: starting PostgreSQL 12.5 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 7.3.0, 64-bit
2023-03-03 11:27:58.888 CST [41939] LOG: listening on IPv4 address "0.0.0.0", port 5432
2023-03-03 11:27:58.888 CST [41939] LOG: listening on IPv6 address "::", port 5432
2023-03-03 11:27:58.890 CST [41939] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
2023-03-03 11:27:58.908 CST [41940] LOG: database system was shut down at 2023-03-03 11:12:37 CST
2023-03-03 11:27:58.911 CST [41939] LOG: database system is ready to accept connections
done
server started

11、验证5432端口已经开启

[postgres@localhost bin]$ netstat -anp | grep 5432

银河麒麟V10——Postgres-12.5主从编译安装_sql_08

12、登录并修改postgres密码

[root@localhost pgsql]# su - postgres  # 切换用户
[postgres@localhost pgsql]# psql  # 登录数据库
alter user postgres with password 'postgres';  # 修改用户密码为postgres
exit

银河麒麟V10——Postgres-12.5主从编译安装_perl_09

#修改为md5表示用密码登录,如果为trust表示不需要密码,

[postgres@localhost bin]$ cd /export/servers/data/pgsql/

[postgres@localhost bin]$ vim pg_hba.conf

银河麒麟V10——Postgres-12.5主从编译安装_sql_10

把trust修改成md5,保存

修改配置文件后需要重启
[postgres@localhost pgsql]$ /export/servers/app/postgresql-12.5/bin/pg_ctl -D /export/servers/data/pgsql/ -l logfile restart

银河麒麟V10——Postgres-12.5主从编译安装_perl_11

13、验证密码是否修改成功

密码修改前的状态如下

银河麒麟V10——Postgres-12.5主从编译安装_perl_12

密码修改后的状态如下:

[postgres@localhost pgsql]$ psql
Password for user postgres:        # 输入修改的密码:这里是postgres

银河麒麟V10——Postgres-12.5主从编译安装_sql_13

五、编译安装proj-6.2.1  

   

银河麒麟V10——Postgres-12.5主从编译安装_postgresql_14

 我的文件位置:/root/postgresql-12.5

[root@localhost postgresql-12.5]# tar -zvxf proj-6.2.1.tar.gz  # 解压


[root@localhost postgresql-12.5]# mv proj-6.2.1 /usr/local    # 把proj-6.2.1文件移到/usr/local

  [root@localhost local]# cd proj-6.2.1

[root@localhost proj-6.2.1]# ./configure --prefix=/usr/local/proj-6.2.1

银河麒麟V10——Postgres-12.5主从编译安装_postgresql_15

日志详情

安装make 时间较长预计20分钟
[root@localhost proj-6.2.1]# make &&make install

六、编译安装geos-3.7.4

我的文件位置:/root/postgresql-12.5

银河麒麟V10——Postgres-12.5主从编译安装_perl_16

[root@localhost postgresql-12.5]# tar -xf geos-3.7.4.tar.bz2  # 解压

银河麒麟V10——Postgres-12.5主从编译安装_postgresql_17

[root@localhost postgresql-12.5]# mv geos-3.7.4 /usr/local # 移动到/usr/local/下
[root@localhost local]# cd geos-3.7.4 # 打开目录

银河麒麟V10——Postgres-12.5主从编译安装_sql_18

[root@localhost geos-3.7.4]# ./configure --prefix=/usr/local/geos-3.7.4  # 配置
[root@localhost geos-3.7.4]# make && make install # 安装make安装时间较长预计15分钟

七、编译安装gdal-3.1.1

我的文件位置:/root/postgresql-12.5

银河麒麟V10——Postgres-12.5主从编译安装_perl_19

[root@localhost postgresql-12.5]# tar -xf gdal-3.1.1.tar.gz  /uar/local # 解压

银河麒麟V10——Postgres-12.5主从编译安装_perl_20

  [root@localhost postgresql-12.5]# mv gdal-3.1.1 /usr/local # 移动到/usr/local/下

银河麒麟V10——Postgres-12.5主从编译安装_perl_21

  [root@localhost local]# cd gdal-3.1.1  # 打开gdal-3.1.1

[root@localhost gdal-3.1.1]# ./configure --prefix=/usr/local/gdal-3.1.1

  

八、编译安装postgis-3.0.5 

我的文件位置:/root/postgresql-12.5

银河麒麟V10——Postgres-12.5主从编译安装_sql_22

[root@localhost postgresql-12.5]# tar -xf postgis-3.0.5.tar.gz   # 解压

银河麒麟V10——Postgres-12.5主从编译安装_perl_23

[root@localhost postgresql-12.5]# mv postgis-3.0.5 /usr/local # 移动到/usr/local/下

银河麒麟V10——Postgres-12.5主从编译安装_postgresql_24

cd postgis-3.0.5 # 打开目录

银河麒麟V10——Postgres-12.5主从编译安装_sql_25

 

 # 配置

[root@localhost postgis-3.0.5]# ./configure --prefix=/export/servers/app/postgresql-12.5 --with-pgconfig=/export/servers/app/postgresql-12.5/bin/pg_config --with-projdir=/usr/local/proj-6.2.1 --with-geosconfig=/usr/local/geos-3.7.4/bin/geos-config --with-gdalconfig=/usr/local/gdal-3.1.1/bin/gdal-config

  

八、安装插件 

1、登录数据库

[root@localhost postgis-3.0.5]# su - postgres

Last login: Fri Mar 3 13:47:40 CST 2023 on pts/1
su: warning: cannot change directory to /home/postgres: No such file or directory

[postgres@localhost postgis-3.0.5]$ psql

Password for user postgres:         # 输入密码postgres
psql (12.5)
Type "help" for help.

postgres=#

 2、安装插件

创建控件数据库:
create database gisdb;

  切换到gisdb,提示gisdb=# 表示切换到gisdb

\c gisdb
需要给gisdb安装扩展gis插件:
CREATE EXTENSION postgis;
gisdb=# CREATE EXTENSION postgis;
ERROR:  could not open extension control file "/export/servers/app/postgresql-12.5/share/extension/postgis.control": No such file or directory
翻译:ERROR:无法打开扩展控制文件"/export/servers/app/postgresql-12.5/share/extension/postgis.control":没有这样的文件或目录
处理方法:

[root@localhost auto_explain]# find / -name postgis  # 查找postgis有关文件路径
/usr/local/postgis-3.0.5/postgis
/usr/local/postgis-3.0.5/extensions/postgis

[root@localhost auto_explain]# pwd
/export/servers/app/postgresql-12.5/contrib/auto_explain   # 找到进入postgresql-12.5源码包解压后的,auto_explain目录,编译和安装

[root@localhost auto_explain]# make && make install
[root@localhost auto_explain]# make
make -C ../../src/backend generated-headers
make[1]: Entering directory '/export/servers/app/postgresql-12.5/src/backend'
make -C catalog distprep generated-header-symlinks
make[2]: Entering directory '/export/servers/app/postgresql-12.5/src/backend/catalog'
make[2]: Nothing to be done for 'distprep'.
make[2]: Nothing to be done for 'generated-header-symlinks'.
make[2]: Leaving directory '/export/servers/app/postgresql-12.5/src/backend/catalog'
make -C utils distprep generated-header-symlinks
make[2]: Entering directory '/export/servers/app/postgresql-12.5/src/backend/utils'
make[2]: Nothing to be done for 'distprep'.
make[2]: Nothing to be done for 'generated-header-symlinks'.
make[2]: Leaving directory '/export/servers/app/postgresql-12.5/src/backend/utils'
make[1]: Leaving directory '/export/servers/app/postgresql-12.5/src/backend'
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -O2 -fPIC -I. -I. -I../../src/include  -D_GNU_SOURCE   -c -o auto_explain.o auto_explain.c
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -O2 -fPIC -shared -o auto_explain.so auto_explain.o  -L../../src/port -L../../src/common    -Wl,--as-needed -Wl,-rpath,'/export/servers/app/postgresql-12.5/lib',--enable-new-dtags  
[root@localhost auto_explain]# make install
make -C ../../src/backend generated-headers
make[1]: Entering directory '/export/servers/app/postgresql-12.5/src/backend'
make -C catalog distprep generated-header-symlinks
make[2]: Entering directory '/export/servers/app/postgresql-12.5/src/backend/catalog'
make[2]: Nothing to be done for 'distprep'.
make[2]: Nothing to be done for 'generated-header-symlinks'.
make[2]: Leaving directory '/export/servers/app/postgresql-12.5/src/backend/catalog'
make -C utils distprep generated-header-symlinks
make[2]: Entering directory '/export/servers/app/postgresql-12.5/src/backend/utils'
make[2]: Nothing to be done for 'distprep'.
make[2]: Nothing to be done for 'generated-header-symlinks'.
make[2]: Leaving directory '/export/servers/app/postgresql-12.5/src/backend/utils'
make[1]: Leaving directory '/export/servers/app/postgresql-12.5/src/backend'
/usr/bin/mkdir -p '/export/servers/app/postgresql-12.5/lib'
/usr/bin/install -c -m 755  auto_explain.so '/export/servers/app/postgresql-12.5/lib/auto_explain.so'

  安装结束,无报错。接下来添加shared_preload_libraries,重启数据库,创建auto_explain扩展测试。

 

报错:ERROR: could not load library "/export/servers/app/postgresql-12.5/lib/postgis-3.so": libgeos_c.so.1: cannot open shared object file: No such file or directory 

问题处理:原因是找不到链接库,新增动态链接库的配置文件
vim /etc/ld.so.conf.d/postgres.conf
/usr/local/geos-3.7.4/lib
/usr/local/gdal-3.1.1/lib
/usr/local/proj-6.2.1/lib

 

 

 

 


#生效
[root@Rz01 ]# ldconfig

 

 

navcat连接postgres数据库:提示:2013 - Lost connection to MySQL server at 'reading initial communication packet , system error: 0

(2013年-在读取初始通信包时失去与MySQL服务器的连接,系统错误:0)

银河麒麟V10——Postgres-12.5主从编译安装_perl_26

 

 

重启MySQL服务未解决

navicat 连接银河麒麟postgres数据库失败 2013 - Lost connection to MySQL server at 'reading initial communication pac

 



好博客就要一起分享哦!分享海报

此处可发布评论

评论(0展开评论

暂无评论,快来写一下吧

展开评论

您可能感兴趣的博客

客服QQ 1913284695