热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

数据仓库的未来MariaDBColumnStore

MariaDBColumnStore简介Part1:写在最前MariaDBColumnStoreisthefutureofdatawarehousing.ColumnStoreal

技术分享

MariaDB ColumnStore

简介

Part1:写在最前

MariaDB ColumnStore is the future of data warehousing. ColumnStore allows us to store more data and analyze it faster. Everyday, Pinger’s mobile applications process millions of text messages and phone calls. We also process more than 1.5 billion rows of logs per day. Analytic scalability and performance is critical to our business. MariaDB’s ColumnStore manages massive amounts of data and will scale with Pinger as we grow.

                             ----from mariadb.com


Part2:大牛如何说

MariaDB ColumnStore是在MariaDB 10.1基础上移植了InfiniDB4.6.2构建的大规模并行,高性能,压缩,分布式开源列式存储引擎,类似收费产品Infobright。它设计用于大数据离线分析,用来抗衡Hadoop。你可以使用标准SQL语句进行查询,支持目前流行的sqlyog/navicat客户端工具连接,对业务方使用没有任何的不便,并且你不需要创建任何索引,不需要修改业务方的复杂SQL(自身就支持复杂的关联查询、聚合、存储过程和用户定义的函数),你唯一要做的就是把数据导入到ColumnStore里,就没你事了。这对一家没有Hadoop工程师的公司来说,MariaDB ColumnStore会是一个更好的替代产品。

                                                        -----from 贺春旸


Part3:环境简介

192.168.1.248 HE1 um1

192.168.1.249 HE2 um2

192.168.1.250 HE3 pm1

192.168.1.251 HE4 pm2

Column Store架构概述

Part1:写在最前

MariaDB ColumnStore是一种专为分布式大规模并行处理(MPP)设计的列式存储引擎。它由三个组件组成,协同工作。

技术分享




在官方给出的架构图中,我们可以看到分为三个组件构成:UM、PM、数据存储层。


用户模块(UM):

用户模块管理和控制终端用户查询的操作,它维护每个查询的状态,向一个或多个性能模块发出请求以代为执行SQL查询工作,最后,用户模块汇集来自各个参与的性能模块的所有查询结果,以形成返回给用户的完整的查询结果集。


性能模块(PM):

性能模块负责存储,检索和管理数据,处理对查询操作的块请求,并将其传递回用户模块以完成查询请求。性能模块将获取的数据缓存在其内存中计算。MPP是通过允许用户配置尽可能多的性能模块,以实现更高的处理能力。


存储:

MariaDB ColumnStore对于存储系统极为灵活。当在内部运行时,它可以使用本地存储或共享存储(例如SAN)来存储数据。在Amazon EC2环境中,它可以使用临时或弹性块存储(EBS)卷。当无共享部署需要数据冗余时,它被构建为与GlusterFS和Apache Hadoop分布式文件系统(HDFS)集成。


一句话总结:用户模块(UM)将客户端发出的SQL请求进行分配,分配到后端性能模块(PM),PM进行数据查询分析,将处理的结果返回给UM,UM再把PM分析的结果进行聚合,最后返回给客户端最终的查询结果。


Column Store性能对比

Percona专业MySQL服务提供商性能测试InfiniDB比其他OLAP优势明显。

技术分享

Column Store安装

Part1:打通互信

[root@HE1 ~]# ssh-keygen
[root@HE1 ~]# ssh-copy-id ‘-p 22 root@192.168.1.248‘
[root@HE1 ~]# ssh-copy-id ‘-p 22 root@192.168.1.249‘
[root@HE1 ~]# ssh-copy-id ‘-p 22 root@192.168.1.250‘
[root@HE1 ~]# ssh-copy-id ‘-p 22 root@192.168.1.251‘
[root@HE1 ~]# ssh HE1
[root@HE1 ~]# ssh HE2
[root@HE1 ~]# ssh HE3
[root@HE1 ~]# ssh HE4
[root@HE1 ~]# cat /etc/hosts
192.168.1.248   HE1
192.168.1.249   HE2
192.168.1.250   HE3
192.168.1.251   HE4

在HE1,HE2,HE3,HE4每台机器上执行上述命令,打通ssh互信。


Part2:关闭防火墙

[root@HE1 ~]# /etc/init.d/iptables status

iptables: Firewall is not running.

[root@HE1 ~]# chkconfig iptables off

