为内网 CentOS7 搭建 yum repo 源

说明: 为内网CentOS7 搭建 yum repo 源

环境: CentOS 7.9

示例:postgresql_repo

在外网机 download repo

1
2
3
4
5
6
7
8
root@chunli:~# mkdir repo
root@chunli:~# cd repo
root@chunli:~/repo# wget -r -c -np https://download.postgresql.org/pub/repos/yum/14/redhat/rhel-7.9-x86_64/
root@chunli:~/repo# wget -r -c -np https://download.postgresql.org/pub/repos/yum/common/redhat/rhel-7.9-x86_64/
root@chunli:~# du -sh repo/download.postgresql.org/pub/repos/yum/*
143M repo/download.postgresql.org/pub/repos/yum/14
886M repo/download.postgresql.org/pub/repos/yum/common
root@chunli:~#

把文件 传到内网:

目录层次如下:

1
2
3
4
5
[root@chunli ~]# ll /media/postgresql_repo/
total 0
drwxr-xr-x. 3 root root 20 Feb 8 17:35 14
drwxr-xr-x. 3 root root 20 Feb 8 17:25 common
[root@chunli ~]#

创建 repo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@chunli ~]# vim /etc/yum.repos.d/CentOS-PostgreSQL.repo
[c7-postgresql-common]
name=CentOS-$releasever - Media
baseurl=file:///media/postgresql_repo/common/redhat/rhel-7.9-x86_64
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

[c7-postgresql-14]
name=CentOS-$releasever - Media
baseurl=file:///media/postgresql_repo/14/redhat/rhel-7.9-x86_64
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[root@chunli ~]#

应用

安装 postgresql14-server

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[root@chunli ~]# yum list
[root@chunli ~]# yum install postgresql14-server
[root@chunli ~]# /usr/pgsql-14/bin/postgresql-14-setup initdb
Initializing database ... OK

[root@chunli ~]# systemctl enable postgresql-14
Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql-14.service to /usr/lib/systemd/system/postgresql-14.service.
[root@chunli ~]# systemctl start postgresql-14

[root@chunli ~]# netstat -tnlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1152/sshd
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 13084/postmaster
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1362/master
tcp6 0 0 192.168.107.107:9200 :::* LISTEN 1738/java
tcp6 0 0 192.168.107.107:9300 :::* LISTEN 1738/java
tcp6 0 0 :::22 :::* LISTEN 1152/sshd
tcp6 0 0 ::1:5432 :::* LISTEN 13084/postmaster
tcp6 0 0 ::1:25 :::* LISTEN 1362/master
[root@chunli ~]#