大网数据广告活动
服务器运维问答

RHEL 7 / Centos 7 Copy package with all depedencies from server A (installed package) to server B (offline)

· 52CE 我爱测

I have two server,then these servers need to install postgresql10 , server A could install postgresql10 using yum install , but server B has a rule that is not allowed to connect the internet. So I trying to install with rpm file…

问题原文

原帖链接 · salamflamo · CC BY-SA 4.0

I have two server,then these servers need to install postgresql10 , server A could install postgresql10 using yum install , but server B has a rule that is not allowed to connect the internet. So I trying to install with rpm file in server B.

  1. I download postgresql10 with all depedencies using yumdownloader from my development server
  2. I upload all rpm files into server B
  3. I start to install with command rpm -ivh *.rpm inside server B
  4. After I try that so many depedenciess are not downloaded by yumdownloader

My idea is make a file that contain the package and all depedencies in single file, like tar.gz file then I install to other server as simple as extract file but I still research, then still stuck on it.

So if you has a story same as me, what best way did you have? Is there any script that could help my problem. Please share with me, Thank you very much

已采纳解答

原帖链接 · Chris Maes · CC BY-SA 4.0

There is a way, but it is quite tricky and might mess up your servers, so be very careful.

Nomenclature:

  • online : your system that is connected to the repositories
  • offline: your system that is not connected

Steps:

Compress your rpm database from the offline system and transfer it to the online system:

cd /var/lib/rpm/
tar -cvzf /tmp/rpmdb.tgz *
scp /tmp/rpmdb.tgz root@online:/tmp

on your online system; replace your rpm db with the one from the offline system:

cp -r /var/lib/rpm{,.bak} # back up your rpmdb from your online system. Make sure not to lose this!!
rm -rf /var/lib/rpm/*
cd /var/lib/rpm
tar -xvf /tmp/rpmdb.tgz # now your online system pretends to have the rpm database from the offline system. Don't start really installing / uninstalling rpms or you'll break everything

now simulate your update with download-only:

yum install --downloadonly # or
zypper up --download-only

Now you can fetch all the downloaded packages and they should suffice for updating your offline system

And now restore your online machine:

rm -rf /var/lib/rpm
cp -r /var/lib/rpm{.bak,}

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-07-12)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。