[文章作者:张宴 本文版本:v1.1 最后修改:2010.05.18 转载请注明原文链接:http://blog.zyan.cc/infobright/]

  Infobright是一个与MySQL集成的开源数据仓库(Data Warehouse)软件,可作为MySQL的一个存储引擎来使用,SELECT查询与普通MySQL无区别。

  一、Infobright的基本特征:
  优点:
  查询性能高:百万、千万、亿级记录数条件下,同等的SELECT查询语句,速度比MyISAM、InnoDB等普通的MySQL存储引擎快5~60倍
  存储数据量大:TB级数据大小,几十亿条记录
  高压缩比:在我们的项目中为18:1,极大地节省了数据存储空间
  基于列存储:无需建索引,无需分区
  适合复杂的分析性SQL查询:SUM, COUNT, AVG, GROUP BY

  限制:
  不支持数据更新:社区版Infobright只能使用“LOAD DATA INFILE”的方式导入数据,不支持INSERT、UPDATE、DELETE
  不支持高并发:只能支持10多个并发查询



  二、Infobright 安装与基本用法:
  1、下载安装社区版Infobright二进制Linux版本,端口3307
ulimit -SHn 65535
mkdir -p /data0/mysql/3307
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql

cd /usr/local


  ①、64位系统:
wget http://www.infobright.org/downloads/ice/infobright-3.3.1-x86_64-ice.tar.gz
tar zxvf infobright-3.3.1-x86_64-ice.tar.gz
mv infobright-3.3.1-x86_64 infobright


  ②、32位系统:
wget http://www.infobright.org/downloads/ice/infobright-3.3.1-i686-ice.tar.gz
tar zxvf infobright-3.3.1-i686-ice.tar.gz
mv infobright-3.3.1-i686 infobright




cd infobright
./install-infobright.sh --datadir=/data0/mysql/3307/data --cachedir=/data0/mysql/3307/cache --config=/data0/mysql/3307/my.cnf --port=3307 --socket=/tmp/mysql3307.sock --user=mysql --group=mysql




  2、开始安装,提示以下信息:
Infobright installation script is running...
Checking system configuration...
Infobright license agreement...
System tool 'Less' - a text file viewer will be used to display license agreement.
Please only use up/down arrow keys for scrolling license text and press Q when finished reading.
Press R -Read license agreement, N -Exit the installation [R/N]:


  选择R,空格翻页到页尾,看到以下提示时,选择Q继续安装:

                     END OF TERMS AND CONDITIONS

============ Press Q to continue installation ==========
(END)


  接下来会显示以下信息,选择Y同意:
Press Y -I agree, Any other key -I do not agree [Y/*]:

  这时,会提示是否在线注册,选择N不注册:
Installation has been made for system user root and mysql.
Please see README or User guide for instructions related to start/stop the Infobright server and connect to it.
Register your copy of ICE and receive a free copy of the User Manual (a $50 value) as well as a copy of the Bloor Research Spotlight Report "What's Cool About Columns" which explains the differences and benefits of a columnar versus row database.
Registration will require opening an HTTP connection to Infobright, do you wish to register now? [Y/N]:




  3、修改Infobright内存使用限制
vi /data0/mysql/3307/data/brighthouse.ini

  根据自身的物理内存大小修改ServerMainHeapSize、ServerCompressedHeapSize、LoaderMainHeapSize的值,有参考:
############  Critical Memory Settings ############
# System Memory    Server Main Heap Size     Server Compressed Heap Size   Loader Main Heap Size
# 32GB                 24000                      4000                       800
# 16GB                 10000                      1000                       800
#  8GB                  4000                       500                       800
#  4GB                  1300                       400                       400
#  2GB                  600                        250                       320




  4、创建管理MySQL数据库的shell脚本:
vi /data0/mysql/3307/mysql

  输入以下内容(这里的用户名admin和密码12345678接下来的步骤会创建):
#!/bin/sh

mysql_port=3307
mysql_username="admin"
mysql_password="12345678"

function_start_mysql()
{
    printf "Starting MySQL...\n"
    cd /usr/local/infobright/ && /bin/sh ./bin/mysqld_safe --defaults-file=/data0/mysql/${mysql_port}/my.cnf 2>&1 > /dev/null &
}

function_stop_mysql()
{
    printf "Stoping MySQL...\n"
    cd /usr/local/infobright/ && ./bin/mysqladmin -u ${mysql_username} -p${mysql_password} -S /tmp/mysql${mysql_port}.sock shutdown
}

function_restart_mysql()
{
    printf "Restarting MySQL...\n"
    function_stop_mysql
    sleep 5
    function_start_mysql
}

function_kill_mysql()
{
    kill -9 $(ps -ef | grep 'bin/mysqld_safe' | grep ${mysql_port} | awk '{printf $2}')
    kill -9 $(ps -ef | grep 'libexec/mysqld' | grep ${mysql_port} | awk '{printf $2}')
}

if [ "$1" = "start" ]; then
    function_start_mysql
elif [ "$1" = "stop" ]; then
    function_stop_mysql
elif [ "$1" = "restart" ]; then
function_restart_mysql
elif [ "$1" = "kill" ]; then
function_kill_mysql
else
    printf "Usage: /data0/mysql/${mysql_port}/mysql {start|stop|restart|kill}\n"
fi




  5、赋予shell脚本可执行权限:
chmod +x /data0/mysql/3307/mysql




  6、启动MySQL/Infobright:
/data0/mysql/3307/mysql start




  7、通过命令行登录管理MySQL服务器(提示输入密码时直接回车):
/usr/local/infobright/bin/mysql -u root -p -S /tmp/mysql3307.sock




  8、输入以下SQL语句,创建一个具有root权限的用户(admin)和密码(12345678):
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' IDENTIFIED BY '12345678';
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'127.0.0.1' IDENTIFIED BY '12345678';




  9、示例:从普通的MySQL数据库(假设MySQL安装路径为/usr/local/webserver/mysql)导出数据到csv文件:
/usr/local/webserver/mysql/bin/mysql -S /tmp/mysql3306.sock -D tongji_logs -e "select * from log_visits_2010_05_10 into outfile '/data0/test.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '\"'  ESCAPED BY '\\\' LINES TERMINATED BY '\n';"




  10、示例:普通MySQL和Infobright建表对比
  ①、普通MySQL的InnoDB存储引擎建表:
CREATE TABLE IF NOT EXISTS `log_visits_2010_05_12` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `cate_id` int(11) NOT NULL,
  `site_id` int(11) unsigned NOT NULL,
  `visitor_localtime` char(8) NOT NULL,
  `visitor_idcookie` varchar(255) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `cate_site_id` (`cate_id`,`site_id`),
  KEY `visitor_localtime` (`visitor_localtime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


  ②、Infobright的BRIGHTHOUSE存储引擎建表:
CREATE TABLE IF NOT EXISTS `log_visits` (
  `id` int(11) NOT NULL,
  `cate_id` int(11) NOT NULL,
  `site_id` int(11) NOT NULL,
  `visitor_localtime` char(8) NOT NULL,
  `visitor_idcookie` varchar(255) NOT NULL,
) ENGINE=BRIGHTHOUSE DEFAULT CHARSET=utf8;

  注:BRIGHTHOUSE存储引擎建表时不能有AUTO_INCREMENT自增、unsigned无符号、unique唯一、主键PRIMARY KEY、索引KEY。



  11、示例:从csv文件导入数据到Infobright数据仓库:
/usr/local/infobright/bin/mysql -S /tmp/mysql3307.sock -D dw --skip-column-names -e "LOAD DATA INFILE '/data0/test.csv' INTO TABLE log_visits_2010_04_13 FIELDS TERMINATED BY ',' ESCAPED BY '\\\' LINES TERMINATED BY '\n';"




  12、示例:普通MySQL和Infobright查询速度对比(共220多万条记录):
  ①、普通MySQL的InnoDB存储引擎(已建索引):
mysql> SELECT config_browser_name, count(*) AS total FROM `browser_info` GROUP BY config_browser_name order by total DESC;
+---------------------+---------+
| config_browser_name | total   |
+---------------------+---------+
| IE                  | 2204016 |
| CH                  |   20650 |
| FF                  |   10475 |
| MO                  |    6147 |
| OT                  |    1631 |
| OP                  |    1282 |
| SF                  |     797 |
| KM                  |       5 |
| KO                  |       2 |
+---------------------+---------+
9 rows in set (1 min 28.13 sec)


  ②、Infobright的BRIGHTHOUSE存储引擎:
mysql> SELECT config_browser_name, count(*) AS total FROM `browser_info` GROUP BY config_browser_name order by total DESC;
+---------------------+---------+
| config_browser_name | total   |
+---------------------+---------+
| IE                  | 2204016 |
| CH                  |   20650 |
| FF                  |   10475 |
| MO                  |    6147 |
| OT                  |    1631 |
| OP                  |    1282 |
| SF                  |     797 |
| KM                  |       5 |
| KO                  |       2 |
+---------------------+---------+
9 rows in set (0.84 sec)




  13、(可选)停止MySQL/Infobright:
/data0/mysql/3307/mysql stop






技术大类 » 数据库技术 | 评论(62) | 引用(0) | 阅读(118560)
hogan280 Email
2012-5-10 18:06
Nella segnalazione del Rochdale "processo grooming" molto è stato fatto del fatto che gli uomini erano in gran parte pakistani, mentre Hogan le 47 vittime, anche se solo sette hanno fornito prove - erano tutti bianchi e classe operaia. Le vittime avevano un'età compresa tra 13 e 15 anni al momento dell'abuso, e la polizia li ha descritti come da "caotica" e "Consiglio tenuta" sfondi.
Dragon
2012-7-16 17:24
请问下,这个似乎只能本机登录?连远程登录都不行的?
Dragon
2012-7-16 17:25
另外也不能像普通mysql服务器那样通过脚本操作数据库吧?
virginiag Email Homepage
2012-7-24 16:29
Birkenstock Sandals are become the best friends of more and more young people.Whether in the city or in the town,the comfortable and relax of Birkenstock Sandals always can bring the new and leisure way of life.So now pls also change the slipper,the Birkenstock Sandals is the new and best choice for you.Also you need choose the top quality of Birkenstock Sandals in this professional of Birkenstock Outlet online store.
79云投
2012-12-10 21:53
Well done 提名式投票
abc
2012-12-31 11:28
社区版不支持DML是硬伤
naokiplus Homepage
2013-5-24 10:36
china-pub 最近做了mysql书籍专题
磨延城 Email Homepage
2013-10-21 20:45
磨途歌学习了
西瓜霜
2013-12-16 17:37
step4中 好多‘|’都变成了‘|’,刚开始没仔细看脚本,老是报错,张,页面编码问题了,希望修正一下下。
lvsi
2014-8-4 16:05
slava1:/opt # rpm -ivh infobright-4.0.7-0-x86_64-ice.rpm Preparing...                ########################################### [100%]Installing infobright 4.0.7-0 (x86_64)The installer will generate /tmp/ib4.0.7-0-install.log install trace log.   1:infobright             ########################################### [100%]https://www.infobright.org/index.php/Download/ICECreating/Updating datadir and cachedirCreating user mysql and group mysqlInstalling default databasesInstalling MySQL system tables...OKFilling help tables...OKTo start mysqld at boot time you have to copysupport-files/mysql.server to the right place for your systemPLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !To do so, start the server, then issue the following commands:/usr/local/infobright-4.0.7-x86_64/bin/mysqladmin -u root password 'new-password'/usr/local/infobright-4.0.7-x86_64/bin/mysqladmin -u root -h slava1 password 'new-password'Alternatively you can run:/usr/local/infobright-4.0.7-x86_64/bin/mysql_secure_installationwhich will also give you the option of removing the testdatabases and anonymous user created by default.  This isstrongly recommended for production servers.See the manual for more instructions.You can start the MySQL daemon with:cd /usr/local/infobright-4.0.7-x86_64 ; /usr/local/infobright-4.0.7-x86_64/bin/mysqld_safe &You can test the MySQL daemon with mysql-test-run.plcd /usr/local/infobright-4.0.7-x86_64/mysql-test ; perl mysql-test-run.plPlease report any problems with the /usr/local/infobright-4.0.7-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: 16019(MB)Infobright optimal ServerMainHeapSize is set to 10000(MB)Infobright optimal LoaderMainHeapSize is set to 800(MB)Infobright server installed into folder /usr/local/infobrightInstallation log file /tmp/ib4.0.7-0-install.log--------------------------------------To activate infobright server, please run ./postconfig.sh script from /usr/local/infobright-4.0.7-x86_64.Example command: cd /usr/local/infobright-4.0.7-x86_64; ./postconfig.sh你好张大神,我用的rpm安装接下来如何使用,请赐教591244761
Steven Email Homepage
2015-3-19 02:39
Thank you for this post Weight Loss Tea
steven Email Homepage
2015-3-20 22:22
Thank you asphalt 8 cheats
smithdaisy443 Email Homepage
2019-9-5 19:22
Need Online Assignment Help Australia? Goto Assignment Help offers all these courses:- Assignment Help Australia, Online Assignment Help, Australian Assignment Help, Help with Assignment, Assignment Helper with 25% OFF
Assignment Help Email Homepage
2020-1-8 21:17
Gotoassignmenthelp is a round the clock assignment help service which caters solutions request to various subjects’ tools & methodology in a multi environment learning concept for all subjects. We provide Assignment Help Australia service at affordable price in australia. We are a renowned service provider of online assignment help  and have been receiving an overwhelmed response by the British and nearby the territories.
Top Essay Writing Homepage
2020-1-16 21:48
top essay writing services are affordable and of high quality when your seek top essay writing by visiting topessaywriting login.
PierceWelsh Email
2021-11-1 04:08
Very impressive, To start my feedback i would like to congratulate  your team for giving us this source of knowledge and we are freely to connect with you too. Please have a sweet day by reading  this, 바카라 사이트
pg slot เว็บตรง แตกไว Email Homepage
2022-7-7 18:45
pg slot เว็บตรง แตกไวสล็อตน่าเล่น มีเกม สล็อต เว็บไซต์ตรง แจกเครดิตฟรี ให้เลือกเล่นล้นหลามมากมายแบบอย่าง เสมือนเลียนแบบแหล่งคาสิโนจากสถานที่จริงๆมาไว้บนโทรศัพท์เคลื่อนที่
sexypg1688 Email Homepage
2022-11-12 14:58
สล็อต 89ที่ดีที่สุด กับ SexyPG1688
sexypg1688 Email Homepage
2022-11-15 12:04
คาสิโน ออนไลน์ ที่ดีที่สุดได้เงินจริงกับ SexyPG1688
kiwisbrown Email
2023-3-18 02:26
Thanks for this , have a look at this onehttp://filmplusapk.info/
分页: 3/4 第一页 上页 1 2 3 4 下页 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]