odps dship客戶端使用
1、下載DShip外掛
下載地址:最下面的“開發者資源”,“資料上傳下載工具”,下載檔案為odps-dship.zip。
odps-dship\dship.bat即為windows下的執行檔案。
2、配置DShip
odps-dship\odps.conf為DShip的配置檔案,(需要jdk1.6以上),配置檔案原來是這樣的:
#odps dship config
endpoint=
id=
key=
project=
配置好專案名稱,access ID,access Key。
正確配置請參照文件下面部分的odps.conf配置
3、開啟客戶端
注意:要到命令列cd到相應的目錄下面,執行命令dfish可以看到dfish的幫助資訊。
C:\Users\yangswa>cd C:\Users\yangswa\Desktop\odps-dship
C:\Users\yangswa\Desktop\odps-dship>dship
Usage: dship
Type 'dship help
Type 'dship --version' to see the program version.
Available subcommands:
upload (u)
download (d)
resume (r)
show (s)
config (c)
purge (p)
help (h)
Valid global options:
-c [--charset] ARG : file charset
-dfp [--date-format-pattern] ARG : date format pattern
-e [--endpoint] ARG : specify endpoint
-fd [--field-delimiter] ARG : field delimiter
-i [--id] ARG : access id
-k [--key] ARG : access key
-ni [--null-indicator] ARG : null indicator string
-p [--project] ARG : default project
-rd [--record-delimiter] ARG : record delimiter
-te [--tunnel-endpoint] ARG : specify tunnel endpoint
dship is tool for odps data transfer.
4、在odps的yangsw_test專案中有一個dual表
表結構:
id,型別為bigint。
Name, 型別為string
Dt,型別為string,該欄位為分割槽欄位
odps:sql:yangsw_test> desc dual;
+------------------------------------------------------------------------------------+
| Table: dual |
| Owner: ALIYUN$************** | Project: yangsw_test |
| TableComment: |
+------------------------------------------------------------------------------------+
| CreatedTime: 2014-11-11 10:14:25 |
| LastMetaModifiedTime: 2014-11-11 10:14:25 |
| LastDataModifiedTime: 1970-01-01 08:00:00 |
+------------------------------------------------------------------------------------+
| Type : Table | Size: 0 Bytes |
+------------------------------------------------------------------------------------+
| Native Columns: |
+------------------------------------------------------------------------------------+
| Field | Type | Comment |
+------------------------------------------------------------------------------------+
| id | BIGINT | |
| name | STRING | |
+------------------------------------------------------------------------------------+
| Partition Columns: |
+------------------------------------------------------------------------------------+
| dt | STRING | |
+------------------------------------------------------------------------------------+
我們給dual表加一個分割槽
odps:sql:yangsw_test> alter table dual add partition(dt='2014');
InstanceId: 20141111021906223gw514il
OK
5、準備資料檔案
Dual_2014.txt
1,tom
2,jacky
3,jet
4,rose
5,marry
6,obama
6、用dship上傳資料
C:\Users\yangswa\Desktop\odps-dship> dship upload -fd "," -rd "\r\n" C:\Users\yangswa\Desktop\dual_2014.txt dual/dt="2014";
ERROR: Unknown error -
405 Not Allowed
檢視日誌檔案odps-dship\sessions\.sidnull\log.txt
2014-11-11 11:10:56 - java.lang.Exception: ERROR: Unknown error -
405 Not Allowed
at com.aliyun.odps.ship.DShip.parseCommandLine(DShip.java:101)
at com.aliyun.odps.ship.DShip.main(DShip.java:35)
Caused by: java.lang.RuntimeException:
405 Not Allowed
at com.aliyun.odps.tunnel.TunnelException.
at com.aliyun.odps.tunnel.TableTunnel$UploadSession.initiate(TableTunnel.java:462)
at com.aliyun.odps.tunnel.TableTunnel$UploadSession.
at com.aliyun.odps.tunnel.TableTunnel.createUploadSession(TableTunnel.java:95)
at com.aliyun.odps.ship.upload.TunnelUploadSession.
at com.aliyun.odps.ship.DShip.parseCommandLine(DShip.java:62)
... 1 more
Caused by: Parse response failed
at com.aliyun.odps.tunnel.TunnelException.loadFromJson(TunnelException.java:138)
at com.aliyun.odps.tunnel.TunnelException.
... 6 more
Caused by: org.codehaus.jackson.JsonParseException: Unexpected character ('
at [Source: ; line: 1, column: 2]
at org.codehaus.jackson.JsonParser._constructError(JsonParser.java:1433)
at org.codehaus.jackson.impl.JsonParserMinimalBase._reportError(JsonParserMinimalBase.java:521)
at org.codehaus.jackson.impl.JsonParserMinimalBase._reportUnexpectedChar(JsonParserMinimalBase.java:442)
at org.codehaus.jackson.impl.Utf8StreamParser._handleUnexpectedValue(Utf8StreamParser.java:2090)
at org.codehaus.jackson.impl.Utf8StreamParser._nextTokenNotInObject(Utf8StreamParser.java:606)
at org.codehaus.jackson.impl.Utf8StreamParser.nextToken(Utf8StreamParser.java:492)
at org.codehaus.jackson.map.ObjectMapper._initForReading(ObjectMapper.java:2770)
at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:2718)
at org.codehaus.jackson.map.ObjectMapper.readTree(ObjectMapper.java:1507)
at com.aliyun.odps.tunnel.TunnelException.loadFromJson(TunnelException.java:127)
... 7 more
難道是多個分號?????
C:\Users\yangswa\Desktop\odps-dship>dship upload -fd "," -rd "\r\n" C:\Users\yangswa\Desktop\dual_2014.txt dual/dt="2014"
ERROR: TunnelException – null
檢視日誌檔案odps-dship\sessions\.sidnull\log.txt
2014-11-11 14:41:38 - null
at com.aliyun.odps.tunnel.TableTunnel$UploadSession.initiate(TableTunnel.java:467)
at com.aliyun.odps.tunnel.TableTunnel$UploadSession.
at com.aliyun.odps.tunnel.TableTunnel.createUploadSession(TableTunnel.java:95)
at com.aliyun.odps.ship.upload.TunnelUploadSession.
at com.aliyun.odps.ship.DShip.parseCommandLine(DShip.java:62)
at com.aliyun.odps.ship.DShip.main(DShip.java:35)
Caused by: java.net.UnknownHostException: null
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.(Unknown Source)
at sun.net.(Unknown Source)
at sun.net.(Unknown Source)
at sun.net.(Unknown Source)
at sun.net.(Unknown Source)
at sun.net.(Unknown Source)
at sun.net.(Unknown Source)
at sun.net.(Unknown Source)
at sun.net.(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at com.aliyun.odps.commons.transport.DefaultConnection.getResponse(DefaultConnection.java:101)
at com.aliyun.odps.tunnel.TableTunnel$UploadSession.initiate(TableTunnel.java:457)
... 5 more
還是報錯。。。 。。。
這位大神的配置起作用:
最終在windows環境下我得odps.conf改為下面就可以上傳資料了(注意上面兩行)
\u00EF\u00BB\u00BF\#odps=dship config
tunnel-endpoint=http\://dt.odps.aliyun.com
id=*******
key=********
project=yangsw_test
最終的執行結果如下:
C:\Users\yangswa\Desktop\odps-dship>dship upload -fd "," -rd "\r\n" C:\Users\yangswa\Desktop\dual_2014.txt yangsw_test.dual/dt="2014"
Upload session: 201411111456542581870a0024a407
2014-11-11 14:56:25 scanning file: 'dual_2014.txt'
2014-11-11 14:56:26 uploading file: 'dual_2014.txt'
2014-11-11 14:56:28 'dual_2014.txt' uploaded
OK
7、用odps sql查一下dual表的資料
odps:sql:yangsw_test> select * from dual;
InstanceId: 20141111070328172gre5pdx5
+------------+------+----+
| id | name | dt |
+------------+------+----+
| 1 | tom | 2014 |
| 2 | jacky | 2014 |
| 3 | jet | 2014 |
| 4 | rose | 2014 |
| 5 | marry | 2014 |
| 6 | obama | 2014 |
至此,使用dship上傳資料成功了。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26613085/viewspace-1328434/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- ODPS初始篇--客戶端配置和使用客戶端
- github客戶端使用Github客戶端
- FTP 客戶端使用教程FTP客戶端
- MQTTJava客戶端的使用MQQTJava客戶端
- redis客戶端的使用Redis客戶端
- ftp客戶端,ftp客戶端軟體具體怎麼使用?FTP客戶端
- 使用 Webix 建立 Email 客戶端WebAI客戶端
- NEO-GUI 客戶端使用GUI客戶端
- dbus客戶端使用指南客戶端
- ubuntu 下svn客戶端使用Ubuntu客戶端
- Winform客戶端引用WCF客戶端後,部分類無法正常使用ORM客戶端
- [jaeger] 二、客戶端使用 (Java版本)客戶端Java
- Curator(ZoooKeeper客戶端)使用詳解客戶端
- 命令列客戶端MySQL如何使用命令列客戶端MySql
- zookeeper 開源客戶端ZkClient使用客戶端client
- zookeeper 開源客戶端Curator使用客戶端
- Elasticsearch及java客戶端jest使用ElasticsearchJava客戶端
- 免安裝Oracle客戶端使用Oracle客戶端
- WebSocket簡單使用(二)-客戶端Web客戶端
- 郵件客戶端的配置使用客戶端
- 中文版vnc客戶端,中文版vnc客戶端下載,中文版vnc客戶端如何使用?VNC客戶端
- ftp客戶端軟體,ftp客戶端軟體哪個好用,使用方法FTP客戶端
- dubbo客戶端客戶端
- Pulsar客戶端客戶端
- mqtt 客戶端MQQT客戶端
- vnc windows客戶端,vnc windows客戶端下載,具體使用教程。VNCWindows客戶端
- 客戶端,服務端客戶端服務端
- 服務端,客戶端服務端客戶端
- Nacos - 客戶端心跳續約及客戶端總結客戶端
- ETH官方客戶端Geth的使用(一)客戶端
- 使用 .NET MAUI 開發 ChatGPT 客戶端UIChatGPT客戶端
- Zookeeper客戶端使用與叢集原理客戶端
- windows 上rsync客戶端使用方法Windows客戶端
- TortoiseSVN(小烏龜)客戶端使用方法客戶端
- Linux中使用Electronic WeChat客戶端Linux客戶端
- git SourceTree 客戶端 安裝/使用教程Git客戶端
- 在客戶端程式中使用REST SOE客戶端REST
- keycloak~scope客戶端模板的使用客戶端