以centos7 下安装openvpn为例演示在不完全环境下,特殊包的安装

很多情况下,我们在一个yum源等不完全的环境(专有云)下需要安装某个组件时,会遇到很多很麻烦的问题。

如果只是去把相应的rpm包下载下来,去安装的话容易有一堆依赖没有,针对这种情况,可以用以下方法解决。以下用centos7 环境下安装openvpn为例。

目的安装主机A :省略默认yum找不到包

寻找一个和目的主机A相同系统的机器,能够正常链接到公网,例如安装主机B:我们这里使用centos7

使用命令 repoquery 可以查询某个包的全部依赖(如果这个都没有。。。直接去下载吧),并且可以全部下载下来:

可以使用repoquery,需要先安装yum-utils

yum install -y yum-utils

[roott]# repoquery --requires --resolve --recursive openvpn
device-mapper-7:1.02.146-4.el7.x86_64
nss-pem-0:1.0.3-4.el7.x86_64
shadow-utils-2:4.1.5.1-24.el7.x86_64
libpwquality-0:1.2.3-5.el7.i686
rpm-0:4.11.3-32.el7.x86_64
rpm-libs-0:4.11.3-32.el7.x86_64
openssl-libs-1:1.0.2k-12.el7.x86_64
iptables-0:1.4.21-24.1.el7_5.x86_64
binutils-0:2.27-27.base.el7.x86_64
libselinux-0:2.5-12.el7.x86_64
ca-certificates-0:2018.2.22-70.0.el7_5.noarch
libssh2-0:1.4.3-10.el7_2.1.x86_64
libpwquality-0:1.2.3-5.el7.x86_64
lzo-0:2.06-8.el7.x86_64
hardlink-1:1.0-19.el7.x86_64
shared-mime-info-0:1.8-4.el7.x86_64
cracklib-0:2.9.0-11.el7.x86_64
libmount-0:2.23.2-52.el7.i686
libblkid-0:2.23.2-52.el7.i686
gmp-1:6.0.0-15.el7.i686
elfutils-libs-0:0.170-4.el7.x86_64
libgcc-0:4.8.5-28.el7_5.1.x86_64
device-mapper-libs-7:1.02.146-4.el7.x86_64
elfutils-libelf-0:0.170-4.el7.x86_64
kmod-0:20-21.el7.x86_64
bzip2-libs-0:1.0.6-13.el7.x86_64
pcre-0:8.32-17.el7.i686
diffutils-0:3.3-4.el7.i686
ncurses-0:5.9-14.20130511.el7_4.x86_64
libacl-0:2.2.51-14.el7.x86_64
libnfnetlink-0:1.0.1-4.el7.x86_64
acl-0:2.2.51-14.el7.x86_64
libstdc++-0:4.8.5-28.el7_5.1.x86_64
python-0:2.7.5-68.el7.x86_64
libutempter-0:1.1.6-4.el7.x86_64
elfutils-default-yama-scope-0:0.170-4.el7.noarch
tzdata-0:2018e-3.el7.noarch
libffi-0:3.0.13-18.el7.x86_64
libgpg-error-0:1.12-3.el7.i686
libcap-ng-0:0.7.5-4.el7.i686
pkgconfig-1:0.27.1-4.el7.x86_64
basesystem-0:10.0-7.el7.centos.noarch
libxml2-0:2.9.1-6.el7_2.3.x86_64
cracklib-0:2.9.0-11.el7.i686
glibc-0:2.17-222.el7.i686
xz-libs-0:5.2.2-1.el7.x86_64
libffi-0:3.0.13-18.el7.i686
systemd-libs-0:219-57.el7.x86_64
nss-softokn-0:3.36.0-5.el7_5.x86_64
libgcc-0:4.8.5-28.el7_5.1.i686
libverto-0:0.2.5-4.el7.x86_64
nss-util-0:3.36.0-1.el7_5.i686
xz-0:5.2.2-1.el7.x86_64
nspr-0:4.17.0-1.el7.x86_64
findutils-1:4.5.11-5.el7.x86_64
libgcrypt-0:1.5.3-14.el7.x86_64
dbus-1:1.10.24-7.el7.x86_64
p11-kit-0:0.23.5-3.el7.i686
keyutils-libs-0:1.5.8-3.el7.i686
nss-0:3.34.0-4.el7.x86_64
keyutils-libs-0:1.5.8-3.el7.x86_64
python-libs-0:2.7.5-68.el7.x86_64
setup-0:2.8.71-9.el7.noarch
libcom_err-0:1.42.9-12.el7_5.x86_64
krb5-libs-0:1.15.1-19.el7.x86_64
gmp-1:6.0.0-15.el7.x86_64
libtasn1-0:4.10-1.el7.x86_64
diffutils-0:3.3-4.el7.x86_64
libidn-0:1.28-4.el7.x86_64
nss-0:3.36.0-5.el7_5.i686
libuser-0:0.60-9.el7.x86_64
lua-0:5.1.4-15.el7.x86_64
pcre-0:8.32-17.el7.x86_64
bash-0:4.2.46-30.el7.x86_64
util-linux-0:2.23.2-52.el7.x86_64
audit-libs-0:2.8.1-3.el7.x86_64
pkcs11-helper-0:1.11-3.el7.x86_64
glib2-0:2.54.2-2.el7.i686
libuuid-0:2.23.2-52.el7.x86_64
p11-kit-trust-0:0.23.5-3.el7.x86_64
expat-0:2.1.0-10.el7_3.i686
procps-ng-0:3.3.10-17.el7_5.2.x86_64
bzip2-libs-0:1.0.6-13.el7.i686
nspr-0:4.19.0-1.el7_5.i686
util-linux-0:2.23.2-52.el7.i686
libdb-0:5.3.21-24.el7.x86_64
systemd-0:219-57.el7.x86_64
ncurses-libs-0:5.9-14.20130511.el7_4.x86_64
libcap-0:2.22-9.el7.x86_64
libsemanage-0:2.5-11.el7.x86_64
libuuid-0:2.23.2-52.el7.i686
openldap-0:2.4.44-13.el7.x86_64
info-0:5.1-5.el7.x86_64
chkconfig-0:1.7.4-1.el7.x86_64
procps-ng-0:3.3.10-17.el7.i686
libnetfilter_conntrack-0:1.0.6-1.el7_3.x86_64
systemd-libs-0:219-57.el7.i686
ustr-0:1.0.4-16.el7.x86_64
pkgconfig-1:0.27.1-4.el7.i686
iproute-0:4.11.0-14.el7.x86_64
libmount-0:2.23.2-52.el7.x86_64
libgpg-error-0:1.12-3.el7.x86_64
device-mapper-libs-7:1.02.146-4.el7.i686
libacl-0:2.2.51-14.el7.i686
lz4-0:1.7.5-2.el7.x86_64
curl-0:7.29.0-46.el7.x86_64
libdb-utils-0:5.3.21-24.el7.x86_64
libcap-ng-0:0.7.5-4.el7.x86_64
cyrus-sasl-lib-0:2.1.26-23.el7.x86_64
gawk-0:4.0.2-4.el7_3.1.x86_64
centos-release-0:7-5.1804.el7.centos.x86_64
libgcrypt-0:1.5.3-14.el7.i686
audit-libs-0:2.8.1-3.el7.i686
nss-tools-0:3.34.0-4.el7.x86_64
libblkid-0:2.23.2-52.el7.x86_64
libselinux-0:2.5-12.el7.i686
libsepol-0:2.5-8.1.el7.i686
sqlite-0:3.7.17-8.el7.x86_64
pam-0:1.1.8-22.el7.x86_64
zlib-0:1.2.7-17.el7.x86_64
gzip-0:1.5-10.el7.x86_64
dbus-libs-1:1.10.24-7.el7.x86_64
pam-0:1.1.8-22.el7.i686
grep-0:2.20-3.el7.x86_64
kpartx-0:0.4.9-119.el7.x86_64
libmnl-0:1.0.3-7.el7.x86_64
cpio-0:2.11-27.el7.x86_64
glib2-0:2.54.2-2.el7.x86_64
readline-0:6.2-10.el7.x86_64
ncurses-base-0:5.9-14.20130511.el7_4.noarch
nss-util-0:3.36.0-1.el7_5.x86_64
expat-0:2.1.0-10.el7_3.x86_64
filesystem-0:3.2-25.el7.x86_64
zlib-0:1.2.7-17.el7.i686
libcurl-0:7.29.0-46.el7.i686
qrencode-libs-0:3.4.1-3.el7.x86_64
libcurl-0:7.29.0-46.el7.x86_64
p11-kit-0:0.23.5-3.el7.x86_64
nss-sysinit-0:3.34.0-4.el7.x86_64
xz-libs-0:5.2.2-1.el7.i686
popt-0:1.13-16.el7.x86_64
cracklib-dicts-0:2.9.0-11.el7.x86_64
libsepol-0:2.5-8.1.el7.x86_64
kmod-libs-0:20-21.el7.x86_64
glibc-common-0:2.17-222.el7.x86_64
nss-softokn-freebl-0:3.36.0-5.el7_5.x86_64
dracut-0:033-535.el7.x86_64
gdbm-0:1.10-8.el7.x86_64
tar-2:1.26-34.el7.x86_64
coreutils-0:8.22-21.el7.x86_64
cryptsetup-libs-0:1.7.4-4.el7.x86_64
systemd-sysv-0:219-57.el7.x86_64
glibc-0:2.17-222.el7.x86_64
sed-0:4.2.2-5.el7.x86_64
libattr-0:2.4.46-13.el7.x86_64

 

