プロジェクトに取り組んでいる場合、A 社のサーバーのセキュリティ管理が厳しく、すべてのサーバー環境にインターネット ネットワークが存在しない場合があり、プロジェクト サーバーからのアップロードまたはダウンロードの操作が要塞マシンを介して行われるため、審査を申請する必要があります。権限を解放する前にデプロイされることが多いため、プロジェクト中は非常に不便であり、定期的な脆弱性スキャンのためにパッチ パッケージを更新する必要がある場合もあります。そのため、インターネットがない場合にソフトウェア パッケージをインストールするには 3 つの一般的な方法があります。ネットワーク環境。

  • システム DVD ISO イメージを指定したサーバーにアップロードしてマウントし、ローカルの yum ソースを構成します。
  • プロジェクト システムをローカルの同じ環境に展開し、ソフトウェアまたはライブラリをコンパイルしてインストールし、それをパッケージ化してプロジェクト サーバーにアップロードします。
  • 最初の方法では、Nginx を使用して世代を逆にし、イントラネット内の他の yum ソース構成をイントラネット URL に変更します。これにより、他のイントラネット サーバーはインターネット ネットワークなしでソフトウェアを迅速にインストールできます。

したがって、この操作は、最初の方法に従ってローカルのオフライン yum ソースを構成することです。

1、ISO イメージのストレージとマウント ディレクトリを作成するOB

Terminal window
mkdir -pv /mnt/{iso,cdrom}

isoディレクトリは、システム ISO イメージが保存されるディレクトリです cdromディレクトリはマウントディレクトリです

2、ISO イメージをマウントする

Terminal window
mount -o loop /mnt/iso/CentOS-7-x86_64-DVD-2009.iso /mnt/cdrom
df -Th # マウントが成功したかどうかを確認する

ls -l CDROM マウント ディレクトリ情報を表示します

Terminal window
-rw-r--r--. 3 root root 14 Oct 30 2020 CentOS_BuildTag
drwxr-xr-x. 3 root root 2048 Oct 27 2020 EFI
-rw-rw-r--. 21 root root 227 Aug 30 2017 EULA
-rw-rw-r--. 21 root root 18009 Dec 10 2015 GPL
drwxr-xr-x. 3 root root 2048 Oct 27 2020 images
drwxr-xr-x. 2 root root 2048 Nov 3 2020 isolinux
drwxr-xr-x. 2 root root 2048 Oct 27 2020 LiveOS
drwxr-xr-x. 2 root root 673792 Nov 4 2020 Packages
drwxr-xr-x. 2 root root 4096 Nov 4 2020 repodata
-rw-rw-r--. 21 root root 1690 Dec 10 2015 RPM-GPG-KEY-CentOS-7
-rw-rw-r--. 21 root root 1690 Dec 10 2015 RPM-GPG-KEY-CentOS-Testing-7
-r--r--r--. 1 root root 2883 Nov 4 2020 TRANS.TBL

3、ローカルの Yum ソースを構成する ローカルリポジトリファイルを作成して設定する

Terminal window
mkdir -pv /opt/repo_bak
mv /etc/yum.repos.d/*.repo /opt/repo_bak/
touch /etc/yum.repos.d/local.repo

次の設定をlocal.repoファイルに追加します

Terminal window
[local]
name=local
baseurl=file:///mnt/cdrom # /mnt/cdrom は ISO イメージをマウントするディレクトリです
gpgcheck=0
enabled=1
gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-CentOS-7

⚠️ 注意 すべてはオフラインの Yum ソースを使用します。システムに付属の Yum ソース ファイル (/etc/yum.repos.d/ ディレクトリ 内) を最初にバックアップしてから削除する必要があります。そうしないと、yum makecache 操作が失敗します。と以下の情報が出力されます。

Terminal window
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org"
One of the configured repositories failed (Unknown),
and yum doesn't have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work "fix" this:
1. Contact the upstream for the repository and get them to fix the problem.
2. Reconfigure the baseurl/etc. for the repository, to point to a working
upstream. This is most often useful if you are using a newer
distribution release than is supported by the repository (and the
packages for the previous distribution release still work).
3. Run the command with the repository temporarily disabled
yum --disablerepo=<repoid> ...
4. Disable the repository permanently, so yum won't use it by default. Yum
will then just ignore the repository until you permanently enable it
again or use --enablerepo for temporary usage:
yum-config-manager --disable <repoid>
or
subscription-manager repos --disable=<repoid>
5. Configure the failing repository to be skipped, if it is unavailable.
Note that yum will try to contact the repo. when it runs most commands,
so will have to try and fail each time (and thus. yum will be be much
slower). If it is a very temporary problem though, this is often a nice
compromise:
yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true
Cannot find a valid baseurl for repo: base/7/x86_64

4、ローカルの Yum ソースを更新して確認する

Terminal window
[root@localhost ~]# yum clean all # ローカルのyumキャッシュをすべてクリアする
Loaded plugins: fastestmirror, langpacks
Cleaning repos: local
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
[root@localhost ~]# yum makecache # ローカルのyumキャッシュを再生成する
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
local | 3.6 kB 00:00:00
(1/4): local/group_gz | 153 kB 00:00:00
(2/4): local/filelists_db | 3.3 MB 00:00:00
(3/4): local/primary_db | 3.3 MB 00:00:00
(4/4): local/other_db | 1.3 MB 00:00:00
Metadata Cache Created
[root@localhost ~]# yum search openssl # ローカルのyumソースを確認する
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
================================================= N/S matched: openssl =================================================
apr-util-openssl.x86_64 : APR utility library OpenSSL crytpo support
openssl-devel.x86_64 : Files for development of applications which will use OpenSSL
perl-Crypt-OpenSSL-Bignum.x86_64 : Perl interface to OpenSSL for Bignum
perl-Crypt-OpenSSL-RSA.x86_64 : Perl interface to OpenSSL for RSA
perl-Crypt-OpenSSL-Random.x86_64 : Perl interface to OpenSSL for Random
pyOpenSSL.x86_64 : Python wrapper module around the OpenSSL library
xmlsec1-openssl.x86_64 : OpenSSL crypto plugin for XML Security Library
m2crypto.x86_64 : Support for using OpenSSL in python scripts
nss_compat_ossl.x86_64 : Source-level compatibility library for OpenSSL to NSS porting
openssl.x86_64 : Utilities from the general purpose cryptography library with TLS implementation
openssl-libs.x86_64 : A general purpose cryptography library with TLS implementation
openssl098e.x86_64 : A compatibility version of a general cryptography and TLS library
perl-Crypt-SSLeay.x86_64 : Crypt::SSLeay - OpenSSL glue that provides LWP https support
perl-Net-SSLeay.x86_64 : Perl extension for using OpenSSL
qca-ossl.x86_64 : OpenSSL plugin for the Qt Cryptographic Architecture v2
Name and summary matches only, use "search all" for everything.
[root@localhost ~]#