安裝和使用Inforbright

Inforbright簡介

Infobright是一款基於知識網格的列式數據庫,對大批量數據(百萬、千萬、億級)的查詢性能非常高,據說比MyISAM、InnoDB等普通MySQL引擎快5~60倍,可存儲TB級體積的數據,存儲數據高壓縮比可達到40:1。基於列式存儲,無需索引、無需分區。快速響應複製的聚合查詢,非常適合分析性的SQL,如SUM、AVG、COUNT、GROUP BY 等。

Infobright的使用場景

1、大數據量的分析應用。如:網頁/在線分析、移動端數據分析、營銷分析、廣告定位、客戶行爲分析等。
2、日誌/事件管理系統。電信詳單分析和報告、系統/網絡 安全認證記錄。
3、數據集市。企事業單位特定數據倉庫、爲中小企業提供數據倉庫。
4、嵌入式分析。爲獨立軟件供應商/ SaaS供應商提供嵌入式分析應用

Infobright的限制

1、不支持數據更新:社區版Infobright只能使用“LOAD DATA INFILE”的方式導入數據,不支持INSERT、UPDATE、DELETE。
2、不支持高併發:只能支持10多個併發查詢,用於企業高層決策和產品定向已經足夠了。

Infobright安裝

下載相應的Windows版本安裝:https://www.infobright.org/index.php/Download/ICE

安裝成功後如圖:
這裏寫圖片描述

打開Infobright Commond Line Client,如圖
這裏寫圖片描述

設置密碼之後只能通過命令行窗口進入Infobright的bin目錄執mysql,可以打開Infobright的命令行窗口:
這裏寫圖片描述
但是設置密碼之後會有一系列的權限問題,解決方法先保留。

創建數據庫(無密碼)

創建數據庫並指定字符集:

CREATE DATABASE mytest;

結果

mysql> CREATE DATABASE mytest;
Query OK, 1 row affected (0.00 sec)

mysql> use mytest;
Database changed
mysql>

創建表

從現有的MySQL表腳本修改

現有的MySQL建表腳本(這裏以我的reviews表爲例)

CREATE TABLE `reviews` (
    `id` VARCHAR(32) NOT NULL,
    `review` VARCHAR(10000) NULL DEFAULT NULL,
    `reviewer` VARCHAR(100) NULL DEFAULT NULL,
    `date` DATE NOT NULL DEFAULT '0000-00-00',
    `helpful_count` INT(11) NULL DEFAULT NULL,
    `starts` FLOAT NULL DEFAULT NULL,
    PRIMARY KEY (`id`),
    FULLTEXT INDEX `fulltext_reviews` (`review`, `reviewer`)
)
ENGINE=MyISAM
;

修改爲適應Infobright的建表腳本如下:

CREATE TABLE `reviews` (
    `id` CHAR(32) NOT NULL,
    `review` VARCHAR(10000) NULL DEFAULT NULL,
    `reviewer` VARCHAR(100) NULL DEFAULT NULL,
    `date` DATE NOT NULL DEFAULT '0000-00-00',
    `helpful_count` INT(11) NULL DEFAULT NULL,
    `starts` FLOAT NULL DEFAULT NULL
)
ENGINE=brighthouse;

對比一下,ID是定長的,乾脆改成CHAR了。
去掉PRIMARY KEYFULLTEXT INDEX等索引,因爲Infobright是無需索引的。
把ENGINE修改爲brighthouse
執行腳本:
這裏寫圖片描述

導入CSV數據

使用命令先設置以CSV格式導入(安裝的是社區版(ICE),只能支持CSV)

 set @bh_dataformat = 'txt_variable';


如果是企業版(IEE),需要支持多種格式如binary、MySQL,可以參考
{Infobright_home}/Data_Loading_Guide.pdf

使用MySQL客戶端工具將現有的reviews表數據導出爲reviews.csv,使用命令導入到Infobright的mytest.reviews表中

load data infile 'd:\\reviews.csv' into table reviews fields terminated by ',' optionally enclosed by  '"' lines terminated by '\n';

Infobright的默認端口是:5029


附加

mysql設置編碼命令

SET character_set_client = utf8;
SET character_set_connection = utf8;
SET character_set_database = utf8;
SET character_set_results = utf8;
SET character_set_server = utf8;

SET collation_connection = utf8_bin;
SET collation_database = utf8_bin;
SET collation_server = utf8_bin;

my.ini中配置默認編碼

default-character-set=utf8

Ubuntu安裝Infobright

下載https://www.infobright.org/index.php/download/ICE/infobright-4.0.7-0-x86_64-ice.deb