[root@HE1 ~]# chkconfig --list | grep iptables

iptables       0:off1:off2:off3:off4:off5:off6:off


Part3:关闭文件系统访问时间和修改磁盘调度策略

[root@HE1 ~]# cat /etc/fstab 

#
# /etc/fstab
# Created by anaconda on Sat Mar  5 09:35:40 2016
#
# Accessible filesystems, by reference, are maintained under ‘/dev/disk‘
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=397d50ba-22b0-4d50-9e29-89e3b92d2d07 /                       ext4    defaults,noatime,barrier=0        1 1


[root@HE1 ~]# echo "deadline" > /sys/block/sda/queue/scheduler


Part4:关闭numa

[root@HE1 ~]# cat /etc/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/sda2
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=1
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32-573.18.1.el6.x86_64.debug)
root (hd0,0)
kernel /vmlinuz-2.6.32-573.18.1.el6.x86_64.debug ro root=UUID=397d50ba-22b0-4d50-9e29-89e3b92d2d07 rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFOnT=latarcyrheb-sun16 crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet numa=off
initrd /initramfs-2.6.32-573.18.1.el6.x86_64.debug.img
title CentOS (2.6.32-431.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-431.el6.x86_64 ro root=UUID=397d50ba-22b0-4d50-9e29-89e3b92d2d07 rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFOnT=latarcyrheb-sun16 crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet numa=off
initrd /initramfs-2.6.32-431.el6.x86_64.img


Part5:安装jemalloc内存管理

[root@HE1 ~]# yum install jemalloc-*

[root@HE1 ~]# reboot

在HE1,HE2,HE3,HE4每台机器上执行上述命令


Part6:安装boost软件包

[root@HE1 ~]# yum -y install boost*

[root@HE1 ~]# yum -y groupinstall "Development Tools"

[root@HE1 ~]# yum -y install cmake

[root@HE1 ~]# tar xvf boost_1_55_0.tar.gz

[root@HE1 ~]# cd boost_1_55_0

[root@HE1 boost_1_55_0]#  ./bootstrap.sh   --with-libraries=atomic,date_time,exception,filesystem,iostreams,locale,program_options,regex,signals,system,test,thread,timer,log   --prefix=/usr

[root@HE1 boost_1_55_0]# ./b2 install


Part6:安装perl依赖包

[root@HE1 ~]#  yum -y install expect perl perl-DBI openssl zlib   perl-DBD-MySQL


Part7:安装Mariadb ColumStore

[root@HE1 ~]# tar xvf mariadb-columnstore-1.0.6-1-centos6.x86_64.bin.tar.gz -C /usr/local


Part8:配置Mariadb ColumStore

[root@HE1 ~]# /usr/local/mariadb/columnstore/bin/postConfigure

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

至此,MariaDB ColumnStore安装并配置完成


Column Store单点故障测试

Part1:关闭HE2


当前HE2为primary um

mcsadmin> getSystemStatus
getsystemstatus   Mon Dec 26 15:56:47 2016
System columnstore-1
System and Module statuses
Component     Status                       Last Status Change
------------  --------------------------   ------------------------
System        BUSY_INIT                    Mon Dec 26 15:56:38 2016
Module um1    AUTO_DISABLED/DEGRADED       Mon Dec 26 15:56:40 2016
Module um2    ACTIVE                       Mon Dec 26 15:54:21 2016
Module pm1    ACTIVE                       Mon Dec 26 02:03:27 2016
Module pm2    ACTIVE                       Mon Dec 26 02:03:41 2016
Active Parent OAM Performance Module is ‘pm1‘
Primary Front-End MariaDB Columnstore Module is ‘um2‘
MariaDB Columnstore Replication Feature is enabled
[root@HE2 ~]# reboot

在当前primary um重启后,可以看到primary um已经自动切换至um1

mcsadmin> getSystemStatus
getsystemstatus   Mon Dec 26 15:58:19 2016
System columnstore-1
System and Module statuses
Component     Status                       Last Status Change
------------  --------------------------   ------------------------
System        BUSY_INIT                    Mon Dec 26 15:58:10 2016
Module um1    ACTIVE                       Mon Dec 26 15:57:17 2016
Module um2    AUTO_DISABLED/DEGRADED       Mon Dec 26 15:58:11 2016
Module pm1    ACTIVE                       Mon Dec 26 02:03:27 2016
Module pm2    ACTIVE                       Mon Dec 26 02:03:41 2016
Active Parent OAM Performance Module is ‘pm1‘
Primary Front-End MariaDB Columnstore Module is ‘um1‘
MariaDB Columnstore Replication Feature is enabled


Part2:检查状态

在原primary um (HE2)中进入数据库查看,现在已经是um1的从库

[root@HE2 ~]# mcsmysql 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 10.1.19-MariaDB Columnstore 1.0.6-1
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
MariaDB [(none)]> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 192.168.1.248
                  Master_User: idbrep
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000013
          Read_Master_Log_Pos: 1879
               Relay_Log_File: relay-bin.000002
                Relay_Log_Pos: 537
        Relay_Master_Log_File: mysql-bin.000013
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: 
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 1879
              Relay_Log_Space: 829
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File: 
           Master_SSL_CA_Path: 
              Master_SSL_Cert: 
            Master_SSL_Cipher: 
               Master_SSL_Key: 
        Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 1
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
                   Using_Gtid: No
                  Gtid_IO_Pos: 
      Replicate_Do_Domain_Ids: 
  Replicate_Ignore_Domain_Ids: 
                Parallel_Mode: conservative
1 row in set (0.00 sec)
MariaDB [(none)]>


Column Store测试

Part1:主键和索引

MariaDB [helei]> create table helei_innodb(
    -> id int(10) unsigned NOT NULL AUTO_INCREMENT,
    -> c1 int(10) NOT NULL DEFAULT ‘0‘,
    -> c2 int(10) unsigned DEFAULT NULL,
    -> c5 int(10) unsigned NOT NULL DEFAULT ‘0‘,
    -> c3 timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    -> c4 varchar(200) NOT NULL DEFAULT ‘‘,
    -> PRIMARY KEY(id),
    -> KEY idx_c1(c1),
    -> KEY idx_c2(c2)
    -> )ENGINE=InnoDB ;
Query OK, 0 rows affected (0.03 sec)
MariaDB [helei]> create table helei_cs(
    -> id int(10) unsigned NOT NULL AUTO_INCREMENT,
    -> c1 int(10) NOT NULL DEFAULT ‘0‘,
    -> c2 int(10) unsigned DEFAULT NULL,
    -> c5 int(10) unsigned NOT NULL DEFAULT ‘0‘,
    -> c3 timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    -> c4 varchar(200) NOT NULL DEFAULT ‘‘,
    -> PRIMARY KEY(id),
    -> KEY idx_c1(c1),
    -> KEY idx_c2(c2)
    -> )ENGINE=Columnstore;
ERROR 1069 (42000): Too many keys specified; max 0 keys allowed

这里可以看出,columnstore存储引擎不支持主键也不需要索引

MariaDB [helei]> create table helei_cs(
    -> id int(10) unsigned NOT NULL ,
    -> c1 varchar(200) NOT NULL DEFAULT ‘‘
    -> )ENGINE=Columnstore;
Query OK, 0 rows affected (0.34 sec)
MariaDB [helei]> insert into helei_cs values(1,‘1‘);
Query OK, 1 row affected (0.60 sec)
MariaDB [helei]> insert into helei_cs values(2,‘2‘);
Query OK, 1 row affected (0.08 sec)
MariaDB [helei]> insert into helei_cs values(3,‘3‘);
Query OK, 1 row affected (0.17 sec)

这里可以看出columnstore的插入速度较慢


Warning:

columnstore不支持主键、索引、timestamp、collate用法、char\varchar类型的sum/average用法。



Part2:效率测试

1G内存虚拟机MariaDB ColumnStore 2.82s,线上生产库8G的innodb_buffer_pool_size该条慢查询耗时17.894s。

技术分享

技术分享




——总结——

大家可以用生产的复杂SQL跑一跑,来体验一下。由于笔者的水平有限,编写时间也很仓促,文中难免会出现一些错误或者不准确的地方,不妥之处恳请读者批评指正。


本文出自 “贺磊的技术博客” 博客,请务必保留此出处http://suifu.blog.51cto.com/9167728/1886417

数据仓库的未来 MariaDB ColumnStore


推荐阅读
  • 本文介绍了lua语言中闭包的特性及其在模式匹配、日期处理、编译和模块化等方面的应用。lua中的闭包是严格遵循词法定界的第一类值,函数可以作为变量自由传递,也可以作为参数传递给其他函数。这些特性使得lua语言具有极大的灵活性,为程序开发带来了便利。 ... [详细]
  • HDU 2372 El Dorado(DP)的最长上升子序列长度求解方法
    本文介绍了解决HDU 2372 El Dorado问题的一种动态规划方法,通过循环k的方式求解最长上升子序列的长度。具体实现过程包括初始化dp数组、读取数列、计算最长上升子序列长度等步骤。 ... [详细]
  • 本文讨论了Alink回归预测的不完善问题,指出目前主要针对Python做案例,对其他语言支持不足。同时介绍了pom.xml文件的基本结构和使用方法,以及Maven的相关知识。最后,对Alink回归预测的未来发展提出了期待。 ... [详细]
  • 本文介绍了C#中数据集DataSet对象的使用及相关方法详解,包括DataSet对象的概述、与数据关系对象的互联、Rows集合和Columns集合的组成,以及DataSet对象常用的方法之一——Merge方法的使用。通过本文的阅读,读者可以了解到DataSet对象在C#中的重要性和使用方法。 ... [详细]
  • 本文介绍了OC学习笔记中的@property和@synthesize,包括属性的定义和合成的使用方法。通过示例代码详细讲解了@property和@synthesize的作用和用法。 ... [详细]
  • 本文介绍了在SpringBoot中集成thymeleaf前端模版的配置步骤,包括在application.properties配置文件中添加thymeleaf的配置信息,引入thymeleaf的jar包,以及创建PageController并添加index方法。 ... [详细]
  • 知识图谱——机器大脑中的知识库
    本文介绍了知识图谱在机器大脑中的应用,以及搜索引擎在知识图谱方面的发展。以谷歌知识图谱为例,说明了知识图谱的智能化特点。通过搜索引擎用户可以获取更加智能化的答案,如搜索关键词"Marie Curie",会得到居里夫人的详细信息以及与之相关的历史人物。知识图谱的出现引起了搜索引擎行业的变革,不仅美国的微软必应,中国的百度、搜狗等搜索引擎公司也纷纷推出了自己的知识图谱。 ... [详细]
  • 本文详细介绍了Linux中进程控制块PCBtask_struct结构体的结构和作用,包括进程状态、进程号、待处理信号、进程地址空间、调度标志、锁深度、基本时间片、调度策略以及内存管理信息等方面的内容。阅读本文可以更加深入地了解Linux进程管理的原理和机制。 ... [详细]
  • 后台获取视图对应的字符串
    1.帮助类后台获取视图对应的字符串publicclassViewHelper{将View输出为字符串(注:不会执行对应的ac ... [详细]
  • 《数据结构》学习笔记3——串匹配算法性能评估
    本文主要讨论串匹配算法的性能评估,包括模式匹配、字符种类数量、算法复杂度等内容。通过借助C++中的头文件和库,可以实现对串的匹配操作。其中蛮力算法的复杂度为O(m*n),通过随机取出长度为m的子串作为模式P,在文本T中进行匹配,统计平均复杂度。对于成功和失败的匹配分别进行测试,分析其平均复杂度。详情请参考相关学习资源。 ... [详细]
  • Java验证码——kaptcha的使用配置及样式
    本文介绍了如何使用kaptcha库来实现Java验证码的配置和样式设置,包括pom.xml的依赖配置和web.xml中servlet的配置。 ... [详细]
  • 高质量SQL书写的30条建议
    本文提供了30条关于优化SQL的建议,包括避免使用select *,使用具体字段,以及使用limit 1等。这些建议是基于实际开发经验总结出来的,旨在帮助读者优化SQL查询。 ... [详细]
  • 本文介绍了指针的概念以及在函数调用时使用指针作为参数的情况。指针存放的是变量的地址,通过指针可以修改指针所指的变量的值。然而,如果想要修改指针的指向,就需要使用指针的引用。文章还通过一个简单的示例代码解释了指针的引用的使用方法,并思考了在修改指针的指向后,取指针的输出结果。 ... [详细]
  • 在project.properties添加#Projecttarget.targetandroid-19android.library.reference.1..Sliding ... [详细]
  • 猜字母游戏
    猜字母游戏猜字母游戏——设计数据结构猜字母游戏——设计程序结构猜字母游戏——实现字母生成方法猜字母游戏——实现字母检测方法猜字母游戏——实现主方法1猜字母游戏——设计数据结构1.1 ... [详细]
author-avatar
日本化妆品专卖_703
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有