[Oracle Cloud] Private Subnet内にあるOCI DBCSにOCI CLIをインストールしてみた

本記事の目的

プライベートサブネット内に配置されているOCI DBCS(DBaaS)に、OCI CLIをインストールした手順のメモ。

今回はNATゲートウェイを利用。

 

手順

  1. 所属するVCNにNATゲートウェイを作成(未作成の場合)
  2. DBCS用のサブネットのルートテーブルに、NAT用のルールを追加
    Target Type:NAT Gateway
    DESTINATION CIDR BLOCK:0.0.0.0/0
    TARGET NAT GATEWAY:作成したNAT-GWを選択
  3. DBCS用サブネットのセキュリティ・リストに以下ルールを追加
    Type:Egress Rule
    CIDR:0.0.0.0/0
    IP PROTOCOL:TCP
    SOURCE PORT RANGE:未記入(all)
    DESTINATION PORT RANGE:443
  4. python3のインストール
  5. OCI CLIのクイック・インストール

※手順3はOCI CLIのクイック・インストール用設定。試してないけど、NSGでも代替可能なはず。

 

作業ログ(抜粋)

※手順1-3は省略

環境

DBCS 2node RAC

[opc@dbvmrac1 ~]$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.7 (Maipo)


[root@dbvmrac1 ~]# /opt/oracle/dcs/bin/dbcli describe-component

System Version
---------------
19.4.3.0.0

Component Installed Version Available Version
---------------------------------------- -------------------- --------------------
GI 19.5.0.0.191015 19.6.0.0.200114
DB 19.5.0.0.191015 19.6.0.0.200114

 

Python3のインストール

・現在のバージョン確認

[opc@dbvmrac2 ~]$ python -V
Python 2.7.5

⇒デフォルトでインストールされているPythonのバージョンは2.x系となっている。。

⇒このままOCI CLIをインストールしようとすると、警告メッセージが表示されるので手動で3系をインストールする。

 

・yumリポジトリ確認

[opc@dbvmrac2 ~]$ sudo yum repolist enabled
Loaded plugins: ulninfo, versionlock
Excluding 78 updates due to versionlock (use "yum versionlock status" to show them)
repo id repo name status
ol7_UEKR5/x86_64 Latest Unbreakable Enterprise Kernel Release 5 for Oracle Linux 7Server (x86_64) 221+19
ol7_latest/x86_64 Oracle Linux 7Server Latest (x86_64) 16,352+896
repolist: 16,573

[opc@dbvmrac2 ~]$ sudo yum list available python3
Loaded plugins: ulninfo, versionlock
Excluding 78 updates due to versionlock (use "yum versionlock status" to show them)
Available Packages
python3.x86_64

 

・手動インストール

[opc@dbvmrac2 ~]$ sudo yum install -y python3
Loaded plugins: ulninfo, versionlock
Excluding 78 updates due to versionlock (use "yum versionlock status" to show them)
Resolving Dependencies
--> Running transaction check
---> Package python3.x86_64 0:3.6.8-10.0.1.el7 will be installed
--> Processing Dependency: python3-libs(x86-64) = 3.6.8-10.0.1.el7 for package: python3-3.6.8-10.0.1.el7.x86_64
--> Processing Dependency: python3-pip for package: python3-3.6.8-10.0.1.el7.x86_64
--> Processing Dependency: python3-setuptools for package: python3-3.6.8-10.0.1.el7.x86_64
--> Processing Dependency: libpython3.6m.so.1.0()(64bit) for package: python3-3.6.8-10.0.1.el7.x86_64
--> Running transaction check
---> Package python3-libs.x86_64 0:3.6.8-10.0.1.el7 will be installed
---> Package python3-pip.noarch 0:9.0.3-5.el7 will be installed
---> Package python3-setuptools.noarch 0:39.2.0-10.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================================
Package Arch Version Repository Size
================================================================================================================================================
Installing:
python3 x86_64 3.6.8-10.0.1.el7 ol7_latest 69 k
Installing for dependencies:
python3-libs x86_64 3.6.8-10.0.1.el7 ol7_latest 7.0 M
python3-pip noarch 9.0.3-5.el7 ol7_latest 1.8 M
python3-setuptools noarch 39.2.0-10.el7 ol7_latest 628 k

Transaction Summary
================================================================================================================================================
Install 1 Package (+3 Dependent packages)