(以上解析了所有openvpn 需要依赖的包),我们使用以下命令将这些包全部下载下来:


repoquery --requires --resolve --recursive openvpn | xargs yumdownloader --destdir /root/mypackages/

这是第一部分所需要的数据包,同时我们在B机器上直接安装,可以看到默认环境中的依赖


[root]# yum install openvpn
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package openvpn.x86_64 0:2.4.6-1.el7 will be installed
--> Processing Dependency: libpkcs11-helper.so.1()(64bit) for package: openvpn-2.4.6-1.el7.x86_64
--> Running transaction check
---> Package pkcs11-helper.x86_64 0:1.11-3.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================================================================================================================================================================
 Package                                                      Arch                                                  Version                                                       Repository                                           Size
============================================================================================================================================================================================================================================
Installing:
 openvpn                                                      x86_64                                                2.4.6-1.el7                                                   epel                                                518 k
Installing for dependencies:
 pkcs11-helper                                                x86_64                                                1.11-3.el7                                                    epel                                                 56 k

Transaction Summary
============================================================================================================================================================================================================================================
Install  1 Package (+1 Dependent package)

Total download size: 574 k
Installed size: 1.3 M

因此需要把真正的openvpn 以及依赖的 pkcs11-helper 下载下来


yum install --downloadonly openvpn 
yum install --downloadonly pkcs11-helper

