centos上安装postgresql(有网、离线)
1、有网环境:
参考链接:https://www.cnblogs.com/stulzq/p/7766409.html
https://www.postgresql.org/download/linux/redhat/
1、查看当前centos版本:
2、选择安装方式(https://www.postgresql.org/download/linux/redhat/):
3、执行命令:
出现
安装成功!
4、验证是否安装成功
5、初始化数据库
6、执行初始化,检查端口发现此时数据库还并没有启动
7、启动服务并检查端口
8、修改默认用户postgres的密码为:postgres(https://www.cnblogs.com/stulzq/p/7766409.html)
9、开启远程访问
vim /var/lib/pgsql/10/data/postgresql.conf
10、信任远程连接
vi /var/lib/pgsql/data/pg_hba.conf
注意,后面的ident都要改为trust,才能用户名密码登录(https://blog.csdn.net/sanbingyutuoniao123/article/details/52209653)
11、重启服务
12、使用navicat连接
13、连接成功
2、无网环境:
1、尝试采用源码包安装,访问官网下载页面:https://www.postgresql.org/ftp/source/v10.3/
点击下载源码包 postgresql-10.3.tar.gz
源码包解压后目录下有个文档INSTALL 记事本或vi打开,里面有详尽安装步骤。
2.服务器上的centos没有gcc,不能编译源码,故将源码包上传到本地的虚拟机,该虚拟机为可联外网的centos系统(与不可联外网的服务器的版本相同,或者低于服务器系统版本),解压,进入解压后的目录,configure
[root@localhost postgresql-10.3]# ls
aclocal.m4 config configure configure.in contrib COPYRIGHT doc GNUmakefile.in HISTORY INSTALL Makefile README src
[root@localhost postgresql-10.3]# ./configure
checking build system type... x86_64-pc-linux-gnu
.......
checking for bison... no
configure: WARNING:
*** Without Bison you will not be able to build PostgreSQL from Git nor
*** change any of the parser definition files. You can obtain Bison from
*** a GNU mirror site. (If you are using the official distribution of
*** PostgreSQL then you do not need to worry about this, because the Bison
*** output is pre-generated.)
checking for flex... no
configure: WARNING:
*** Without Flex you will not be able to build PostgreSQL from Git nor
*** change any of the scanner definition files. You can obtain Flex from
*** a GNU mirror site. (If you are using the official distribution of
*** PostgreSQL then you do not need to worry about this because the Flex
*** output is pre-generated.)
checking for perl... /usr/bin/perl
configure: using perl 5.10.1
checking for ANSI C header files... yes
checking for sys/types.h... yes
.......
checking for library containing shmget... none required
checking for library containing readline... no
configure: error: readline library not found
If you have readline already installed, see config.log for details on the
failure. It is possible the compiler isn't looking in the proper directory.
Use --without-readline to disable readline support.
You have new mail in /var/spool/mail/root
[root@localhost postgresql-10.3]#
报错:需要安装readline
3.安装readline-devel
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.cn99.com
* updates: mirrors.aliyun.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package readline-devel.x86_64 0:6.0-4.el6 will be installed
--> Processing Dependency: ncurses-devel for package: readline-devel-6.0-4.el6.x86_64
--> Running transaction check
---> Package ncurses-devel.x86_64 0:5.7-4.20090207.el6 will be installed
--> Processing Dependency: ncurses-libs = 5.7-4.20090207.el6 for package: ncurses-devel-5.7-4.20090207.el6.x86_64
--> Running transaction check
---> Package ncurses-libs.x86_64 0:5.7-3.20090208.el6 will be updated
---> Package ncurses-libs.x86_64 0:5.7-4.20090207.el6 will be an update
--> Processing Dependency: ncurses-base = 5.7-4.20090207.el6 for package: ncurses-libs-5.7-4.20090207.el6.x86_64
--> Running transaction check
---> Package ncurses-base.x86_64 0:5.7-3.20090208.el6 will be updated
---> Package ncurses-base.x86_64 0:5.7-4.20090207.el6 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
==============================================================================================================================================================================================================================================================================
Package Arch Version Repository Size
==============================================================================================================================================================================================================================================================================
Installing:
readline-devel x86_64 6.0-4.el6 base 134 k
Installing for dependencies:
ncurses-devel x86_64 5.7-4.20090207.el6 base 641 k
Updating for dependencies:
ncurses-base x86_64 5.7-4.20090207.el6 base 61 k
ncurses-libs x86_64 5.7-4.20090207.el6 base 245 k
Transaction Summary
==============================================================================================================================================================================================================================================================================
Install 2 Package(s)
Upgrade 2 Package(s)
Total download size: 1.1 M
Downloading Packages:
(1/4): ncurses-base-5.7-4.20090207.el6.x86_64.rpm | 61 kB 00:00
(2/4): ncurses-devel-5.7-4.20090207.el6.x86_64.rpm | 641 kB 00:00
(3/4): ncurses-libs-5.7-4.20090207.el6.x86_64.rpm | 245 kB 00:00
(4/4): readline-devel-6.0-4.el6.x86_64.rpm | 134 kB 00:00
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 1.8 MB/s | 1.1 MB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : ncurses-base-5.7-4.20090207.el6.x86_64 1/6
Updating : ncurses-libs-5.7-4.20090207.el6.x86_64 2/6
Installing : ncurses-devel-5.7-4.20090207.el6.x86_64 3/6
Installing : readline-devel-6.0-4.el6.x86_64 4/6
Cleanup : ncurses-libs-5.7-3.20090208.el6.x86_64 5/6
Cleanup : ncurses-base-5.7-3.20090208.el6.x86_64 6/6
Verifying : ncurses-devel-5.7-4.20090207.el6.x86_64 1/6
Verifying : readline-devel-6.0-4.el6.x86_64 2/6
Verifying : ncurses-libs-5.7-4.20090207.el6.x86_64 3/6
Verifying : ncurses-base-5.7-4.20090207.el6.x86_64 4/6
Verifying : ncurses-libs-5.7-3.20090208.el6.x86_64 5/6
Verifying : ncurses-base-5.7-3.20090208.el6.x86_64 6/6
Installed:
readline-devel.x86_64 0:6.0-4.el6
Dependency Installed:
ncurses-devel.x86_64 0:5.7-4.20090207.el6
Dependency Updated:
ncurses-base.x86_64 0:5.7-4.20090207.el6 ncurses-libs.x86_64 0:5.7-4.20090207.el6
Complete!
安装完成
4.再次执行./configure
checking build system type... x86_64-pc-linux-gnu
.......
checking for inflate in -lz... no
configure: error: zlib library not found
If you have zlib already installed, see config.log for details on the
failure. It is possible the compiler isn't looking in the proper directory.
Use --without-zlib to disable zlib support.
[root@localhost postgresql-10.3]#
报错:缺少zlib
5.安装zlib
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.cn99.com
* updates: mirrors.aliyun.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package zlib-devel.x86_64 0:1.2.3-29.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==============================================================================================================================================================================================================================================================================
Package Arch Version Repository Size
==============================================================================================================================================================================================================================================================================
Installing:
zlib-devel x86_64 1.2.3-29.el6 base 44 k
Transaction Summary
==============================================================================================================================================================================================================================================================================
Install 1 Package(s)
Total download size: 44 k
Installed size: 115 k
Is this ok [y/N]: y
Downloading Packages:
zlib-devel-1.2.3-29.el6.x86_64.rpm | 44 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : zlib-devel-1.2.3-29.el6.x86_64 1/1
Verifying : zlib-devel-1.2.3-29.el6.x86_64 1/1
Installed:
zlib-devel.x86_64 0:1.2.3-29.el6
Complete!
[root@localhost postgresql-10.3]#
安装完成。
6.第三次执行./configure
checking build system type... x86_64-pc-linux-gnu
.......
checking for bison... no
configure: WARNING:
*** Without Bison you will not be able to build PostgreSQL from Git nor
*** change any of the parser definition files. You can obtain Bison from
*** a GNU mirror site. (If you are using the official distribution of
*** PostgreSQL then you do not need to worry about this, because the Bison
*** output is pre-generated.)
checking for flex... no
configure: WARNING:
*** Without Flex you will not be able to build PostgreSQL from Git nor
*** change any of the scanner definition files. You can obtain Flex from
*** a GNU mirror site. (If you are using the official distribution of
*** PostgreSQL then you do not need to worry about this because the Flex
*** output is pre-generated.)
checking for perl... /usr/bin/perl
configure: using perl 5.10.1
checking for ANSI C header files... yes
.......
checking whether gcc supports -Wl,--as-needed... yes
configure: using compiler=gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18)
configure: using CFLAGS=-Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -O2
configure: using CPPFLAGS= -D_GNU_SOURCE
configure: using LDFLAGS= -Wl,--as-needed
configure: creating ./config.status
config.status: creating GNUmakefile
config.status: creating src/Makefile.global
config.status: creating src/include/pg_config.h
config.status: creating src/include/pg_config_ext.h
config.status: creating src/interfaces/ecpg/include/ecpg_config.h
config.status: linking src/backend/port/tas/dummy.s to src/backend/port/tas.s
config.status: linking src/backend/port/dynloader/linux.c to src/backend/port/dynloader.c
config.status: linking src/backend/port/posix_sema.c to src/backend/port/pg_sema.c
config.status: linking src/backend/port/sysv_shmem.c to src/backend/port/pg_shmem.c
config.status: linking src/backend/port/dynloader/linux.h to src/include/dynloader.h
config.status: linking src/include/port/linux.h to src/include/pg_config_os.h
config.status: linking src/makefiles/Makefile.linux to src/Makefile.port
[root@localhost postgresql-10.3]#
完成!
7.此时发现目录下多了一个config.log文件。将文件整体打包上传至服务器。
8.执行make命令,发现不可行。
make -C src all
make[1]: 杩涘叆鐩綍鈥opt/oudar/software/postgresql/postgresql-compiled/postgresql-10.3/src鈥
make -C common all
make[2]: 杩涘叆鐩綍鈥opt/oudar/software/postgresql/postgresql-compiled/postgresql-10.3/src/common鈥
make -C ../backend submake-errcodes
make[3]: 杩涘叆鐩綍鈥opt/oudar/software/postgresql/postgresql-compiled/postgresql-10.3/src/backend鈥
prereqdir=`cd 'utils/' >/dev/null && pwd` && \
cd '../../src/include/utils/' && rm -f errcodes.h && \
ln -s "$prereqdir/errcodes.h" .
make[3]: 绂诲紑鐩綍鈥opt/oudar/software/postgresql/postgresql-compiled/postgresql-10.3/src/backend鈥
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -O2 -DFRONTEND -I../../src/include -D_GNU_SOURCE -DVAL_CONFIGURE="\"\"" -DVAL_CC="\"gcc\"" -DVAL_CPPFLAGS="\"-DFRONTEND -D_GNU_SOURCE\"" -DVAL_CFLAGS="\"-Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -O2\"" -DVAL_CFLAGS_SL="\"-fPIC\"" -DVAL_LDFLAGS="\"-L../../src/common -Wl,--as-needed -Wl,-rpath,'/usr/local/pgsql/lib',--enable-new-dtags\"" -DVAL_LDFLAGS_EX="\"\"" -DVAL_LDFLAGS_SL="\"\"" -DVAL_LIBS="\"-lpgcommon -lpgport -lz -lreadline -lrt -lcrypt -ldl -lm \"" -c -o base64.o base64.c
/bin/sh: gcc: 鏈壘鍒板懡浠
make[2]: *** [base64.o] 閿欒 127
make[2]: 绂诲紑鐩綍鈥opt/oudar/software/postgresql/postgresql-compiled/postgresql-10.3/src/common鈥
make[1]: *** [all-common-recurse] 閿欒 2
make[1]: 绂诲紑鐩綍鈥opt/oudar/software/postgresql/postgresql-compiled/postgresql-10.3/src鈥
make: *** [all-src-recurse] 閿欒 2
[root@ydptmh postgresql-10.3]#
9.更换方案,直接下载安装包rpm安装。回到官网,复制yum命令
[root@localhost home]# ls
mumu postgresql tomcat YDplatform
[root@localhost home]# cd mumu
[root@localhost mumu]# ls
java program 公共的 模板 视频 图片 文档 下载 音乐 桌面
[root@localhost mumu]# wget https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-6-x86_64/pgdg-centos10-10-2.noarch.rpm
--2018-08-31 17:01:53-- https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-6-x86_64/pgdg-centos10-10-2.noarch.rpm
正在解析主机 download.postgresql.org... 204.145.124.244, 217.196.149.55, 174.143.35.246, ...
正在连接 download.postgresql.org|204.145.124.244|:443... 已连接。
错误: 证书通用名 “ftp.postgresql.org” 与所要求的主机名 “download.postgresql.org” 不符。
要以不安全的方式连接至 download.postgresql.org,使用‘--no-check-certificate’。
[root@localhost mumu]# wget --no-check-certificate https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-6-x86_64/pgdg-centos10-10-2.noarch.rp
m--2018-08-31 17:04:08-- https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-6-x86_64/pgdg-centos10-10-2.noarch.rpm
正在解析主机 download.postgresql.org... 174.143.35.246, 204.145.124.244, 217.196.149.55, ...
正在连接 download.postgresql.org|174.143.35.246|:443... 已连接。
警告: 证书通用名 “ftp.postgresql.org” 与所要求的主机名 “download.postgresql.org” 不符。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:4660 (4.6K) [application/x-redhat-package-manager]
正在保存至: “pgdg-centos10-10-2.noarch.rpm”
100%[===========================================================================================================>] 4,660 --.-K/s in 0s
2018-08-31 17:04:10 (203 MB/s) - 已保存 “pgdg-centos10-10-2.noarch.rpm” [4660/4660])
[root@localhost mumu]# ll
总用量 48
drwxrwxr-x. 2 mumu mumu 4096 9月 6 2017 java
-rw-r--r--. 1 root root 4660 9月 24 2017 pgdg-centos10-10-2.noarch.rpm
drwxrwxr-x. 2 mumu mumu 4096 9月 6 2017 program
......
drwxr-xr-x. 2 mumu mumu 4096 6月 21 2017 桌面
[root@localhost mumu]# yum search postgres
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.cn99.com
* updates: mirrors.aliyun.com
=============================================================== N/S Matched: postgres ===============================================================
bacula-director-postgresql.x86_64 : Bacula Director with PostgresSQL database support
freeradius-postgresql.x86_64 : Postgresql support for freeradius
pcp-pmda-postgresql.x86_64 : Performance Co-Pilot (PCP) metrics for PostgreSQL
postgresql.i686 : PostgreSQL client programs
postgresql.x86_64 : PostgreSQL client programs
...........
tcl-pgtcl.x86_64 : A Tcl client library for PostgreSQL
uuid-pgsql.x86_64 : PostgreSQL support for Universally Unique Identifier library
Name and summary matches only, use "search all" for everything.
[root@localhost mumu]# yum install --downloadonly --downloaddir=/home/meme/ postgresql10
Loaded plugins: fastestmirror, refresh-packagekit, security
Usage: yum [options] COMMAND
List of Commands:
check Check for problems in the rpmdb
check-update Check for available package updates
..............
upgrade Update packages taking obsoletes into account
version Display a version for the machine and/or available repos.
Command line error: no such option: --downloadonly
[root@localhost mumu]# ls
java pgdg-centos10-10-2.noarch.rpm program 公共的 模板 视频 图片 文档 下载 音乐 桌面
[root@localhost mumu]# rz [root@localhost mumu]#
[root@localhost mumu]# rm pgdg-centos10-10-2.noarch.rpm
rm:是否删除普通文件 "pgdg-centos10-10-2.noarch.rpm"?y
[root@localhost mumu]# ls
java program 公共的 模板 视频 图片 文档 下载 音乐 桌面
[root@localhost mumu]# pwd
/home/mumu
[root@localhost mumu]# yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-6-x86_64/pgdg-centos10-10-2.noarch.rpm
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.cn99.com
* updates: mirrors.aliyun.com
Setting up Install Process
pgdg-centos10-10-2.noarch.rpm | 4.6 kB 00:00
Examining /var/tmp/yum-root-ijIPzx/pgdg-centos10-10-2.noarch.rpm: pgdg-centos10-10-2.noarch
Marking /var/tmp/yum-root-ijIPzx/pgdg-centos10-10-2.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package pgdg-centos10.noarch 0:10-2 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=====================================================================================================================================================
Package Arch Version Repository Size
=====================================================================================================================================================
Installing:
pgdg-centos10 noarch 10-2 /pgdg-centos10-10-2.noarch 2.7 k
Transaction Summary
=====================================================================================================================================================
Install 1 Package(s)
Total size: 2.7 k
Installed size: 2.7 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : pgdg-centos10-10-2.noarch 1/1
Verifying : pgdg-centos10-10-2.noarch 1/1
Installed:
pgdg-centos10.noarch 0:10-2
Complete!
[root@localhost mumu]# yum search postgres
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.cn99.com
* updates: mirrors.aliyun.com
pgdg10 | 4.1 kB 00:00
pgdg10/primary_db | 172 kB 00:00
=============================================================== N/S Matched: postgres ===============================================================
bacula-director-postgresql.x86_64 : Bacula Director with PostgresSQL database support
check_postgres.noarch : PostgreSQL monitoring script
freeradius-postgresql.x86_64 : Postgresql support for freeradius
pcp-pmda-postgresql.x86_64 : Performance Co-Pilot (PCP) metrics for PostgreSQL
postgresql.i686 : PostgreSQL client programs
..............
postgresql10.x86_64 : PostgreSQL client programs and libraries
.........
postgresql10-server.x86_64 : The programs needed to create and run a PostgreSQL server
..........
tds_fdw10.x86_64 : TDS Foreign Data Wrapper for PostgreSQL
temboard-agent.noarch : PostgreSQL Remote Control agent
topn_10.x86_64 : PostgreSQL extension that returns the top values in a database
usda-r18.noarch : The USDA Food Database Sample for PostgreSQL
uuid-pgsql.x86_64 : PostgreSQL support for Universally Unique Identifier library
Name and summary matches only, use "search all" for everything.
[root@localhost mumu]# mkdir psql10
[root@localhost mumu]# yum install --downloadonly --downloaddir=psql10 postgresql10 postgresql10-server (下载postgresql10-server安装包)
Loaded plugins: fastestmirror, refresh-packagekit, security
Usage: yum [options] COMMAND
List of Commands:
check Check for problems in the rpmdb
............
version Display a version for the machine and/or available repos.
Command line error: no such option: --downloadonly (报错!!)
[root@localhost mumu]# ls
java program psql10 公共的 模板 视频 图片 文档 下载 音乐 桌面
[root@localhost mumu]# cd psql10
[root@localhost psql10]# ls
[root@localhost psql10]# rpm -qa|grep postgres
[root@localhost psql10]# yum install yum-plugin-downloadonly (安装downloadonly插件后,才能用“--downloadonly --downloaddir=psql10”)
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.cn99.com
* updates: mirrors.aliyun.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package yum.noarch 0:3.2.29-40.el6.centos will be updated
---> Package yum.noarch 0:3.2.29-81.el6.centos will be an update
--> Processing Dependency: python-urlgrabber >= 3.9.1-10 for package: yum-3.2.29-81.el6.centos.noarch
--> Running transaction check
---> Package python-urlgrabber.noarch 0:3.9.1-9.el6 will be updated
---> Package python-urlgrabber.noarch 0:3.9.1-11.el6 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
=====================================================================================================================================================
Package Arch Version Repository Size
=====================================================================================================================================================
Updating:
yum noarch 3.2.29-81.el6.centos base 1.0 M
Updating for dependencies:
python-urlgrabber noarch 3.9.1-11.el6 base 86 k
Transaction Summary
=====================================================================================================================================================
Upgrade 2 Package(s)
Total download size: 1.1 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): python-urlgrabber-3.9.1-11.el6.noarch.rpm | 86 kB 00:00
(2/2): yum-3.2.29-81.el6.centos.noarch.rpm | 1.0 MB 00:00
-----------------------------------------------------------------------------------------------------------------------------------------------------
Total 2.3 MB/s | 1.1 MB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : python-urlgrabber-3.9.1-11.el6.noarch 1/4
Updating : yum-3.2.29-81.el6.centos.noarch 2/4
Cleanup : yum-3.2.29-40.el6.centos.noarch 3/4
Cleanup : python-urlgrabber-3.9.1-9.el6.noarch 4/4
Verifying : python-urlgrabber-3.9.1-11.el6.noarch 1/4
Verifying : yum-3.2.29-81.el6.centos.noarch 2/4
Verifying : yum-3.2.29-40.el6.centos.noarch 3/4
Verifying : python-urlgrabber-3.9.1-9.el6.noarch 4/4
Updated:
yum.noarch 0:3.2.29-81.el6.centos
Dependency Updated:
python-urlgrabber.noarch 0:3.9.1-11.el6
Complete!
[root@localhost psql10]# clear
[root@localhost psql10]# yum search postgres
已加载插件:fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.cn99.com
* updates: mirrors.aliyun.com
=============================================================== N/S Matched: postgres ===============================================================
bacula-director-postgresql.x86_64 : Bacula Director with PostgresSQL database support
check_postgres.noarch : PostgreSQL monitoring script
freeradius-postgresql.x86_64 : Postgresql support for freeradius
pcp-pmda-postgresql.x86_64 : Performance Co-Pilot (PCP) metrics for PostgreSQL
postgresql.i686 : PostgreSQL client programs
..........
postgresql10.x86_64 : PostgreSQL client programs and libraries
........
postgresql10-server.x86_64 : The programs needed to create and run a PostgreSQL server
.........
temboard-agent.noarch : PostgreSQL Remote Control agent
topn_10.x86_64 : PostgreSQL extension that returns the top values in a database
usda-r18.noarch : The USDA Food Database Sample for PostgreSQL
uuid-pgsql.x86_64 : PostgreSQL support for Universally Unique Identifier library
Name and summary matches only, use "search all" for everything.
[root@localhost psql10]# ls
[root@localhost psql10]# cd ..
[root@localhost mumu]# ls
java program psql10 公共的 模板 视频 图片 文档 下载 音乐 桌面
[root@localhost mumu]# yum install --downloadonly --downloaddir=psql10 postgresql10 postgresql10-server
已加载插件:fastestmirror, refresh-packagekit, security
设置安装进程
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.cn99.com
* updates: mirrors.aliyun.com
解决依赖关系
--> 执行事务检查
---> Package postgresql10.x86_64 0:10.5-1PGDG.rhel6 will be 安装
--> 处理依赖关系 postgresql10-libs(x86-64) = 10.5-1PGDG.rhel6,它被软件包 postgresql10-10.5-1PGDG.rhel6.x86_64 需要
--> 处理依赖关系 libpq.so.5()(64bit),它被软件包 postgresql10-10.5-1PGDG.rhel6.x86_64 需要
---> Package postgresql10-server.x86_64 0:10.5-1PGDG.rhel6 will be 安装
--> 执行事务检查
---> Package postgresql10-libs.x86_64 0:10.5-1PGDG.rhel6 will be 安装
--> 完成依赖关系计算
依赖关系解决
=====================================================================================================================================================
软件包 架构 版本 仓库 大小
=====================================================================================================================================================
正在安装:
postgresql10 x86_64 10.5-1PGDG.rhel6 pgdg10 1.6 M
postgresql10-server x86_64 10.5-1PGDG.rhel6 pgdg10 5.0 M
为依赖而安装:
postgresql10-libs x86_64 10.5-1PGDG.rhel6 pgdg10 325 k
事务概要
=====================================================================================================================================================
Install 3 Package(s)
总下载量:7.0 M
Installed size: 27 M
确定吗?[y/N]:y
下载软件包:
(1/3): postgresql10-10.5-1PGDG.rhel6.x86_64.rpm | 1.6 MB 00:04
(2/3): postgresql10-libs-10.5-1PGDG.rhel6.x86_64.rpm | 325 kB 00:00
(3/3): postgresql10-server-10.5-1PGDG.rhel6.x86_64.rpm | 5.0 MB 00:07
-----------------------------------------------------------------------------------------------------------------------------------------------------
总计 461 kB/s | 7.0 MB 00:15
exiting because --downloadonly specified
[root@localhost mumu]# ls
java program psql10 公共的 模板 视频 图片 文档 下载 音乐 桌面
[root@localhost mumu]# cd psql10/
[root@localhost psql10]# ls
postgresql10-10.5-1PGDG.rhel6.x86_64.rpm postgresql10-libs-10.5-1PGDG.rhel6.x86_64.rpm postgresql10-server-10.5-1PGDG.rhel6.x86_64.rpm
[root@localhost psql10]# ll
总用量 7152
-rw-r--r--. 1 root root 1716836 8月 9 17:17 postgresql10-10.5-1PGDG.rhel6.x86_64.rpm
-rw-r--r--. 1 root root 332664 8月 9 17:17 postgresql10-libs-10.5-1PGDG.rhel6.x86_64.rpm
-rw-r--r--. 1 root root 5263884 8月 9 17:17 postgresql10-server-10.5-1PGDG.rhel6.x86_64.rpm
[root@localhost psql10]# tar czf package.tar.gz postgresql10-10.5-1PGDG.rhel6.x86_64.rpm postgresql10-libs-10.5-1PGDG.rhel6.x86_64.rpm postgresql10-server-10.5-1PGDG.rhel6.x86_64.rpm
[root@localhost psql10]# ls
package.tar.gz postgresql10-10.5-1PGDG.rhel6.x86_64.rpm postgresql10-libs-10.5-1PGDG.rhel6.x86_64.rpm postgresql10-server-10.5-1PGDG.rhel6.x86_64.rpm
[root@localhost psql10]# rpm -ivh postgresql10-* (先尝试在本机rpm安装)
Preparing... ########################################### [100%]
1:postgresql10-libs ########################################### [ 33%]
2:postgresql10 ########################################### [ 67%]
3:postgresql10-server ########################################### [100%]
[root@localhost psql10]# service postgresql10 initdb
postgresql10: 未被识别的服务
[root@localhost psql10]# service postgresql-10 initdb
正在初始化数据库: [确定]
[root@localhost psql10]# chkconfig postgresql-10 on
[root@localhost psql10]# service postgresql-10 start
启动 postgresql-10 服务: [确定]
[root@localhost psql10]#
10、安装包在本机离线安装是可行的,放到服务器后,就报错了,如下。(参考链接:http://blog.51cto.com/hsbxxl/2117398)
警告:postgresql10-10.5-1PGDG.rhel6.x86_64.rpm: 头V4 DSA/SHA1 Signature, 密钥 ID 442df0f8: NOKEY
错误:依赖检测失败:
libicui18n.so.42()(64bit) 被 postgresql10-server-10.5-1PGDG.rhel6.x86_64 需要
libicuuc.so.42()(64bit) 被 postgresql10-server-10.5-1PGDG.rhel6.x86_64 需要
[root@ydptmh postgresql]#
11、查询原因。本机为sentos6,而服务器为sentos7。尝试在centos6中用yum指令下载sentos7对应的postgresql安装包,但是不行。下载下来的始终是sentos6对应的版本。
只好本地新建虚拟机,装sentos7系统 ,通过上面的命令下载对应的rpm安装包上传。下载完后再上传至服务器。
libicu-50.1.2-15.el7.x86_64.rpm packages_.tar.gz postgresql10-10.5-1PGDG.rhel7.x86_64.rpm postgresql10-libs-10.5-1PGDG.rhel7.x86_64.rpm postgresql10-server-10.5-1PGDG.rhel7.x86_64.rpm
[root@ydptmh postgresql]# rpm -ivh postgresql10-libs-10.5-1PGDG.rhel7.x86_64.rpm
警告:postgresql10-libs-10.5-1PGDG.rhel7.x86_64.rpm: 头V4 DSA/SHA1 Signature, 密钥 ID 442df0f8: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:postgresql10-libs-10.5-1PGDG.rhel################################# [100%]
[root@ydptmh postgresql]# rpm -ivh postgresql10-server-10.5-1PGDG.rhel7.x86_64.rpm
警告:postgresql10-server-10.5-1PGDG.rhel7.x86_64.rpm: 头V4 DSA/SHA1 Signature, 密钥 ID 442df0f8: NOKEY
错误:依赖检测失败:
postgresql10(x86-64) = 10.5-1PGDG.rhel7 被 postgresql10-server-10.5-1PGDG.rhel7.x86_64 需要
[root@ydptmh postgresql]# rpm -ivh postgresql10-10.5-1PGDG.rhel7.x86_64.rpm
警告:postgresql10-10.5-1PGDG.rhel7.x86_64.rpm: 头V4 DSA/SHA1 Signature, 密钥 ID 442df0f8: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:postgresql10-10.5-1PGDG.rhel7 ################################# [100%]
[root@ydptmh postgresql]# rpm -ivh postgresql10-server-10.5-1PGDG.rhel7.x86_64.rpm
警告:postgresql10-server-10.5-1PGDG.rhel7.x86_64.rpm: 头V4 DSA/SHA1 Signature, 密钥 ID 442df0f8: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:postgresql10-server-10.5-1PGDG.rh################################# [100%]
[root@ydptmh postgresql]# service postgresql-10 initdb
The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.
[root@ydptmh postgresql]# systemctl postgresql-10 initdb
Unknown operation 'postgresql-10'.
[root@ydptmh postgresql]# /usr/pgsql-10/bin/postgresql-10-setup initdb
Initializing database ... OK
[root@ydptmh postgresql]# systemctl enable postgresql-10
Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql-10.service to /usr/lib/systemd/system/postgresql-10.service.
[root@ydptmh postgresql]# systemctl start postgresql-10
[root@ydptmh postgresql]# systemctl postgresql10 start
Unknown operation 'postgresql10'.
[root@ydptmh postgresql]# lsof -i:5432
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
postmaste 22061 postgres 3u IPv4 15918812 0t0 TCP localhost:postgres (LISTEN)
[root@ydptmh postgresql]# su posgres
su: user posgres does not exist
[root@ydptmh postgresql]# sudo service postgresql-10 start
Redirecting to /bin/systemctl start postgresql-10.service
[root@ydptmh postgresql]# service postgresql-10 status
Redirecting to /bin/systemctl status postgresql-10.service
● postgresql-10.service - PostgreSQL 10 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-10.service; enabled; vendor preset: disabled)
Active: active (running) since 二 2018-09-04 16:05:56 CST; 3min 58s ago
Docs: https://www.postgresql.org/docs/10/static/
Process: 22055 ExecStartPre=/usr/pgsql-10/bin/postgresql-10-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
Main PID: 22061 (postmaster)
CGroup: /system.slice/postgresql-10.service
├─22061 /usr/pgsql-10/bin/postmaster -D /var/lib/pgsql/10/data/
├─22063 postgres: logger process
├─22065 postgres: checkpointer process
├─22066 postgres: writer process
├─22067 postgres: wal writer process
├─22068 postgres: autovacuum launcher process
├─22069 postgres: stats collector process
└─22070 postgres: bgworker: logical replication launcher
9月 04 16:05:56 ydptmh systemd[1]: Starting PostgreSQL 10 database server...
9月 04 16:05:56 ydptmh postmaster[22061]: 2018-09-04 16:05:56.891 CST [22061] 日志: listening on IPv4 address "127.0.0.1", port 5432
9月 04 16:05:56 ydptmh postmaster[22061]: 2018-09-04 16:05:56.891 CST [22061] 日志: could not bind IPv6 address "::1": 无法指定被请求的地址
9月 04 16:05:56 ydptmh postmaster[22061]: 2018-09-04 16:05:56.891 CST [22061] 提示: 是否有其它 postmaster 已经在端口 5432 上运行了? 如果没有, 请等待几秒钟后然后再重试.
9月 04 16:05:56 ydptmh postmaster[22061]: 2018-09-04 16:05:56.902 CST [22061] 日志: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
9月 04 16:05:56 ydptmh postmaster[22061]: 2018-09-04 16:05:56.921 CST [22061] 日志: listening on Unix socket "/tmp/.s.PGSQL.5432"
9月 04 16:05:56 ydptmh postmaster[22061]: 2018-09-04 16:05:56.944 CST [22061] 日志: 日志输出重定向到日志收集进程
9月 04 16:05:56 ydptmh postmaster[22061]: 2018-09-04 16:05:56.944 CST [22061] 提示: 后续的日志输出将出现在目录 "log"中.
9月 04 16:05:56 ydptmh systemd[1]: Started PostgreSQL 10 database server.
[root@ydptmh postgresql]# sudo passwd postgres
更改用户 postgres 的密码 。
新的 密码:
无效的密码: 密码包含用户名在某些地方
重新输入新的 密码:
抱歉,密码不匹配。
新的 密码:
无效的密码: 密码少于 8 个字符
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
[root@ydptmh postgresql]# su postgresql
su: user postgresql does not exist
[root@ydptmh postgresql]# su postgres
bash-4.2$ psql
psql (10.5)
输入 "help" 来获取帮助信息.
postgres=# \l
数据库列表
名称 | 拥有者 | 字元编码 | 校对规则 | Ctype | 存取权限
-----------+----------+----------+-------------+-------------+-----------------------
postgres | postgres | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 |
template0 | postgres | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(3 行记录)
postgres=# \q
bash-4.2$ exit
exit
[root@ydptmh postgresql]#
服务器端安装数据库成功!
上一篇: PostgreSQL 基本操作
下一篇: PostgreSQL 8.4.1发布
推荐阅读
-
在CentOS7(有图形化界面)上安装maven和idea的详细教程
-
postgresql-2-在centos7系统中离线安装
-
【kong 2.0.2研究】系列二:在CentOS 7上安装&配置PostgreSQL 12,以支持Kong
-
在CentOS上使用离线YUM安装软件包
-
CentOS 7.3 官网离线安装mysql 5.5
-
Centos7上离线编译安装Nginx
-
CentOS6.5上Cloudera Manager和Cloudera Hadoop的离线安装
-
CentOS6.5上Cloudera Manager和Cloudera Hadoop的离线安装
-
centos上安装postgresql(有网、离线)
-
在CentOS7(有图形化界面)上安装maven和idea的详细教程