第一次作業操作
大家好,我是【豆干花生】,這次我帶來了大資料的第一次實踐作業~
可以說十分具體了,包含了具體操作、代碼指令、各個步驟截圖,
文章目錄
- 第一次作業操作
- 一.作業內容
- 二.準備作業
- 三.撰寫程式
- 四.運行程式
- 五.保存
一.作業內容
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-g0LXThuj-1628670451195)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210506155238219.png)]](https://img.uj5u.com/2021/08/14/2561641407141710.png)
這里選擇docker來配置環境
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-iBXMKwYx-1628670451198)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210506155313525.png)]](https://img.uj5u.com/2021/08/14/2561641407141711.png)
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-LHUKgYce-1628670451200)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210506155329169.png)]](https://img.uj5u.com/2021/08/14/2561641407141712.png)
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-kwWSWeIB-1628670451202)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210506155352962.png)]](https://img.uj5u.com/2021/08/14/2561641407141713.png)
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-mNpyLFEM-1628670451205)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210506155404936.png)]](https://img.uj5u.com/2021/08/14/2561641407141714.png)
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-Og2WdgT4-1628670451206)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210506155415933.png)]](https://img.uj5u.com/2021/08/14/2561641407141715.png)
這里采用第0組的中間處理
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-VuuYeMhi-1628670451207)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210506155444339.png)]](https://img.uj5u.com/2021/08/14/2561641407141716.png)
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-Xxwo9Y70-1628670451208)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210506155454203.png)]](https://img.uj5u.com/2021/08/14/2561641407141717.png)
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-2J2bA5pn-1628670451209)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210506164628296.png)]](https://img.uj5u.com/2021/08/14/2561641407141718.png)
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-NaMsfJZT-1628670451210)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210506164648617.png)]](https://img.uj5u.com/2021/08/14/2561641407141719.png)
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-Ir6rRLb8-1628670451211)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210506164655790.png)]](https://img.uj5u.com/2021/08/14/2561641407141720.png)
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-4G5xW6m1-1628670451212)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210506164703632.png)]](https://img.uj5u.com/2021/08/14/2561641407141721.png)
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-Nh3V0PyT-1628670451212)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210506164717224.png)]](https://img.uj5u.com/2021/08/14/2561641407141722.png)
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-579GjcA1-1628670451213)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210506164728093.png)]](https://img.uj5u.com/2021/08/14/2561641407141723.png)
二.準備作業
docker里已經配置好的環境:
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-cUKhUgpZ-1628670451214)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210420194245774.png)]](https://img.uj5u.com/2021/08/14/2561641407141724.png)
1.進入容器
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-pGDR9I5F-1628670451214)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210420194021344.png)]](https://img.uj5u.com/2021/08/14/2561641407141725.png)
docker run -itd dingms/ucas-bdms-hw-u64-2019:16.04 /bin/bash
docker ps
docker exec -it <CONTAINER ID> /bin/bash
2.開啟ssh(hdfs和hbase好像是通過ssh來連接的)
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-w8zYo5vg-1628670451215)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210420194324789.png)]](https://img.uj5u.com/2021/08/14/2561641407141726.png)
service ssh start(每次重啟容器,似乎都要重新開啟ssh)
3.可以閱讀說明檔案(關于hdfs和hbase的操作)
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-LcBlY1Xg-1628670451216)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210420194637746.png)]](https://img.uj5u.com/2021/08/14/256164140714171.png)
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-4cih2Kvf-1628670451216)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210420194726024.png)]](https://img.uj5u.com/2021/08/14/256164140714172.png)
--------------------------------------------------------------------------------
2 README
3 --------------------------------------------------------------------------------
4
5 PLEASE save your code and data to your drive!
6 WARNING: this VM will be cleaned without notice after you log out.
7 Your code and data on the VM will be lost!!!
8
9 ## Directory Layout
10
11 * example: example codes for HDFS and HBase
12 * input: input test data for homework 1
13
14
15
16 Please enter example, in order to follow the guide.
17
18 $ cd example
19
20
21 ## HDFS Usage:
22
23 ### Start and Stop
24
25 $ start-dfs.sh
26
27 then, run 'jps' to check whether following processes have been started:
28
29 * NameNode
30 * DataNode
31 * SecondaryNameNode
32
33
34 To stop HDFS, run
35
36 $ start-dfs.sh
37
38
39 ### HDFS Command List
40
41 $ hadoop fs
42
43 hdfs directory layout:
44
45 $ hadoop fs -ls /
46
47
48 ###. Run Example
49 Description:
50 put a file into HDFS by HDFS commands, and then write a Java program to
51 read the file from HDFS
52
53 1. put file to HDFS
54
55 $ hadoop fs -mkdir /hw1-input
56 $ hadoop fs -put README.md /hw1-input
57 $ hadoop fs -ls -R /hw1-input
58
59 2. write a Java program @see ./HDFSTest.java
60
61 3. compile and run Java program
62
63 $ javac HDFSTest.java
64
65 $ java HDFSTest hdfs://localhost:9000/hw1-input/README.md
66
67
68
69 ## HBase Usage:
70
71 ### Start and Stop
72
73 Start HDFS at first, then HBase.
74 $ start-dfs.sh
75 $ start-hbase.sh
76
77 then, run 'jps' to check whether following processes have been started:
78
79 * NameNode
80 * DataNode
81 * SecondaryNameNode
82 * HMaster
83 * HRegionServer
84 * HQuorumPeer
85
86 To stop HDFS, run
87
88 $ stop-hbase.sh
89 $ start-dfs.sh
90
91
92 ###. Run Example
93 Description:
94 put records into HBase
95
96 1. write a Java program @see ./HBaseTest.java
97
98 2. compile and run Java program
99
100 $ javac HBaseTest.java
101
102 $ java HBaseTest
103
104 3. check
105
106 $ hbase shell
107
108 hbase(main):001:0> scan 'mytable'
109 ROW COLUMN+CELL
110 abc column=mycf:a, timestamp=1428459927307, value=789
111 1 row(s) in 1.8950 seconds
112
113 hbase(main):002:0> disable 'mytable'
114 0 row(s) in 1.9050 seconds
115
116 hbase(main):003:0> drop 'mytable'
117 0 row(s) in 1.2320 seconds
118
119 hbase(main):004:0> exit
120
121 --------------------------------------------------------------------------------
122 version: 2019-spring
4.開啟hdfs和hbase
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-pe19GH2j-1628670451217)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210420194902263.png)]](https://img.uj5u.com/2021/08/14/256164140714173.png)
5.可以進一步查閱示例檔案,參考如何撰寫hbase和hdfs
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-mcEKISQd-1628670451218)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210420195104856.png)]](https://img.uj5u.com/2021/08/14/256164140714174.png)
HBaseTest.java
/*
2 * Make sure that the classpath contains all the hbase libraries
3 *
4 * Compile:
5 * javac HBaseTest.java
6 *
7 * Run:
8 * java HBaseTest
9 */
10
11 import java.io.IOException;
12
13 import org.apache.hadoop.conf.Configuration;
14 import org.apache.hadoop.hbase.HBaseConfiguration;
15 import org.apache.hadoop.hbase.HColumnDescriptor;
16 import org.apache.hadoop.hbase.HTableDescriptor;
17 import org.apache.hadoop.hbase.MasterNotRunningException;
18 import org.apache.hadoop.hbase.TableName;
19 import org.apache.hadoop.hbase.ZooKeeperConnectionException;
20 import org.apache.hadoop.hbase.client.HBaseAdmin;
21 import org.apache.hadoop.hbase.client.HTable;
22 import org.apache.hadoop.hbase.client.Put;
23
24 import org.apache.log4j.*;
25
26 public class HBaseTest {
27
28 public static void main(String[] args) throws MasterNotRunningException, ZooKeeperConnectionException, IOException {
29
30 Logger.getRootLogger().setLevel(Level.WARN);
31
32 // create table descriptor
33 String tableName= "mytable";
34 HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(tableName));
35
36 // create column descriptor
37 HColumnDescriptor cf = new HColumnDescriptor("mycf");
38 htd.addFamily(cf);
39
40 // configure HBase
41 Configuration configuration = HBaseConfiguration.create();
42 HBaseAdmin hAdmin = new HBaseAdmin(configuration);
43
44 if (hAdmin.tableExists(tableName)) {
45 System.out.println("Table already exists");
46 }
47 else {
48 hAdmin.createTable(htd);
49 System.out.println("table "+tableName+ " created successfully");
50 }
51 hAdmin.close();
52
53 // put "mytable","abc","mycf:a","789"
54
55 HTable table = new HTable(configuration,tableName);
56 Put put = new Put("abc".getBytes());
57 put.add("mycf".getBytes(),"a".getBytes(),"789".getBytes());
58 table.put(put);
59 table.close();
60 System.out.println("put successfully");
61 }
62 }
HBaseTest.java
HDFSTest.java
1 import java.io.*;
2 import java.net.URI;
3 import java.net.URISyntaxException;
4
5 import org.apache.hadoop.conf.Configuration;
6 import org.apache.hadoop.fs.FSDataInputStream;
7 import org.apache.hadoop.fs.FSDataOutputStream;
8 import org.apache.hadoop.fs.FileSystem;
9 import org.apache.hadoop.fs.Path;
10 import org.apache.hadoop.io.IOUtils;
11
12 /**
13 *complie HDFSTest.java
14 *
15 * javac HDFSTest.java
16 *
17 *execute HDFSTest.java
18 *
19 * java HDFSTest
20 *
21 */
22
23 public class HDFSTest {
24
25 public static void main(String[] args) throws IOException, URISyntaxException{
26 if (args.length <= 0) {
27 System.out.println("Usage: HDFSTest <hdfs-file-path>");
28 System.exit(1);
29 }
30
31 String file = args[0];
32
33 Configuration conf = new Configuration();
34 FileSystem fs = FileSystem.get(URI.create(file), conf);
35 Path path = new Path(file);
36 FSDataInputStream in_stream = fs.open(path);
37
38 BufferedReader in = new BufferedReader(new InputStreamReader(in_stream));
39 String s;
40 while ((s=in.readLine())!=null) {
41 System.out.println(s);
42 }
43
44 in.close();
45
46 fs.close();
47 }
48 }
HDFSTest.java
三.撰寫程式
作業要求如下:
[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-fipdBfWE-1628670451218)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210420195312210.png)]
需要實作三部分:從hdfs中讀取檔案,根據自己的要求處理檔案,將處理好后的檔案寫入hbase
根據之前的兩個example檔案和課件上的程式,進行撰寫程式:
//引入對應的包
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IOUtils;
import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.AbstractMap.SimpleEntry;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.MasterNotRunningException;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.ZooKeeperConnectionException;
import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Put;
import org.apache.log4j.*;
//建立public類
public class Hw1Grp0 {
private static String fileR; //File R name
private static String fileS;
private static int joinR; // R join key
private static int joinS;
private static ArrayList<Integer> resRs = new ArrayList<> (); //R result column number array
private static ArrayList<Integer> resSs = new ArrayList<> ();
private static ArrayList<String> resRStrs = new ArrayList<> ();//R column family string array
private static ArrayList<String> resSStrs = new ArrayList<> ();
private static boolean isREmpty = true; //Does res contain R's column
private static boolean isSEmpty = true;
/**
* hashmap used for join
* the String type key is the join key
* the Entry's key is the LinkedList of R's columns that in the res
* the Entry's value is the LinkedList of S's columns that in the res
*/
//使用Java內置的hashmap生成哈希表
private static HashMap<String, Entry<LinkedList<LinkedList<String>>,LinkedList<LinkedList<String>>>> joinMap = new HashMap<> ();
private static HTable table;
/**
* process the arguments
* retracts the file name, join key, and res column from the args into the member variable.
* @param input-arguments
* @return void
*/
//進行join連接
private static void processArgs(String[] args)
{
int index = 0;
String resStr;
if(args.length!=4)
{
//進行join連接
System.out.println("Usage: Hw1Grp0 R=<file-1> S=<file-2> join:R*=S* res=R*,S*");
System.exit(1);
}
//打開檔案
fileR = args[0].substring(2);
fileS = args[1].substring(2);
index = args[2].indexOf('=');
joinR = Integer.valueOf(args[2].substring(6,index));
joinS = Integer.valueOf(args[2].substring(index+2));
index = args[3].indexOf(',');
resStr = args[3].substring(4);
String[] resStrs = resStr.split(",");
for(String s : resStrs)
{
System.out.println(s);
if(s.startsWith("R"))
{
resRs.add(Integer.valueOf(s.substring(1)));
resRStrs.add(s);
isREmpty = false;
}
else
{
resSs.add(Integer.valueOf(s.substring(1)));
resSStrs.add(s);
isSEmpty = false;
}
}
}
/**
* Read File R and File S from HDFS line by line and Map them into the joinMap.
* @param void
* @return void
*/
private static void readFileFromHDFS() throws IOException, URISyntaxException
{
Configuration conf = new Configuration();
FileSystem fs = FileSystem.get(conf);
Path pathR = new Path(fileR);
Path pathS = new Path(fileS);
FSDataInputStream in_streamR = fs.open(pathR);
FSDataInputStream in_streamS = fs.open(pathS);
BufferedReader inR = new BufferedReader(new InputStreamReader(in_streamR));
BufferedReader inS = new BufferedReader(new InputStreamReader(in_streamS));
String r, s;
while((r=inR.readLine())!=null)
{
String[] tmp = r.split("\\|");
String joinKey = tmp[joinR];
LinkedList<String> joinValues = new LinkedList<String> ();
if(joinMap.containsKey(joinKey))
{
for(int i : resRs)
{
joinValues.add(tmp[i]);
}
if(isREmpty)
{
joinValues.add("");
}
joinMap.get(joinKey).getKey().add(joinValues);
}
else
{
for(int i : resRs)
{
joinValues.add(tmp[i]);
}
if(isREmpty)
{
joinValues.add("");
}
LinkedList<LinkedList<String>> rValues = new LinkedList<> ();
LinkedList<LinkedList<String>> sValues = new LinkedList<> ();
rValues.add(joinValues);
Entry<LinkedList<LinkedList<String>>, LinkedList<LinkedList<String>>> pair = new SimpleEntry<>(rValues, sValues);
joinMap.put(joinKey, pair);
}
}
while((s=inS.readLine())!=null)
{
String[] tmp = s.split("\\|");
String joinKey = tmp[joinS];
LinkedList<String> joinValues = new LinkedList<String> ();
if(joinMap.containsKey(joinKey))
{
for(int i : resSs)
{
joinValues.add(tmp[i]);
}
if(isSEmpty)
joinValues.add("");
joinMap.get(joinKey).getValue().add(joinValues);
}
}
inR.close();
inS.close();
fs.close();
}
/**
* create Result table in HBase
* @param: void
* @return: void
*/
private static void createHBaseTable() throws IOException, URISyntaxException
{
Logger.getRootLogger().setLevel(Level.WARN);
// create table descriptor
String tableName= "Result";
HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(tableName));
// create column descriptor
HColumnDescriptor cf = new HColumnDescriptor("res");
htd.addFamily(cf);
// configure HBase
Configuration configuration = HBaseConfiguration.create();
HBaseAdmin hAdmin = new HBaseAdmin(configuration);
if (hAdmin.tableExists(tableName)) {
System.out.println("Table already exists");
hAdmin.disableTable(tableName);
hAdmin.deleteTable(tableName);
System.out.println("Table has been deleted");
}
hAdmin.createTable(htd);
System.out.println("table "+tableName+ " created successfully");
hAdmin.close();
table = new HTable(configuration,tableName);
table.setAutoFlush(false);
table.setWriteBufferSize(64*1024*1024);
}
/**
* Use the joinMap to decide which record to put into the Result table.
* @param: void
* @return: void
*/
private static void hashJoin() throws IOException, URISyntaxException
{
for(String joinKey : joinMap.keySet())
{
int count = 0;
Entry<LinkedList<LinkedList<String>>, LinkedList<LinkedList<String>>> entry = joinMap.get(joinKey);
LinkedList<LinkedList<String>> rValues = entry.getKey();
LinkedList<LinkedList<String>> sValues = entry.getValue();
if(sValues.size()==0)
continue;
for(LinkedList<String> rValue : rValues)
{
for(LinkedList<String> sValue : sValues)
{
String countStr = "";
if(count != 0)
{
countStr = "." + Integer.toString(count);
}
if(!isREmpty)
{
for(int i = 0; i < rValue.size(); i++ )
{
Put put = new Put(joinKey.getBytes());
put.add("res".getBytes(), (resRStrs.get(i) + countStr).getBytes(), rValue.get(i).getBytes());
table.put(put);
}
}
if(!isSEmpty)
{
for(int i = 0; i < sValue.size(); i++ )
{
Put put = new Put(joinKey.getBytes());
put.add("res".getBytes(), (resSStrs.get(i) + countStr).getBytes(), sValue.get(i).getBytes());
table.put(put);
}
}
count++ ;
}
}
}
table.flushCommits();
table.close();
}
public static void main (String[] args) throws IOException, URISyntaxException
{
//進行join的方法
processArgs(args);
//從hbase中讀取的方法
readFileFromHDFS();
//創建哈希表
createHBaseTable();
//進行 連接
hashJoin();
return;
}
}
四.運行程式
這里要使用老師上傳的檔案:
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-CmNnlkBR-1628670451219)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210420195457365.png)]](https://img.uj5u.com/2021/08/14/256164140714175.png)
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-3SaFvoS4-1628670451220)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210420195744575.png)]](https://img.uj5u.com/2021/08/14/2561641407141727.png)
先將check檔案夾傳入ubuntu:
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-xCisRiby-1628670451221)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210420200657815.png)]](https://img.uj5u.com/2021/08/14/2561641407141728.png)
對應的Java程式也拖入其中:
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-IdfTxfzW-1628670451221)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210420200747295.png)]](https://img.uj5u.com/2021/08/14/2561641407141729.png)
使用cp指令將檔案傳入docker中:
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-1AGhPMfr-1628670451222)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210420200846355.png)]](https://img.uj5u.com/2021/08/14/2561641407141730.png)
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-v74oesdf-1628670451223)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210420201010476.png)]](https://img.uj5u.com/2021/08/14/256164140714176.png)
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-5gpoeIen-1628670451223)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210420201037430.png)]](https://img.uj5u.com/2021/08/14/256164140714177.png)
sudo docker cp /home/abc/bigdata/hw1-check/0_202028018629028_hw1.java 9d44ee5dfe3b:/home/bdms
sudo docker cp /home/abc/bigdata/hw1-check-v1.1.tar.gz 9d44:/home/bdms/homework/hw1
注意:這里的容器名稱只寫前幾位就行
在容器中,可以找到對應的java檔案和check檔案夾:
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-eNfIXT7b-1628670451224)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210420201422128.png)]](https://img.uj5u.com/2021/08/14/256164140714178.png)
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-O9BZsg2V-1628670451225)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210420201514003.png)]](https://img.uj5u.com/2021/08/14/256164140714179.png)
按照check檔案里的readme.md的指示,進行操作:
//readme.md
0. set language to POSIX
$ export LC_ALL="POSIX"
1. make sure ssh is running
$ service ssh status
if not, then run sshd (note that this is necessary in a docker container)
$ service ssh start
2. make sure HDFS and HBase are successfully started
$ start-dfs.sh
$ start-hbase.sh
check if hadoop and hbase are running correctly
$ jps
5824 Jps
5029 HMaster
5190 HRegionServer
4950 HQuorumPeer
4507 SecondaryNameNode
4173 NameNode
4317 DataNode
3. put input files into HDFS
$ ./myprepare
4. check file name format
$ ./check-group.pl <your-java-file>
5. check if the file can be compiled
$ ./check-compile.pl <your-java-file>
6. run test
$ ./run-test.pl ./score <your-java-file>
Your score will be in ./score. The run-test.pl tests 3 input cases, you will
get one score for each case. So the output full score is 3.
To run the test again, you need to first remove ./score
$ rm ./score
$ ./run-test.pl ./score <your-java-file>
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-U7AaNdm7-1628670451225)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210420201711142.png)]](https://img.uj5u.com/2021/08/14/2561641407141731.png)
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-jAHwQt3L-1628670451226)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210420202315782.png)]](https://img.uj5u.com/2021/08/14/2561641407141732.png)
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-0V3MBzbH-1628670451227)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210420202420836.png)]](https://img.uj5u.com/2021/08/14/2561641407141733.png)
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-lrfs60HG-1628670451228)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210420202452450.png)]](https://img.uj5u.com/2021/08/14/2561641407141734.png)
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-PKywx9Kv-1628670451229)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210420202514338.png)]](https://img.uj5u.com/2021/08/14/2561641407141735.png)
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-9YKXEAbG-1628670451230)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210420202541522.png)]](https://img.uj5u.com/2021/08/14/2561641407141736.png)
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-pc8HCbF0-1628670451231)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210420202646795.png)]](https://img.uj5u.com/2021/08/14/2561641407141737.png)
最后結果輸出為3,說明三個測驗都通過所以完成,
但是這個測驗結果不輸出中間結果,只保存最后的結果,
五.保存
由于容器中的操作結果不被自動保存
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-iBi8p2Cj-1628670451233)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210420203123540.png)]](https://img.uj5u.com/2021/08/14/2561641407141738.png)
https://docs.docker.com/desktop/backup-and-restore/
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-CMsqPXkz-1628670451234)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210420204038596.png)]](https://img.uj5u.com/2021/08/14/2561641407141739.png)
![[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-Dqqq3KRI-1628670451235)(C:\Users\YUANMU\AppData\Roaming\Typora\typora-user-images\image-20210420204052113.png)]](https://img.uj5u.com/2021/08/14/2561641407141740.png)
碼字不易,都看到這里了不如點個贊哦~
我是【豆干花生】,你的點贊+收藏+關注,就是我堅持下去的最大動力~

親愛的朋友,這里是我新成立的公眾號,歡迎關注!
公眾號內容包括但不限于人工智能、影像處理、信號處理等等~之后還將推出更多優秀博文,敬請期待! 關注起來,讓我們一起成長!
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/293553.html
標籤:其他
上一篇:程式員接單步驟詳細知識技能必備

