LoginSignup
5
0

More than 3 years have passed since last update.

Oracle Cloud(OCI)のリージョン内yumリポジトリを使ってみた

Last updated at Posted at 2019-01-27

リージョン内yumリポジトリって?

  • Oracle Cloud Infrastructure(OCI)では、Oracle Linuxのyumリポジトリのミラーがリージョン内に用意されているようです。
  • これを使うと速くていいね、とのこと
    ※Service Gatewayを介してプライベート接続できるとかそういう話では(まだ)ない
    →現在は対応済み!(private subnetからinternetに出ることなくアクセス可能)
  • ココに書いてありました

使えるようにする

既存のリポジトリを退避

[opc@testinstance ~]$ cd /etc/yum.repos.d
[opc@testinstance yum.repos.d]$ ll
total 36
-rw-r--r--. 1 root root 17684 Jan 11 02:55 public-yum-ol7.repo
-rw-r--r--. 1 root root 15423 Dec 17 19:41 public-yum-ol7.repo.orig

# 名前変更
[opc@testinstance yum.repos.d]$ sudo mv public-yum-ol7.repo public-yum-ol7.repo.bak

[opc@testinstance yum.repos.d]$ ll
total 36
-rw-r--r--. 1 root root 17684 Jan 11 02:55 public-yum-ol7.repo.bak # <--★変わってる
-rw-r--r--. 1 root root 15423 Dec 17 19:41 public-yum-ol7.repo.orig

インスタンスのあるリージョンのリポジトリミラーを取ってくる

# 自インスタンスのいるリージョンを調べてREGION変数にいれる
[opc@testinstance yum.repos.d]$ export REGION=`curl http://169.254.169.254/opc/v1/instance/ -s | jq -r '.region'| cut -d '-' -f 2`
[opc@testinstance yum.repos.d]$ echo $REGION
phx

# リージョンのリポジトリを取ってくる
[opc@testinstance yum.repos.d]$ sudo -E wget http://yum-$REGION.oracle.com/yum-$REGION-ol7.repo
--2019-01-27 10:40:57--  http://yum-phx.oracle.com/yum-phx-ol7.repo
Resolving yum-phx.oracle.com (yum-phx.oracle.com)... 129.146.100.180
Connecting to yum-phx.oracle.com (yum-phx.oracle.com)|129.146.100.180|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 17396 (17K) [application/octet-stream]
Saving to: ‘yum-phx-ol7.repo’

100%[======================================>] 17,396      --.-K/s   in 0s

2019-01-27 10:40:57 (113 MB/s) - ‘yum-phx-ol7.repo’ saved [17396/17396]

# 追加されていることを確認
[opc@testinstance yum.repos.d]$ ll
total 56
-rw-r--r--. 1 root root 17684 Jan 11 02:55 public-yum-ol7.repo.bak
-rw-r--r--. 1 root root 15423 Dec 17 19:41 public-yum-ol7.repo.orig
-rw-r--r--. 1 root root 17396 Dec 14 22:26 yum-phx-ol7.repo # <--★取ってこれた

※最初のコマンドでなぜリージョン名が取ってこれるのかは以下の記事で説明しました
「Oracle Cloud(OCI)の自インスタンスの情報を取得する方法」
※sudoの"-E"オプションは、環境変数を引き継がせるためのもの($REGIONを渡すため)

ol7_oci_includedリポジトリの有効化

# 取ってきたばかりの状態でどうなっているか確認
[opc@testinstance yum.repos.d]$ sed -n 491,496p yum-phx-ol7.repo
[ol7_oci_included]
name=Oracle Software for OCI users on Oracle Linux $releasever ($basearch)
baseurl=http://yum-phx.oracle.com/repo/OracleLinux/OL7/oci/included/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=0 # <--★デフォルトでは無効化されている

# リポジトリを指定して有効化
[opc@testinstance yum.repos.d]$ sudo yum-config-manager --enable ol7_oci_included
Loaded plugins: langpacks
============================ repo: ol7_oci_included ============================
[ol7_oci_included]
async = True
bandwidth = 0
base_persistdir = /var/lib/yum/repos/x86_64/7Server
baseurl = http://yum-phx.oracle.com/repo/OracleLinux/OL7/oci/included/x86_64/
cache = 0
cachedir = /var/cache/yum/x86_64/7Server/ol7_oci_included
check_config_file_age = True
compare_providers_priority = 80
cost = 1000
deltarpm_metadata_percentage = 100
deltarpm_percentage =
enabled = 1
enablegroups = True
exclude =
failovermethod = priority
ftp_disable_epsv = False
gpgcadir = /var/lib/yum/repos/x86_64/7Server/ol7_oci_included/gpgcadir
gpgcakey =
gpgcheck = True
gpgdir = /var/lib/yum/repos/x86_64/7Server/ol7_oci_included/gpgdir
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
hdrdir = /var/cache/yum/x86_64/7Server/ol7_oci_included/headers
http_caching = all
includepkgs =
ip_resolve =
keepalive = True
keepcache = False
mddownloadpolicy = sqlite
mdpolicy = group:small
mediaid =
metadata_expire = 21600
metadata_expire_filter = read-only:present
metalink =
minrate = 0
mirrorlist =
mirrorlist_expire = 86400
name = Oracle Software for OCI users on Oracle Linux 7Server (x86_64)
old_base_cache_dir =
password =
persistdir = /var/lib/yum/repos/x86_64/7Server/ol7_oci_included
pkgdir = /var/cache/yum/x86_64/7Server/ol7_oci_included/packages
proxy = False
proxy_dict =
proxy_password =
proxy_username =
repo_gpgcheck = False
retries = 10
skip_if_unavailable = False
ssl_check_cert_permissions = True
sslcacert =
sslclientcert =
sslclientkey =
sslverify = True
throttle = 0
timeout = 30.0
ui_id = ol7_oci_included/x86_64
ui_repoid_vars = releasever,
   basearch
username =

# 確認
[opc@testinstance yum.repos.d]$ sed -n 491,496p yum-phx-ol7.repo
[ol7_oci_included]
name=Oracle Software for OCI users on Oracle Linux $releasever ($basearch)
baseurl=http://yum-phx.oracle.com/repo/OracleLinux/OL7/oci/included/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1 <--★有効化された

「使ってみた」の部分は次のエントリで。
> Oracle Cloud(OCI)のIaaSからDbaaSへSQLPlusで接続してみた

参考

以上

5
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
0