[root]# yum install --downloadonly openvpn
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package openvpn.x86_64 0:2.4.6-1.el7 will be installed
--> Processing Dependency: libpkcs11-helper.so.1()(64bit) for package: openvpn-2.4.6-1.el7.x86_64
--> Running transaction check
---> Package pkcs11-helper.x86_64 0:1.11-3.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================================================================================================================================================================
 Package                                                      Arch                                                  Version                                                       Repository                                           Size
============================================================================================================================================================================================================================================
Installing:
 openvpn                                                      x86_64                                                2.4.6-1.el7                                                   epel                                                518 k
Installing for dependencies:
 pkcs11-helper                                                x86_64                                                1.11-3.el7                                                    epel                                                 56 k

Transaction Summary
============================================================================================================================================================================================================================================
Install  1 Package (+1 Dependent package)

Total download size: 574 k
Installed size: 1.3 M
Background downloading packages, then exiting:
(1/2): openvpn-2.4.6-1.el7.x86_64.rpm                                                                                                                                                                                | 518 kB  00:00:00
(2/2): pkcs11-helper-1.11-3.el7.x86_64.rpm                                                                                                                                                                           |  56 kB  00:00:00
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                       2.1 MB/s | 574 kB  00:00:00
exiting because "Download Only" specified

这里注意记得使用repoquery 把pkcs11-helper 再解析下


