All Products
Search
Document Center

MaxCompute:Use Cloud Shell (odpscmd)

Last Updated:Nov 18, 2024

You can use the MaxCompute client (odpscmd) through the Cloud Shell, a web-based CLI tool from Alibaba Cloud, without manual installation. This topic provides the usage notes and basic examples for operating MaxCompute with Cloud Shell (odpscmd). For more information about Clout Shell, see What is Cloud Shell?.

Prerequisites

If you use the Cloud Shell (odpscmd) of the MaxCompute as a RAM user, ensure the RAM user has the AliyunCloudShellFullAccess permission. For more information, see Authorize RAM users.

Limits

  • Cloud Shell limits

    Item

    Description

    Number of VMs

    Only one virtual machine (VM) can be created at a time regardless of the number of Cloud Shell sessions that are opened. All opened Cloud Shell sessions are automatically connected to the VM.

    Number of sessions

    Up to five sessions can be opened at a time.

    Destruction of VMs

    If no interactive operation is performed for 30 minutes or all sessions are closed, the VM is destroyed in 15 minutes. When you restart Cloud Shell, a new VM is created.

    Destruction on expiration

    A VM that is created by Cloud Shell is valid for only 1 hour. After the VM expires, Cloud Shell immediately destroys the VM. When you restart Cloud Shell, a new VM is created.

    File storage

    Cloud Shell provides 10 GB of temporary storage. You can store your files in the /home/shell directory. However, the directory is reset when the VM is destroyed. You can attach the Cloud Shell instance to File Storage NAS for permanent storage. Then, your files are automatically loaded each time Cloud Shell is started.

    Prohibition

    Long-term use or computing and intensive malicious processes are not supported. In these cases, a session may be terminated or even prohibited without warning.

  • Region limits

    The regions China (Hangzhou), China (Shanghai), China (Beijing), and China (Shenzhen) support Cloud Shell for connecting to MaxCompute.

Precautions

By default, when initiating the Cloud Shell (odpscmd) of the MaxCompute in any region, the Cloud Shell service and temporary storage service are deployed in the China (Shanghai) region. If your project is located in a different region, be aware that using this feature could bring data security risks.

Enter the Cloud Shell (odpscmd) environment

  1. Log on to the MaxCompute console and select a region in the upper-left corner.

  2. Click Command Line in the upper-right corner.

  3. In the Choose Project dialog box, select the project you wish to manage and click OK.

    Note

    If prompted about mounting NAS, you can mount as necessary. For more information, see (Optional) Mount NAS.

    Once Cloud Shell (odpscmd) loads, the interface appears as shown below. image.png

(Optional) Mount NAS

Cloud Shell provides you with 10 GB of temporary storage, which resets upon virtual machine termination. You can mount storage space for storage, which is automatically loaded each time Cloud Shell starts. The steps to mount NAS are as follows.

In the MaxCompute Cloud CMD window, click the image.png icon and select Mount File Storage to attach NAS storage.

Note

Mounting NAS incurs NAS storage fees. After usage, you can detach the storage space promptly. For more information about NAS storage fee, see Billing overview.

Use Cloud Shell (odpscmd)

Cloud Shell (odpscmd) supports the execution of all SQL commands available to the local client. This section shows how to operate Cloud Shell (odpscmd) with examples of running SQL commands and performing data transmission.

Run SQL commands

To create a table named result_table1 by using the following command example.

create table if not exists result_table1
(
 education STRING comment 'education level',
 num BIGINT comment 'number of people');

To view the tables you created by using the command example provided below.

show tables;

Data transmission

  • File upload

    1. Click the image.png icon, select Upload, and upload a local file. As an example, this topic uses the file result.txt.

      Once the upload completes, exit the Cloud Shell (odpscmd) environment with Ctrl+c, then execute ll to verify the upload success and file path.

      image.png

      Return to the Cloud Shell (odpscmd) environment by using the command below.

      cloudshell-odpscmd -p <project.name>
    2. Upload the file result.txt to MaxCompute by using the command example provided.

      tunnel upload result.txt result_table1;
  • File download

    1. To download the MaxCompute table result_table1 to Cloud Shell (odpscmd) by using the command example below.

      Tunnel download result_table1 result_table1.txt;
    2. Click the image.png icon, select Download, and download the file result_table1.txt to your local device.

      Once the download completes, the interface appears as shown below.

      image.png