進入下載目錄執行如下命令:

dpkg -i infobright-4.0.7-0-x86_64-ice.deb 

運行結果

Selecting previously unselected package infobright.
(Reading database ... 184850 files and directories currently installed.)
Preparing to unpack infobright-4.0.7-0-x86_64-ice.deb ...
Installing infobright 4.0.7-0 (x86_64)
The installer will generate /tmp/ib4.0.7-0-install.log install trace log.
Unpacking infobright (4.0.7-0) ...
Setting up infobright (4.0.7-0) ...
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-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 ubuntu password 'new-password'

Alternatively you can run:
/usr/local/infobright-4.0.7-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-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.pl
cd /usr/local/infobright-4.0.7-x86_64/mysql-test ; perl mysql-test-run.pl

Please 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: 3935(MB)
Infobright optimal ServerMainHeapSize is set to 1300(MB)
Infobright optimal LoaderMainHeapSize is set to 400(MB)
Infobright server installed into folder /usr/local/infobright
Installation 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
root@ubuntu:/opt# sh /usr/local/infobright-4.0.7-x86_64/postconfig.sh
Infobright post configuration
--------------------------------------
Please run this script from inside the installed folder.
--------------------------------------
root@ubuntu:/opt# sh /usr/local/infobright-4.0.7-x86_64/postconfig.sh  
Infobright post configuration
--------------------------------------
Please run this script from inside the installed folder.
--------------------------------------

激活

進入/usr/local/infobright-4.0.7-x86_64目錄執行命令:

./postconfig.sh

運行結果:

Infobright post configuration
--------------------------------------
Infobright server activated.
--------------------------------------
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]: y
Do you want to tell us a bit about yourself? We will try to send your information to our server. [Y/N]: y
First Name: gionee   /*這裏要求你輸入*/
Last Name: gionee    /*這裏要求你輸入*/
Company: gionee      /*這裏要求你輸入*/
Job Title: gionee    /*這裏要求你輸入*/
City: shenzhen       /*這裏要求你輸入*/
State/Province: gd   /*這裏要求你輸入*/
Country: China       /*這裏要求你輸入*/
Email address: lz881228@163.com /*這裏要求你輸入*/
Phone number:  /*這裏要求你輸入*/
Industry:
1. Aerospace and Defense
2. Automotive and Transportation
3. Charity, Non-profit Organization
4. Chemicals
5. Computer Hardware
6. Computer Software and Services
7. Consumer Products
8. Diversified Services (Accounting, Legal)
9. Education
10. Electronics
11. Energy, Utilities, Oil and Gas
12. Engineering, Construction, Materials
13. Financial Services, Banking, Insurance
14. Food and Beverages (Consumables)
15. Government
16. Healthcare
17. Leisure, Entertainment, Restaurants
18. Manufacturing
19. Media
20. Metals and Mining
21. Online advertising and Marketing
22. Pharmaceuticals and Medicine
23. Retail
24. Telecommunications
25. Transportation
26. Other
Enter number here[1-26]: 18218089328
Please give a valid number for industry[1-26]: 1
What kind of project do you intend to use ICE for?:
1. Enterprise Data Warehouse
2. Department or Application Data Mart
3. Log Analytics
4. Online Analytics
5. Telecom Analytics
6. Embedded Analytic Database
7. Other
Enter number here[1-7]: 1 /*這裏要求你輸入*/

We successfully submitted your information to our server. Thank you for registration.

啓動infobright

/etc/init.d/mysqld-ib start

日誌:

Starting MySQL
error: list of process IDs must follow p

Usage:
 ps [options]

 Try 'ps --help <simple|list|output|threads|misc|all>'
  or 'ps --help <s|l|o|t|m|a>'
 for additional help text.

For more details see ps(1).
. * 

查看啓動狀態

/etc/init.d/mysqld-ib status
 * MySQL running (10837)

設置root密碼

usr/local/infobright-4.0.7-x86_64/bin/mysqladmin -u root password 'root'  

登錄
執行命令:

/usr/local/infobright-4.0.7-x86_64/bin# mysql-ib -u root -p

結果

root@ubuntu:/usr/local/infobright-4.0.7-x86_64/bin# mysql-ib -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.1.40 build number (revision)=IB_4.0.7_r16961_17249(ice) (static)

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

設置遠程登錄權限以及常規操作

執行命令

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;

結果

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| BH_RSI_Repository  |
| mysql              |
| sys_infobright     |
| test               |
+--------------------+
5 rows in set (0.00 sec)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章