Total download size: 9.4 M
Installed size: 48 M
Downloading packages:
warning: /var/cache/yum/x86_64/7Server/ol7_latest/packages/python3-3.6.8-10.0.1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Public key for python3-3.6.8-10.0.1.el7.x86_64.rpm is not installed
(1/4): python3-3.6.8-10.0.1.el7.x86_64.rpm | 69 kB 00:00:02
(2/4): python3-pip-9.0.3-5.el7.noarch.rpm | 1.8 MB 00:00:03
(3/4): python3-setuptools-39.2.0-10.el7.noarch.rpm | 628 kB 00:00:01
(4/4): python3-libs-3.6.8-10.0.1.el7.x86_64.rpm | 7.0 MB 00:00:11
------------------------------------------------------------------------------------------------------------------------------------------------
Total 827 kB/s | 9.4 MB 00:00:11
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
Importing GPG key 0xEC551F03:
Userid : "Oracle OSS group (Open Source Software group) <build@oss.oracle.com>"
Fingerprint: 4214 4123 fecf c55b 9086 313d 72f9 7b74 ec55 1f03
Package : 7:oraclelinux-release-7.7-1.0.5.el7.x86_64 (@pdit_ol7_latest/$releasever)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Installing : python3-setuptools-39.2.0-10.el7.noarch 1/4
Installing : python3-pip-9.0.3-5.el7.noarch 2/4
Installing : python3-3.6.8-10.0.1.el7.x86_64 3/4
Installing : python3-libs-3.6.8-10.0.1.el7.x86_64 4/4
Verifying : python3-libs-3.6.8-10.0.1.el7.x86_64 1/4
Verifying : python3-setuptools-39.2.0-10.el7.noarch 2/4
Verifying : python3-pip-9.0.3-5.el7.noarch 3/4
Verifying : python3-3.6.8-10.0.1.el7.x86_64 4/4

Installed:
python3.x86_64 0:3.6.8-10.0.1.el7

Dependency Installed:
python3-libs.x86_64 0:3.6.8-10.0.1.el7 python3-pip.noarch 0:9.0.3-5.el7 python3-setuptools.noarch 0:39.2.0-10.el7

Complete!

 

・バージョン確認

[opc@dbvmrac2 ~]$ python -V
Python 2.7.5


[opc@dbvmrac2 ~]$ python3 -V
Python 3.6.8

⇒「python」は2系のまま。「python3」を指定することで3系が利用できるようになった。

 

oci cliのクイックインストール

[opc@dbvmrac2 ~]$ bash -c "$(curl -L https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh)"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 13968 100 13968 0 0 31526 0 --:--:-- --:--:-- --:--:-- 31817

(中略)

-- Installation successful.
-- Run the CLI with /home/opc/bin/oci --help

⇒インストール成功

 

・バージョンとヘルプ確認

[opc@dbvmrac2 ~]$ oci --version
2.9.1
[opc@dbvmrac2 ~]$ oci
Usage: oci [OPTIONS] COMMAND [ARGS]...

Oracle Cloud Infrastructure command line interface, with support for
Audit, Block Volume, Compute, Database, IAM, Load Balancing, Networking,
DNS, File Storage, Email Delivery and Object Storage Services.

Most commands must specify a service, followed by a resource type and then
an action. For example, to list users (where $T contains the OCID of the
current tenant):

oci iam user list --compartment-id $T

Output is in JSON format.

For information on configuration, see
https://docs.cloud.oracle.com/Content/API/Concepts/sdkconfig.htm.

