標籤:infobright
Infobright 是一個非常強大的列式儲存資料庫,基於MySQL的高效資料倉儲。
之所以使用資料倉儲,是因為目前MySQL資料庫中的資料增長很快,定期會對一些記錄表進行清除,但後期的統計分析還會用到這些曆史資料,隨著資料量的增大,查詢也越來越慢,而資料庫倉庫特有的儲存格式能夠減小磁碟空間內的佔用,同時列式的特點使得查詢速度大為改觀。選擇Infobright是因為它鎖支援的資料類型更多些,更接近於mysql,更節省磁碟空間,畢竟主要的統計查詢還不是在資料倉儲上,偶爾的查詢一下速度倒不是要求最優,但是ICE最大的不變用了後你是不能做DM操作的,這點我深有體會,每次如果插入資料有些不合適的地方,需要刪除,你只能drop table,然後從建立表和匯入資料,麻煩呀。而Infinidb在這方便就讓你很開心。
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
找到如下兩行代碼:
[email protected][email protected]
[email protected][email protected]
修改為:
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 ‘,‘ optionallyenclosed 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裡:
[[email protected] 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)每行寫好後必須斷行符號,不然導不進去
##自己驗證正確性把
導資料庫的時候不建議使用用戶端工具來搞,總感覺好多坑的。
本文出自 “DBSpace” 部落格,請務必保留此出處http://dbspace.blog.51cto.com/6873717/1885668
Infobright列式儲存資料庫