
Introduction
Oracle Cloud Infrastructure (OCI) Command Line Interface (CLI) is a small-footprint tool that lets you create and manage resources in Oracle Cloud using a command line interface. It enables you to automate tasks and makes things easier.
The Quickstart documentation provides quick installation instructions. However, installations via RPM (Red Hat Package Manager) on Base and Exadata Database VMs on Oracle Cloud might lead to conflicts and issues while updating the VM’s operating system.
Suppose you need to install OCI CLI on the database host, e.g., to scale up Exadata VM Cluster from within the system. In that case, it’s highly recommended to install the CLI manually and ensure it runs in a virtual environment. This will ensure not to conflict with the RPMs on the database machine.
This blog post provides a step-by-step guide on manual installation on Oracle Linux 8, the default operating system for Base and Exadata Database VMs in Oracle Cloud.
The Environment
- Exadata Database Service on Dedicated Infrastructure running Oracle Linux 8.
Note: OCI CLI is already installed on Base Database Service VMs running Oracle Linux 8.
Step 1: Check Python Installation
Check the existing Python installation on the Exadata VMs:
[opc@vmdbhost ~]$ python --version
Python 3.6.8
Step 2: Create and Configure a Virtual Environment
Choose a directory where you want to install the virtual environment. Run the following commands to create and activate the virtual environment:
[opc@vmdbhost ~]$ mkdir virtual_env
[opc@vmdbhost ~]$ cd virtual_env/
[opc@vmdbhost virtual_env]$ python3.6 -m venv oracle-cli
[opc@vmdbhost virtual_env]$ source oracle-cli/bin/activate
(oracle-cli) [opc@vmdbhost virtual_env]$
Step 3: Install OCI CLI using PyPI
The Python Package Index (PyPI) is a software repository for the Python programming language. Run the following command to upgrade PyPI and install OCI CLI:
(oracle-cli) [opc@vmdbhost virtual_env]$ pip install --upgrade pip
(oracle-cli) [opc@vmdbhost virtual_env]$ pip install oci-cli
(oracle-cli) [opc@vmdbhost virtual_env]$ oci -v
3.74.2
Step 4: Authenticate OCI CLI via Resource Principals
For Base and Exadata Database VMs, use the Resource Principals authentication method described in Authentication Method #3: Resource Principals in this blog post.
Run your CLI commands from the virtual environment:
[opc@vmdbhost ~]$ . virtual_env/oracle-cli/bin/activate
(oracle-cli) [opc@vmdbhost ~]$ oci ...
Conclusion
If you need to install OCI CLI on a database VM in Oracle Cloud, install it manually and ensure it runs in a virtual environment to avoid issues when updating the operating system. Choose Resource Principals for authentication for higher security without the need to manage and store user credentials on the VM host.
