一、测试环境

名称
cpu Intel® Core™ i5-1035G1 CPU @ 1.00GHz
操作系统 CentOS Linux release 7.9.2009 (Core)
Gbase-8a数据库版本 8.6.2.43-R33.132743
FTP服务器IP 192.168.142.11
数据库服务器IP 192.168.142.10

二、LOAD相关数据库参数介绍

参数名 描述
gbase_loader_buffer_count 用于指定加载过程中分配的读缓冲内存块数量,其中单块内存固定大小为8M,每个加载任务单个节点占用的读缓冲内存为8M*gbase_loader_buffer_count。最大值:128
gbase_loader_check_charset 用于设置是否打开字符集检查功能,该参数仅对加载有效,对其他 SQL 无影响。
gbase_loader_last_task_id Session 级只读变量,用于查询当前 Session 的最后加载任务 TASK_ID值。可以使用 select @@gbase_loader_last_task_id 方式查询。
gbase_loader_logs_collect 用于控制日志汇总功能的开启。ON:表示开启加载错误数据日志汇总功能,加载过程中实时的将错误数据与溯源信息汇总至加载发起节点。OFF:表示关闭加载错误数据日志汇总功能,加载遵循现有规则,错误数据日志与溯源信息日志保存在加载节点。
gbase_loader_logs_dir 用户指定错误数据与溯源日志文件汇总目录。
gbase_loader_max_line_length 用于设置源文件中一行数据的最大长度,超过此长度,加载任务将报错停止。单位:字节。
gbase_loader_parallel_degree 该参数用于设置控制加载 SQL 执行的并行度(并行线程数),如果不设定该参数值,则该参数的默认值是 0(0 表示用默认并行度,默认并行度取值是线程池最大可用资源数)。设置 gbase_loader_parallel_degree 参数对加载不再有效。
gbase_loader_read_timeout 用于指定读取 FTP/HTTP/HDFS/SFTP 文件的超时时间,如果填充一个数据块(8M)的时间超过此参数值,加载任务将报错停止。0 表示永不超时。单位:秒。默认
gbase_loader_wildcard_switch 控制是否打开多级目录通配加载功能。1(ON):表示开启多级目录通配功能,加载过程中对 SQL 中含有通配符的文件路径通配展开,获得精确文件路径;0(OFF):表示关闭多级目录通配功能,加载遵循现有规则,按 SQL 指定的路径进行加载。该参数默认值为 1。
gcluster_enable_serial_load 设定超过边界值按当前设定参数的形式统一处理,默认值为 0,代表不受控制。
gcluster_kafka_loader_max_start_count 控制 loader 型 consumer 最多可以启动的数量,如果超过了这个数量,start kafka consumer 命令将报错。
gcluster_loader_max_data_processors 一次加载任务使用的最大加载机个数(参与数据解析处理的最大节点数)
gcluster_loader_min_chunk_size 数据文件最小分块粒度,单位是字节,UINT_MAX 取值为 4294967295。

三 、LOAD语法树

