安装并登录MaxCompute本地客户端

更新时间:
复制 MD 格式

MaxCompute本地客户端(odpscmd)在本地计算机上运行,提供了一个简单且高效的方式来执行命令和管理MaxCompute服务。本文介绍如何安装并启动MaxCompute客户端,启动成功后即表示已经登录MaxCompute客户端并进入MaxCompute项目。

适用范围

  • The MaxCompute client requires Java 8 or later.

  • 版本兼容性

    • MaxCompute客户端从v0.28.0版开始支持JDK 1.9,v0.28.0以下版本只支持JDK 1.8。根据本文步骤安装客户端后,可在命令行界面查看客户端版本号。

    • The output format of the MaxCompute client is not backward-compatible. Command formats and behavior may differ between client versions. Do not rely on the client output format for parsing.

    • For other client versions, see aliyun-odps-console.

  • Character encoding

    The client uses UTF-8 by default. If your local environment's character encoding is not UTF-8, garbled characters may appear when you query data containing Chinese characters from a MaxCompute table or use a Tunnel command to upload local files containing them.

Install and configure odpscmd

odpscmd v0.27.0 and later support the MaxCompute 2.0 data types. We recommend that you use these data types. For a list of supported data types, see Data Types (V2.0).

Procedure

  1. Download the odpscmd installation package (GitHub).

    Note
    • Follow the link to the release page and download the latest version of the odpscmd installation package (odpscmd_public.zip).

    • If you cannot download the package from the GitHub link, try downloading the odpscmd installation package (OSS). If you have issues accessing GitHub, we recommend that you search for solutions online.

  2. Unzip the downloaded package. The extracted directory contains the bin, conf, lib, and plugins folders.

  3. Go to the conf folder and configure the odps_config.ini file.

    In the odps_config.ini file, the number sign (#) indicates a comment. The following table describes the parameters.

    Parameter

    Required

    Description

    Example

    project_name

    Yes

    The name of the destination MaxCompute project.

    If you created a workspace in standard mode, distinguish between the project names for the production environment and the development environment (_dev) when you configure the project_name parameter. For more information, see Differences between workspace modes.

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

    2. In the left-side navigation pane, choose Manage Configurations > Projects.

    3. On the Projects page, view your MaxCompute project name.

    doc_test_dev

    access_id

    Yes

    The AccessKey ID of your Alibaba Cloud account or RAM user. Obtain the AccessKey ID from the AccessKey Management page.

    N/A

    access_key

    Yes

    The AccessKey Secret that corresponds to the AccessKey ID.

    N/A

    end_point

    Yes

    The endpoint of the MaxCompute service.

    You must configure the endpoint based on the region where your MaxCompute project is located and the network connection type. For a list of endpoints for different regions and network types, see Endpoints.

    Important
    • An endpoint connects to the MaxCompute service, while a tunnel endpoint connects to the MaxCompute Tunnel service. Specify the endpoint for the MaxCompute service here.

    • An incorrect endpoint configuration causes an access error.

    http://service.cn-hangzhou.maxcompute.aliyun.com/api

    log_view_host

    No

    The LogView URL. We recommend that you configure this parameter. If you do not configure this parameter, you cannot quickly identify the cause of a job failure.

    Use this URL to view detailed job runtime information and troubleshoot errors. The fixed value is http://logview.odps.aliyun.com.

    http://logview.odps.aliyun.com

    https_check

    No

    Specifies whether to enable HTTPS to encrypt requests for accessing the MaxCompute project. Valid values:

    • True: Enables HTTPS.

    • False: Uses HTTP.

    The default value is False.

    True

    data_size_confirm

    No

    The maximum input data size in GB. This value has no upper limit. Recommended value: 100.

    100

    update_url

    No

    This parameter is reserved for future use.

    N/A

    use_instance_tunnel

    No

    Specifies whether to use InstanceTunnel to download SQL execution results. Valid values:

    • True: Use InstanceTunnel to download SQL execution results.

    • False: Do not use InstanceTunnel to download SQL execution results.

    The default value is False.

    True

    instance_tunnel_max_record

    No

    The maximum number of records in an SQL execution result. If use_instance_tunnel is set to True, you must configure this parameter. The maximum value is 10,000.

    10000

    tunnel_endpoint

    No

    The public endpoint for the Tunnel service.

    • If you do not configure this parameter, Tunnel automatically routes requests to the tunnel endpoint that corresponds to the network of the MaxCompute service.

    • If you configure a tunnel endpoint, Tunnel uses that value and does not perform automatic routing.

    For a list of tunnel endpoints for different regions and network types, see Endpoints.

    http://dt.cn-hangzhou.maxcompute.aliyun.com

    set.<key>

    No

    Sets a property for the MaxCompute project.

    For more information about properties, see property list.

    set.odps.sql.decimal.odps2=true

    Ensure the preceding information is configured correctly. Misconfigurations can cause project connection failures.

启动MaxCompute客户端

Use one of the following methods to start the MaxCompute client:

Script file

In the bin directory of your MaxCompute client installation, double-click odpscmd.bat (on Windows) or odpscmd (on macOS) to start the MaxCompute client. The following output indicates a successful connection to the MaxCompute project.

odpscmd
Aliyun ODPS Command Line Tool
Version 0.4xxx
@Copyright 2020 Alibaba Cloud Computing Co., Ltd. All rights reserved.
Connecting to http://service.xxx.maxcompute.aliyun.com/api, project: xxx
Executing predefined SET command: SET odps.sql.hive.compatible=true
OK
Endpoint: http://service.xxx.maxcompute.aliyun.com/api
Project: xxx
Schema: default
Quota: default in region N/A
Timezone: Asia/Shanghai
Connected!

Command-line window

In a command-line window, navigate to the bin directory of your MaxCompute client installation. Run odpscmd on Windows or sh odpscmd on Linux or macOS to start the MaxCompute client. A success message indicates that the client has connected to the MaxCompute project.

Note

On Ubuntu, sh odpscmd returns an error. Use ./odpscmd instead.

When you start the MaxCompute client from a command-line window, you can specify startup parameters to run commands. For more information, see Startup parameters.

后续步骤

相关文档