Linux在不能使用yum的环境下安装pgsql(公司内网)

news/2024/7/9 21:58:48

目录

  • 前言
    • 一、安装环境
    • 二、开始安装pgsql (按照操作流程来的)
    • 三、问题解决方案
      • 1、两个问题
      • 2、npm的安装过程
  • 后言

前言

本次的情况先说明一下:
任务就是在公司的内网服务器中搭建一个pgsql的数据库

无yum下载,只能使用rpm文件搞定相关软件安装

在这里插入图片描述


一、安装环境

liunx系统: Centos7
pgsql数据库:postgresql-10.2
服务器视图化工具:finalshell
数据库视图化工具:Navicat 12

本次pgsql的文件存放位置: /home/pgsql

在这里插入图片描述


二、开始安装pgsql (按照操作流程来的)

(1)解压压缩包
[root@localhost pgsql]# tar -zxvf postgresql-10.2.tar.gz

(2)进入压缩后文件
[root@localhost pgsql]# cd postgresql-10.2
[root@localhost pgsql]# ls
aclocal.m4 configure contrib doc HISTORY Makefile src
config configure.in COPYRIGHT GNUmakefile.in INSTALL README

(3)编译postgresql源码
[root@localhost postgresql-10.2]# ./configure --prefix=/home/pgsql/postgresql

出现问题请一定要看后面问题解决方案!!!

在这里插入图片描述
[root@localhost postgresql-10.2]# make
[root@localhost postgresql-10.2]# make install
至此,已完成postgreql的安装。进入/home/pgsql/postgresql目录可以看到安装后的postgresql的文件。
[root@localhost postgresql]# ls
bin include lib share

(4)创建一个用户
创建pgsql用户并设置密码:
[root@localhost postgresql]# groupadd postgres
[root@localhost postgresql]# useradd postgres
[root@localhost postgresql]# passwd postgres
[root@localhost postgresql]# id postgres
uid=501(postgres) gid=501(postgres) 组=501(postgres)

两次输入密码并确认

(5)创建pgsql的数据库存储data主目录,并修改文件所有者

[root@localhost postgresql-10.2]# cd /home/pgsql/postgresql
[root@localhost postgresql]# mkdir data
[root@localhost postgresql]# chown postgres:postgres data
[root@localhost postgresql]# ls -al
total 20
drwxr-xr-x. 7 root root 68 Mar 30 14:38 .
drwxr-xr-x. 4 root root 77 Mar 30 15:52 …
drwxr-xr-x. 2 root root 4096 Mar 30 14:35 bin
drwx------. 19 postgres postgres 4096 Mar 30 15:34 data
drwxr-xr-x. 6 root root 4096 Mar 30 14:35 include
drwxr-xr-x. 4 root root 4096 Mar 30 14:35 lib
drwxr-xr-x. 6 root root 4096 Mar 30 14:35 share

(6)添加环境变量
[root@localhost postgresql]# vi /etc/profile

添加内容为:

export PGHOME=/home/pgsql/postgresql/
export PGDATA=/home/pgsql/postgresql/data
export PATH=$PGHOME/bin:$PATH:$HOME/bin

刷新一下
[root@localhost postgresql]# source /etc/profile

在这里插入图片描述
(7)换postgres账号并使用initdb初始化数据库
[root@localhost /]# su postgres
bash-4.2$ cd /home/pgsql/postgresql
bash-4.2$ initdb
The files belonging to this database system will be owned by user “postgres”.
This user must also own the server process.
The database cluster will be initialized with locale “en_US.UTF-8”.
The default database encoding has accordingly been set to “UTF8”.
The default text search configuration will be set to “english”.
Data page checksums are disabled.
fixing permissions on existing directory /home/pgsql/postgresql/data … ok
creating subdirectories … ok
selecting default max_connections … 100
selecting default shared_buffers … 128MB
selecting dynamic shared memory implementation … posix
creating configuration files … ok
running bootstrap script … ok
performing post-bootstrap initialization … ok
syncing data to disk … ok
WARNING: enabling “trust” authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
–auth-local and --auth-host, the next time you run initdb.
Success. You can now start the database server using:
pg_ctl -D /home/pgsql/postgresql/data -l logfile start