[root]# repoquery --requires --resolve --recursive pkcs11-helper
pcre-0:8.32-17.el7.x86_64
bash-0:4.2.46-30.el7.x86_64
basesystem-0:10.0-7.el7.centos.noarch
libacl-0:2.2.51-14.el7.x86_64
glibc-0:2.17-222.el7.i686
zlib-0:1.2.7-17.el7.x86_64
libgcc-0:4.8.5-28.el7_5.1.i686
libverto-0:0.2.5-4.el7.x86_64
grep-0:2.20-3.el7.x86_64
openssl-libs-1:1.0.2k-12.el7.x86_64
libselinux-0:2.5-12.el7.x86_64
nspr-0:4.19.0-1.el7_5.i686
nspr-0:4.19.0-1.el7_5.x86_64
ca-certificates-0:2018.2.22-70.0.el7_5.noarch
ncurses-base-0:5.9-14.20130511.el7_4.noarch
nss-util-0:3.36.0-1.el7_5.x86_64
ncurses-libs-0:5.9-14.20130511.el7_4.x86_64
libcap-0:2.22-9.el7.x86_64
filesystem-0:3.2-25.el7.x86_64
nss-util-0:3.36.0-1.el7_5.i686
p11-kit-0:0.23.5-3.el7.i686
keyutils-libs-0:1.5.8-3.el7.i686
info-0:5.1-5.el7.x86_64
chkconfig-0:1.7.4-1.el7.x86_64
glibc-0:2.17-222.el7.x86_64
keyutils-libs-0:1.5.8-3.el7.x86_64
gmp-1:6.0.0-15.el7.i686
p11-kit-0:0.23.5-3.el7.x86_64
libgcc-0:4.8.5-28.el7_5.1.x86_64
tzdata-0:2018e-3.el7.noarch
setup-0:2.8.71-9.el7.noarch
popt-0:1.13-16.el7.x86_64
p11-kit-trust-0:0.23.5-3.el7.x86_64
libsepol-0:2.5-8.1.el7.x86_64
libcom_err-0:1.42.9-12.el7_5.x86_64
glibc-common-0:2.17-222.el7.x86_64
krb5-libs-0:1.15.1-19.el7.x86_64
nss-softokn-freebl-0:3.34.0-2.el7.x86_64
gmp-1:6.0.0-15.el7.x86_64
libtasn1-0:4.10-1.el7.x86_64
pcre-0:8.32-17.el7.i686
ncurses-0:5.9-14.20130511.el7_4.x86_64
coreutils-0:8.22-21.el7.x86_64
libffi-0:3.0.13-18.el7.i686
libstdc++-0:4.8.5-28.el7_5.1.x86_64
gawk-0:4.0.2-4.el7_3.1.x86_64
centos-release-0:7-5.1804.el7.centos.x86_64
libffi-0:3.0.13-18.el7.x86_64
sed-0:4.2.2-5.el7.x86_64
libattr-0:2.4.46-13.el7.x86_64

同时下载下来


repoquery --requires --resolve --recursive pkcs11-helper | xargs yumdownloader --destdir /root/mypackages/

那么这时候,我们已经拥有了四部分包,openvpn本身的rpm包,openvpn直接依赖的pkcs11-helper的包,openvpn原始依赖的一片包,pkcs11-helper原始依赖的一片包。
我们将这四部分包拷贝到A主机上,进行安装,
考虑到依赖
可以先尝试直接通过RPM安装openvpn,看他需要哪些依赖,一个一个补充(反正都下载下来了,不怕缺依赖了)


rpm -i openvpn-2.4.6-1.el7.x86_64.rpm

然后一环一环安装完成即可。

发表评论