Apache Sqoop:scoop-import提供Undefined错误。

时间:2017-06-07 10:38:38

标签: mysql hdfs hadoop2 sqoop

我正在使用Apache Hadoop和Apache Sqoop。我试图将mysql表导入hdfs。

这是我正在执行的命令:

<!DOCTYPE html>

<html>

<head>
  <meta charset="UTF8">
  <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js" type="text/javascript"></script>
  <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" type="text/javascript"></script>
  <link href="javascripts/frontend.js">
  <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
  <link href="/stylesheets/userlist.css" rel="stylesheet">
  <link href='//fonts.googleapis.com/css?family=Amatic SC' rel='stylesheet'>
  <link href='//fonts.googleapis.com/css?family=NTR' rel='stylesheet'>



  <title>Userlist</title>
  <!-- <script>$(document).ready({

	});
	</script> -->
</head>

<body>
  <div class="container-fluid">
    <div class="row">
      <h1><strong>FORM</strong></h1>

      <hr id="hr2" style="border: 6px solid palevioletred">


      <form action="/users/add_user" class="form-horizontal" id="user_form" method="post" name="user_form">
        <fieldset>
          <!-- Text input-->


          <div class="form-group">
            <label class="col-md-4 control-label" for="textinput">Name :</label>

            <div class="col-md-4">
              <input class="form-control input-md" id="nameinput" name="name" onfocus="if (this.value=='Name') this.value='';" placeholder="Enter Username" type="text" value="Name">
            </div>
          </div>
          <!-- Text input-->


          <div class="form-group">
            <label class="col-md-4 control-label" for="textinput">Age :</label>

            <div class="col-md-4">
              <input class="form-control input-md" id="ageinput" name="age" placeholder="Enter Age" type="number">
            </div>
          </div>
          <!-- Button -->
          <!-- Button (Double) -->


          <div class="form-group">
            <div class="col-md-8">
              <button class="btn btn-success" id="singlebutton" type="submit"><b>Add User</b></button>
            </div>
          </div>
        </fieldset>
      </form>


      <h1><strong>USERS</strong>
      </h1>

      <hr id="hr1" style="border: 6px solid #7ec4ec;">


      <ul class="triangle" id="list">
        <!-- Link trigger modal -->
        <!-- Modal -->


        <li style="list-style: none; display: inline">

          <%for(var i=0; i<userlist.length; i++) {%>
        </li>


        <!-- ______ MODAL ______ -->

        <div aria-labelledby="myModalLabel" class="modal fade" id="openModal" role="dialog" tabindex="-1">
          <div class="modal-dialog" role="dialog">
            <div class="modal-content">
              <div class="modal-header">
                <button aria-label="Close" class="close" data-dismiss="modal" type="button"><span aria-hidden="true">&times;</span></button>

                <h4 class="modal-title" id="myModalLabel">Edit :</h4>
              </div>


              <div class="modal-body">
                HEY!!
                <!--		<form>
										Name:<input id="nameId" name="modal_username" type="text" value=""> Age:<input id="ageId" name="modal_age" type="number" value="">
									</form> -->
              </div>


              <div class="modal-footer">
                <button class="btn btn-default" data-dismiss="modal" type="button">Close</button> <button class="btn btn-primary" type="button">Save changes</button>
              </div>
            </div>
          </div>
        </div>


        <li>
          <%= userlist[i].name %>:
            <%= userlist[i].age %> <a class="delete_user" data-id="<%= userlist[i]._id %>" href="#" id="delete" title="Delete this User">Delete</a> || <a href="#openModal" class="update_user" data-target="#openModal" data-toggle="modal" id="update" title="Update user info"
                data-id="<%= userlist[i]._id %>">Update</a>
        </li>
        <%} %>
      </ul>
    </div>
  </div>
</body>

</html>

我已按如下方式设置Sqoop家庭环境变量:

sqoop-import --connect jdbc:mysql://localhost/billing_engine -username root -password root > --table cpDetail;

但是执行上面的命令会给我以下错误:

export SQOOP_HOME=/Users/bng/Documents/sqoop-1.4.6.bin__hadoop-2.0.4-alpha
export PATH=$PATH:$SQOOP_HOME/bin

以下是显示我的名称节点的屏幕截图: enter image description here

请建议,我哪里错了?

1 个答案:

答案 0 :(得分:0)

这是我需要使用的正确命令:

sqoop import --connect jdbc:mysql://localhost/billing_engine?useSSL=false --username bil --password bil --table cpdetail -m 1 --target-dir /sqoopFromMysql

该命令的详细信息如下;

  1. Sqoop import:命令告诉使用sqoop的导入命令
  2. - connect:表示要使用的连接
  3. jdbc:mysql:// localhost / billing_engine?useSSL = false:使用jdbc连接到mysql。 db的主机是localhost,数据库名称是billing_engine。 useSSL = false指定我们不通过SSL层连接。
  4. - username bil --password bil:指定数据库的用户名和密码。
  5. - table cpdetail:指定特定表
  6. -m 1:指定要使用的地图
  7. - target-dir / sqoopFromMysql:指定HDFS中的目标目录,其中将导入数据。