LOAD DATA INFILE 'file_list'
INTO TABLE [dbname.]tbl_name
[options]
options:[CHARACTER SET charset_name][DATA_FORMAT number [HAVING LINES SEPARATOR]][NULL_VALUE 'string'][FIELDS[TERMINATED BY 'string'][ENCLOSED BY 'string'][PRESERVE [LEADING | TRAILING] BLANKS][AUTOFILL][LENGTH 'string'][TABLE_FIELDS 'string']][LINES[TERMINATED BY 'string']][MAX_BAD_RECORDS number][DATETIME FORMAT format][DATE FORMAT format][TIMESTAMP FORMAT format][TIME FORMAT format][TRACE number][TRACE_PATH 'string'][NOSPLIT][PARALLEL number][MAX_DATA_PROCESSORS number][MIN_CHUNK_SIZE number][SKIP_BAD_FILE number][SET col_name = value[,...]][IGNORE NUM LINES][FILE_FORMAT format]
参数名 描述
CHARACTER SET 用来指定待加载数据文件的编码格式,目前支持GBK和UTF8两种格式。省略时,认为不需要转码。
DATA_FORMAT 用来指定使用哪种方式解析数据文件并加载。指定为3,表示使用文本方式加载。指定为4,表示使用定长方式加载。如果某列数据可能包含了行分隔符,则需要在SQL中输入’HAVING LINES SEPARATOR’子句。指定为5,表示使用文本文件宽松模式,即数据源文件为包围符中含有换行符和包围符文本文件,或多列少列文本文件。
NULL_VALUE 用于指定空值字符,支持不超过15个任意字符的组合,参数值以引号包围,指定方式与字段包围符一样。
FIELDS
TERMINATED BY 用于指定字段分隔符,支持不超过15个任意字符的组合,支持任意字符,参数值以引号包围,仅当使用文本方式加载时有效。可使用字符本身(仅限可见字符,如:“|”)、C风格转义字符(如:“\a”)、\xhh十六进制(如:“\xFF”)或x’‘十六进(如:"x’09’")四种方式指定。例如:‘|’,表示用|作为分隔字符。
ENCLOSED BY 用于指定字段包围符,支持任意单字符,参数值以单引号包围,仅当使用文本方式加载时有效。可使用字符本身(仅限可见字符,如:“|”)、C风格转义字符(如:“\a”)、\xhh十六进制(如:“\xFF”)或x’‘十六进制(如:"x’09’")四种方式指定。
PRESERVE BLANKS 用于设定是否保留字段内容两端的空格,默认不保留空格。支持format=3、format=4。1、不保留空格,不写PRESERVE BLANKS(缺省);2、保留前空格,PRESERVE LEADING BLANKS;3、保留后空格,PRESERVE TRAILING BLANKS;
AUTOFILL 用于设定是否启用缺失列自动补齐功能,启用该参数后,对缺失分割符的字段数据按照default值或者NULL值进行加载,默认不自动补齐。
DEFINER 在使用定长模式加载时,用于设定字段长度的参数。定长格式数据导入时,设置每个字段的长度,有多个字段时,用逗号分隔。
LENGTH 在使用定长模式加载时,用于设定字段长度的参数。定长格式数据导入时,设置每个字段的长度,有多个字段时,用逗号分隔。
TABLE_FIELDS 用于指定列加载,对于日期时间类型可以设置每一列的格式。对于数据加载过程中,数据文件中不需要加载的字段,可以使用table_fields参数中的filler关键字将其忽略掉。
SET 指定列值加载,加载系统将待加载文件和指定加载列值加载到集群系统的表中。输入的类型应为常量,包括字符串、整数值、浮点值和NULL。
LINES
TERMINATED BY 行分隔符,支持任意单字符,参数值以引号包围。指定方式与包围符一样。默认行分隔符为’\n’。
MAX_BAD_RECORDS 在每次加载的任务中,设定错误数据行数的上限。当本次加载任务产生的错误数据行数大于max_bad_records设定的值时,加载任务回滚,加载工具报错退出。不指定该参数表示不限制错误条数,指定该参数时,此参数取值范围为:[0, 4294967295]。0表示只要有错误数据就报错退出。最大加载错误数的计算方式:所有集群节点独立计算,一旦有一个节点加载时错误数据达到本限制,则终止所有节点的加载任务。集群加载提交之前检查总错误条数是否超出限制,如果超出限制,放弃提交,报错退出。
DATE FORMAT 用来指定date列类型的默认格式,如’%Y-%m-%d’。
DATETIME FORMAT 用来指定datetime列的默认格式,如’%Y-%m-%d %H:%i:%s’。
TIMESTAMP FORMAT 用来指定timestamp列的默认格式,如’%Y-%m-%d %H:%i:%s.%f’。
TIME FORMAT 用来指定time列的默认格式,如’%H:%i:%s’。
TRACE 用来指示本次加载是否保存错误数据溯源。如果指定为0,则不溯源。如果指定为1,则进行溯源.默认值为1。溯源信息包括:错误数据所在的文件,所在行号。
TRACE_PATH 用来指定本次加载过程中产生的错误数据和日志存放路径。支持设置为本地绝对路径,远程FTP或SFTP目录。在禁用日志汇总功能时,该参数才能起作用,默认值为加载节点的“/opt/gnode/log/gbase/loader_logs”中。
NOSPLIT 用来指定本次加载任务中是否禁用分块加载功能,指定该参数将禁用分块加载功能。不指定该参数,在集群加载时,将自动启动分块加载功能,按照数据量和参与运算的加载节点数对数据进行均匀分块,以均衡数据服务器和数据处理节点的负载,优化加载性能。
PARALLEL 用来控制集群加载并行度,取值范围[0,1024]。默认值为0,表示并行度取值是线程池最大可用线程数。
MAX_DATA_PROCESSORS 用来指定本次加载任务中参与数据解析的处理的最大节点数,取值范围[1, 4294967295],默认值16。
MIN_CHUNK_SIZE 用来指定本次加载任务中数据分块的最小粒度,取值范围[1, 4294967295],默认值64M。
SKIP_BAD_FILE 用来指定本次加载任务中是否忽略不存在或没有读取权限的数据文件继续加载。如果指定为0,则加载报错终止。如果指定为1,则忽略异常文件继续加载。默认值为0。
IGNORE NUM LINES :配置该参数加载工具会将本次加载指定的所有数据文件的表头进行过滤,跳过每个文件的前NUM行(表头所占行数),NUM取值范围为[0,MAX_UINT]。
FILE_FORMAT 用来指定被加载文件的格式。枚举型参数,取值为UNDEFINED、UNCOMPRESSED、GZIP、SNAPPY、LZO,默认为UNDEFINED。指定为UNDEFINED,表示不指定格式,按文件后缀自动判断文件格式;指定为UNCOMPRESSED,表示按普通文本方式加载文件;指定为GZIP,表示按GZIP格式加载文件;指定为SNAPPY,表示按SNAPPY格式加载文件;指定为LZO,表示按LZO格式加载文件。