可以看到 /home/pgsql/postgresql/data已经有文件了。
bash-4.2$ cd /home/pgsql/postgresql/data
bash-4.2$ ls
base pg_commit_ts pg_hba.conf pg_logical pg_notify pg_serial pg_stat pg_subtrans pg_twophase pg_wal postgresql.auto.conf
global pg_dynshmem pg_ident.conf pg_multixact pg_replslot pg_snapshots pg_stat_tmp pg_tblspc PG_VERSION pg_xact postgresql.conf

(8)配置pgsql的服务
修改/pgsql/postgresql/data目录下的两个文件。

postgresql.conf : 配置PostgreSQL数据库服务器的相应的参数。

pg_hba.conf : 配置对数据库的访问权限。

bash-4.2$ vi postgresql.conf

listen_addresses = '*'                 # what IP address(es) to listen on;
                                        # comma-separated list of addresses;
                                        # defaults to 'localhost'; use '*' for all
                                        # (change requires restart)
port = 5432                            # (change requires restart)

其中,参数“listen_addresses”表示监听的IP地址,默认是在localhost处监听,也就是127.0.0.1的ip地址上监听,只接受来自本机localhost的连接请求,这会让远程的主机无法登陆这台数据库,如果想从其他的机器上登陆这台数据库,需要把监听地址改为实际网络的地址,一种简单的方法是,将行开头的#去掉,把这个地址改为*,表示在本地的所有地址上监听。

bash-4.2$ vi pg_hba.conf
找到最下面这一行 ,这样局域网的人才能访问。红色为新添加内容。

IPv4 local connections:

host all all 0.0.0.0/0 trust
host all all 127.0.0.1/32 trust

(9)设置开机自启动
bash-4.2$ cd /home/pgsql/postgresql-10.2/contrib/start-scripts
bash-4.2$ ls
freebsd linux macos osx

1)切换为root用户,修改linux文件属性,添加X属性
bash-4.2$ su root
Password:
[root@localhost start-scripts]# chmod a+x linux

2)复制linux文件到/etc/init.d目录下,更名为postgresql
[root@localhost start-scripts]# cp linux /etc/init.d/postgresql

3)修改/etc/init.d/postgresql文件的两个变量
[root@localhost start-scripts]# vi /etc/init.d/postgresql

prefix设置为postgresql的安装路径:/pgsql/postgresql

PGDATA设置为postgresql的数据目录路径:/pgsql/postgresql/data

4)设置postgresql服务开机自启动
[root@localhost start-scripts]# chkconfig --add /etc/init.d/postgresql
查看开机自启动服务设置成功。
[root@localhost start-scripts]# chkconfig
postgresql 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭

5)打开5432的防火墙

//开放5432端口
firewall-cmd --zone=public --add-port=5432/tcp --permanent
//跟新防火墙规则
firewall-cmd --reload
//防火墙列表
firewall-cmd --zone=public --list-ports
//防火墙状态
systemctl status firewalld
//启动防火墙
systemctl start firewalld
//关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service

(10)开启服务 service postgresql start
[root@localhost sysconfig]# cd /etc/init.d
[root@localhost init.d]# service postgresql start
Starting PostgreSQL: su: warning: cannot change directory to /home/postgres: No such file or directory ok

查看postgresql的状态
[root@localhost init.d]# ps -ef | grep postgres

在这里插入图片描述


三、问题解决方案

1、两个问题

①第一个问题 : configure:error:readline library not found (readline的软件问题)

解决方法1:下载一个合适的版本!(记住一定要是合适的版本!)
readline-devel下载地址
不知道什么才叫合适的点这里
在这里插入图片描述
解决方法2:加上–without-readline(不用readline功能)

./configure --prefix=/home/pgsql/postgresql --without-readline

②第二个问题 : configure: error: zlib library not found (zlib的软件问题)

