中堅プログラマーの備忘録

忘れっぽくなってきたので備忘録として・・・

raspberry PI 3B + にインストールしたCentOS7.6にEPELリポジトリを追加する

基本パッケージにはないが、使いたいパッケージがある場合
EPELリポジトリを追加すると便利です。

EPEL(Extra Packages for Enterprise Linux)とは、Red Hat Enterprise Linux(RHEL)向けの
「追加パッケージ」を提供するリポジトリです。

だそうです。

まずは現在有効になっているリポジトリの一覧を確認します。

[root@localhost ~]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.yz.yamagata-u.ac.jp
 * centos-kernel: ftp.yz.yamagata-u.ac.jp
 * extras: ftp.yz.yamagata-u.ac.jp
 * updates: ftp.yz.yamagata-u.ac.jp
repo id                                      repo name                                        status
base/7/armhfp                                CentOS-7 - Base                                  7,403
centos-kernel/7/armhfp                       CentOS Kernels for armhfp                           41
extras/7/armhfp                              CentOS-7 - Extras                                  320
updates/7/armhfp                             CentOS-7 - Updates                               1,333
repolist: 9,097


では早速【EPELリポジトリ】を追加してみます。

[root@localhost ~]# yum -y install epel-release
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.yz.yamagata-u.ac.jp
 * centos-kernel: ftp.yz.yamagata-u.ac.jp
 * extras: ftp.yz.yamagata-u.ac.jp
 * updates: ftp.yz.yamagata-u.ac.jp
No package epel-release available.
Error: Nothing to do

パッケージがないと怒られてしまいました。
なので直接とりにいきます。


http://ftp-srv2.kddilabs.jp/Linux/distributions/fedora/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm
ファイルは上記URLからダウンロードしました。
バージョンによってURLが異なりますので注意が必要です。

[root@localhost ~]# wget http://ftp-srv2.kddilabs.jp/Linux/distributions/fedora/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm
  • bash: wget: command not found

【wget】もありませんでした・・・
なのでこれもインストール!

[root@localhost ~]# yum install wget
[root@localhost ~]# wget http://ftp-srv2.kddilabs.jp/Linux/distributions/fedora/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm
Resolving ftp-srv2.kddilabs.jp (ftp-srv2.kddilabs.jp)... 202.255.47.226
Connecting to ftp-srv2.kddilabs.jp (ftp-srv2.kddilabs.jp)|202.255.47.226|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 15080 (15K) [application/octet-stream]
Saving to: ‘epel-release-7-11.noarch.rpm’

100%[==========================================================>] 15,080      --.-K/s   in 0s

2019-06-11 17:03:50 (45.6 MB/s) - ‘epel-release-7-11.noarch.rpm’ saved [15080/15080]

[root@localhost ~]# rpm -ivh epel-release-7-11.noarch.rpm
warning: epel-release-7-11.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:epel-release-7-11                ################################# [100%]

これでインストールが完了しました。
リポジトリの一覧を確認してみます。

[root@localhost ~]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
epel/armhfp/metalink                                                         |  50 kB  00:00:00
Could not parse metalink https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=armhfp error was
No repomd file
Loading mirror speeds from cached hostfile
Loading mirror speeds from cached hostfile
Loading mirror speeds from cached hostfile
Loading mirror speeds from cached hostfile
Loading mirror speeds from cached hostfile


 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= ...

     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 
        or
            subscription-manager repos --disable=

     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=.skip_if_unavailable=true

File /var/cache/yum/armhfp/7/epel/metalink.xml does not exist

また怒られてしまいました・・・
なんでだろうと考えていたら衝撃の事実が発覚しました。

試験環境が【Rraspberry PI 3B +】なので【armv7hl】だったのが原因でした。
これに気づかずに時間を浪費しまくってしまいました。
更に【EPEL】は【armftp用】のパッケージがないため、途方に暮れていたところ
下記の記述を見つけました。
【$basearch】を【x86_64】に固定してしまえばいいようです。
早速試してみます。

[root@localhost ~]# mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.org
[root@localhost ~]# sed -e 's/$basearch/x86_64/g' /etc/yum.repos.d/epel.repo.org > /etc/yum.repos.d/epel.repo

ここでリポジトリの一覧を確認してみます。

[root@localhost ~]# yum repolist
repo id                  repo name                                        status
base/7/armhfp            CentOS-7 - Base                                   7,403
centos-kernel/7/armhfp   CentOS Kernels for armhfp                            41
epel                     Extra Packages for Enterprise Linux 7 - x86_64   13,225
extras/7/armhfp          CentOS-7 - Extras                                   320
updates/7/armhfp         CentOS-7 - Updates                                1,333
repolist: 22,322

無事【EPEL】が追加されていることを確認出来ました。


ここまで苦労してやりたかったことは【raspberry PI 3B +】で【node.js】を使いたかった為です。
では【node.js】をインストール出来るか確認してみます。
まずはyumのアップデートを行います。

yum -y update

【nnode.js】をインストールします。

[root@localhost ~]# yum install -y nodejs
No package nodejs available.
Error: Nothing to do

パッケージがないよと怒られてしまいました・・・




もうめんどくさいので直接インストールします。

[root@localhost ~]# wget https://nodejs.org//dist/v9.9.0/node-v9.9.0-linux-armv7l.tar.xz 
[root@localhost ~]# tar -xvf node-v9.9.0-linux-armv7l.tar.xz 
[root@localhost ~]# cd node-v9.9.0-linux-armv7l
[root@localhost node-v4.0.0-linux-armv7l]# cp -R * /usr/local/

【node.js】のバージョンを確認します。

[root@localhost node-v9.9.0-linux-armv7l]# node -v
v9.9.0


何とかインストールできました。
最初からこうしておけばよかったんですね・・・