问题描述
- 项目环境无法访问互联网;
- 要在无发访问互联网的环境下安装salt;
解决思路
- 模拟一个项目环境A,A可以访问外网;
- 在A中下载离线安装salt所需的RPM包,将这些包传入项目环境,从而在项目环境中离线安装salt-master;
试验环境
- Docker Image -> centos:6.8
- Python -> 2.6/2.7
第1部分 - 创建模拟环境
- 由于项目环境是centos6.8,所以模拟环境也是centos6.8;
- 模拟环境用Docker跑一个官方centos:6.8镜像实现,快速轻量;
PS C:\Users\LiXinlei> docker pull centos:6.8
6.8: Pulling from library/centos
Digest: sha256:147bb07a3a271ae84d53fbf7f619b00929c332845e389b7423f15d618236acd1
Status: Image is up to date for centos:6.8
PS C:\Users\LiXinlei> docker run -itd -v d:/volume/orange:/data 6704d778b3ba
PS C:\Users\LiXinlei> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
197e2218632c 6704d778b3ba "/bin/bash" 23 minutes ago Up 23 minutes optimistic_nobel
PS C:\Users\LiXinlei> docker exec -it 197e2218632c /bin/bash
[root@197e2218632c /]#
第2部分 - 下载rpm包
2.1 安装SaltStack的Repository
- 该Repository由Salt官方提供;
- 相较于和CentOS版本号对应的epel仓库,官方仓库能提供最新的Salt版本;
[root@197e2218632c data]# yum install https://repo.saltstack.com/yum/redhat/salt-repo-latest-2.el6.noarch.rpm
Loaded plugins: fastestmirror, ovl
Setting up Install Process
salt-repo-latest-2.el6.noarch.rpm | 4.2 kB 00:00
Examining /var/tmp/yum-root-85W5__/salt-repo-latest-2.el6.noarch.rpm: salt-repo-latest-2.el6.noarch
Marking /var/tmp/yum-root-85W5__/salt-repo-latest-2.el6.noarch.rpm to be installed
Loading mirror speeds from cached hostfile
* base: mirrors.huaweicloud.com
* extras: mirrors.huaweicloud.com
* updates: mirrors.huaweicloud.com
Resolving Dependencies
--> Running transaction check
---> Package salt-repo.noarch 0:latest-2.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===================================================================================================================================================================================================================
Package Arch Version Repository Size
===================================================================================================================================================================================================================
Installing:
salt-repo noarch latest-2.el6 /salt-repo-latest-2.el6.noarch 1.9 k
Transaction Summary
===================================================================================================================================================================================================================
Install 1 Package(s)
Total size: 1.9 k
Installed size: 1.9 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : salt-repo-latest-2.el6.noarch 1/1
Verifying : salt-repo-latest-2.el6.noarch 1/1
Installed:
salt-repo.noarch 0:latest-2.el6
Complete!
2.2 刷新yum缓存
[root@197e2218632c data]# yum clean expire-cache
Loaded plugins: fastestmirror, ovl
Cleaning repos: base extras salt-latest updates
6 metadata files removed
2.3 下载rpm包
- 把rpm包下载到volume中,使得宿主机(Windows10笔记本)可以直接访问,从而方便下载的rpm包从宿主机到项目环境的传输;
- 下载功能由yum提供,yum可以做到只下载不安装;
- 由yum提供的下载,可以做到所需的rpm包一个不落;
[root@197e2218632c data]# mkdir /data/salt-master
[root@197e2218632c data]# cd salt-master/
[root@197e2218632c salt-master]# yum -y install --downloadonly --downloaddir=/data/salt-master/ salt-master
Loaded plugins: fastestmirror, ovl
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: mirrors.huaweicloud.com
* extras: mirrors.huaweicloud.com
* updates: mirrors.huaweicloud.com
base | 3.7 kB 00:00
extras | 3.4 kB 00:00
salt-latest | 2.9 kB 00:00
salt-latest/primary_db | 57 kB 00:01
updates | 3.4 kB 00:00
Resolving Dependencies
--> Running transaction check
---> Package salt-master.noarch 0:2018.3.1-1.el6 will be installed
--> Processing Dependency: salt = 2018.3.1-1.el6 for package: salt-master-2018.3.1-1.el6.noarch
--> Processing Dependency: /usr/bin/python2.7 for package: salt-master-2018.3.1-1.el6.noarch
--> Running transaction check
---> Package python27.x86_64 0:2.7.13-3.ius.el6 will be installed
--> Processing Dependency: python27-libs(x86-64) = 2.7.13-3.ius.el6 for package: python27-2.7.13-3.ius.el6.x86_64
--> Processing Dependency: libpython2.7.so.1.0()(64bit) for package: python27-2.7.13-3.ius.el6.x86_64
---> Package salt.noarch 0:2018.3.1-1.el6 will be installed
--> Processing Dependency: python27-tornado < 5.0 for package: salt-2018.3.1-1.el6.noarch
--> Processing Dependency: python27-tornado >= 4.2.1 for package: salt-2018.3.1-1.el6.noarch
--> Processing Dependency: python27-requests >= 1.0.0 for package: salt-2018.3.1-1.el6.noarch
--> Processing Dependency: python27-msgpack >= 0.4 for package: salt-2018.3.1-1.el6.noarch
--> Processing Dependency: python27-futures >= 2.0 for package: salt-2018.3.1-1.el6.noarch
--> Processing Dependency: python27-crypto >= 2.6.1 for package: salt-2018.3.1-1.el6.noarch
--> Processing Dependency: yum-utils for package: salt-2018.3.1-1.el6.noarch
--> Processing Dependency: python27-zmq for package: salt-2018.3.1-1.el6.noarch
--> Processing Dependency: python27-six for package: salt-2018.3.1-1.el6.noarch
--> Processing Dependency: python27-psutil for package: salt-2018.3.1-1.el6.noarch
--> Processing Dependency: python27-markupsafe for package: salt-2018.3.1-1.el6.noarch
--> Processing Dependency: python27-jinja2 for package: salt-2018.3.1-1.el6.noarch
--> Processing Dependency: pciutils for package: salt-2018.3.1-1.el6.noarch
--> Processing Dependency: PyYAML27 for package: salt-2018.3.1-1.el6.noarch
--> Running transaction check
---> Package PyYAML27.x86_64 0:3.11-3.el6 will be installed
--> Processing Dependency: libyaml-0.so.2()(64bit) for package: PyYAML27-3.11-3.el6.x86_64
---> Package pciutils.x86_64 0:3.1.10-4.el6 will be installed
--> Processing Dependency: pciutils-libs = 3.1.10-4.el6 for package: pciutils-3.1.10-4.el6.x86_64
--> Processing Dependency: libpci.so.3(LIBPCI_3.1)(64bit) for package: pciutils-3.1.10-4.el6.x86_64
--> Processing Dependency: libpci.so.3(LIBPCI_3.0)(64bit) for package: pciutils-3.1.10-4.el6.x86_64
--> Processing Dependency: libpci.so.3()(64bit) for package: pciutils-3.1.10-4.el6.x86_64
---> Package python27-crypto.x86_64 0:2.6.1-5.el6 will be installed
---> Package python27-futures.noarch 0:3.0.3-3.el6 will be installed
---> Package python27-jinja2.noarch 0:2.8.1-3.el6 will be installed
--> Processing Dependency: python27-babel >= 0.8 for package: python27-jinja2-2.8.1-3.el6.noarch
---> Package python27-libs.x86_64 0:2.7.13-3.ius.el6 will be installed
---> Package python27-markupsafe.x86_64 0:0.11-12.el6 will be installed
---> Package python27-msgpack.x86_64 0:0.4.6-3.el6 will be installed
---> Package python27-psutil.x86_64 0:5.4.2-1.ius.el6 will be installed
---> Package python27-requests.noarch 0:2.7.0-9.el6 will be installed
--> Processing Dependency: python27-urllib3 >= 1.10.4 for package: python27-requests-2.7.0-9.el6.noarch
--> Processing Dependency: python27-chardet >= 2.2.1-1 for package: python27-requests-2.7.0-9.el6.noarch
---> Package python27-six.noarch 0:1.9.0-4.el6 will be installed
---> Package python27-tornado.x86_64 0:4.2.1-4.el6 will be installed
--> Processing Dependency: python27-pycurl for package: python27-tornado-4.2.1-4.el6.x86_64
---> Package python27-zmq.x86_64 0:14.5.0-4.el6 will be installed
--> Processing Dependency: libzmq.so.4()(64bit) for package: python27-zmq-14.5.0-4.el6.x86_64
---> Package yum-utils.noarch 0:1.1.30-40.el6 will be installed
--> Processing Dependency: yum >= 3.2.29-77 for package: yum-utils-1.1.30-40.el6.noarch
--> Processing Dependency: libxml2-python for package: yum-utils-1.1.30-40.el6.noarch
--> Running transaction check
---> Package libxml2-python.x86_64 0:2.7.6-21.el6_8.1 will be installed
--> Processing Dependency: libxml2 = 2.7.6-21.el6_8.1 for package: libxml2-python-2.7.6-21.el6_8.1.x86_64
---> Package libyaml.x86_64 0:0.1.3-4.el6_6 will be installed
---> Package pciutils-libs.x86_64 0:3.1.10-4.el6 will be installed
---> Package python27-babel.noarch 0:0.9.4-5.3.el6 will be installed
---> Package python27-chardet.noarch 0:2.2.1-4.el6 will be installed
---> Package python27-pycurl.x86_64 0:7.19.0-11.el6 will be installed
---> Package python27-urllib3.noarch 0:1.10.4-8.el6 will be installed
---> Package yum.noarch 0:3.2.29-73.el6.centos will be updated
---> Package yum.noarch 0:3.2.29-81.el6.centos will be an update
---> Package zeromq.x86_64 0:4.0.5-4.el6 will be installed
--> Running transaction check
---> Package libxml2.x86_64 0:2.7.6-21.el6 will be updated
---> Package libxml2.x86_64 0:2.7.6-21.el6_8.1 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
===================================================================================================================================================================================================================
Package Arch Version Repository Size
===================================================================================================================================================================================================================
Installing:
salt-master noarch 2018.3.1-1.el6 salt-latest 2.3 M
Installing for dependencies:
PyYAML27 x86_64 3.11-3.el6 salt-latest 152 k
libxml2-python x86_64 2.7.6-21.el6_8.1 base 325 k
libyaml x86_64 0.1.3-4.el6_6 base 52 k
pciutils x86_64 3.1.10-4.el6 base 85 k
pciutils-libs x86_64 3.1.10-4.el6 base 34 k
python27 x86_64 2.7.13-3.ius.el6 salt-latest 82 k
python27-babel noarch 0.9.4-5.3.el6 salt-latest 1.4 M
python27-chardet noarch 2.2.1-4.el6 salt-latest 230 k
python27-crypto x86_64 2.6.1-5.el6 salt-latest 501 k
python27-futures noarch 3.0.3-3.el6 salt-latest 27 k
python27-jinja2 noarch 2.8.1-3.el6 salt-latest 284 k
python27-libs x86_64 2.7.13-3.ius.el6 salt-latest 5.6 M
python27-markupsafe x86_64 0.11-12.el6 salt-latest 24 k
python27-msgpack x86_64 0.4.6-3.el6 salt-latest 69 k
python27-psutil x86_64 5.4.2-1.ius.el6 salt-latest 383 k
python27-pycurl x86_64 7.19.0-11.el6 salt-latest 76 k
python27-requests noarch 2.7.0-9.el6 salt-latest 98 k
python27-six noarch 1.9.0-4.el6 salt-latest 28 k
python27-tornado x86_64 4.2.1-4.el6 salt-latest 660 k
python27-urllib3 noarch 1.10.4-8.el6 salt-latest 107 k
python27-zmq x86_64 14.5.0-4.el6 salt-latest 478 k
salt noarch 2018.3.1-1.el6 salt-latest 9.1 M
yum-utils noarch 1.1.30-40.el6 base 113 k
zeromq x86_64 4.0.5-4.el6 salt-latest 568 k
Updating for dependencies:
libxml2 x86_64 2.7.6-21.el6_8.1 base 805 k
yum noarch 3.2.29-81.el6.centos base 1.0 M
Transaction Summary
===================================================================================================================================================================================================================
Install 25 Package(s)
Upgrade 2 Package(s)
Total download size: 24 M
Downloading Packages:
(1/27): PyYAML27-3.11-3.el6.x86_64.rpm | 152 kB 00:04
(2/27): libxml2-2.7.6-21.el6_8.1.x86_64.rpm | 805 kB 00:01
(3/27): libxml2-python-2.7.6-21.el6_8.1.x86_64.rpm | 325 kB 00:01
(4/27): libyaml-0.1.3-4.el6_6.x86_64.rpm | 52 kB 00:00
(5/27): pciutils-3.1.10-4.el6.x86_64.rpm | 85 kB 00:00
(6/27): pciutils-libs-3.1.10-4.el6.x86_64.rpm | 34 kB 00:00
(7/27): python27-2.7.13-3.ius.el6.x86_64.rpm | 82 kB 00:02
(8/27): python27-babel-0.9.4-5.3.el6.noarch.rpm | 1.4 MB 00:17
(9/27): python27-chardet-2.2.1-4.el6.noarch.rpm | 230 kB 00:02
(10/27): python27-crypto-2.6.1-5.el6.x86_64.rpm | 501 kB 00:10
(11/27): python27-futures-3.0.3-3.el6.noarch.rpm | 27 kB 00:00
(12/27): python27-jinja2-2.8.1-3.el6.noarch.rpm | 284 kB 00:03
(13/27): python27-libs-2.7.13-3.ius.el6.x86_64.rpm | 5.6 MB 00:27
(14/27): python27-markupsafe-0.11-12.el6.x86_64.rpm | 24 kB 00:00
(15/27): python27-msgpack-0.4.6-3.el6.x86_64.rpm | 69 kB 00:00
(16/27): python27-psutil-5.4.2-1.ius.el6.x86_64.rpm | 383 kB 00:01
(17/27): python27-pycurl-7.19.0-11.el6.x86_64.rpm | 76 kB 00:00
(18/27): python27-requests-2.7.0-9.el6.noarch.rpm | 98 kB 00:00
(19/27): python27-six-1.9.0-4.el6.noarch.rpm | 28 kB 00:00
(20/27): python27-tornado-4.2.1-4.el6.x86_64.rpm | 660 kB 00:01
(21/27): python27-urllib3-1.10.4-8.el6.noarch.rpm | 107 kB 00:00
(22/27): python27-zmq-14.5.0-4.el6.x86_64.rpm | 478 kB 00:02
(23/27): salt-2018.3.1-1.el6.noarch.rpm | 9.1 MB 00:49
(24/27): salt-master-2018.3.1-1.el6.noarch.rpm | 2.3 MB 00:08
(25/27): yum-3.2.29-81.el6.centos.noarch.rpm | 1.0 MB 00:01
(26/27): yum-utils-1.1.30-40.el6.noarch.rpm | 113 kB 00:00
(27/27): zeromq-4.0.5-4.el6.x86_64.rpm | 568 kB 00:03
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 156 kB/s | 24 MB 02:40
exiting because --downloadonly specified
[root@197e2218632c salt-master]# ll
total 25084
-rwxr-xr-x 1 root root 155976 Jun 15 17:54 PyYAML27-3.11-3.el6.x86_64.rpm
-rwxr-xr-x 1 root root 824428 Jun 23 2016 libxml2-2.7.6-21.el6_8.1.x86_64.rpm
-rwxr-xr-x 1 root root 332300 Jun 23 2016 libxml2-python-2.7.6-21.el6_8.1.x86_64.rpm
-rwxr-xr-x 1 root root 53232 Jan 28 2015 libyaml-0.1.3-4.el6_6.x86_64.rpm
-rwxr-xr-x 1 root root 87232 Aug 5 2014 pciutils-3.1.10-4.el6.x86_64.rpm
-rwxr-xr-x 1 root root 34736 Aug 5 2014 pciutils-libs-3.1.10-4.el6.x86_64.rpm
-rwxr-xr-x 1 root root 83548 Jun 15 17:54 python27-2.7.13-3.ius.el6.x86_64.rpm
-rwxr-xr-x 1 root root 1493924 Jun 15 17:54 python27-babel-0.9.4-5.3.el6.noarch.rpm
-rwxr-xr-x 1 root root 235140 Jun 15 17:54 python27-chardet-2.2.1-4.el6.noarch.rpm
-rwxr-xr-x 1 root root 513120 Jun 15 17:54 python27-crypto-2.6.1-5.el6.x86_64.rpm
-rwxr-xr-x 1 root root 27168 Jun 15 17:54 python27-futures-3.0.3-3.el6.noarch.rpm
-rwxr-xr-x 1 root root 291024 Jun 15 17:54 python27-jinja2-2.8.1-3.el6.noarch.rpm
-rwxr-xr-x 1 root root 5839868 Jun 15 17:54 python27-libs-2.7.13-3.ius.el6.x86_64.rpm
-rwxr-xr-x 1 root root 24560 Jun 15 17:54 python27-markupsafe-0.11-12.el6.x86_64.rpm
-rwxr-xr-x 1 root root 70224 Jun 15 17:54 python27-msgpack-0.4.6-3.el6.x86_64.rpm
-rwxr-xr-x 1 root root 391728 Jun 15 17:54 python27-psutil-5.4.2-1.ius.el6.x86_64.rpm
-rwxr-xr-x 1 root root 78212 Jun 15 17:54 python27-pycurl-7.19.0-11.el6.x86_64.rpm
-rwxr-xr-x 1 root root 100340 Jun 15 17:54 python27-requests-2.7.0-9.el6.noarch.rpm
-rwxr-xr-x 1 root root 28776 Jun 15 17:54 python27-six-1.9.0-4.el6.noarch.rpm
-rwxr-xr-x 1 root root 675764 Jun 15 17:54 python27-tornado-4.2.1-4.el6.x86_64.rpm
-rwxr-xr-x 1 root root 109196 Jun 15 17:54 python27-urllib3-1.10.4-8.el6.noarch.rpm
-rwxr-xr-x 1 root root 489436 Jun 15 17:54 python27-zmq-14.5.0-4.el6.x86_64.rpm
-rwxr-xr-x 1 root root 9584392 Jun 15 17:54 salt-2018.3.1-1.el6.noarch.rpm
-rwxr-xr-x 1 root root 2359628 Jun 15 17:54 salt-master-2018.3.1-1.el6.noarch.rpm
-rwxr-xr-x 1 root root 1042364 Mar 23 2017 yum-3.2.29-81.el6.centos.noarch.rpm
-rwxr-xr-x 1 root root 115416 Mar 23 2017 yum-utils-1.1.30-40.el6.noarch.rpm
-rwxr-xr-x 1 root root 581800 Jun 15 17:54 zeromq-4.0.5-4.el6.x86_64.rpm