---
title: "infobright安装"
author: "tofhao"
date: "2013-07-19T16:15:47Z"
tags: []
categories: ["开源软件"]
slug: "infobright"
draft: false
lastmod: "2013-07-23T17:36:30Z"
id: 1909269
url: "https://tofhao.iteye.com/blog/1909269"
---

参考<http://blog.s135.com/infobright/>

1.官网下载www.infobright.org
2.
```java
tar zxvf infobright-4.0.7-0-linux-i686-ice.tar.gz
```

3.
```java
cd  infobright-4.0.7-0-linux-i686-ice
./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=root
```


　4、开始安装，提示以下信息：
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，空格翻页到页尾，看到以下提示时，选择Q继续安装：

                     END OF TERMS AND CONDITIONS

============ Press Q to continue installation ==========
(END)

　　接下来会显示以下信息，选择Y同意：
Press Y -I agree, Any other key -I do not agree :

　　这时，会提示是否在线注册，选择N不注册：
5.创建管理MySQL数据库的shell脚本：

```java
vi /data0/mysql/3307/mysql
```

  输入以下内容:
  
```java
#!/bin/sh

mysql_port=3307
mysql_username="root"
mysql_password="123456"

function_start_mysql()
{
    printf "Starting MySQL...\n"
    cd /usr/local/infobright/ && /bin/sh ./bin/mysqld_safe --defaults-file=/data0/mysql/${mysql_port}/my.cnf --user=${mysql_username} --datadir=/data0/mysql/${mysql_por
t}/data 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
```


6.赋予shell脚本可执行权限：

```java
chmod +x /data0/mysql/3307/mysql
```

7.启动MySQL/Infobright：

```java
/data0/mysql/3307/mysql start
```

8.通过命令行登录管理MySQL服务器（提示输入密码时直接回车）：

```java
/usr/local/infobright/bin/mysql -u root -p -S /tmp/mysql3307.sock
```

9.GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456';
10.导出原数据
/usr/local/mysql/bin/mysql -h127.0.0.1 -uroot -D mobilepush -e "select * from fact_app_market_pin_plat into outfile '/tmp/test.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '\"'  ESCAPED BY '\\\' LINES TERMINATED BY '\n';
11.创建infobright表
  
```java
CREATE TABLE `fact_app_market_pin_plat` (
  `s_o_memberid` varchar(100) NOT NULL,
  `u_sex_manrate_avg_id` int(11) DEFAULT NULL,
  `province_name` varchar(360) DEFAULT NULL,
  `u_age_id` int(11) DEFAULT NULL,
  `u_have_child_id` int(11) DEFAULT NULL,
  `u_gestation_id` int(11) DEFAULT NULL,
  `facturer_top1` varchar(360) DEFAULT NULL,
  `facturer_top2` varchar(360) DEFAULT NULL,
  `facturer_top3` varchar(360) DEFAULT NULL,
  `facturer_top4` varchar(360) DEFAULT NULL,
  `facturer_top5` varchar(360) DEFAULT NULL,
  `pre_color1` int(11) DEFAULT NULL,
  `pre_color2` int(11) DEFAULT NULL,
  `pre_color3` int(11) DEFAULT NULL,
  `brand_top1` varchar(360) DEFAULT NULL,
  `brand_top2` varchar(360) DEFAULT NULL,
  `brand_top3` varchar(360) DEFAULT NULL,
  `browse_top1` int(11) DEFAULT NULL,
  `browse_top2` int(11) DEFAULT NULL,
  `browse_top3` int(11) DEFAULT NULL,
  `browse_top4` int(11) DEFAULT NULL,
  `browse_top5` int(11) DEFAULT NULL,
  `ps_id_top1` int(11) DEFAULT NULL,
  `ps_name_top1` varchar(360) DEFAULT NULL,
  `ps_id_top2` int(11) DEFAULT NULL,
  `ps_name_top2` varchar(360) DEFAULT NULL,
  `ps_id_top3` int(11) DEFAULT NULL,
  `ps_name_top3` varchar(360) DEFAULT NULL,
  `ps_id_top4` int(11) DEFAULT NULL,
  `ps_name_top4` varchar(360) DEFAULT NULL,
  `ps_id_top5` int(11) DEFAULT NULL,
  `ps_name_top5` varchar(360) DEFAULT NULL,
  `totalprice` double DEFAULT NULL,
  `u_wgs_cars_id` int(11) DEFAULT NULL,
  `usr_level_class_id` int(11) DEFAULT NULL,
  `u_buy_type_id` int(11) DEFAULT NULL,
  `u_p_l_category_id` int(11) DEFAULT NULL,
  `u_w_s_class_id` int(11) DEFAULT NULL,
  `visit_num` int(11) DEFAULT NULL,
  `client` varchar(360) DEFAULT NULL,
  `client_version` varchar(360) DEFAULT NULL,
  `nettype` varchar(360) DEFAULT NULL,
  `brand` varchar(360) DEFAULT NULL,
  `model` varchar(360) DEFAULT NULL
) ENGINE=BRIGHTHOUSE DEFAULT CHARSET=utf8;
```

 注：BRIGHTHOUSE存储引擎建表时不能有AUTO_INCREMENT自增、unsigned无符号、unique唯一、主键PRIMARY KEY、索引KEY。


12.导出文件复制文件 
    
```java
/usr/local/mysql/bin/mysql -S /tmp/mysql3306.sock -D db -e "select * from log_2 into outfile '/tmp/test.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '\"'  ESCAPED BY '\\\' LINES TERMINATED BY '\n';"
```

   
```java
scp /tmp/test.csv root@10.28.174.237:/home/tuhao/
```

13.从csv文件导入数据到Infobright数据仓库：
 
```java
  /usr/local/infobright/bin/mysql -S /tmp/mysql3307.sock -D moblepush --skip-column-names -e "LOAD DATA INFILE '/home/tuhao/test.csv' INTO TABLE fact_app_market_pin_plat FIELDS TERMINATED BY ',' ESCAPED BY '\\\' LINES TERMINATED BY '\n';"
```

14.测试
 
```java
select count(1) t from fact_app_market_pin_plat where  ( browse_top5=654 OR browse_top1=830 OR browse_top2=830 OR browse_top3=830 OR browse_top4=830 OR browse_top5=830 OR browse_top1=654 OR browse_top2=654 OR browse_top3=654 OR browse_top4=654 ) ;
```