四、支持的数据源

类型名 备注
S3 本文暂不介绍
local 本文介绍
https 本文暂不介绍
ftp 本文介绍
sftp 本文介绍
hdfs 本文暂不介绍,由于安装包太大,流量不够,下次再写,嘿嘿!!!
gbfs 本文暂不介绍

五、部署FTP服务器

参考原文连接:Linux 上搭建 FTP 服务。

不测试LOAD的FTP加载可以不安装,跳过此步。

1-7步都在192.168.142.11节点执行。

1、安装vsftpd并配置自启

[root@xdw1 ~]# yum install -y vsftpd[root@xdw1 ~]# systemctl enable vsftpd[root@xdw1 ~]# systemctl start vsftpd[root@xdw1 ~]# netstat -npl |grep ftp
tcp        0      0 0.0.0.0:21              0.0.0.0:*               LISTEN      9343/vsftpd

2、创建FTP用户

[root@xdw1 ~]# useradd ftpuser[root@xdw1 ~]# passwd ftpuser

密码我设置的是qwer1234。

3、建目录改权限

[root@xdw1 ~]# mkdir /var/ftp/test[root@xdw1 ~]# chown -R ftpuser:ftpuser /var/ftp/test

4、配置vsftpd.conf

[root@xdw1 ~]# cat /etc/vsftpd/vsftpd.conf
# Example config file /etc/vsftpd/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=YES
#
# Uncomment this to allow local users to log in.
# When SELinux is enforcing check for SE bool ftp_home_dir
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
# When SELinux is enforcing check for SE bool allow_ftpd_anon_write, allow_ftpd_full_access
#anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# Activate logging of uploads/downloads.
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# You may override where the log file goes if you like. The default is shown
# below.
#xferlog_file=/var/log/xferlog
#
# If you want, you can have your log file in standard ftpd xferlog format.
# Note that the default log file location is /var/log/xferlog in this case.
xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode. The vsftpd.conf(5) man page explains
# the behaviour when these options are disabled.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd/banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
# (Warning! chroot'ing can be very dangerous. If using chroot, make sure that
# the user does not have write access to the top level directory within the
# chroot)
chroot_local_user=YES
chroot_list_enable=YES
# (default follows)
chroot_list_file=/etc/vsftpd/chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES
#
# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
listen=YES
#
# This directive enables listening on IPv6 sockets. By default, listening
# on the IPv6 "any" address (::) will accept connections from both IPv6
# and IPv4 clients. It is not necessary to listen on *both* IPv4 and IPv6
# sockets. If you want that (perhaps because you want to listen on specific
# addresses) then you must run two copies of vsftpd with two configuration
# files.
# Make sure, that one of the listen options is commented !!
#listen_ipv6=YESpam_service_name=vsftpd
userlist_enable=YES
#tcp_wrappers=YES

