银河麒麟V10高级服务器编译安装pg13.4

安装postgres依赖

yum install -y openssl openssl-devel pam pam-devel libxml2 libxml2-devel libxslt libxslt-devel perl perl-devel python-devel perl-ExtUtils-Embed readline readline-devel  zlib zlib-devel gettext gettext-devel bison flex  gcc gcc-c++ uuid uuid-devel

创建用户

useradd postgres
passwd postgres

创建目录

mkdir /home/postgres/pg13 
mkdir /home/postgres/pg13/data 
chown -R postgres:postgres /home/postgres

安装postgresql 13

[postgres@localhost postgres] tar -zxvf postgresql-13.4.tar.gz
[postgres@localhost postgres] cd postgresql-13.4/
[postgres@localhost postgresql-14.5] ./configure --prefix=/home/postgres/pg13/ --with-pgport=5432 --with-openssl --with-ossp-uuid --with-libxml --with-libxslt --with-perl --with-blocksize=16
[postgres@localhost postgresql-14.5] make && make install
## 参数说明
--with-blocksize=16  #根据业务需求选择编译的内容
--with-system #可注册成系统服务。

初始化数据库

[postgres@localhost postgres]$ initdb -D /home/postgres/pg13/data -E UTF8 --locale=zh_CN.utf8

配置远程访问

[postgres@local  postgres]$ vi /home/postgres/pg13/data/pg_hba.conf
···

host    all             all             0.0.0.0/0               trust

配置端口

vi /home/postgres/pg13/data/postgresql.conf
listen_addresses = '0.0.0.0'
prot = 5432
max_connections = 10000

启动postgresql

[postgres@local  pg14]$ mkdir logs
[postgres@local  pg14]$ /home/postgres/pg13/bin/pg_ctl -D /home/postgres/pg13/data -l /home/postgres/pg13/logs/pgsql.log start

环境变量设置

使用postgres用户,环境变量使用/home/postgres/.bashrc文件

vi /home/postgres/.bashrc

    export PGHOME=/home/postgres/pg13
    export PGDATA=/home/postgres/pg13/data
    export LD_LIBRARY_PATH=$PGHOME/lib:lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH
    export DATE='date +"%Y%m%d%H%M"'
    export PATH=$PGHOME/bin:$PATH:.
    export MANPATH=$PGHOME/share/man:$MANPATH

设置密码

[postgres@localhost system]$ psql
psql (13.4)
Type "help" for help.

postgres=# alter user postgres with password 'postgres';
ALTER ROLE
postgres=# exit;

开放端口

切换为root用户

(1)查看对外开放的端口状态
查询已开放的端口 netstat -anp
查询指定端口是否已开 firewall-cmd --query-port=5432/tcp
提示 yes,表示开启;no表示未开启。

(2)查看防火墙状态 查看防火墙状态 systemctl status firewalld 开启防火墙 systemctl start firewalld  
关闭防火墙 systemctl stop firewalld
开启防火墙 service firewalld start
若遇到无法开启
先用:systemctl unmask firewalld.service
然后:systemctl start firewalld.service

(3)对外开发端口
查看想开的端口是否已开:
firewall-cmd --query-port=5432/tcp

(4)添加指定需要开放的端口:
firewall-cmd --add-port=5432/tcp --permanent
重载入添加的端口:
firewall-cmd --reload
查询指定端口是否开启成功:
firewall-cmd --query-port=5432/tcp

(5)移除指定端口:
firewall-cmd --permanent --remove-port=5432/tcp

注册为服务

# 创建服务文件
[root@localhost ~]# vim /etc/systemd/system/postgres.service
# 添加以下内容

[Unit]
Description=PostgreSQL database server
After=network.target

[Service]
Type=forking
User=postgres
ExecStart=/home/postgres/pg13/bin/pg_ctl start -D /home/postgres/pg13/data -l /home/postgres/pg13/logs/pgsql.log
ExecStop=/home/postgres/pg13/bin/pg_ctl stop -D /home/postgres/pg13/data

[Install]
WantedBy=multi-user.target

# 保存退出
# 加载系统配置并设置为开机自启
[root@localhost system]# systemctl daemon-reload
[root@localhost system]# systemctl enable postgres.service

# 完成重启电脑

创建企业级地理数据库

# 将GeoScene Enterprise安装目录下的对应PostGres版本的st_geometry.dll文件移动到PostGres目录下的lib文件夹里面

[root@jyxx sysgen]# cd /home/geoscene/geoscene/server/DatabaseSupport/PostgreSQL/13/Linux64/
[root@jyxx Windows64]# ll
总用量 166356
-rw------- 1 geoscene GEOscene   303104 1223  2022 st_geometry.so
-rw------- 1 geoscene GEOscene 42509824 1223  2022 PGSQLEngine.so

[root@localhost lib]# cd /home/postgres/pg13/lib
[root@localhost lib]# ll
总用量 46896
......
-rwxr-xr-x 1 postgres postgres   223144  122 10:45 plpgsql.so
-rw-r--r-- 1 root     root     42507776  122 13:54 st_geometry.so
-rwxr-xr-x 1 postgres postgres   131568  122 10:45 utf8_and_big5.so
......

# 修改用户及用户组
[root@localhost lib]# chown -R postgres:postgres /home/postgres/pg13/lib/st_geometry.so
[root@localhost lib]# chmod 755 /home/postgres/pg13/lib/st_geometry.so

## 打开Geoscene Pro 操作
# 授权文件位置:/home/geoscene/geoscene/server/framework/runtime/.wine/drive_c/Program Files/ESRI/License10.9/sysgen

打开工具“创建企业级地理数据库”
输入以下参数:
	数据库平台:PostgreSQL
	实     例:192.168.0.21,5432(根据自己数据库地址修改)
	数 据 库 :xiluodu		  (数据库名称)
	数据库管理员:postgres		(自己数据库的账号)
	数据库管理员密码:postgres  (自己数据库的密码)
	地理数据库管理员密码:sde	 (不理解)
	表空间名称:				 (不填)
	授权文件:				  (根据前面的路径去找)
	表空间类型:ST_Geometry
	
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

南念-shmily

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值