Hive+Sqoop+Mysql整合

来源:https://www.cnblogs.com/hongten/archive/2019/01/16/hongten_hive_sqoop_mysql.html
-Advertisement-
Play Games

Hive+Sqoop+Mysql整合 在本文中,LZ隨意想到了一個場景: 車,道路,監控,攝像頭 ...


Hive+Sqoop+Mysql整合

在本文中,LZ隨意想到了一個場景:

車,道路,監控,攝像頭

即當一輛車在道路上面行駛的時候,道路上面的監控點裡面的攝像頭就會對車進行數據採集。

我們對採集的數據進行分析,處理,最後把結果保存到mysql資料庫中供Web UI顯示監控點/攝像頭狀態。

 

A:監控點/攝像頭狀態

工作流程如下:

 

 

1.數據格式

/**
 * 產生測試數據:
 * 數據format:
 * 記錄時間                 車牌號碼            車速                     道路編號       監控地點        攝像頭編號
 * date_time     vehicle_plate     vehicle_speed    road_id   monitor_id    camera_id
 * 
 * 中間使用'\t'隔開
 * 16/01/2019 10:20:30 SCN89000J 124 10002 20004 40007
 * 
 * 具體說明:
 * 道路編號
 * 10001 - 10100
 * 
 * 監控地點 - 在一條道路上面有2個監控點
 * 20001 - 20200
 * 
 * 攝像頭編號 - 在一個監控點上面2個攝像頭
 * 40001 - 40400
 * 
 * 道路:      10001                         10002
 * 監控:      20001-20002                   20003-20004
 * 攝像頭:  40001-40002-40003-40004       40005-40006-40007-40008
 * 
 * 車速: 1-300。 如果大於260,則為超速行駛
 * 
 * 車牌: SCN89000J
 * 
 * 記錄時間: 16/01/2019 10:20:30 
 * 
 */

 

2.生成測試數據

--編譯運行java code
cd /root/vehicle_dir/

vi DataGenerate.java

 

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;

/**
 * 產生測試數據:
 * 數據format:
 * 記錄時間                 車牌號碼            車速                     道路編號       監控地點        攝像頭編號
 * date_time     vehicle_plate     vehicle_speed    road_id   monitor_id    camera_id
 * 
 * 中間使用'\t'隔開
 * 16/01/2019 10:20:30 SCN89000J 124 10002 20004 40007
 * 
 * 具體說明:
 * 道路編號
 * 10001 - 10100
 * 
 * 監控地點 - 在一條道路上面有2個監控點
 * 20001 - 20200
 * 
 * 攝像頭編號 - 在一個監控點上面2個攝像頭
 * 40001 - 40400
 * 
 * 道路:      10001                         10002
 * 監控:      20001-20002                   20003-20004
 * 攝像頭:  40001-40002-40003-40004       40005-40006-40007-40008
 * 
 * 車速: 1-300。 如果大於260,則為超速行駛
 * 
 * 車牌: SCN89000J
 * 
 * 記錄時間: 16/01/2019 10:20:30 
 * 
 * @author Hongten
 */
public class DataGenerate {

    Integer[] roadIdArray = new Integer[Common.ROAD_NUM];

    public static void main(String[] args) {
        long begin = System.currentTimeMillis();
        DataGenerate dataGenerate = new DataGenerate();
        dataGenerate.init();
        dataGenerate.generateData();
        long end = System.currentTimeMillis();
        System.out.println("Total: " + (end - begin) + " ms");
    }

    public void init() {
        // create files
        FileUtils.createFile(Common.VEHICLE_LOG);
        FileUtils.createFile(Common.ROAD_MONITOR_CAMERA_RELATIONSHIP);

        generateRoadIds();
    }