5、配置chroot_list

[root@xdw1 ~]# cat /etc/vsftpd/chroot_list
ftpuser

6、重启FTP服务

[root@xdw1 ~]# systemctl restart vsftpd

7、生成测试文件

[root@xdw1 ~]# cat /var/ftp/test/test.txt
1
2

8、验证FTP服务器(可做可不做)

192.168.142.10节点执行如下命令。

(1)安装FTP命令

yum install ftp

(2)登录FTP拉去文件

[root@xdw0 src]# ftpftp> open 192.168.142.11
Connected to 192.168.142.11 (192.168.142.11).
220 (vsFTPd 3.0.2)
Name (192.168.142.11:root): ftpuser
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.ftp> get /var/ftp/test/test.txt /opt/test.txt
local: /opt/test.txt remote: /var/ftp/test/test.txt
227 Entering Passive Mode (192,168,142,11,22,160).
150 Opening BINARY mode data connection for /var/ftp/test/test.txt (4 bytes).
226 Transfer complete.
4 bytes received in 0.000162 secs (24.69 Kbytes/sec)ftp> quit
221 Goodbye.[root@xdw0 src]# cat /opt/test.txt
1
2

六、测试LOAD

1、FTP

gbase> desc sun;
+-------+---------+------+-----+---------+-------+
| Field | Type    | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| a     | int(11) | YES  |     | NULL    |       |
+-------+---------+------+-----+---------+-------+
1 row in set (Elapsed: 00:00:00.00)gbase> LOAD DATA INFILE 'ftp://ftpuser:qwer1234@192.168.142.11//var/ftp/test/test.txt' into table sun DATA_FORMAT 3 FIELDS TERMINATED BY '|';
Query OK, 2 rows affected (Elapsed: 00:00:00.22)
Task 1310724 finished, Loaded 2 records, Skipped 0 recordsgbase> select * from sun;
+------+
| a    |
+------+
|    1 |
|    2 |
+------+
2 rows in set (Elapsed: 00:00:00.00)

2、SFTP

gbase> LOAD DATA INFILE 'sftp://root:qwer1234@192.168.142.11//var/ftp/test/test.txt' into table sun DATA_FORMAT 3 FIELDS TERMINATED BY '|';
Query OK, 2 rows affected (Elapsed: 00:00:00.77)
Task 1310725 finished, Loaded 2 records, Skipped 0 recordsgbase> select * from sun;
+------+
| a    |
+------+
|    1 |
|    2 |
|    1 |
|    2 |
+------+
4 rows in set (Elapsed: 00:00:00.01)

3、本地

gbase> LOAD DATA INFILE 'file://192.168.142.10//opt/test.txt' into table sun DATA_FORMAT 3 FIELDS TERMINATED BY '|';
Query OK, 2 rows affected (Elapsed: 00:00:00.04)
Task 1310728 finished, Loaded 2 records, Skipped 0 recordsgbase> select * from sun;
+------+
| a    |
+------+
|    1 |
|    2 |
|    1 |
|    2 |
|    1 |
|    2 |
+------+
6 rows in set (Elapsed: 00:00:00.00)