Options:
-v, --version Show the version and exit.
--config-file TEXT The path to the config file. [default:
~/.oci/config]
--profile TEXT The profile in the config file to load. This
profile will also be used to locate any
default parameter values which have been
specified in the OCI CLI-specific
configuration file. [default: DEFAULT]
--cli-rc-file, --defaults-file TEXT
The path to the OCI CLI-specific
configuration file, containing parameter
default values and other configuration
information such as command aliases and
predefined queries. The --defaults-file
option is deprecated and you should use the
--cli-rc-file option instead. [default:
~/.oci/oci_cli_rc]
--opc-request-id, --opc-client-request-id, --request-id TEXT
The request id to use for tracking the
request.
--region TEXT The region to make calls against. For a
list of valid region names use the command:
"oci iam region list".
--endpoint TEXT The value to use as the service endpoint,
including any required API version path. For
example: "https://iaas.us-
phoenix-1.oracle.com/20160918". This will
override the default service endpoint / API
version path. Note: The --region parameter
is the recommended way of targeting
different regions.
--cert-bundle TEXT The full path to a CA certificate bundle to
be used for SSL verification. This will
override the default CA certificate bundle.
--output [json|table] The output format. [Default is json]
--query TEXT JMESPath query [http://jmespath.org/] to run
on the response JSON before output.

Queries
can be entered directly on the command line
or referenced from the
[OCI_CLI_COMMAND_ALIASES] section of your
configuration file by using the syntax
query://<query_name>, for example
query://get_id_and_name
--raw-output If the output of a given query is a single
string value, this will return the string
without surrounding quotes
--auth [api_key|instance_principal|security_token|instance_obo_user|resource_principal]
The type of auth to use for the API request.
By default the API key in your config file
will be used. This value can also be
provided in the OCI_CLI_AUTH environment
variable.
--generate-full-command-json-input
Prints out a JSON document which represents
all possible options that can be provided to
this command.

This JSON document can be
saved to a file, modified with the
appropriate option values, and then passed
back via the --from-json option. This
provides an alternative to typing options
out on the command line.
--generate-param-json-input TEXT
Complex input, such as arrays and objects,
are passed in JSON format.

When passed the
name of an option which takes complex input,
this will print out example JSON of what
needs to be passed to that option.
--no-retry Disable retry logic for calls to services.
-d, --debug Show additional debug information.
-?, -h, --help For detailed help on the individual OCI CLI
command, enter <command> --help.

Commands:
analytics Analytics
announce Announcements Service
api-gateway API Gateway
application-migration Application Migration Service
audit Audit
autoscaling Autoscaling
budgets Budgets
bv Block Volume Service
ce Container Engine for Kubernetes
compute Compute Service
compute-management Compute Management Service
data-catalog Data Catalog
data-flow Data Flow
data-science Data Science
db Database Service
dns DNS
dts Data Transfer Service
email Email Delivery
events Events
fn Functions Service
fs File Storage
health-checks Health Checks
iam Identity and Access Management Service
integration Oracle Integration
kms Key Management Service
lb Load Balancing
limits Service limits
marketplace Marketplace Service
monitoring Monitoring
network Networking Service
oce Oracle Content and Experience
oda Digital Assistant Control Plane
ons Notifications
os Object Storage Service
os-management OSMS
raw-request Makes a raw request against an OCI service
resource-manager Resource Manager
search Search Service
session Session commands for CLI
setup Setup commands for CLI
streaming Streaming Service
waas Web Application Acceleration and Security Services
work-requests Work Requests

 

おまけ

NATゲートウェイを配置せずにインストールしようとした場合のエラー

[opc@dbvmrac1 ~]$ bash -c "$(curl -L https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh)"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:02:07 --:--:-- 0curl: (7) Failed connect to raw.githubusercontent.com:443; Connection timed out

 

python3をインストールせずにインストールしようとした場合のエラー

[opc@dbvmrac1 ~]$ bash -c "$(curl -L https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh)"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 13968 100 13968 0 0 37724 0 --:--:-- --:--:-- --:--:-- 38268

******************************************************************************
You have started the OCI CLI Installer in interactive mode. If you do not wish
to run this in interactive mode, please include the --accept-all-defaults option.
If you have the script locally and would like to know more about
input options for this script, then you can run:
./install.sh -h
If you would like to know more about input options for this script, refer to:
https://github.com/oracle/oci-cli/blob/master/scripts/install/README.rst
******************************************************************************
Downloading Oracle Cloud Infrastructure CLI install script from https://raw.githubusercontent.com/oracle/oci-cli/v2.6.12/scripts/install/install.py to /tmp/oci_cli_install_tmp_Muqt.
######################################################################## 100.0%
Python3 not found on system PATH★
Running install script.
python /tmp/oci_cli_install_tmp_Muqt
-- Verifying Python version.
-- Python version 2.7.5 okay.

===> In what directory would you like to place the install? (leave blank to use '/home/opc/lib/oracle-cli'):

 

 

参考情報

[Oracle Cloud] OCI Database(DBaaS)にCLIを設定してみた

・7系LinuxにPython3+OCI CLIをインストールする&2020/2/13以降はOCI CLIがサポートするPythonのバージョンが3.5+になる件
https://qiita.com/yamada-hakase/items/2b4f33710d8ee41ab420

 

スポンサードリンク

Be the first to comment

Leave a Reply

Your email address will not be published.


*