    /**
     * 道路: 10001 10002 監控: 20001-20002 20003-20004 攝像頭: 40001-40002-40003-40004
     * 40005-40006-40007-40008
     */
    public void generateRoadIds() {
        StringBuilder readMonitorCameraRelationship = new StringBuilder();
        for (int i = 0; i < Common.ROAD_NUM; i++) {
            int roadId = 10000 + (i + 1);// 10001
            roadIdArray[i] = roadId;

            int monitorB = roadId * 2;// 20002
            int monitorA = monitorB - 1;// 20001

            int cameraAB = monitorA * 2;// 40002
            int cameraAA = cameraAB - 1;// 40001

            int cameraBB = monitorB * 2;// 40004
            int cameraBA = cameraBB - 1;// 40003

            // monitorA
            // 10001 20001 40001
            // 10001 20001 40002
            readMonitorCameraRelationship.append(roadId).append(Common.SEPARATOR).append(monitorA).append(Common.SEPARATOR).append(cameraAA).append(Common.LINE_BREAK);
            readMonitorCameraRelationship.append(roadId).append(Common.SEPARATOR).append(monitorA).append(Common.SEPARATOR).append(cameraAB).append(Common.LINE_BREAK);
            // monitorB
            // 10001 20002 40003
            // 10001 20002 40004
            readMonitorCameraRelationship.append(roadId).append(Common.SEPARATOR).append(monitorB).append(Common.SEPARATOR).append(cameraBA).append(Common.LINE_BREAK);
            readMonitorCameraRelationship.append(roadId).append(Common.SEPARATOR).append(monitorB).append(Common.SEPARATOR).append(cameraBB).append(Common.LINE_BREAK);
        }
        saveData(Common.ROAD_MONITOR_CAMERA_RELATIONSHIP, readMonitorCameraRelationship.toString());
    }

    public void saveData(String pathFileName, String newContent) {
        //remove the last '\n'
        newContent = newContent.substring(0, newContent.length() - 1);
        FileUtils.saveFile(pathFileName, newContent);
    }

    public void generateData() {
        //StringBuffer可以保證線程安全
        StringBuffer contentSb = new StringBuffer();
        SimpleDateFormat simpleDateFormat_ddMMyyyy = new SimpleDateFormat(Common.DATE_FORMAT_YYYYMMDD);
        Date today = new Date();
        String date = simpleDateFormat_ddMMyyyy.format(today);
        Random random = new Random();
        
        //異常道路
        List<Integer> errorRoadIdList = new ArrayList<Integer>();
        generateErrorRoadIdList(random, errorRoadIdList);
                
        long begin = System.currentTimeMillis();
        
        //使用多線程
        ExecutorService exec = Executors.newCachedThreadPool();
        for (int i = 0; i < Common.VEHICLE_NUMBER; i++) {
            String vehiclePlate = VehiclePlateGenerateSG.generatePlate();
            //使用Future和Callable組合,可以獲取到返回值
            Future<String> result = exec.submit(new GenerateVehicleLog(date, random, errorRoadIdList, vehiclePlate, roadIdArray));
            try {
                contentSb.append(result.get());
                if(i % 100 == 0){
                    System.out.println(i);
                }
                
                if(i != 0 && i % 900 == 0){
                    long end = System.currentTimeMillis();
                    System.out.println(i + " sleeping 1 seconds." + " " + (end - begin)/1000 + " s");
                    //waiting the pre-task to finish.
                    TimeUnit.SECONDS.sleep(1);
                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            } catch (ExecutionException e) {
                e.printStackTrace();
            }
            //System.out.println(contentSb.toString());
        }
        exec.shutdown();
        saveData(Common.VEHICLE_LOG, contentSb.toString());
    }

    private void generateErrorRoadIdList(Random random, List<Integer> errorRoadIdList) {
        for (int x = 0; x < Common.ROAD_ERROR_NUM; x++) {
            if (errorRoadIdList.contains(roadIdArray[random.nextInt(roadIdArray.length)])) {
                generateErrorRoadIdList(random, errorRoadIdList);
            } else {
                errorRoadIdList.add(roadIdArray[random.nextInt(roadIdArray.length)]);
            }
        }
    }
}

class GenerateVehicleLog implements Callable<String>{

    StringBuffer contentSb;
    String date;
    Random random;
    List<Integer> errorRoadIdList;
    String vehiclePlate;
    Integer[] roadIdArray;
    
