本次安装的各版本如下
postgresql-13.5.tar
geos-3.10.2
gdal-3.4.1
proj-8.2.1
postgis-3.2.1
一、安装postgreSQL
1.1安装
包下载地址
选postgresql-13.5.tar.gz。
使用工具将下载好的包传到服务器。
解压 ,进入解压目录
[root@localhost local]# yum install gcc readline-devel zlib-devel make [root@localhost local]# tar -zxvf postgresql-13.5.tar.gz [root@localhost local]# cd postgresql-13.5 [root@localhost postgresql-13.5]# ./configure --prefix=/usr/local/pgsql [root@localhost postgresql-13.5]# make
[root@localhost postgresql-13.5]# make install
[root@localhost postgresql-13.5]# groupadd postgres
[root@localhost postgresql-13.5]# useradd -g postgres postgres
[root@localhost postgresql-13.5]# chown postgres:postgres /usr/local/pgsql/data
[root@localhost postgresql-13.5]# su - postgres
[postgres@localhost bin]$ ./initdb -D /usr/local/pgsql/data
[postgres@localhost bin]$ ./pg_ctl -D /usr/local/pgsql/data -l logfile start
[postgres@localhost bin]$ ./psql
postgres=# ALTER USER postgres WITH PASSWORD 'ABcd_123456';
postgres=# CREATE DATABASE gis57;
postgres=# ALTER DATABASE gis57 OWNER TO postgres;
postgres=# \q
配置环境变量
[root@localhost local]# echo 'export PATH=/usr/local/pgsql/bin:$PATH' >> /etc/profile
[root@localhost local]# source /etc/profile
[root@localhost local]# psql --version
创建systemd服务文件
[root@localhost local]# sudo vi /etc/systemd/system/pgsql.service
[Unit] Description=PostgreSQL database server After=network.target [Service] Type=forking User=postgres Group=postgres ExecStart=/usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data -s -l /usr/local/pgsql/data/logfile ExecStop=/usr/local/pgsql/bin/pg_ctl stop -D /usr/local/pgsql/data -s -m fast ExecReload=/usr/local/pgsql/bin/pg_ctl reload -D /usr/local/pgsql/data -s [Install] WantedBy=multi-user.target
[root@localhost local]# sudo systemctl daemon-reload [root@localhost local]# sudo systemctl start pgsql [root@localhost local]# sudo systemctl enable pgsql [root@localhost local]# sudo systemctl status pgsql
标签:postgreSQL,postgres,Centos,root,pgsql,源码,usr,local,localhost From: https://www.cnblogs.com/fangts/p/18358977