温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Infobright列式存储数据库

发布时间:2020-04-25 11:55:43 来源:网络 阅读:920 作者:DBAspace 栏目:数据库

Infobright 是一个非常强大的列式存储数据库,基于MySQL的高效数据仓库。

之所以使用数据仓库,是因为目前MySQL数据库中的数据增长很快,定期会对一些历史记录表进行清除,但后期的统计分析还会用到这些历史数据,随着数据量的增大,查询也越来越慢,而数据库仓库特有的存储格式能够减小磁盘空间内的占用,同时列式的特点使得查询速度大为改观。选择Infobright是因为它锁支持的数据类型更多些,更接近于mysql,更节省磁盘空间,主要的统计查询还不是在数据仓库上,偶尔的查询一下速度倒不是要求最优,作为社区版本(ICE版本)最×××烦是不能做DML操作的,实际测试也是那么回事,如果插入数据有些不合适的地方,需要删除,只能drop table,然后从新建表和导入数据........

infobright的优势:

1.    数据压缩:适合存放很大的数据量,节约磁盘存储

2.    查询速度:基础的汇总语句,sum avg  min max  count()  groupby 速度比oracle的要快,不用建立索引、不用给大表分区,省很多工作量,适合数据汇总、报表统计

infobright的局限性ICE:

1.    infobright不支持DML(只支持select)

只有select可以支持,update/insert/deltete以及truncate table 都不能使用,插入表数据:用laod data infile

2.只支持单击、单核

由于Infobright官方已经提供好了rpm的包,所以安装起来相对来说较为简单:

rpm -ivh infobright-4.0.7-0-x86_64-ice.rpm --prefix=/usr/local/infobright

这样就会安装到/usr/local/infobright/infobright-4.0.7-0-x86_64

对于整个安装过程,相当的简单,比较繁琐的是对于相关参数的设置:

A、配置内存大小

vim /usr/local/infobright-4.0.7-x86_64/data/brighthouse.ini

修改内存的配置可参加其建议值进行设置:

############  Critical MemorySettings ############

# System Memory   Server Main Heap Size     ServerCompressed Heap Size   Loader Main HeapSize

# 32GB                24000                     4000                       800

# 16GB                10000                     1000                       800

#  8GB                  4000                       500                       800

#  4GB                  1300                       400                       400

#  2GB                  600                        250                       320

B、系统自带配置功能

sh /usr/local/infobright-4.0.7-x86_64/postconfig.sh

这个脚本可以改变datadir,cachedir,socket,port等配置,需要root来执行,执行后返回的信息如下:(如无需修改,则全部N即可)

Infobright post configuration

--------------------------------------

Using postconfig you can:

--------------------------------------

(1) Move existing data directory to other location,

(2) Move existing cachedirectoryto other location,

(3)Configure server socket,

(4)Configure server port,

(5) Relocate datadir pathto an existing data directory.

 

Please type'y'foroption that you want or press ctrl+c for exit.

 

Current configuration:

 

--------------------------------------

Current config file: [/etc/my-ib.cnf]

Current brighthouse.ini file: [/usr/local/infobright-4.0.7-x86_64/data/brighthouse.ini]

Current datadir: [/usr/local/infobright-4.0.7-x86_64/data]

Current CacheFolder in brighthouse.ini file: [/usr/local/infobright-4.0.7-x86_64/cache]

Current socket: [/tmp/mysql-ib.sock]

Current port: [5029]

--------------------------------------

 

(1) Do you want to copy current datadir [/usr/local/infobright-4.0.7-x86_64/data] to a new location? [y/n]:n

(2) Do you want tomovecurrent CacheFolder [/usr/local/infobright-4.0.7-x86_64/cache] to a new location? [y/n]:n

(3) Do you want tochangecurrent socket [/tmp/mysql-ib.sock]? [y/n]:n

(4) Do you want tochangecurrent port [5029]? [y/n]:n

(5) Do you want torelocateto an existing datadir? Current datadir is [/usr/local/infobright-4.0.7-x86_64/data]. [y/n]:n

 

--------------------------------------

--------------------------------------

No changes has been made.

--------------------------------------

C、设置字符集

infobright默认情况下不支持中文,为了更好的支持中文,需要设置默认的字符集。

vim /etc/my-ib.cnf

找到如下内容

collation_server=latin1_bin

character_set_server=latin1

将其修改为:

collation_server=utf8_bin

character_set_server=utf8

D、安装启动脚本

cp /usr/local/infobright-4.0.7-x86_64/share/mysql/mysql.server /etc/init.d/mysqld-ib

vim /etc/init.d/mysqld-ib

找到如下两行代码:

conf=@BH_CONF@

user=@BH_USER@

修改为:

conf=/etc/my-ib.cnf

user=root##这里只能用root启动服务,其他用户需要研究如何启动

相关的其他指令:

/etc/init.d/mysqld-ib stop

/etc/init.d/mysqld-ib restart

添加开机启动:

chkconfig --add mysqld-ib

E、Mysql安全设置

PATH=$PATH:/usr/local/infobright-4.0.7-x86_64/bin

mysql_secure_installation

完成后再给mysql添加一个远程连接的账号,只想如下命令进入mysql client:

mysql -uroot -p

添加完远程用户方法如下:

GRANT ALL PRIVILEGESON *.* TO'infobright'@'%'IDENTIFIEDBY'password'WITHGRANTOPTION;
FLUSHPRIVILEGES;

mysql数据导入到infobright中

CREATE TABLE `ricci_var` (

  `id`int(11) DEFAULT NULL,

 `name` varchar(20) DEFAULT NULL,

 `c_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATECURRENT_TIMESTAMP

) ENGINE=InnoDB

select * from ricci_var into outfile'/tmp/var.csv' fields terminated by ',' optionally enclosed by '"' lines terminated by '\n'

###红色部分在导入的数据设置的分隔符等信息,导入也要相同

#导出数据的时候需要存放在数据库目录下或者/tmp目录下,MySQL5.7是没有权限导出需要设置

secure_file_priv配置对数据导入导出的影响:

secure_file_priv  mysqld 用这个配置项来完成对数据导入导出的限制

1、限制mysqld 不允许导入 | 导出

 mysqld --secure_file_prive=null

2、限制mysqld 的导入 | 导出只能发生在/tmp/目录下

 mysqld --secure_file_priv=/tmp/

3、不对mysqld 的导入| 导出做限制

 /etc/my.cnf
    [mysqld]
    secure_file_priv

把数据导入infobright库里

在inf库里添加相同类型的表在导入数据:

load data infile "/tmp/var.csv"into table var fields terminated by ',' optionally enclosed by '"' linesterminated by '\n'

文本数据导入inf里:

[root@localhost home]# cat aa.txt 

1,"noe,two or three",2222

2,3,4

create table aa(id int,textfiedl varchar(40),number int)

load data infile "/home/aa.txt" into table aa fields terminated by ',' enclosed by '"';

mysql> select * from aa;

+------+------------------+--------+

| id   | textfiedl        | number |

+------+------------------+--------+

|    1 | noe,two or three |   2222 |

|    2 | 3                |      4 |

+------+------------------+--------+

(1)“”是为了将列区分开

(2)每行写好后必须回车,不然导不进去

##自己验证正确性把

导数据库的时候不建议使用客户端工具来搞,总感觉好多坑的。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI