MySQL Infobright 数据仓库快速安装笔记[转]
[文章作者:張宴 本文版本: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
mkdir -p /data0/mysql/3307
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
cd /usr/local
①、64位系統:
tar zxvf infobright-3.3.1-x86_64-ice.tar.gz
mv infobright-3.3.1-x86_64 infobright
②、32位系統:
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內存使用限制
根據自身的物理內存大小修改ServerMainHeapSize、ServerCompressedHeapSize、LoaderMainHeapSize的值,有參考:
# 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腳本:
輸入以下內容(這里的用戶名admin和密碼12345678接下來的步驟會創建):
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腳本可執行權限:
6、啟動MySQL/Infobright:
7、通過命令行登錄管理MySQL服務器(提示輸入密碼時直接回車):
8、輸入以下SQL語句,創建一個具有root權限的用戶(admin)和密碼(12345678):
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'127.0.0.1' IDENTIFIED BY '12345678';
9、示例:從普通的MySQL數據庫(假設MySQL安裝路徑為/usr/local/webserver/mysql)導出數據到csv文件:
10、示例:普通MySQL和Infobright建表對比
①、普通MySQL的InnoDB存儲引擎建表:
??`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存儲引擎建表:
??`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數據倉庫:
12、示例:普通MySQL和Infobright查詢速度對比(共220多萬條記錄):
①、普通MySQL的InnoDB存儲引擎(已建索引):
+---------------------+---------+
| 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存儲引擎:
+---------------------+---------+
| 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:
轉載于:https://www.cnblogs.com/zzjhn/p/5678684.html
總結
以上是生活随笔為你收集整理的MySQL Infobright 数据仓库快速安装笔记[转]的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: tp_link路由器 重新设置
- 下一篇: javascript 高级程序设计学习笔