mySQL and sqoop for ubuntu

数据的导入导出

——MySQL & sqoop in Ubuntu

1.完成搭建hadoop集群

2.安装MySQL

sudo apt-get install mysql-server mysql-client

sudo  apt-get  update   //可能要这一句?

my.cnf -> #bind-address =127.0.0.1

3.安装Sqoop

1.解压

2.profile $SQOOP

3.conf

export hadoop balabala home *2

4.把MySQL启动拷入sqoop/lib

4.使用命令进行导入

(文档:sqoop1 、sqoop2使用示例)

sqoop list-databases --connect --username --password

sqoop import --target-dir  -m 1

hdfs<->mysql

 

 

MySQL 安装

安装

sudo apt-get install mysql-server mysql-client

配置cnf

sudo gedit /etc/mysql/my.cnf    //路径存疑

//找到如下内容,并注释

bind-address = 127.0.0.1

 

 

 

Sqoop 安装

1.解压

tar xvf sqoop-1.4.6.bin__hadoop-2.0.4-alpha.tar.gz

2.改profile

sudo gedit /etc/profile

 

加入以下内容

export SQOOP_HOME=/home/yuqiao/sqoop-1.4.6.bin__hadoop-2.0.4-alpha

export PATH=$PATH:$SQOOP_HOME/bin

 

 

source /etc/profile

 

3. 改sqoop-env.sh

sudo gedit SQOOP_HOME/conf/sqoop-env.sh

(如果没有就复制粘贴template)

加入以下内容:

#Set path to where bin/hadoop is available

export HADOOP_COMMON_HOME=/home/hadoop/hadoop-2.7.1

#Set path to where hadoop-*-core.jar is available

export HADOOP_MAPRED_HOME=/home/hadoop/hadoop-2.7.1

 

 

4.放入mysql驱动

把mysql-connector-java-5.1.35.jar放入sqoop的lib文件夹

 

 

 

 

4.安装完成后简单验证(显示所有数据库)

                    sqoop list-databases --connect jdbc:mysql://master:3306/ --username root --password 1234

(password是自己的,其余内容不改)

如果报错说ERROR 1130: Host master is not allowed to connect to this MySQL server

 

就按顺序原封不动(与机子无关)运行下列语句:

 

mysql -u root -p

mysql>use mysql;

mysql>update user set host = '%'  where user ='root';

mysql>flush privileges;

mysql>select 'host','user' from user where user='root';
 GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' with grant option;

 

 

方法来自博客:

http://www.blogjava.net/brock/archive/2009/04/13/265323.html

关掉该终端之后,重开,运行之前那句显示所有数据库,即可成功

 

你可能感兴趣的:(mySQL and sqoop for ubuntu)