解决方案: 下载一个合适的版本!(记住一定要是合适的版本!)
zlib-devel下载地址
不知道什么才叫合适的点这里

在这里插入图片描述


2、npm的安装过程

(1)下载一个npm文件
(2)运行一个npm文件:rpm -ivh rpm文件名 (有可能版本和系统不一致而导致用不了的)
–force (强行覆盖)
–nodeps (忽略依赖关系)
列如:rpm -ivh zlib-devel-1.2.7-18.el7.x86_64.rpm --force --nodeps

这篇博客写的比较详细了

后言

本次搞这个是最累人的一次了:我先讲一下比较有用的参考:
内容很详细了,不过是2018年的多少有些变动了,【主要参考】
这个也可以的,我也就是参照一部分的内容,【次要参考】
rpm写的很详细,只不过我要用的就前面一点点

因为之前没有搞过这种情况的服务器,什么都要先下下来然后再上传到服务器上。经过这一次我也涨见识了许多。
①了解了yum源可以换成163的源
②rpm文件原来还可以这么玩
③pgsql等一些配置服务的配置

我是按照流程一步一步来的,如果有什么纰漏大家也可以看我推荐的参考。
也欢迎大家在评论区讨论(~ ̄▽ ̄)~


http://www.niftyadmin.cn/n/3725558.html

相关文章

SqlBulkCopy加了事务真的会变快吗?

使用UseInternalTransaction 在构造函数SqlBulkCopy(String, SqlBulkCopyOptions)里面有SqlBulkCopyOptions的选项,有如下可选项。 我们看到可选项分别有保持Identity键,检查约束,是否锁表,保持null值,触发触发器&…

mysql数据表内容_MySQL表内容操作

bit[(M)]二进制位(101001),m表示二进制位的长度(1-64),默认m=1tinyint[(m)] [unsigned] [zerofill]小整数,数据类型用于保存一些范围的整数数值范围:有符号:-128 ~ 127.无符号:0 &am…

Windows 2000内核KPEB/KTEB详细结构(http://webcrazy.yeah.net/)

Windows 2000内核KPEB/KTEB详细结构 WebCrazy(http://webcrazy.yeah.net/) EPROCESS与ETHREAD结构在Windows NT/2000内核的地位是不言而喻的。他们结构中的成员包含了内核的方方面面,是两个比较大的结构。在Windows 2000 Server Build 2195 Free Kern…

springboot使用quartz解决调用不到spring注入service的问题

目录前言一、先图解一下本次文件内容二、放代码....三、测试代码0、创建定时任务1、定时任务自动停止2、定时任务中参数改变策略后言前言 在很多刚使用quartz的小伙伴的体验中,如果说没有碰到这个问题的话,那可能就是还没有往深入的走,也或许…

mysql数据库引擎mylsam_mysql数据库引擎 myisam/innodb

Mysql 数据库最常用的两种引擎是innordb和myisam。Innordb的功能要比myiasm强大很多,但是innordb的性能要比myisam差很多。如果只是做简单的查询,更新,删除,那么用myiasm是最好的选择。测试方法:连续提交10个query&…

raw.githubusercontent.com 访问不了

问题:github的raw文件访问不了 简单的说就是域名被DNS污染了 在hosts文件加上:199.232.4.133 raw.githubusercontent.com 这样就行了

mysql 双机rac_Mysql上的RAC:Percona XtraDB Cluster负载均衡集群安装部署手冊

Percona XtraDB Cluster安装部署手冊编写此文档,供PerconaXtraDB Cluster部署时使用。系统维护人员及实施人员。通过阅读该手冊,让读者明白PerconaXtraDB Cluster的安装、配置和维护情况,为兴许数据库运维工作提供指导。应用部署方案环境准备…

gradle的安装配置

目录前言1、下载gradle2、配置环境变量3、测试4、设置下载数据源前言 gradle是个相对于maven的版本控制器。 1、下载gradle 下载地址: https://gradle.org/releases/ 自己挑选合适的gradle 2、配置环境变量 根据自身习惯来就行 配置到path 3、测试 4、设置下…