    public GenerateVehicleLog( String date, Random random, List<Integer> errorRoadIdList, String vehiclePlate, Integer[] roadIdArray){
        this.contentSb = new StringBuffer();
        this.date = date;
        this.random = random;
        this.errorRoadIdList = errorRoadIdList;
        this.vehiclePlate = vehiclePlate;
        this.roadIdArray = roadIdArray;
    }
    
    @Override
    public String call() throws Exception {
        return getVehicleLog(contentSb, date, random, errorRoadIdList, vehiclePlate, roadIdArray);
    }
    
    private String getVehicleLog(StringBuffer contentSb, String date, Random random, List<Integer> errorRoadIdList, String vehiclePlate, Integer[] roadIdArray) {
        // 每一輛車產生記錄在100條記錄以內
        // 即最多過100個監控點
        // 即最多過50條路
        // 這裡可以根據需要調節
        for (int n = 0; n < random.nextInt(Common.ROAD_NUM); n++) {
            int roadId = roadIdArray[random.nextInt(roadIdArray.length)];
            Integer[] monitorIdArray = new Integer[2];
            Integer[] cameraIdArray = new Integer[2];
            boolean isAllError = false;
            int monitorId = 0;
            if (errorRoadIdList.contains(roadId)) {
                // System.out.println("find error road.... " + roadId +
                // " for vehicle : " + vehiclePlate);
                if (roadId % 2 == 0) {
                    // 監控設備全部壞掉
                    isAllError = true;
                } else {
                    // 部分壞掉
                    monitorIdArray[0] = roadId * 2 - 1;
                    monitorIdArray[1] = roadId * 2 - 1;

                    monitorId = monitorIdArray[random.nextInt(monitorIdArray.length)];

                    cameraIdArray[0] = roadId * 4 - 3;
                    cameraIdArray[1] = roadId * 4 - 2;
                }
            } else {
                monitorIdArray[0] = roadId * 2 - 1;
                monitorIdArray[1] = roadId * 2;

                monitorId = monitorIdArray[random.nextInt(monitorIdArray.length)];

                cameraIdArray[0] = monitorId * 2 - 1;
                cameraIdArray[1] = monitorId * 2;
            }

            if (!isAllError) {
                // 16/01/2019 10:20:30 SCN89000J 124 10002 20004 40007
                contentSb.append(date).append(Common.BLANK).append(StringUtils.fulfuill(String.valueOf(random.nextInt(25)))).append(Common.COLON).append(StringUtils.fulfuill(String.valueOf(random.nextInt(61)))).append(Common.COLON).append(StringUtils.fulfuill(String.valueOf(random.nextInt(61)))).append(Common.SEPARATOR);
                contentSb.append(vehiclePlate).append(Common.SEPARATOR);
                contentSb.append((random.nextInt(Common.MAX_SPEED) + 1)).append(Common.SEPARATOR);
                contentSb.append(roadId).append(Common.SEPARATOR);
                contentSb.append(monitorId).append(Common.SEPARATOR);
                contentSb.append(cameraIdArray[random.nextInt(cameraIdArray.length)]).append(Common.LINE_BREAK);
            }
        }
        return contentSb.toString();
    }
}



class FileUtils implements Serializable {

    private static final long serialVersionUID = 1L;

    public static boolean createFile(String pathFileName) {
        try {
            File file = new File(pathFileName);
            if (file.exists()) {
                System.err.println("Find file" + pathFileName + ", system will delete it now!!!");
                file.delete();
            }
            boolean createNewFile = file.createNewFile();
            System.err.println("create file " + pathFileName + " success!");
            return createNewFile;
        } catch (IOException e) {
            e.printStackTrace();
        }
        return false;
    }

