在上一篇文章中,我们介绍了主流商业列存储数据库Sybase IQ 15.2版的功能特点,并给出了tpc-h scala=10,ssb (星型模式)scala=10性能测试的数据。在本文写作之际, Infobright和InfiniDB刚刚发布了新版本,并声称比之前版本性能上有了进一步提升,而sybase IQ的新版v15.3可能要在4、5月份才能推出,据说在压缩、查询和多节点上也有了大幅度提升,这次测试专门基于它们目前各自的最新版本,以反映各种软件的最大性能表现。另外,基于相同的原因,不再测试性能受限的社区版,只测试企业版。 系列文章回顾: 主流列式数据库评测:InfiniDB和MonetDB 主流列式数据库评测之Infobright 主流列式数据库评测:南大通用GBase 8a 主流列式数据库评测:Sybase IQ 一、测试平台 比较测试的平台沿用上篇Sybase IQ安装的机器,是基于Intel Xeon 7550*8的PC服务器上用VMWare VSphere 4.1管理的虚拟机,虚拟机的逻辑CPU个数是8,内存100GB,存储为8个300GB本地磁盘的RAID5阵列。操作系统采用和RHEL 5相同的核心级别的Red Flag Asian Linux Sever 3.0 x64。用于比较的Oracle采用11.2.0.2版本,本次测试采用了并行查询的方式。由于Linux是互联网公司常用的服务器操作系统,因此这一测评,对更大范围的用户也有参考价值。 二、安装 我们先来安装Infobright和InfiniDB这两个轻量级的数据库的Linux版,虽然比Windows版本复杂一些,但Infobright官方wiki提供的安装文章只有一页,可想而知安装是多么容易,InfiniDB的安装手册页数略多,但包含了升级、集群等复杂安装模式,总体而言,单服务器新装软件还是相当快捷的。下面分别是各种软件的安装步骤。 (一) Infobright的安装步骤 1. 注册新用户从http://support.infobright.com/Support/Downloads下载对应操作系统的安装包IEE v3.5.2 64-Bit RPM (Red Hat Enterprise 5.x and CentOS 5.x)(69M) ,infobright-3.5.2-0-x86_64-eval.rpm,如果没有测试授权lic文件,也要申请一个。 2.登录到操作系统,在软件存放目录输入下面的命令安装软件。 rpm -ivh infobright-3.5.2-0-x86_64-eval.rpm Preparing... ########################################### [100%] Installing infobright 3.5.2-0 (x86_64_eval) The installer will generate /tmp/ib3.5.2-0-install.log install trace log. 1:infobright ########################################### [100%] Creating/Updating datadir and cachedir Creating user mysql and group mysql Installing default databases Installing MySQL system tables... OK Filling help tables... OK To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /usr/local/infobright-3.5.2-x86_64/bin/mysqladmin -u root password "new-password" /usr/local/infobright-3.5.2-x86_64/bin/mysqladmin -u root -h redflag11012601.localdomain password "new-password" Alternatively you can run: /usr/local/infobright-3.5.2-x86_64/bin/mysql_secure_installation which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the manual for more instructions. You can start the MySQL daemon with: cd /usr/local/infobright-3.5.2-x86_64 ; /usr/local/infobright-3.5.2-x86_64/bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd /usr/local/infobright-3.5.2-x86_64/mysql-test ; perl mysql-test-run.pl Please report any problems with the /usr/local/infobright-3.5.2-x86_64/scripts/mysqlbug script! The latest information about MySQL is available at http://www.mysql.com/ Support MySQL by buying support/licenses from http://shop.mysql.com/ System Physical memory: 100723(MB) Infobright optimal ServerMainHeapSize is set to 32000(MB) Infobright optimal LoaderMainHeapSize is set to 800(MB) Infobright server installed into folder /usr/local/infobright Installation log file /tmp/ib3.5.2-0-install.log Installation of 3.5.2-0 completed! 3.将授权文件拷贝到安装目录,注意这个授权文件的有效期是从申请日开始计时的,不分操作系统平台和数据库软件版本。 cp /user1/app/*lic /usr/local/infobright-3.5.2-x86_64/ 4.用/etc/init.d/mysqld-ib start命令启动infobright,并用mysql-ib连接数据库。 [root@redflag11012601 app]# /etc/init.d/mysqld-ib start Starting MySQL.[确定] [root@redflag11012601 app]# mysql-ib Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.1.40 build number (revision)=IB_3.5.2_r11794_12019(iee_eval - commercial) Type "help;" or "\h" for help. Type "\c" to clear the current input statement. mysql> 5.安装完后可以执行脚本以改变安装选项,比如数据存储位置,这一步是可选的,并且可以在任何时候根据需要关闭数据库执行。注意最后一步删除原有存储位置的数据在3.42版是脚本自动完成的,而3.52版让用户手工执行,更有利于数据的安全。 [root@redflag11012601 bin]# /etc/init.d/mysqld-ib stop Shutting down MySQL...[确定] [root@redflag11012601 infobright-3.5.2-x86_64]# ./postconfig.sh Infobright post configuration Using postconfig, you can: (1) Move existing data directory to other location, (2) Move existing cache directory to other location, (3) Configure server socket, (4) Configure server port, (5) Relocate datadir path to an existing data directory. Please type "y" for option that you want or press ctrl+c for exit. (1) Do you want to move current datadir [/usr/local/infobright-3.5.2-x86_64/data]? [y/n]:y Give new datadir path (e.g. /opt/datadirnewpath/data):/user1/infbhtdata (2) Do you want to move current CacheFolder [/usr/local/infobright-3.5.2-x86_64/cache]? [y/n]:n (3) Do you want to change current socket [/tmp/mysql-ib.sock]? [y/n]:n (4) Do you want to change current port [5029]? [y/n]:n (5) Relocation is disabled when options 1-4 are chosen! New datadir is going to be /user1/infbhtdata Please confirm to proceed? [y/n]:y Copying /usr/local/infobright-3.5.2-x86_64/data to /user1/infbhtdata ...is done. You can now remove your old /usr/local/infobright-3.5.2-x86_64/data ... Done! (二) InfiniDB的安装步骤 1.从http://www.calpont.com/resources/resource-library/category/3-infinidb-enterprise-edition下载对应操作系统的安装包InfiniDB Enterprise Edition Trial Software - 64 bit RPMs (26.17 MB),calpont-infinidb-2.0.3-4.x86_64.rpm.tar.gz。 2.登录到操作系统,在软件存放目录输入下面的命令解压缩安装包并安装软件。 tar zxf calpont-infinidb-2.0.3-4.x86_64.rpm.tar.gz rpm -ivh cal*rpm [root@redflag11012601 app]# rpm -ivh cal*rpm Preparing... ########################################### [100%] 1:calpont ########################################### [ 33%] Calpont RPM install completed 2:calpont-mysqld ########################################### [ 67%] Calpont RPM install completed 3:calpont-mysql ########################################### [100%] Calpont RPM install completed 3.运行/usr/local/Calpont/bin/postConfigure,执行安装后配置,这一步是必须的。主要用于初始化InfiniDB数据库,以及将后台服务进程加入/etc/init.d/,令数据库随系统重启自动启动。 [root@redflag11012601 app]# /usr/local/Calpont/bin/postConfigure This is the Calpont InfiniDB System Configuration and Installation tool. It will Configure the Calpont InfiniDB System based on user inputs and will perform a Package Installation of all of the Servers within the System that is being configured. IMPORTANT: This tool should only be run on the Parent OAM Module which is either a Management Module #1 or a Performance Module. Instructions: Press "enter" to accept a value in (), if available or Enter one of the options within [], if available, or Enter a new value Select the type of server install [1=single, 2=multi] (2) > 1 Performing a Single Server Install. A copy of the InfiniDB Configuration file has been saved during Package install. You have an option of utilizing the configuration data from that file or starting with the InfiniDB Configuration File that comes with the InfiniDB Package. Do you want to utilize the configuration data from the saved copy? [y,n] > y ===== Setup Data Storage Mount Configuration ===== Enter InfiniDB Data Storage Mount Type [storage,local] (local) > Enter the Number of InfiniDB Data Storage (DBRoots) areas (1) > Setting Max Memory Settings to 25% of total memory. Value set to 16G Running the Infinidb MySQL setup scripts Starting MySQL.[确定] Shutting down MySQL.[确定] Starting MySQL.[确定] Shutting down MySQL.[确定] Starting Calpont InfiniDB Database Platform Starting MySQL.[确定] Please wait......... DONE Creating System Catalog.. DONE InfiniDB Install Successfully Completed Enter the following command to define InfiniDB Alias Commands . /usr/local/Calpont/bin/calpontAlias Enter "idbmysql" to access the mysqld console Enter "cc" to access the InfiniDB OAM console 如果执行脚本出现错误,需要解决错误后,关闭数据库后台服务进程再执行上述脚本。 [root@redflag11012601 app]# /etc/init.d/infinidb stop Shutting down Calpont InfiniDB Database Platform 如果执行配置脚本无误,运行产生别名的脚本,便于用户执行各种管理命令。 [root@redflag11012601 app]# . /usr/local/Calpont/bin/calpontAlias [root@redflag11012601 app]# idbmysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.1.39 MySQL Embedded / Calpont InfiniDB Enterprise 2.0.3-4 GA (Commercial) Type "help;" or "\h" for help. Type "\c" to clear the current input statement. mysql> InfiniDB无法直接改变数据的存储位置,但安装文档指出在Linux系统中可以将/usr/local/Calpont/下的data1目录挂载(mount)到外部存储,实际上也可以用软连接(ln -s)指向一个空闲空间较多的分区。利用软连接的操作步骤如下: 1)在安装完InfiniDB数据库软件,尚未配置之前将安装目录下的data1目录的内容移动到另一个空闲目录下。 [root@redflag11012601 app]# cd /usr/local/Calpont [root@redflag11012601 Calpont]# mv data1/* /user1/caldata/ [root@redflag11012601 Calpont]# ll data1 总计 0 [root@redflag11012601 Calpont]# ll /user1/caldata/ 总计 4 drwxrwxrwt 4 root root 4096 02-12 18:45 systemFiles 2)删除这个data1目录,并创建一个同名的软连接 [root@redflag11012601 Calpont]# rmdir data1 [root@redflag11012601 Calpont]# ln -s /user1/caldata /usr/local/Calpont/data1 [root@redflag11012601 Calpont]# ll 总计 44 drwxr-xr-x 2 root root 4096 02-12 18:45 bin drwxr-xr-x 3 root root 4096 02-12 18:45 data lrwxrwxrwx 1 root root 14 02-12 18:51 data1 -> /user1/caldata drwxrwxrwt 2 root root 4096 02-12 18:45 etc drwxr-xr-x 2 root root 4096 02-12 18:45 lib drwxr-xr-x 2 root root 4096 02-12 18:45 local drwxr-xr-x 6 root root 4096 02-12 18:45 mysql drwxr-xr-x 2 root root 4096 02-12 18:45 post -rw-rr 1 root root 78 02-03 09:19 releasenum drwxr-xr-x 2 root root 4096 02-12 18:45 sbin drwxr-xr-x 3 root root 4096 02-12 18:45 share drwxr-xr-x 3 root root 4096 02-12 18:45 tools 3)执行安装后配置 [root@redflag11012601 Calpont]# cd bin [root@redflag11012601 bin]# ./postConfigure 注意:如果数据库已经配置过并创建了新的内容,需要关闭数据库才能进行移动操作,但不建议这么做,如果操作失误,可能导致启动失败或数据丢失。尽量在数据库安装阶段就规划好磁盘分布。 三、功能比较 各种数据库提供的主要功能在前面的文章中有过详细介绍,这里简述一下它们有区别的地方。 1. 对SQL标准的支持 SybaseIQ对SQL标准的支持程度较高,具备其他列式数据库不具备的建立索引和主键功能。其他列式数据库还不支持分析函数和group by cube等扩展语法。 2. 数据库指定数据存储位置 我们在安装过程中特别关注能否改变数据存储位置,因为一般Linux系统的/usr/local空间很有限,主要用于保存软件的二进制文件,而用户数据需要保存在其它位置,现在我们看到,各种数据库都具备了这方面的能力。无论是通过配置脚本、操作系统系统命令或SQL语句,都能最终完成任务。如果是不支持软连接的Windows操作系统,InfiniDB的存储位置在安装后不可改变,因此要特别注意将软件安装到空间较大的硬盘分区。 3. 数据加载错误处理 默认情况下,如果数据加载时错误Sybase IQ会报错并中止导入,所有数据回滚,而Infobright和InfiniDB会忽略错误继续导入。Sybase IQ也可以忽略错误继续导入,但需要在Load脚本中加入ON FILE ERROR CONTINUE语句。 4. 数据库空间扩展 Sybase IQ、Infobright和InfiniDB都可以自动自动增长,SybaseIQ 还可以人工创建和维护数据库空间,并支持裸设备。 四、性能测试 测试项目包含三方面,第一是加载,数据仓库要处理的数据量巨大,数据加载能力是选择数据库软件要考虑的重要因素之一,我们将测试包括外部文本数据加载和从数据库内部抽取部分数据到其他表的性能。第二是压缩,数据压缩时常被作为列式存储数据库的一个卖点来宣传,因此我们单独把它拿出来测试。由于多数数据库没有单独的表压缩命令,都是依靠参数指定是否压缩或根本无法指定不压缩(Sybase IQ),只测试压缩后的占用空间对原始外部文件的压缩率。第三是测试重点,数据查询,分别采用tpc-h scala=10,SSB (星型模式基准)scala=10数据作全表分组查询。 (一) 数据加载 1. 从外部文本文件导入 4种数据库分别采用各自推荐的最快的导入方式。Oracle用sqlldr直接路径加载,Infobright用自带的加载引擎使用load data命令。InfiniDB利用cpimport 采用8个读入和写入进程的参数,Sybase利用前面介绍的Load table方式。为了解决末尾一个列分隔符的问题,利用了命名管道,这个转换的负担很轻,基本不影响导入速度。 Gzip解压缩“管道”的负担对数据加载而言很轻,因为此时解压缩无论是消耗的CPU还是I/O比起文件加载到数据库都不是瓶颈。如果实际工作中经常需要将大量数据搬移到另一台机器使用,采用gzip格式是个很不错的选择。采用并行gzip工具pigz可以充分利用cpu资源大幅度提升压缩速度。 [oracle@redflag11012501 oradata]$ gzip stdout -d /user1/app/oradata/hui1.csv.gz > /user1/app/oradata/hui_np.txt & [1] 7993 [oracle@redflag11012501 oradata]$ date;sqlldr rk/RK control=/user1/app/oradata/hui_sqlldr.ctl streamsize=8192000 direct=true;date InfiniDB只支持外部数据数据来源被重定向到STDIN标准输入,而不支持其它的命名管道,另外3种数据库都支持命名管道方式。不过cpimport是一个独立的可执行文件,而不需要用命令行工具登录后再执行内部命令,不支持命名管道也不是什么大问题。 [root@redflag11012601 bin]# cat /user1/app/data/lineitem.tbl tr -d "\r" /usr/local/Calpont/bin/cpimport -j 5 -fSTDIN -r8 -w8 [root@redflag11012601 bin]# gzip stdout -d /user1/app/hu.csv.gz /usr/local/Calpont/bin/cpimport -j 1 -fSTDIN -r8 -w8 由于原始数据当中存在一些不是数字的非法值,导入SybaseIQ失败。我们在Sybase IQ导入整数类型的HUI表时也采用了命名管道,与前一个转换相比,这个awk转换大大降低了加载速度,时间达到11118.569秒,缺乏可比性,因此利用Sybase导出此表的文本文件,重新导入再计时。其他数据库都是利用Sybase导出的文本文件加载的。 Infobright不知何故,当数据加载引擎设为Infobright的文本方式(set @BH_DATAFORMAT="txt_variable")时,导入SSB数据集某些表总是出错,但最大的lineorder表反而能够导入成功,因此其它小表采用mysql加载引擎加载,速度稍慢,但总时间影响不大。由于ren表记录实在太多,原始数据又带有一些不是整数的非法值,因此没有在Oracle和SybaseIQ中进行字符到整数类型的转换,依靠hui表已经足够说明问题。 对于RK数据集,Infobright在利用Infobright加载引擎并关闭自动提交的情况下,仍然比其他数据库慢很多,耗费时间大约是InfiniDB的4到5倍,原因是它的高压缩比要耗费大量的CPU等资源,拖累了导入的性能,如果它能适当地在压缩比和时间之间取得一个平衡,就更实用了。
各种数据库加载外部文本文件时间 (单位:秒)
把上述数据制作成统计图如下:纵坐标是时间,单位:秒。 】 我们看到对TPC-H数据和SSB数据,Sybase IQ的导入时间最短,对于用户自定义数据,InfiniDB的导入时间最短,Oracle的sqlldr导入一般不如列存储数据库,除了自定义数据集,但Oracle的导入时间不包括数据压缩,若指定导入压缩表,则时间大大增加,不如导入完成以后在数据库中并行转换为压缩格式来得高效。对于Infobright和InfiniDB,导入列类型为整数的表速度更快,而SybaseIQ则不是,对rk的hui表平均比字符类型的hu表慢50%。 SybaseIQ不但从外部文本格式文件导入文本表比导入整数类型更快,导出也是同样的结果,看来它的数据类型转换的开销还真的很大。 我们看到对TPC-H数据和SSB数据,Sybase IQ的导入时间最短,对于用户自定义数据,InfiniDB的导入时间最短,Oracle的sqlldr导入一般不如列存储数据库,除了自定义数据集,但Oracle的导入时间不包括数据压缩,若指定导入压缩表,则时间大大增加,不如导入完成以后在数据库中并行转换为压缩格式来得高效。对于Infobright和InfiniDB,导入列类型为整数的表速度更快,而SybaseIQ则不是,对rk的hui表平均比字符类型的hu表慢50%。 SybaseIQ不但从外部文本格式文件导入文本表比导入整数类型更快,导出也是同样的结果,看来它的数据类型转换的开销还真的很大。 2. 从数据库内部抽取部分数据到其他表 各种数据库从库内转移数据的能力各不相同,Infobright,SybaseIQ,Oracle均支持insert into 表1 select * from 表2这种方式。 Infobright 虽然支持这种方式,但它的内部操作过程,是先把压缩数据解压缩到cache目录,然后从cache目录读取数据插入压缩表,当数据量较大时,这种做法不但占用了大量磁盘空间,转换时间很长,而且还很容易失败,不如将数据先导出为文本,再用load data加载效率高,因此实用性有限。 InfiniDB不支持子查询插入,只能通过文本或操作系统管道导出和导入,这点也有待加强。那么只剩下Sybase和Oracle可以一较高下了。 我们从hu表取出ID第一位为"1"的记录保存到hu1表,Oracle占用的时间是56.99秒,上篇文章SybaseIQ的用时是271.953秒。但考虑到SybaseIQ自动创建索引的消耗,这个时间差是可以接受的。 Oracle的命令行: SQL> create table hu1 compress parallel(degree 8) partition by range(id) (partition p11 values less than ("12"), partition p12 values less than ("13"), partition p13 values less than ("14"), partition p14 values less than ("15"), partition p15 values less than ("16") ) as select /*+parallel (hu,8)*/ * from hu where id < "2"; 表已创建。 已用时间: 00: 01: 13.04 SQL> select count(*) from hu1; COUNT(*) 41533005 已用时间: 00: 00: 00.51 (二) 数据压缩 Sybase IQ采用sp_iqtablesize("用户名.表名")查看各个表占用的空间大小。我们将Kbytes的数据换算成GB。 Oracle采用查询USER_SEGMENT数据字典的bytes列的总和查看。同样换算成GB。 Infobright采用du -sh 目录名 查看数据存储目录下的物理文件大小。或者查询information_schema系统库的tables表,这2种方法得到的结果是相近的。 mysql> SELECT TABLE_SCHEMA,TABLE_NAME,DATA_LENGTH+INDEX_LENGTH,TABLE_ROWS FROM TABLES WHERE TABLE_SCHEMA in ("tpch2")order by 1,2; +++++ TABLE_SCHEMA TABLE_NAME DATA_LENGTH+INDEX_LENGTH TABLE_ROWS +++++ tpch2 CUSTOMER 80638414 1500000 tpch2 LINEITEM 1284138449 59986052 tpch2 NATION 1830 25 tpch2 ORDERS 314605383 15000000 tpch2 PART 31483651 2000000 tpch2 PARTSUPP 235571312 8000000 tpch2 REGION 907 5 tpch2 SUPPLIER 5179217 100000 +++++ [root@redflag11012601 infbhtdata]# du -s tpch2/*bht 78964 tpch2/CUSTOMER.bht 1255568 tpch2/LINEITEM.bht 80 tpch2/NATION.bht 307708 tpch2/ORDERS.bht 30932 tpch2/PART.bht 230384 tpch2/PARTSUPP.bht 64 tpch2/REGION.bht 5192 tpch2/SUPPLIER.bht InfiniDB的information_schema系统库的信息不正确,也没有提供其它的函数或过程,只能从磁盘空间粗略估算,而且它的命名规律不是人能读懂的格式,只能从导入前后的空间差计算,这点不太方便,有待改进。Calpont的技术支持给我提供了一套脚本,在Linux操作系统下运行,可以列出数据库、表、列占用的存储空间,本文的数据就用此脚本的结果。 [root@redflag11012601 scripts]# ./databaseSizeReport.sh ssb: 4.48282 GB tpch: 8.18472 GB rk: 30.4541 GB rki: 17.3675 GB 为了给出和专用压缩工具压缩绿的比较,专门引入了gzip格式的默认压缩文件大小。 我们将原始csv文件的大小除以各种数据库压缩后的数据大小,得到的倍数作为它们的压缩率,得到下面的表格: 由此得到的统计图如下:
评论