快速入门GaussDB(DWS)丨【这次高斯不是数学家】
前期准备
进入快速入门数据仓库服务GaussDB(DWS)的沙箱实验室,实验室链接:
https://lab.huaweicloud.com/testdetail_1661
该实验指导用户云上快速创建GaussDB(DWS)数据仓库集群,并将OBS源数据导入数据仓库,完成数据的简易查询。
点击开始实验。
进入实验台。
1 创建虚拟私有云(VPC)
进入华为云的控制台,选择 虚拟私有云(VPC) 。
点击 创建虚拟私有云。
虚拟私有云的参数配置如下:
配置完成后,点击右下角的 立即创建。
2 创建数据仓库服务(DWS)
登录华为云控制台,鼠标移动到云桌面浏览器页面中左侧菜单栏,点击服务列表->“大数据”->“数据仓库服务GaussDB(DWS)”,进入左侧栏“数据仓库服务”页面。
点击右上角 创建数据仓库集群。
按照下图所示进行配置。
配置完成后,点击右下角的 立即创建。
任务提交成功,返回集群列表。
可以看到集群的状态为 创建中,等待创建完成,约10分钟。
3 上传数据到OBS桶
3.1 创建OBS桶
登录华为云控制台,鼠标移动到云桌面浏览器页面中左侧菜单栏,点击服务列表->“存储”->“对象存储服务 OBS”,进入左侧栏“对象存储服务”页面,点击 创建桶。
桶的参数配置如下:
配置完成后,点击右下角的 立即创建。
创建OBS桶成功后,左侧选择“桶列表”,单击新创建的obs-demo桶名,左侧导航选择“对象”,单击“新建文件夹”,文件夹名称为“input_data,单击“确定”。
3.2 准备txt数据源并上传OBS桶
回到实验室的桌面。双击 Xfce终端,打开Terminal终端。
执行下面代码新建一个product_info0.csv数据文件。
vim /home/user/Desktop/product_info0.csv
复制以下内容,并粘贴到product_info0.csv中。
100,XHDK-A,2017-09-01,A,2017 Shirt Women,red,M,328,2017-09-04,715,good!
205,KDKE-B,2017-09-01,A,2017 T-shirt Women,pink,L,584,2017-09-05,40,very good!
300,JODL-X,2017-09-01,A,2017 T-shirt men,red,XL,15,2017-09-03,502,Bad.
310,QQPX-R,2017-09-02,B,2017 jacket women,red,L,411,2017-09-05,436,It's nice.
150,ABEF-C,2017-09-03,B,2017 Jeans Women,blue,M,123,2017-09-06,120,good.
重复执行以上操作,生成“product_info1.csv”和“product_info2.csv”另外两个数据文件。
product_info1.csv
200,BCQP-E,2017-09-04,B,2017 casual pants men,black,L,997,2017-09-10,301,good quality.
250,EABE-D,2017-09-10,A,2017 dress women,black,S,841,2017-09-15,299,This dress fits well.
108,CDXK-F,2017-09-11,A,2017 dress women,red,M,85,2017-09-14,22,It's really amazing to buy.
450,MMCE-H,2017-09-11,A,2017 jacket women,white,M,114,2017-09-14,22,very good.
260,OCDA-G,2017-09-12,B,2017 woolen coat women,red,L,2004,2017-09-15,826,Very comfortable.
product_info2.csv
980,"ZKDS-J",2017-09-13,"B","2017 Women's Cotton Clothing","red","M",112,,,
98,"FKQB-I",2017-09-15,"B","2017 new shoes men","red","M",4345,2017-09-18,5473
50,"DMQY-K",2017-09-21,"A","2017 pants men","red","37",28,2017-09-25,58,"good","good","good"
80,"GKLW-l",2017-09-22,"A","2017 Jeans Men","red","39",58,2017-09-25,72,"Very comfortable."
30,"HWEC-L",2017-09-23,"A","2017 shoes women","red","M",403,2017-09-26,607,"good!"
40,"IQPD-M",2017-09-24,"B","2017 new pants Women","red","M",35,2017-09-27,52,"very good."
50,"LPEC-N",2017-09-25,"B","2017 dress Women","red","M",29,2017-09-28,47,"not good at all."
60,"NQAB-O",2017-09-26,"B","2017 jacket women","red","S",69,2017-09-29,70,"It's beautiful."
70,"HWNB-P",2017-09-27,"B","2017 jacket women","red","L",30,2017-09-30,55,"I like it so much"
80,"JKHU-Q",2017-09-29,"C","2017 T-shirt","red","M",90,2017-10-02,82,"very good."
完成后,可在桌面看到三个CSV文件:
执行以下命令,确认3个CSV文件都已准备好。
ll
回到桌面浏览器的OBS管理控制台,左侧导航选择 桶列表,单击新创建的“obs-demo”桶名,左侧导航选择对象,单击进入“input_data”文件夹,单击 上传对象。将桌面的3个CSV文件上传。
对象上传成功:
4 下载gsql客户端并连接DWS数据库
4.1 下载gsql客户端
华为云控制台左侧菜单栏,点击服务列表->“大数据”->“数据仓库服务GaussDB(DWS)”,进入左侧栏“数据仓库服务”页面,左侧导航选择“连接管理”,选择gsql命令行客户端的OS版本:Redhat x86_64,单击“下载”
回到桌面打开终端,执行以下命令将将下载的dws_client_8.1.x_redhat_x64.zip包拷贝到/opt目录下。
cp /home/user/Downloads/dws_client_8.1.x_redhat_x64.zip /opt
4.2 连接DWS数据库
后续由于沙箱实验时间的限制,没有继续进行。
第五步是导入OBS桶数据并进行查询。
可以按照实验手册继续开展。
参考文献
【这次高斯不是数学家】有奖征文火热进行中:https://bbs.huaweicloud.com/blogs/345260
- 点赞
- 收藏
- 关注作者
评论(0)