    public static void saveFile(String pathFileName, String newContent) {
        FileOutputStream fos = null;
        OutputStreamWriter osw = null;
        PrintWriter pw = null;
        try {
            String content = newContent;
            File file = new File(pathFileName);
            fos = new FileOutputStream(file, true);
            osw = new OutputStreamWriter(fos, Common.CHARSETNAME_UTF_8);
            pw = new PrintWriter(osw);
            pw.write(content);
            pw.close();
            osw.close();
            fos.close();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (pw != null) {
                pw.close();
            }
            if (osw != null) {
                try {
                    osw.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (fos != null) {
                try {
                    fos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

class StringUtils {

    public static String fulfuill(String str) {
        if (str.length() == 1) {
            return Common.ZERO + str;
        }
        return str;
    }
}

/**
 * From wiki:
 * https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_Singapore<br>
 * 
 * A typical vehicle registration number comes in the format "SKV 6201 B":<br>
 * 
 * <li>S – Vehicle class ("S", with some exceptions, stands for a private
 * vehicle since 1984)</li><br>
 * <li>KV – Alphabetical series ("I" and "O" are not used to avoid confusion
 * with "1" and "0")</li><br>
 * <li>6201 – Numerical series</li><br>
 * <li>B – Checksum letter ("F","I", "N", "O", "Q", "V" and "W" are never used
 * as checksum letters; absent on special government vehicle plates and events
 * vehicle plates)</li>
 * 
 */
class VehiclePlateGenerateSG implements Serializable {

    private static final long serialVersionUID = -8006144823705880339L;

    public static Random random = new Random();

    // 主要目的就是使得產生的數字字元不在這個list裡面
    // 如果在這個list裡面找到,那麼需要重新產生
    private static List<String> uniqueList = new ArrayList<String>();

    public static String generatePlate() {
        // System.out.println(ALPHABETICAL_ARRAY[18]);// S
        String alphabeticalSeries = getAlphabeticalStr(Common.ALPHABETICAL_ARRAY, random) + getAlphabeticalStr(Common.ALPHABETICAL_ARRAY, random);
        // System.out.println(alphabeticalSeries);//KV

        String numbericalSeries = getNumericalSeriesStr(random);
        // System.out.println(numbericalSeries);//62010

        String checksumLetter = getChecksumLetterStr(Common.ALPHABETICAL_ARRAY, random);
        // System.out.println(checksumLetter);//B

        String singaporeVehiclePlate = Common.ALPHABETICAL_ARRAY[18] + alphabeticalSeries + numbericalSeries + checksumLetter;
        return singaporeVehiclePlate;
    }

    private static String getAlphabeticalStr(String[] ALPHABETICAL_ARRAY, Random random) {
        String alphabeticalStr = Common.ALPHABETICAL_ARRAY[random.nextInt(Common.ALPHABETICAL_ARRAY.length)];
        // "I", "O"
        if (!(alphabeticalStr.equals(Common.ALPHABETICAL_ARRAY[8]) || alphabeticalStr.equals(Common.ALPHABETICAL_ARRAY[14]))) {
            return alphabeticalStr;
        } else {
            return getAlphabeticalStr(Common.ALPHABETICAL_ARRAY, random);
        }
    }

    private static String getNumericalSeriesStr(Random random) {
        // 為了區別真實的車牌,我們把數字設置為5位
        String numericalStr = random.nextInt(10) + "" + random.nextInt(10) + "" + random.nextInt(10) + "" + random.nextInt(10) + "" + random.nextInt(10);
        if (uniqueList.contains(numericalStr)) {
            // 如果存在,則重新產生
            return getNumericalSeriesStr(random);
        } else {
            uniqueList.add(numericalStr);
            return numericalStr;
        }
    }

    private static String getChecksumLetterStr(String[] ALPHABETICAL_ARRAY, Random random) {
        String checksumLetter = ALPHABETICAL_ARRAY[random.nextInt(ALPHABETICAL_ARRAY.length)];
        // "F","I", "N", "O", "Q", "V" and "W"
        if (!(checksumLetter.equals(Common.ALPHABETICAL_ARRAY[5]) || checksumLetter.equals(Common.ALPHABETICAL_ARRAY[8]) || checksumLetter.equals(Common.ALPHABETICAL_ARRAY[13]) || checksumLetter.equals(Common.ALPHABETICAL_ARRAY[14]) || checksumLetter.equals(Common.ALPHABETICAL_ARRAY[16]) || checksumLetter.equals(Common.ALPHABETICAL_ARRAY[21]) || checksumLetter.equals(Common.ALPHABETICAL_ARRAY[22]))) {
            return checksumLetter;
        } else {
            return getChecksumLetterStr(ALPHABETICAL_ARRAY, random);
        }
    }
}

class Common implements Serializable {
    private static final long serialVersionUID = 1L;

    public static String VEHICLE_LOG = "./vehicle_log";
    public static String ROAD_MONITOR_CAMERA_RELATIONSHIP = "./road_monitor_camera_relationship";

    public static final String[] ALPHABETICAL_ARRAY = new String[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
    public static final String DATE_FORMAT_YYYYMMDD = "dd/MM/yyyy";
    public static final String CHARSETNAME_UTF_8 = "UTF-8";
    public static final String SEPARATOR = "\t";
    public static final String LINE_BREAK = "\n";
    public static final String BLANK = " ";
    public static final String COLON = ":";
    public static final String ZERO = "0";
    
    //車輛數
    public static final int VEHICLE_NUMBER = 100000;
    //道路數
    public static final int ROAD_NUM = 400;
    public static final int ROAD_ERROR_NUM = 8;
    //最大車速
    public static final int MAX_SPEED = 300;
}

 

2.1.編譯執行

:wq

javac DataGenerate.java
java DataGenerate

--運行完成,會生成下麵兩個文件
/root/vehicle_dir/vehicle_log
/root/vehicle_dir/road_monitor_camera_relationship

 

2.2.車輛記錄log樣本

16/01/2019 14:06:44    SVM35185L    258    10295    20590    41179
16/01/2019 15:56:25    SVM35185L    110    10288    20575    41149
16/01/2019 02:22:29    SVM35185L    28    10109    20217    40436
16/01/2019 24:29:59    SSK43417H    254    10281    20562    41123
16/01/2019 07:36:54    SSK43417H    149    10124    20247    40495
16/01/2019 12:21:30    SSK43417H    196    10211    20421    40843
16/01/2019 12:42:43    SSK43417H    92    10308    20615    41230
16/01/2019 02:57:59    SDV20274X    206    10166    20332    40663
16/01/2019 11:60:17    SDV20274X    191    10372    20744    41488
16/01/2019 00:09:06    SDV20274X    197    10094    20188    40374
16/01/2019 21:18:30    SDV20274X    294    10101    20201    40401
16/01/2019 11:23:38    SDV20274X    74    10163    20325    40652
16/01/2019 04:35:16    SDV20274X    53    10077    20153    40305
16/01/2019 20:56:56    SDV20274X    31    10113    20226    40449
16/01/2019 16:50:11    SEN89218Y    58    10202    20404    40808
16/01/2019 18:34:47    SEN89218Y    113    10042    20083    40168
16/01/2019 02:25:52    SEN89218Y    35    10051    20101    40204
16/01/2019 24:08:52    SEN89218Y    77    10165    20330    40657

 

2.3.道路-監控-攝像頭關係樣本

10001    20001    40001
10001    20001    40002
10001    20002    40003
10001    20002    40004
10002    20003    40005
10002    20003    40006
10002    20004    40007
10002    20004    40008
10003    20005    40009
10003    20005    40010
10003    20006    40011
10003    20006    40012
10004    20007    40013
10004    20007    40014
10004    20008    40015
10004    20008    40016

 

3.在Hive中創建table並且導入數據

-- 創建table,並且把結果數據導入到Hive table裡面
cd /root/vehicle_dir/

vi hive_vehicle.sql


--1.drop t_vehicle_log
drop table IF EXISTS t_vehicle_log;

--2.create t_vehicle_log
CREATE TABLE t_vehicle_log(
date_time string ,
vehicle_plate string ,
vehicle_speed int ,
road_id string ,
monitor_id string ,
camera_id string
)ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\t'
LINES TERMINATED BY '\n';

--3.load data into t_vehicle_log
load data local inpath '/root/vehicle_dir/vehicle_log' into table t_vehicle_log;

--4.drop t_road_monitor_camera_relationship
drop table IF EXISTS t_road_monitor_camera_relationship;

--5.create t_road_monitor_camera_relationship
CREATE TABLE t_road_monitor_camera_relationship(
road_id string ,
monitor_id string ,
camera_id string
)ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\t'
LINES TERMINATED BY '\n';

--6.load data into t_road_monitor_camera_relationship
load data local inpath '/root/vehicle_dir/road_monitor_camera_relationship' into table t_road_monitor_camera_relationship;

--7.drop t_monitor_camera
drop table IF EXISTS t_monitor_camera;

--8.create t_monitor_camera
create table t_monitor_camera(
monitor_id string ,
cameranum int,
workingcameranum int,
notWorkingCameraNum int
)ROW FORMAT DELIMITED
FIELDS TERMINATED BY '|'
LINES TERMINATED BY '\n';

--9.load data from other table into t_monitor_camera
from (select monitor_id, count(distinct camera_id) cameraNum from t_road_monitor_camera_relationship group by monitor_id) t1 
left outer join 
(select monitor_id, NVL(count(distinct camera_id), 0) workingCameraNum from t_vehicle_log group by monitor_id) t2
on t1.monitor_id=t2.monitor_id
insert into table t_monitor_camera
select t1.monitor_id, t1.cameraNum cameraNum, NVL(t2.workingCameraNum, 0) workingCameraNum,NVL((t1.cameraNum - NVL(t2.workingCameraNum, 0)), 0) notWorkingCameraNum;

 

4.編寫Sqoop配置文件

--配置sqoop:hive數據導入到mysql中
--註意: --export-dir /user/hive/warehouse/t_monitor_camera/ 這裡的地址可以在hive中,
--通過desc formatted t_monitor_camera 查看
--Location: hdfs://mycluster/user/hive/warehouse/t_monitor_camera

cd /root/vehicle_dir/

vi hive_to_mysql_for_vehicle

export
--connect
jdbc:mysql://node1:3306/sqoop_db
--username
root
--password
'!QAZ2wsx3edc'
--table
t_hive_to_mysql_for_vehicle
-m
1
--columns
monitor_id,camera_num,working_camera_num,not_working_camera_num
--fields-terminated-by
'|'
--export-dir
/user/hive/warehouse/t_monitor_camera/

:wq

 

5.在Mysql中創建table

--在mysql裡面創建表
mysql -u root -p 
!QAZ2wsx3edc
use sqoop_db;

--如果有則刪除
DROP TABLE IF EXISTS t_hive_to_mysql_for_vehicle;

CREATE TABLE t_hive_to_mysql_for_vehicle (monitor_id VARCHAR(5), camera_num INT, working_camera_num INT, not_working_camera_num INT);

 

 

6.編寫自動化可執行腳本

--編輯可執行腳本
cd /root/vehicle_dir/
vi hive_to_mysql_vehicle.sh

echo 'job begin'

cd /home/hive/bin
./hive -f /root/vehicle_dir/hive_vehicle.sql

echo 'begin to inport to mysql'

sqoop --options-file /root/vehicle_dir/hive_to_mysql_for_vehicle
echo 'done.'

:wq

 

7.賦予腳本可執行屬性

--賦予腳本可執行屬性
chmod +x hive_to_mysql_vehicle.sh

 

8.執行腳本

--執行腳本
./hive_to_mysql_vehicle.sh

 

9.結果

9.1.執行腳本前,檢查mysql table

--執行腳本之前,查詢t_hive_to_mysql_for_vehicle
mysql> select * from t_hive_to_mysql_for_vehicle;
Empty set (0.00 sec)

 

9.2.執行腳本

[root@node1 vehicle_dir]# ./hive_to_mysql_vehicle.sh 
job begin
19/01/16 01:00:53 WARN conf.HiveConf: DEPRECATED: hive.metastore.ds.retry.* no longer has any effect.  Use hive.hmshandler.retry.* instead

Logging initialized using configuration in jar:file:/root/apache-hive-0.13.1-bin/lib/hive-common-0.13.1.jar!/hive-log4j.properties
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/root/hadoop-2.5.1/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/root/apache-hive-0.13.1-bin/lib/slf4j-log4j12-1.6.4.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
OK
Time taken: 1.432 seconds
OK
Time taken: 0.306 seconds
Copying data from file:/root/vehicle_dir/vehicle_log
Copying file: file:/root/vehicle_dir/vehicle_log
Loading data to table default.t_vehicle_log
Table default.t_vehicle_log stats: [numFiles=1, numRows=0, totalSize=121817379, rawDataSize=0]
OK
Time taken: 5.958 seconds
OK
Time taken: 0.101 seconds
OK
Time taken: 0.042 seconds
Copying data from file:/root/vehicle_dir/road_monitor_camera_relationship
Copying file: file:/root/vehicle_dir/road_monitor_camera_relationship
Loading data to table default.t_road_monitor_camera_relationship
Table default.t_road_monitor_camera_relationship stats: [numFiles=1, numRows=0, totalSize=28799, rawDataSize=0]
OK
Time taken: 0.637 seconds
OK
Time taken: 0.094 seconds
OK
Time taken: 0.071 seconds
Total jobs = 4
Launching Job 1 out of 4
Number of reduce tasks not specified. Estimated from input data size: 1
In order to change the average load for a reducer (in bytes):
  set hive.exec.reducers.bytes.per.reducer=<number>
In order to limit the maximum number of reducers:
  set hive.exec.reducers.max=<number>
In order to set a constant number of reducers:
  set mapreduce.job.reduces=<number>
Starting Job = job_1547622676146_0025, Tracking URL = http://node1:8088/proxy/application_1547622676146_0025/
Kill Command = /home/hadoop-2.5/bin/hadoop job  -kill job_1547622676146_0025
Hadoop job information for Stage-1: number of mappers: 1; number of reducers: 1
2019-01-16 01:01:29,337 Stage-1 map = 0%,  reduce = 0%
2019-01-16 01:01:40,583 Stage-1 map 
              
您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 本文介紹windows server 1709(不含UI)版本系統的模板部署,僅限於公司內部使用 ...
  • 開發過程中,會有好多的日誌輸出到日誌文件中了,每次看日誌都需要打開,log文件,覺得麻煩 找了個省事的方法 使用PowerShell 使用命令:Get-Content D:\www\webapp1\Logs\t20190116.log -wait Get-Content 獲取指定文件的內容 -wai ...
  • 發現在shell裡面執行source,提示找不到命令。所以,我取搜了一些資料,總結一下。 一. 腳本中,source找不到命令 是因為用了sh執行腳本,而debian系統的sh指向dash。需要更改系統sh指向: (1)cd /bin (2)mv sh sh.old (3)ln -s sh bash ...
  • 一 前期準備 1.1 配置規格 節點 類型 IP CPU 記憶體 ceph-deploy 部署管理平臺 172.24.8.71 2 C 4 G node1 Monitor OSD 172.24.8.72 2 C 8 G node2 OSD 172.24.8.73 2 C 8 G node3 OSD 1 ...
  • 一、下載禪道,並傳到你的伺服器上面的/opt文件下。 二、使用命令解壓。 三、如果你伺服器上面原本就安裝了LNMP環境的,需要先停掉nginx和mysql服務。以前就是因為禪道有自帶的apache和mysql。 四、啟動禪道 五,修改禪道的埠和mysql的埠; 註意不要亂改mysql的埠,我改 ...
  • 狂神聲明 : 文章均為自己的學習筆記 , 轉載一定註明出處 ; 編輯不易 , 防君子不防小人~共勉 ! linux學習:【第3篇】遠程連接及軟體安裝 遠程連接 xshell , xftp軟體官網 : netsarang官網 Xftp : 遠程文件傳輸軟體 遠程協議使用SFTP , 埠 : 22 X ...
  • 一. 庫的操作 1.創建資料庫 創建資料庫: create database 庫名 charset utf8; charset uft8 可選項 1.2 資料庫命名規範: 可以由字母、數字、下劃線、@、#、$ 區分大小寫 唯一性 不能使用關鍵字如 create select 不能單獨使用數字 最長1 ...
  • [oracle@testrac2 11204]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Wed Jan 16 18:50:03 2019 Copyright (c) 1982, 2013, Oracle. All ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...