南大通用数据库-Gbase-8a-学习-14-LOAD加载数据相关推荐

  1. linux安装南大通用数据库 GBase 8s V8.8

    linux安装南大通用数据库 GBase 8s V8.8 1.操作系统.数据库 2.下载链接 3.安装文档 4.安装前准备 4.1.以root用户创建 gbasedbt 组和用户 4.2.创建 GBa ...

  2. 南大通用数据库Gbase 8s遇到的坑

    南大通用数据库Gbase 8s的坑 1.没有批量插入,只能在xml循环拼接完整的INSERT语句,而不能拼接多个values 2.关键字段不能用于列查询,如timestamp,需要用表名点列名 3.在 ...

  3. springbootJpa 连接南大通用数据库Gbase配置

    第一步:添加连接驱动包以及hibernate方言包 驱动包下载链接:GBase8sV8.8连接驱动包.zip-其它文档类资源-CSDN下载 第二步:配置连接信息 spring:profiles: de ...

  4. 南大通用数据库(2):客户端的使用(GBase 企业管理器的使用)

    在安装好南大通用服务端之后,安装好客户端之后,测试企业管理器的使用. 服务端是VMware 虚拟机 Centos7.6, IP 是192.168.80.129, PORT是5258 客户端是Win10 ...

  5. 南大通用数据库-Gbase-8a-学习-17-Gbase8a集群版本升级

    一.测试环境 名称 值 cpu Intel® Core™ i5-1035G1 CPU @ 1.00GHz 操作系统 CentOS Linux release 7.9.2009 (Core) 内存 4G ...

  6. 南大通用数据库-Gbase-8a-学习-34-gcdump(导出数据库对象定义)

    目录 一.测试环境 二.介绍 三.命令帮助 四.参数介绍 1.--print-defaults (1)含义 (2)例子 2.--connect_timeout (1)含义 (2)例子 3.-A, -- ...

  7. 南大通用数据库-Gbase-8a-学习-19-Gbase8a从Kafka订阅Topic消费数据

    一.测试环境 名称 值 cpu Intel® Core™ i5-1035G1 CPU @ 1.00GHz 操作系统 CentOS Linux release 7.9.2009 (Core) 内存 4G ...

  8. 南大通用数据库-Gbase-8a-学习-13-配置ODBC数据源(Linux、Win)

    一.测试环境 名称 值 cpu Intel® Core™ i5-1035G1 CPU @ 1.00GHz 操作系统 CentOS Linux release 7.9.2009 (Core) Gbase ...

  9. 南大通用数据库迁移工具使用指南

    一.工具简介 GBase Migration Toolkit 是南大通用自主研发的数据对象迁移工具,能够以图形化界面形式,实现以任务为单位对不同数据库之间库元数据和用户数据的自动迁移. 该工具基于C/ ...

最新文章

  1. Python分析离散心率信号(下)
  2. volatile原理与技巧
  3. 近期发现的一些-20190519
  4. 去除JSP页面中JSTL、EL生成的空行
  5. 无状态会话的ejb_Java EE状态会话Bean(EJB)示例
  6. python怎么加图片_python中如何保存图片
  7. 2万 | 北京做Java开发月薪 2 万,so easy!
  8. HIVE--数据倾斜解决办法
  9. AltiumDesigner画图不求人12 AD库转换为PADS库
  10. 21世纪最需要的7种人才
  11. 烧钱圈地后,医疗大数据如何变现?
  12. 中国人和犹太人做生意的区别
  13. 2021年党员各种谈心谈话记录加空白表
  14. CRC16_CCITT/True的Java计算实现
  15. JDBC从入门到精通
  16. TypeError错误解决方案
  17. 2021年4月26日 星期一 三月十五 阴
  18. 对于拓展欧几里德算法的理解
  19. xhEditor编辑器入门基础
  20. 我只管向前奔跑,其他的交给时间

热门文章

  1. python 'utf-8' codec can't decode byte 0xca in position 21: invalid continuation byte
  2. 频率控制方式及优缺点总结
  3. Linux 压缩、解压缩命令
  4. 怎么压缩视频到最小,什么操作简单
  5. memset 和 bzero的效率测试。
  6. 【Microsoft Azure 的1024种玩法】二十六. 在Azure VM中手动部署Windows Admin Center管理平台
  7. C++11 ThreadPool总结
  8. 关于百度站长工具中站点属性LOGO提交申请详解说明
  9. 区块链学习一--初始比特币
  10. 利用OpenGL设计贪吃蛇游戏