We will be using the sakila database extensively inside the rest of the course and it would be great if you can follow the installation process below.

Importing the Sakila Database

一、 Change the File 。这一步原来提供的文件中可能已经i做好了。

Find and Replace all "InnoDB" with "MyISAM" in the schema file - different database engine - Full text - so don't have to upgrade

// MySQL用我的host03.xyy上安装了mysql数据库,所以在host03上做

二、登录数据库并执行数据库脚本

mysql -u root -p

root

SOURCE /home/cloudera/Spark/sakila-db/sakila-schema.sql

SOURCE /home/cloudera/Spark/sakila-db/sakila-data.sql

SHOW FULL TABLES;

DROP VIEW actor_info;

DROP VIEW customer_list;

DROP VIEW film_list;

DROP VIEW nicer_but_slower_film_list;

DROP VIEW sales_by_film_category;

DROP VIEW sales_by_store;

DROP VIEW staff_list;

三、使用hive并创建hive数据库

// Hive在host03机器上切换到hdfs用户,然后执行hive,进入hive命令行

CREATE DATABASE sakila;

四、执行导入mysql数据到hive。通过sqoop命令

// Terminal在03机器上使用hdfs用户进入,执行如下命令,否则找不到驱动程序。

sqoop import-all-tables --connect "jdbc:mysql://host03.xyy:3306/sakila" --username root --password root --hive-import --hive-database sakila

因为sqoop回转化为hadoop的mapreduce来做,所以会从多个机器上同时执行。

这个时候可能发生其他机器上链接不上mysql的问题,因为默认的mysql是拒绝其他机器访问的。

可以如下操作

mysql -u root -p
GRANT ALL PRIVILEGES ON *.* TO root@"host01.xyy" IDENTIFIED BY "root" WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO root@"host02.xyy" IDENTIFIED BY "root" WITH GRANT OPTION;

或者直接所有的远程机器都可以访问授权。

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

大数据入门到精通13--为后续和MySQL数据库准备的更多相关文章

  1. 大数据入门到精通18--sqoop 导入关系库到hdfs中和hive表中

    一,选择数据库,这里使用标准mysql sakila数据库 mysql -u root -D sakila -p 二.首先尝试把表中的数据导入到hdfs文件中,这样后续就可以使用spark来dataf ...

  2. 大数据入门到精通5--spark 的 RDD 的 reduce方法使用

    培训系列5--spark 的 RDD 的 reduce方法使用 1.spark-shell环境下准备数据 val collegesRdd= sc.textFile("/user/hdfs/C ...

  3. 大数据入门到精通2--spark rdd 获得数据的三种方法

    通过hdfs或者spark用户登录操作系统,执行spark-shell spark-shell 也可以带参数,这样就覆盖了默认得参数 spark-shell --master yarn --num-e ...

  4. 大数据入门到精通19--mysql 数据导入到hive数据中

    一.正常按照数据库和表导入 \\前面介绍了通过底层文件得形式导入到hive的表中,或者直接导入到hdfs中,\\现在介绍通过hive的database和table命令来从上层操作.sqoop impo ...

  5. 大数据入门到精通17--union all 和disctinct 的用法

    一.union all 的用法.使用union all 或者 unionselect * from rental where rental_id <10union allselect * fro ...

  6. 大数据入门到精通16--hive 的条件语句和聚合函数

    一.条件表达 case when ... then when .... then ... when ... then ...end select film_id,rpad(title,20," ...

  7. 大数据入门到精通12--spark dataframe 注册成hive 的临时表

    一.获得最初的数据并形成dataframe val ny= sc.textFile("data/new_york/")val header=ny.firstval filterNY ...

  8. 大数据入门到精通11-spark dataframe 基础操作

    // dataframe is the topic 一.获得基础数据.先通过rdd的方式获得数据 val ny= sc.textFile("data/new_york/")val ...

  9. 大数据入门到精通10--spark rdd groupbykey的使用

    //groupbykey 一.准备数据val flights=sc.textFile("data/Flights/flights.csv")val sampleFlights=sc ...

随机推荐

  1. Cocos2dx利用intersectsRect函数检测碰撞

    if (sp1->boundingBox().intersectsRect(sp2->boundingBox())) { pLabel->setString(“碰撞飞机爆炸”); } ...

  2. CSS 社区的解决方案,对比

    在众多解决方案中,没有绝对的优劣.还是要结合自己的场景来决定. 我们团队在使用过 scss 和 css modules 后,仍然又重新选择了使用 scss.css modules 虽然有效解决了样式冲 ...

  3. sql 不够七位数 在左侧自动补零 ,并循环插入N条记录

    select right(cast('0000000000'+rtrim(字段) as varchar(20)),7) declare @i intdeclare @qid int set @i=1s ...

  4. bootstrap模态框弹框后执行Ajax

    如下: editModal:模态框ID <script> $(document).ready(function() { $('#editModal').on('hidden.bs.moda ...

  5. html5-websocket实现基于远程方法调用的数据交互

    html5-websocket实现基于远程方法调用的数据交互   一般在传统网页中注册用户信息都是通过post或ajax提交到页面处理,到了HTML5后我们有另一种方法就是通过websocket进行数 ...

  6. Python递归解压缩多级.zip压缩包

    参考如下代码(from:https://stackoverflow.com/questions/36285502/how-to-extract-zip-file-recursively-in-pyth ...

  7. Error:Execution failed for task :app:transformClassesWithInstantRunForDebug解决方案

    转自https://blog.csdn.net/student9128/article/details/53026990

  8. 随机森林RandomForest

    ID3,C4.5决策树的生成: 输入:训练集D,特征集A,阈值eps, 输出:决策树T 若D中所有样本属于同一类Ck,则T为单节点树,将类Ck作为该结点的类标记,返回T: 若A为空集,即没有特征作为划 ...

  9. ssl协议相关

    <1> SSL版本 测试浏览器支持的SSL版本的网站: https://www.ssllabs.com/ssltest/viewMyClient.html 0xfefd    (DTLS ...

  10. Inception-v3的设计思路小结

    一.网络更深.更宽带来的问题 参数太多,若训练数据集有限,容易过拟合: 网络越大计算复杂度越大,难以应用:(内存和计算资源) 网络越深,梯度越往后穿越容易消失,难以优化模型. 解决: 如何减少参数(且 ...