OCI client Install and setup OCI SDK API

安装 oci cli OCI client Install and setup

以Oracle Linux 8为例:

If you’re using Oracle Linux 8, you can use dnf to install the CLI.

To use dnf to install the CLI:

sudo dnf -y install oraclelinux-developer-release-el8
sudo dnf install python36-oci-cli

The CLI will be installed to the Python site packages:

  • /usr/lib/python3.6/site-packages/oci_cli
  • /usr/lib/python3.6/site-packages/services

Documentation and examples will be installed in the /usr/share/doc/python36-oci-cli-<version>/ directory.

Oracle Linux 7 If you're using Oracle Linux 7, you can use yum to install the CLI.
To use yum to install the CLI:


sudo yum install python36-oci-cli


配置 oci cli 链接OCI的用户信息


1. 登录oci console进行API Keys配置



新建一个fingerprint,相关信息内容如下:
[DEFAULT] user=ocid1.user.oc1..aaaaaaaa3kba4v6yjmolglt6ag7nfqpl5rjnq36qovf6yum5m3c7vp7 a3mxq fingerprint=8c:88:95:8e:60:12:c0:16:cb:be:50:2e:d8:5e:b1:0f tenancy=ocid1.tenancy.oc1..aaaaaaaarsuxvqi2qi3ilw75rvp2p5q4g65zyem3aximz6sum t6ukdoetpmq region=ap-seoul-1
key_file=<path to your private keyfile> # TODO

config: 放到.oci目录下面,保障oci cli能登录到相关的oci账户,请保障该文件的最后一行配置路径是正确的。

检查 oci cli 是否配置成功

配置文件为 .oci/config 文件. 请保障该文件的最后一行配置路径是正确的。

运行下面命令检查是否配置成功

oci os ns get 

[opc@p6-app-1 .oci]$ oci os ns get

–如果配置成功,将显示oci tenancy信息

{ “data”: “ocichina001” }

 如果能正确显示oci tenancy信息,说明oci cli已经配置成功。

查询OCI的版本,python SDK的版本

oci --version

pip3 show oci

通过环境变量进行使用不同的config文件的内容

OCI_CLI_PROFILE=ocichina001

Github OCI Python SDK

https://github.com/oracle/oci-python-sdk

https://docs.oracle.com/en-us/iaas/tools/python/2.126.4/api/landing.html

OCI CLI 文档

https://docs.oracle.com/iaas/tools/oci-cli/latest/oci_cli_docs

Print Friendly, PDF & Email

Leave a Reply

Your email address will not be published. Required fields are marked *