无法在ubuntu服务器中执行jar文件

时间:2017-04-10 12:33:48

标签: eclipse hadoop sqoop ubuntu-16.04 ubuntu-server

我有一个小的sqoop导入项目,我必须从mysql导入到hdfs。这是一个maven项目,而我在我的本地系统中运行它工作正常。现在当我试图通过运行jar文件在我的ubuntu服务器上运行时,它正在执行但没有显示任何输出。它不是基于Web的应用程序,正常应用程序,我正在运行hadoop deamons并运行此项目。告诉我如何在服务器中运行此类项目并运行。

package org.ezytruk.sqoop;

import java.io.FileInputStream;
import java.util.Properties;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.sqoop.tool.ImportTool;

import com.cloudera.sqoop.SqoopOptions;
import com.cloudera.sqoop.SqoopOptions.FileLayout;

public class SqoopImport {
    public static void importMySQLToHDFS() throws Exception {
        try {
            String driver = "com.mysql.jdbc.Driver";
            Class.forName(driver).newInstance();

            Configuration config = new Configuration();
            config.addResource(new Path("/usr/local/hadoop/etc/hadoop/conf/core-site.xml"));
            config.addResource(new Path("/usr/local/hadoop/etc/hadoop/conf/hdfs-site.xml"));

            Properties properties = new Properties();
            properties.load(new FileInputStream("/home/*****/SqoopImportHDFS/resources/sqoopImport.properties"));

            //org.apache.sqoop.SqoopOptions sqoopOptions = new org.apache.sqoop.SqoopOptions();
            SqoopOptions sqoopOptions = new SqoopOptions();
            sqoopOptions.setDriverClassName(driver);
            sqoopOptions.setHadoopHome("/usr/local/hadoop");
            sqoopOptions.setConnectString(properties.getProperty("db_mysql_connection_string"));
            sqoopOptions.setTableName(properties.getProperty("db_mysql_table_name"));
            sqoopOptions.setUsername(properties.getProperty("db_mysql_username"));
            sqoopOptions.setPassword(properties.getProperty("db_mysql_password"));
            sqoopOptions.setNumMappers(1);
            //sqoopOptions.setWarehouseDir(properties.getProperty("db_hdfs_warehouse_directory"));
            sqoopOptions.setTargetDir(properties.getProperty("db_hdfs_output_directory"));
            sqoopOptions.setFileLayout(FileLayout.TextFile);
            new ImportTool().run(sqoopOptions);

            } catch (Exception e) {

         }

     }
       public static void main(String[] args) throws Exception {

        SqoopImport mySqlImport = new SqoopImport();
        mySqlImport.importMySQLToHDFS();

    }

}

0 个答案:

没有答案