基本环境配置:

镜像

XianDian-BigData-v2.2

CentOS-7-x86_64-DVD-1511.iso

IP可自行设置

配置主机名

【master】

# hostnamectl set-hostname master
# bash

【slave1】

# hostnamectl set-hostname slave1
# bash

修改hosts文件

【master】(内网IP)

# vi /etc/hosts
192.168.200.131 master.hadoop master
192.168.200.133 slave1.hadoop

【slave1】(内网IP)

# vi /etc/hosts
192.168.200.131 master.hadoop 隧道IP 即10.0.0.0网段
192.168.200.133 slave1.hadoop slave1

备份(两个都执行)

#mv /etc/yum.repos.d/* /media/

挂载镜像

【master】

#lsblk
#mkdir /opt/centos
#mount -o loop /dev/sr0 /mnt/
#cp -rvf /mnt/* /opt/centos/
#umount /mnt/
#mount -o loop /dev/sr1 /mnt/
#cp -rvf /mnt/* /opt/
#umount /mnt/

将XianDian-BigData-v2.2.iso挂在到/mnt目录下,将其中的ambari解压到/opt目录下,并在master节点配置ftp服务。

注意:

因为安装大数据相关软件包时,可能会用到相关依赖软件包,所以需要配置Centos7 Yum源,这里可以采用IAAS中的Centos7 Yum源。

由于该操作是基于虚拟机而不是在服务器上搭建,所以需要centos镜像,并且可以使用lsblk,这个lsblk我在前两个平台搭建都有介绍。

创建master节点的repo文件

#vi /etc/yum.repos.d/ambari.repo
[centos]
name=centos
baseurl=file:///opt/centos
gpgcheck=0
enabled=1
[ambari]
name=ambari
baseurl=file:///opt/ambari-2.6.0.0
gpgcheck=0
enabled=1

搭建ftp服务器,开启并设置自启

#路径可能出错导致256错误,路径包中没有vsftpd 安装包 vsftpd-3.0.2-11.el7_2.x86_64.rpm
#解决办法
#1.从iaas/base中下载安装包导入/opt/ambari-2.6.0.0/ambari 然后使用rpm 安装
#2.cd ambari/ 进入路径 rpm -ivh vsftpd-3.0.2-11.el7_2.x86_64.rpm 开始安装
[root@master ambari]# rpm -ivh vsftpd-3.0.2-11.el7_2.x86_64.rpm
warning: vsftpd-3.0.2-11.el7_2.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
  1:vsftpd-3.0.2-11.el7_2            ################################# [100%]
#yum install vsftpd –y
#vi /etc/vsftpd/vsftpd.conf
加anon_root=/opt/
保存退出
#systemctl start vsftpd
#systemctl enable vsftpd

创建slave1节点repo文件

#vi /etc/yum.repos.d/ambari.repo
[centos]
name=centos
baseurl=ftp://192.168.100.131/centos
gpgcheck=0
enabled=1
[ambari]
name=ambari
baseurl=ftp://192.168.100.131/ambari-2.6.0.0
gpgcheck=0
enabled=1 

关闭防火墙(两节点都关)

【master、slave1】

#systemctl stop firewalld
#systemctl disable firewalld
setenforce 0

清理yum源

【master】

#yum clean all
#yum list
#vi /etc/selinux/config
SELINUX=permissive
#setenforce 0
#getenforce
permissive

【slave1】

# yum clean all
# yum list

启动httpd服务

#yum -y install httpd
#cd /opt/
#ll
#cp -rvf  HDP* /var/www/html/
#systemctl enable httpd.service
#systemctl status httpd.service

 

配置ntp

【master】

# yum -y install ntp
# vi /etc/ntp.conf
注释或者删除以下四行
server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst
添加以下两行
server 127.127.1.0 
fudge 127.127.1.0 stratum 10
#systemctl enable ntpd
#systemctl start  ntpd

【slave1】

# yum -y install ntpdate
# ntpdate master.hadoop //同步时间命令
2 Oct 06:25:32 ntpdate[2399]: adjust time server 192.168.100.10 offset -0.295545 sec
# systemctl enable ntpdate //启动服务

安装ambari-agent

yum remove xxxx yum卸载服务

 

 

 

 

 

安装配置JDK

【master】

在挂载镜像中,我是使用的/dev/sr1,如果在服务器上便是真正的镜像XianDian-BigData-v2.2.iso。

# mkdir /usr/jdk64/ 
# mount -o loop /opt/XianDian-BigData-v2.2.iso /mnt  
# cd /opt/
# tar -zxvf jdk-8u77-linux-x64.tar.gz  -C  /usr/jdk64/
# vi /etc/profile
添加
export JAVA_HOME=/usr/jdk64/jdk1.8.0_77
export PATH=$JAVA_HOME/bin:$PATH
# source /etc/profile
#java –version
java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)

【slave1】

在第二个命令是使用的masterIP,在执行完这个命令,输入的是进入虚拟机root的密码。

#mkdir /usr/jdk64/
#scp 172.24.14.106://opt/jdk-8u77-linux-x64.tar.gz .
The authenticity of host '192.168.100.10 (192.168.100.10)' can't be established.
ECDSA key fingerprint is 65:5a:7f:6e:36:75:02:aa:1f:1f:16:49:3d:7b:9e:f9.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.100.10' (ECDSA) to the list of known hosts.
root@192.168.100.10's password: 
jdk-8u77-linux-x64.tar.gz                                                                 100%  173MB  86.5MB/s   00:02  
# tar -zxvf jdk-8u77-linux-x64.tar.gz -C /usr/jdk64/
# vi /etc/profile
export JAVA_HOME=/usr/jdk64/jdk1.8.0_77
export PATH=$JAVA_HOME/bin:$PATH
# source /etc/profile
#java  –version
java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)

配置ambari-server

【master】

[root@master ambari]# rpm -ivh ambari-server-2.6.0.0-0.x86_64.rpm 
error: Failed dependencies:
        postgresql-server >= 8.1 is needed by ambari-server-2.6.0.0-0.x86_64
#[ambari@jesgoo-hz16 software]$ sudo rpm -ivh postgresql-libs-8.4.18-1.el6_4.x86_64.rpm
#[ambari@jesgoo-hz16 software]$ sudo rpm -ivh postgresql-8.4.18-1.el6_4.x86_64.rpm
#[ambari@jesgoo-hz16 software]$ sudo rpm -ivh postgresql-server-8.4.18-1.el6_4.x86_64.rpm

# yum -y install ambari-server

安装Ambari-agent

【slave1】

# vi /etc/ambari-anent/conf/ambari-agent.ini
找到	
[server]
hostname=master.hadoop

ambari-agent server start

【master】

# yum install   Ambari-agent
# vi /etc/ambari-anent/conf/ambari-agent.ini
[server]
hostname=master.hadoop

 

安装MariaDB数据库

【master】

# yum install  mariadb mariadb-server mysql-connector-java

启动服务

【master】

# systemctl enable mariadb
# systemctl start mariadb

配置MySQL

【master】

在配置MySQL中如果命令执行后一直无法展示,到时候使用reboot命令重启一下,就可以了。我在执行这个命令时,有时候出错,就是使用的reboot重启一下,就好了

#mysql_secure_installation
按enter确认后设置数据库root密码,我们这里设置为“bigdata”
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] n
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
#删除匿名用户?[是/否]是
#不允许远程根用户登录?[是/否]否
#删除测试数据库并访问它?[是/否]是
#现在重新加载特权表?[是/否]是

创建ambari数据库

# mysql -uroot -pbigdata

MariaDB [(none)]> create database ambari;
#创建数据库ambari;
MariaDB [(none)]> grant all privileges on ambari.* to 'ambari'@'localhost' identified by 'bigdata';
#将ambari.*的本地所有特权授予“ambari”
MariaDB [(none)]> grant all privileges on ambari.* to 'ambari'@'%' identified by 'bigdata';
#将ambari.*的所有主机特权授予“ambari”@“%”
MariaDB [(none)]> use ambari;
#使用ambari;
MariaDB [ambari]> source /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql
#source/var/lib/ambari server/resources/ambari DDL MySQL-创建.sql
MariaDB [ambari]> quit
#退出

导入数据库

【master】

# mysql -uroot -pbigdata  ambari < /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql

# mysql -uroot -pbigdata  
show databases;
use amabri;
MariaDB [ambari]> show  tables
MariaDB [ambari]> quit

 

安装配置ambari-server

【master】

#vi /etc/profile
export buildNumber=2.6.0.0
# ambari-server setup
WARNING: SELinux is set to 'permissive' mode and temporarily disabled.
#警告:SELinux设置为“许可”模式并暂时禁用。
OK to continue [y/n] #y
#是否继续[y/n]#y
Customize user account for ambari-server daemon [y/n] #n
#为ambari服务器后台程序自定义用户帐户[y/n]#n
Checking JDK...
#正在检查JDK。。.
[1] Oracle JDK 1.8 + Java Cryptography Extension (JCE) Policy Files 8
#[1] Oracle JDK 1.8+Java加密扩展(JCE)策略文件8
[2] Oracle JDK 1.7 + Java Cryptography Extension (JCE) Policy Files 7
#[2] Oracle JDK 1.7+Java加密扩展(JCE)策略文件7
[3] Custom JDK
#[3] 自定义JDK
==============================================================================
Enter choice (1): #3
#输入选项(1):#3
Path to JAVA_HOME: #/usr/jdk64/jdk1.8.0_77
#JAVA_HOME的路径:#/usr/jdk64/jdk1.8.0_77
Validating JDK on Ambari Server...done.
#正在验证Ambari服务器上的JDK…完成。
Completing setup...
#正在完成安装。。。
Configuring database... 
#正在配置数据库。。。
Enter advanced database configuration [y/n] # y
#输入高级数据库配置[y/n]#y
Configuring database...
#正在配置数据库。。。
====================================================================
Choose one of the following options:
#选择以下选项之一:
[1] - PostgreSQL (Embedded)
#[1] -PostgreSQL(嵌入式)
[2] - Oracle
#[2] -甲骨文
[3] - MySQL
#[3] -云数据库
[4] - PostgreSQL
[5] - Microsoft SQL Server (Tech Preview)
#[5] -Microsoft SQL Server(技术预览版)
[6] - SQL Anywhere
====================================================================
Enter choice (1): #3
#输入选项(1):#3
Hostname (localhost): 
#主机名(localhost):
Port (3306): 
#端口(3306):
Database name (ambari): 
#数据库名称(ambari):
Username (ambari): 
#用户名(ambari):
Enter Database Password (bigdata):
#输入数据库密码(bigdata):
Proceed with configuring remote database connection properties [y/n] #y
#继续配置远程数据库连接属性[y/n]#y
Ambari Server 'setup' completed successfully
#Ambari服务器“安装”已成功完成。
# ambari-server setup --jdbc-db=mysql --jdbc-driver=/usr/share/java/mysql-connector-java.jar
Ambari Server 'setup' completed successfully.
“安装”已成功完成。

启动ambari-server服务

【master】

# ambari-server start

登陆界面http://192.168.200.131:8080/

登录用户名密码为admin:admin

 

 

部署管理Hadoop集群

登陆界面http://{IP Address}:8080/,用户名密码为admin:admin。接下来就可以启动安装向导,创建集群,安装服务。

image-20201011104140951

image-20201011104216117

image-20201011104226841

http://192.168.100.10/HDP-2.6/HDP-2.6.1.0

http://192.168.100.10/HDP-2.6/HDP-UTLS-1.1.0.21

image-20201011104242777

image-20201011104407066

平台中已经安装了以下服务组件:HDFS、MapReduce2、YARN、Tez、Hive、HBase、Pig、Zookeeper、Mahout。其中master节点Mariadb数据库用户密码配置如表3所示。

image-20201011104418178

image-20201011104428640

image-20201011104515405

image-20201011104531381

image-20201011104540975

image-20201011104550823

接下来安装Hive

点击动作 ----添加服务---选择服务

slave1 节点上面没有数据库 我们使用master数据库--下一步

image-20201021091359131

 

自定义服务 ----Hive---Advanced--在mtster节点上面数据库创建一个hive数据库

# mysql -uroot -pbigdata
MariaDB [(none)]> create database hive;
MariaDB [(none)]> grant all privileges on hive.* to 'hive'@'localhost' identified by 'bigdata';
MariaDB [(none)]> grant all privileges on hive.* to 'hive'@'%' identified by 'bigdata';

 

image-20201021091513029

设置账户密码 将URL 设置为master 点击 Test 测试 ---点击下一步

image-20201021092204454

安装完成后重启服务

网页安装完毕 然后重启所有服务

在两个节点上面

#先后在master节点和slaver节点的Linux Shell中查看Hadoop集群的服务进程信息。
[root@master ~]# jps
16145 Jps
18195 Bootstrap
9668 DataNode
23796 QuorumPeerMain
10053 NameNode
11285 NodeManager
3340 HMaster
1374 AmbariServer
3375 ApplicationHistoryServer
[root@slaverl~]#jps
20529 RunJar
8242 NodeManager
7907 ApplicationHistoryServer
19509 RunJar
5830 SecondaryNameNode
17494 Jps
5464 DataNode
21129 RunJar
9513 QuorumPeerMain
7117 JobHistoryServer
8637 ResourceManager

大数据运维

1.HDFS管理(2分)

(1)在HDFS文件系统的根目录下创建目录yidaoyun/file;

(2)将附件中的BigDataSkills.txt文件上传到yidaoyun/file目录中;

(3)查看HDFS中yidaoyun/file目录的文件列表信息;

(4)查询HDFS文件系统中/tmp目录下的目录个数、文件个数和文件总大小。

依次将操作命令及返回结果以文本形式提交到答题框。

[root@master ~]# hadoop fs -mkdir -p /yidaoyun/file
[root@master ~]# hadoop fs -put BigDataSkills.txt /yidaoyun/file
[root@master ~]# hadoop fs -ls /yidaoyun/file 
Found 1 items
-rw-r--r--  3 root hdfs     49 2017-05-06 09:57 /yidaoyun/file/BigDataSkills.txt
[root@master ~]# hadoop fs -count /tmp
​     21      6        4336 /tmp

 

2.HBase管理(2分)

登录大数据master节点,新建hbasetest.txt文件,编写内容,要求如下:

(1)新建一张表为'test', 列族为'cf';

(2)向这张表批量插入如下数据;

'row1', 'cf:a', 'value1'

'row2', 'cf:b', 'value2'

'row3', 'cf:c', 'value3'

'row4', 'cf:d', 'value4'

(3)插入数据完毕后用scan命令查询表内容;

(4)用get命令只查询row1的内容;

(5)最后退出hbase shell。

使用命令运行hbasetest.txt。依次将hbasetest.txt的内容、执行命令和返回结果以文本形式提交到答题框。

[root@exam1 ~]# cat hbasetest.txt 
create 'test', 'cf' 
list 'test' 
put 'test', 'row1', 'cf:a', 'value1' 
put 'test', 'row2', 'cf:b', 'value2' 
put 'test', 'row3', 'cf:c', 'value3' 
put 'test', 'row4', 'cf:d', 'value4' 
scan 'test' 
get 'test', 'row1' 
exit
[root@exam1 ~]# hbase shell hbasetest.txt 
0 row(s) in 1.5010 seconds
TABLE                                           
test                                            
1 row(s) in 0.0120 seconds
0 row(s) in 0.1380 seconds
0 row(s) in 0.0090 seconds
0 row(s) in 0.0050 seconds
0 row(s) in 0.0050 seconds
ROW           COLUMN+CELL                            
 row1          column=cf:a, timestamp=1522314428726, value=value1         
 row2          column=cf:b, timestamp=1522314428746, value=value2         
 row3          column=cf:c, timestamp=1522314428752, value=value3         
 row4          column=cf:d, timestamp=1522314428758, value=value4         
4 row(s) in 0.0350 seconds
COLUMN         CELL                               
 cf:a          timestamp=1522314428726, value=value1               
1 row(s) in 0.0190 seconds

 

3.Spark案例-单词统计(2分)

登录大数据master节点,在root目录下新建一个abc.txt,里面的内容为(单词之间用空格隔开):

#hadoop hive 
#solr  redis 
#kafka  hadoop 
#storm  flume 
#sqoop  docker 
#spark  spark 
#hadoop spark 
#elasticsearch  hbase 
#hadoop hive 
#spark  hive 
#hadoop spark

登录spark-shell,首先使用命令统计abc.txt的行数,接着对abc.txt文档中的单词进行计数,并按照单词首字母的升序进行排序,最后统计结果行数。依次将操作命令及返回结果以文本形式提交到答题框。

4.Sqoop管理(2分)

使用Sqoop工具查询master节点MySQL中的所有数据库。依次将操作命令及返回结果以文本形式提交到答题框。

[root@master ~]# sqoop list-databases --connect jdbc:mysql://localhost --username root --password bigdata       
Warning: /usr/hdp/2.4.3.0-227/accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
17/05/07 07:02:34 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6.2.4.3.0-227
17/05/07 07:02:34 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
17/05/07 07:02:34 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.
information_schema
ambari
mysql
performance_schema

5.Ambari平台添加MongoDB Cluster模块(2分)

使用提供的MongoDB安装包,在Ambari平台增加服务界面增加MongoDB Cluster模块,配置完成后,在页面添加MongoDB服务并验证。依次将操作命令及返回结果以文本形式提交到答题框。

大数据平台运维 HDFS题: 1.在HDFS文件系统的根目录下创建递归目录“1daoyun/file”,将附件中的BigDataSkills.txt文件,上传到1daoyun/file目录中,使用相关命令查看文件系统中1daoyun/file目录的文件列表信息,将操作命令和返回结果以文本形式提交到答题框。

[root@master ~]# hadoop fs -mkdir -p /1daoyun/file [root@master ~]# hadoop fs -put BigDataSkills.txt /1daoyun/file [root@master ~]# hadoop fs -ls /1daoyun/file

2.在HDFS文件系统的根目录下创建递归目录“1daoyun/file”,将附件中的BigDataSkills.txt文件,上传到1daoyun/file目录中,并使用HDFS文件系统检查工具检查文件是否受损,将操作命令和返回结果以文本形式提交到答题框。

[root@master ~]# hadoop fs -mkdir -p /1daoyun/file [root@master ~]# hadoop fs -put BigDataSkills.txt/1daoyun/file [root@master ~]# hadoop fsck /1daoyun/file/BigDataSkills.txt

3.在HDFS文件系统的根目录下创建递归目录“1daoyun/file”,将附件中的BigDataSkills.txt文件,上传到1daoyun/file目录中,上传过程指定BigDataSkills.txt文件在HDFS文件系统中的复制因子为2,并使用fsck工具检查存储块的副本数,将操作命令和返回结果以文本形式提交到答题框。

[root@master ~]# hadoop fs -mkdir -p /1daoyun/file [root@master ~]# hadoop fs -D dfs.replication=2 -put BigDataSkills.txt /1daoyun/file [root@master ~]# hadoop fsck /1daoyun/file/BigDataSkills.txt

4.HDFS文件系统的根目录下存在一个/apps的文件目录,要求开启该目录的可创建快照功能,并为该目录文件创建快照,快照名称为apps_1daoyun,使用相关命令查看该快照文件的列表信息,将操作命令和返回结果以文本形式提交到答题框。

[root@master ~]# hadoop dfsadmin -allowSnapshot /apps [root@master ~]# hadoop fs -createSnapshot /apps apps_1daoyun [root@master ~]# hadoop fs -ls /apps/.snapshot

5.HDFS文件系统的/user/root/small-file目录中存在一些小文件,要求使用Hadoop Arachive工具将这些小文件归档成为一个文件,文件名为xiandian-data.har。归档完成后,查看xiandian-data.har的列表信息,输出结果为。

[root@master ~]# hadoop archive -archiveName xiandian-data.har -p /user/root/small-file /user/root/ [root@master ~]# hadoop fs -ls /user/root/xiandian-data.har

6.当Hadoop集群启动的时候,会首先进入到安全模式的状态,该模式默认30秒后退出。当系统处于安全模式时,只能对HDFS文件系统进行读取,无法进行写入修改删除等的操作。现假设需要对Hadoop集群进行维护,需要使集群进入安全模式的状态,并检查其状态。将集群进入安全模式和检查安全模式状态的操作命令以文本形式提交到答题框中。

[root@master ~]# hdfs dfsadmin -safemode enter [root@master ~]# hdfs dfsadmin -safemode get

7.为了防止操作人员误删文件,HDFS文件系统提供了回收站的功能,但过多的垃圾文件会占用大量的存储空间。要求在先电大数据平台的WEB界面将HDFS文件系统回收站中的文件彻底删除的时间间隔为7天,以文本形式提交修改的文件名称、参数信息和参数值到答题框中。

高级core-site fs.trash.interval 10080

8.为了防止操作人员误删文件,HDFS文件系统提供了回收站的功能,但过多的垃圾文件会占用大量的存储空间。要求在Linux Shell中使用“vi”命令修改相应的配置文件以及参数信息,关闭回收站功能。完成后,重启相应的服务。以文本形式提交以上操作命令和修改的参数信息到答题框中。

[root@master ]# vi /etc/hadoop/2.4.3.0-227/0/core-site.xml

fs.trash.interval 0

[root@master ~]# su - hdfs [hdfs@master ~]/ u s r / h d p / c u r r e n t / h a d o o p − c l i e n t / s b i n / h a d o o p − d a e m o n . s h − − c o n f i g / u s r / h d p / c u r r e n t / h a d o o p − c l i e n t / c o n f s t o p n a m e n o d e [ h d f s @ m a s t e r ] /usr/hdp/current/hadoop-client/sbin/hadoop-daemon.sh --config /usr/hdp/current/hadoop-client/confstop namenode [hdfs@master ~]/usr/hdp/current/hadoo**pclien**t/sbi**n/hadoo**pdaemo**n.s**h−−confi**g/usr/hdp/current/hadoo**pclien**t/confstopnamenod**e[hdf**s@maste**r ]/usr/hdp/current/hadoop-client/sbin/hadoop-daemon.sh --config /usr/hdp/current/hadoop-client/confstart namenode [hdfs@master ~]/ u s r / h d p / c u r r e n t / h a d o o p − c l i e n t / s b i n / h a d o o p − d a e m o n . s h − − c o n f i g / u s r / h d p / c u r r e n t / h a d o o p − c l i e n t / c o n f s t o p d a t a n o d e [ h d f s @ m a s t e r ] /usr/hdp/current/hadoop-client/sbin/hadoop-daemon.sh --config /usr/hdp/current/hadoop-client/confstop datanode [hdfs@master ~]/usr/hdp/current/hadoo**pclien**t/sbi**n/hadoo**pdaemo**n.s**h−−confi**g/usr/hdp/current/hadoo**pclien**t/confstopdatanod**e[hdf**s@maste**r ]/usr/hdp/current/hadoop-client/sbin/hadoop-daemon.sh --config /usr/hdp/current/hadoop-client/confstart datanode

9.为了防止操作人员误删文件,HDFS文件系统提供了回收站的功能,假设一名工程师发现自己前一天以root用户的身份不小心删除了HDFS文件系统中一个名为cetc55.txt的文件,现需要你使用find命令找到这个文件路径,并还原文件至原来的位置。完成后输出结果为。

[root@master ~]# hadoop fs -find / -name ‘cetc55.txt’ [root@master ~]# hadoop fs -mv /user/root/.Trash/Current/cetc55.txt /

10.Hadoop集群中的主机在某些情况下会出现宕机或者系统损坏的问题,一旦遇到这些问题,HDFS文件系统中的数据文件难免会产生损坏或者丢失,为了保证HDFS文件系统的可靠性,现需要在先电大数据平台的WEB界面将集群的冗余复制因子修改为5,以文本形式提交修改的参数信息和参数值输出结果为。

General Block replication 5

11.Hadoop集群中的主机在某些情况下会出现宕机或者系统损坏的问题,一旦遇到这些问题,HDFS文件系统中的数据文件难免会产生损坏或者丢失,为了保证HDFS文件系统的可靠性,需要将集群的冗余复制因子修改为5,在Linux Shell中使用“vi”命令修改相应的配置文件以及参数信息,完成后,重启相应的服务。以文本形式提交以上操作命令和修改的参数信息输出结果为。

[root@master ~]# vi/etc/hadoop/2.4.3.0-227/0/hdfs-site.xml

dfs.replication 5

[root@master ~]# su - hdfs [hdfs@master ~]/ u s r / h d p / c u r r e n t / h a d o o p − c l i e n t / s b i n / h a d o o p − d a e m o n . s h − − c o n f i g / u s r / h d p / c u r r e n t / h a d o o p − c l i e n t / c o n f s t o p n a m e n o d e [ h d f s @ m a s t e r ] /usr/hdp/current/hadoop-client/sbin/hadoop-daemon.sh --config /usr/hdp/current/hadoop-client/confstop namenode [hdfs@master ~]/usr/hdp/current/hadoo**pclien**t/sbi**n/hadoo**pdaemo**n.s**h−−confi**g/usr/hdp/current/hadoo**pclien**t/confstopnamenod**e[hdf**s@maste**r ]/usr/hdp/current/hadoop-client/sbin/hadoop-daemon.sh --config /usr/hdp/current/hadoop-client/confstart namenode [hdfs@master ~]/ u s r / h d p / c u r r e n t / h a d o o p − c l i e n t / s b i n / h a d o o p − d a e m o n . s h − − c o n f i g / u s r / h d p / c u r r e n t / h a d o o p − c l i e n t / c o n f s t o p d a t a n o d e [ h d f s @ m a s t e r ] /usr/hdp/current/hadoop-client/sbin/hadoop-daemon.sh --config /usr/hdp/current/hadoop-client/confstop datanode [hdfs@master ~]/usr/hdp/current/hadoo**pclien**t/sbi**n/hadoo**pdaemo**n.s**h−−confi**g/usr/hdp/current/hadoo**pclien**t/confstopdatanod**e[hdf**s@maste**r ]/usr/hdp/current/hadoop-client/sbin/hadoop-daemon.sh --config /usr/hdp/current/hadoop-client/confstart datanode

12.使用命令查看hdfs文件系统中/tmp目录下的目录个数,文件个数和文件 总大小,将操作命令和返回结果以文本形式提交到答题框。

[root@master ~]# hadoop fs -count /tmp

MapReduce题: 1.在集群节点中/usr/hdp/2.4.3.0-227/hadoop-mapreduce/目录下,存在一个案例JAR包hadoop-mapreduce-examples.jar。运行JAR包中的PI程序来进行计算圆周率π的近似值,要求运行5次Map任务,每个Map任务的投掷次数为5,运行完成后以文本形式提交以上操作命令和输出结果到答题框中。

[root@master ~]# hadoop jar /usr/hdp/2.4.3.0-227/hadoop-mapreduce/hadoop-mapreduce-examples-2.7.1.2.4.3.0-227.jar pi 5 5

2.在集群节点中/usr/hdp/2.4.3.0-227/hadoop-mapreduce/目录下,存在一个案例JAR包hadoop-mapreduce-examples.jar。运行JAR包中的wordcount程序来对/1daoyun/file/BigDataSkills.txt文件进行单词计数,将运算结果输出到/1daoyun/output目录中,使用相关命令查询单词计数结果,以文本形式提交以上 操作命令和输出结果到答题框中。

[root@master ~]# hadoop jar/usr/hdp/2.4.3.0-227/hadoop-mapreduce/hadoop-mapreduce-examples-2.7.1.2.4.3.0-227.jar wordcount /1daoyun/file/BigDataSkills.txt /1daoyun/output

3.在集群节点中/usr/hdp/2.4.3.0-227/hadoop-mapreduce/目录下,存在一个案例JAR包hadoop-mapreduce-examples.jar。运行JAR包中的sudoku程序来计算下表中数独运算题的结果。运行完成后以文本形式提交以上操作命令和输出结果到答题框中。

[root@master ~]# cat puzzle1.dta [root@master hadoop-mapreduce]# hadoop jarhadoop-mapreduce-examples-2.7.1.2.4.3.0-227.jar sudoku /root/puzzle1.dta

4.在集群节点中/usr/hdp/2.4.3.0-227/hadoop-mapreduce/目录下,存在一个案例JAR包hadoop-mapreduce-examples.jar。运行JAR包中的grep程序来统计文件系统中/1daoyun/file/BigDataSkills.txt文件中“Hadoop”出现的次数,统计完成后,查询统计结果信息。以文本形式提交以上操作命令和输出结果到答题框中。

[root@master hadoop-mapreduce]# hadoop jarhadoop-mapreduce-examples-2.7.1.2.4.3.0-227.jar grep /1daoyun/file/BigDataSkills.txt /output hadoop

HBase题: 1.启动先电大数据平台的Hbase数据库,其中要求使用master节点的RegionServer。在Linux Shell中启动Hbase shell,查看HBase的版本信息。将以上操作命令(相关数据库命令语言请全部使用小写格式)以文本形式提交到答题框。

[root@master ~]# hbase shell hbase(main):001:0> version

2.启动先电大数据平台的Hbase数据库,其中要求使用master节点的RegionServer。在Linux Shell中启动Hbase shell,查看HBase的状态信息。将以上操作命令(相关数据库命令语言请全部使用小写格式)以文本形式提交到答题框。

[root@master ~]# hbase shell hbase(main):001:0> status

3.启动先电大数据平台的Hbase数据库,其中要求使用master节点的RegionServer。在Linux Shell中启动Hbase shell,查看进入HBase shell的当前系统用户。将以上操作命令(相关数据库命令语言请全部使用小写格式)以文本形式提交到答题框。

[root@master ~]# hbase shell hbase(main):001:0> whoami

4.在HBase数据库中创建表xiandian_user,列族为info,创建完成后查看 xiandian_user表的描述信息。将以上操作命令(相关数据库命令语言请全部使用小写格式)以文本形式提交到答题框。

hbase(main):001:0> create ‘xiandian_user’,‘info’ hbase(main):003:0> describe ‘xiandian_user’

5.开启HBase的安全认证功能,在HBase Shell中设置root用户拥有表 xiandian_user的读写与执行的权限,设置完成后,使用相关命令查看其权限信息。将开启HBase的安全认证功能的参数和参数值以及以上操作命令(相关数据库命令语言请全部使用小写格式)和查询结果以文本形式提交到答题框。

参数 hbase.security.authorization 参数值 true

hbase(main):001:0> grant’root’,‘RWX’,‘xiandian_user’ hbase(main):002:0> user_permission ‘xiandian_user’

6.在HBase Shell创建表xiandian_user,列族为info,并list查询,之后删除这个表,并list查询,将操作命令和查询结果以文本形式提交到答题框。

hbase(main):001:0> create ‘xiandian_user’,‘info’ hbase(main):002:0> list hbase(main):003:0> disable ‘xiandian_user’ hbase(main):004:0> drop ‘xiandian_user’ hbase(main):005:0> list

7.在Hbase Shell中创建表xiandian,向表xiandian中插入一组数据为 xiandian,row1,info:name,xiaoming,插入后查询表xiandian中rowkey为row1的记录,将操作命令和返回结果以文本形式提交到答题框。

hbase(main):001:0> create ‘xiandian_user’,‘info’ hbase(main):002:0> put ‘xiandian_user’,‘row1’,‘info:name’,‘xiaoming’ hbase(main):003:0> get ‘xiandian_user’ ‘row1’

8.在Hbase Shell中创建表xiandian,列族为“info”然后查询表中所有的记录,将操作命令和返回结果以文本形式提交到答题框。

hbase(main):001:0> create ‘xiandian_user’,‘info’ hbase(main):002:0> scan ‘xiandian_user’

9.登录hbase数据库,使用命令创建一张表,列族为member_id’,‘address’,‘info’,创建完毕后查看该表的详细信息,后来发现列族’member_id’这个列族是多余的,需要删除,使用命令将该列族删除并查看详细信息,最后查看该表是否是enabled的。将上述所有命令和返回结果以文本形式提交到答题框。

[root@master ~]# hbase shell hbase(main):001:0> create ‘xiandian_user’,‘member_id’,‘address’,‘info’ hbase(main):002:0> describe ‘xiandian_user’ hbase(main):003:0> disable ‘xiandian_user’ hbase(main):004:0> alter ‘xiandian_user’,‘delete’=>‘member_id’ hbase(main):005:0> describe ‘xiandian_user’ hbase(main):006:0> enable ‘xiandian_user’ hbase(main):007:0> is_enabled ‘xiandian_user’

10.登录hbase数据库,创建一张表,列族为’address’,‘info’,创建完之后,向该表插入数据,插入完毕后,使用命令按照要求查询所需信息。将以上所有的操作命令和返回结果以文本形式提交到答题框。

11.登录hbase数据库,新建一张表,列族为’address’,‘info’,创建完之后,向该表插入数据,插入之后查询这条信息,并修改信息,改完后,查询修改前和修改后的信息。将以上所有操作命令和返回结果以文本形式提交到答题框。

修改也是用put命令

12.登录hbase数据库,创建一张表,列族为’address’,‘info’,创建完之后,向该表插入数据,插入完毕后,使用scan命令查询该表指定startrow的信息。 将以上所有操作命令和返回结果以文本形式提交到答题框。

13.在关系数据库系统中,命名空间namespace是表的逻辑分组,同一组中的表有类似的用途。登录hbase数据库,新建一个命名空间叫newspace并用list查询,然后在这个命名空间中创建表,列族为’address’,‘info’,创建完之后,向该表插入数据,插入完毕后,使用scan命令只查询表中特定的信息,将以上所有操作命令和返回结果以文本形式提交到答题框。

create_namespace ‘newspace’ list_namespace create ‘newspace:xiandian_user’,‘address’,‘info’

14.登录master节点,在本地新建一个文件叫hbasetest.txt文件,编写内容,要求新建一张表为’test’,列族为’cf’,然后向这张表批量插入数据,数据如下所示: ‘row1’, ‘cf:a’, ‘value1’ ‘row2’, ‘cf:b’, ‘value2’ ‘row3’, ‘cf:c’, ‘value3’ ‘row4’, ‘cf:d’, ‘value4’ 在插入数据完毕后用scan命令查询表内容,然后用get命令只查询row1的 内容,最后退出hbase shell。使用命令运行hbasetest.txt,将hbasetest.txt的内容和执行命令后的返回结果以文本形式提交到答题框。

[root@master ~]# cat hbasetest.txt create ‘test’,‘cf’ list ‘test’ put ‘test’,‘row1’,‘cf:a’ ‘value1’ put ‘test’,‘row2’,‘cf:b’,‘value2’ put ‘test’,‘row3’,‘cf:c’,‘value3’ put ‘test’,‘row4’,‘cf:d’,‘value4’ scan ‘test’ get ‘test’ ‘row1’ exit

[root@master ~]# hbase shell hbasetest.txt

Hive题: 1.启动先电大数据平台的Hive数据仓库,启动Hvie客户端,通过Hive查 看hadoop所有文件路径(相关数据库命令语言请全部使用小写格式),将操作命令查询结果以文本形式提交到答题框中。

[root@master ~]# hive hive> dfs -ls;

2.使用Hive工具来创建数据表xd_phy_course,将phy_course_xd.txt导入到该表中,其中xd_phy_course表的数据结构如下表所示。导入完成后,通过hive查询数据表xd_phy_course中数据在HDFS所处的文件位置列表信息,将以上操作命令(相关数据库命令语言请全部使用小写格式)和输出结果以文本形式提交到答题框。 stname(string) stID(int) class(string) opt_cour(string)

hive> create table xd_phy_course (stname string,stID int,class string,opt_cour string) row format delimited fields terminated by ‘\t’ lines terminated by ‘\n’ stored as textfile;

hive> load data local inpath ‘/root/phy_course_xd.txt’ into table xd_phy_course;

hive> dfs -ls /apps/hive/warehouse;

3.使用Hive工具来创建数据表xd_phy_course,并定义该表为外部表,外部存储位置为/1daoyun/data/hive,将phy_course_xd.txt导入到该表中,其中xd_phy_course表的数据结构如下表所示。导入完成后,在hive中查询数据表xd_phy_course的数据结构信息,将以上操作命令(相关数据库命令语言请全部使用小写格式)和输出结果以文本形式提交到答题框。

hive> create external table xd_phy_course (stnamestring,stID int,class string,opt_cour string) row format delimited fields terminated by ‘\t’ lines terminated by ‘\n’ location ‘/1daoyun/data/hive’;

hive> load data local inpath '/root/phy_course_xd.txt’into table xd_phy_course;

hive> desc xd_phy_course2;

4.使用Hive工具来查找出phy_course_xd.txt文件中某高校Software_1403班级报名选修volleyball的成员所有信息,其中phy_course_xd.txt文件数据结构如下表所示,选修科目字段为opt_cour,班级字段为class,将以上操作命令(相关数据库命令语言请全部使用小写格式)和输出结果以文本形式提交到答题框。

hive> create table xd_phy_course (stnamestring,stID int,class string,opt_cour string) row format delimited fields terminated by ‘\t’ lines terminated by ‘\n’;

hive> load data local inpath’/root/phy_course_xd.txt’ into table xd_phy_course;

hive> select * from xd_phy_course where class=‘Software_1403’ and opt_cour=‘volleyball’;

5.使用Hive工具来统计phy_course_xd.txt文件中某高校报名选修各个体育科目的总人数,其中phy_course_xd.txt文件数据结构如下表所示,选修科目字段为opt_cour,将统计的结果导入到表phy_opt_count中,通过SELECT语句查询表phy_opt_count内容,将统计语句以及查询命令(相关数据库命令语言请全部使用小写格式)和输出结果以文本形式提交到答题框。

hive> create table xd_phy_course (stname string,stIDint,class string,opt_cour string) row format delimited fields terminated by’\t’ lines terminated by ‘\n’;

hive> load data local inpath’/root/phy_course_xd.txt’ into table xd_phy_course;

hive> create table phy_opt_count (opt_cour string,cour_count int) row format delimited fields terminated by ‘\t’ linesterminated by ‘\n’;

hive> insert overwrite table phy_opt_count select xd_phy_course.opt_cour,count(distinct xd_phy_course.stID) from xd_phy_course group by xd_phy_course.opt_cour;

hive> select * from phy_opt_count;

6.使用Hive工具来查找出phy_course_score_xd.txt文件中某高校Software_1403班级体育选修成绩在90分以上的成员所有信息,其中phy_course_score_xd.txt文件数据结构如下表所示,选修科目字段为opt_cour,成 绩字段为score,将以上操作命令(相关数据库命令语言请全部使用小写格式)和输出结果以文本形式提交到答题框。 stname(string) stID(int) class(string) opt_cour(string) score(float)

hive> create table phy_course_score_xd (stnamestring,stID int,class string,opt_cour string,score float) row format delimited fields terminated by ‘\t’ lines terminated by ‘\n’;

hive> load data local inpath’/root/phy_course_score_xd.txt’ into table phy_course_score_xd;

hive> select * from phy_course_score_xd whereclass=‘Software_1403’ and score>90;

7.使用Hive工具来统计phy_course_score_xd.txt文件中某高校各个班级体育课的平均成绩,使用round函数保留两位小数。其中phy_course_score_xd.txt文件数据结构如下表所示,班级字段为class,成绩字段为score,将以上操作命令(相关数据库命令语言请全部使用小写格式)和输出结果以文本形式提交到答题框。

hive> select class,round(avg(score)) from phy_course_score_xd group by class;

8.使用Hive工具来统计phy_course_score_xd.txt文件中某高校各个班级体育课的最高成绩。其中phy_course_score_xd.txt文件数据结构如下表所示,班级字段为class,成绩字段为score,将以上操作命令(相关数据库命令语言请全部使用小写格式)和输出结果以文本形式提交到答题框。

hive> select class,max(score) from phy_course_score_xd group by class;

9.在Hive数据仓库将网络日志weblog_entries.txt中分开的request_date和request_time字段进行合并,并以一个下划线“_”进行分割,如下图所示,其中weblog_entries.txt的数据结构如下表所示。将以上操作命令(相关数据库命令语言请全部使用小写格式)和后十行输出结果以文本形式提交到答题框。 md5(string) url(string) request_date(string) request_time(string) ip(string)

hive> create external table weblog_entries (md5string,url string,request_date string,request_time string,ip string) row formatdelimited fields terminated by ‘\t’ lines terminated by ‘\n’ location’/data/hive/weblog/’;

hive> load data local inpath’/root/weblog_entries.txt’ into table weblog_entries;

hive> select concat_ws(’_’, request_date,request_time) from weblog_entries;

10.在Hive数据仓库将网络日志weblog_entries.txt中的IP字段与ip_to_country中IP对应的国家进行简单的内链接,输出结果如下图所示,其中 weblog_entries.txt的数据结构如下表所示。将以上操作命令(相关数据库命令语言请全部使用小写格式)和后十行输出结果以文本形式提交到答题框。

hive> create table ip_to_country (ip string,countrystring) row format delimited fields terminated by ‘\t’ lines terminated by '\n’location ‘/data/hive/ip_to_county/’;

hive> load data local inpath’/root/ip_to_country.txt’ into table ip_to_country;

hive> select wle.*,itc.country from weblog_entrieswle join ip_to_country itc on wle.ip=itc.ip;

11.使用Hive动态地关于网络日志weblog_entries.txt的查询结果创建Hive表。通过创建一张名为weblog_entries_url_length的新表来定义新的网络日志数据库的三个字段,分别是url,request_date,request_time。此外,在表中定义一个获取url字符串长度名为“url_length”的新字段,其中 weblog_entries.txt的数据结构如下表所示。完成后查询weblog_entries_url_length表文件内容,将以上操作命令(相关数据库命令语言请全部使用小写格式)和后十行输出结果以文本形式提交到答题框。

hive> create tableweblog_entries_url_length as select url, request_date, request_time,length(url) as url_length from weblog_entries;

hive> select * from weblog_entries_url_length;

Sqoop题:

1.在master和slaver节点安装Sqoop Clients,完成后,在master节点查看Sqoop的版本信息,将操作命令和输出结果以文本形式提交到答题框中。

[root@master ~]# sqoop version

2.使用Sqoop工具列出master节点中MySQL中所有数据库,将操作命令和 输出结果以文本形式提交到答题框中。

[root@master ~]# sqoop list-databases --connect jdbc:mysql://localhost --username root --password bigdata

3.使用Sqoop工具列出master节点中MySQL中ambari数据库中所有的数据表,将操作命令和输出结果以文本形式提交到答题框中。

[root@master ~]# sqoop list-tables --connectjdbc:mysql://localhost/ambari --username root --password bigdata

4.在MySQL中创建名为xiandian的数据库,在xiandian数据库中创建 xd_phy_course数据表,其数据表结构如表1所示。使用Hive工具来创建数据表xd_phy_course,将phy_course_xd.txt导入到该表中,其中xd_phy_course 表的数据结构如表2所示。使用Sqoop工具将hive数据仓库中的xd_phy_course表导出到master节点的MySQL中xiandain数据库的xd_phy_course表。将以上操作命令和输出结果以文本形式提交到答题框中。 表1 stname varchar(20) stID int(1) class varchar(20) opt_cour varchar(20) 表2 stname(string) stID(int) class(string) opt_cour(string)

[root@master ~]# mysql -uroot -pbigdata

MariaDB [(none)]> create database xiandian; MariaDB [(none)]> use xiandian;

MariaDB [xiandian]> create table xd_phy_course(stnamevarchar(20),stID int(1),class varchar(20),opt_cour varchar(20));

hive> create table xd_phy_course3 (stnamestring,stID int,class string,opt_cour string) row format delimited fields terminated by ‘\t’ lines terminated by ‘\n’;

hive> load data local inpath’/root/phy_course_xd.txt’ into table xd_phy_course3;

[root@master ~]# sqoop export --connectjdbc:mysql://localhost:3306/xiandian --username root --password bigdata --table xd_phy_course --hcatalog-database sopdm --hcatalog-table xd_phy_course

[root@master ~]# sqoop export --connectjdbc:mysql://localhost:3306/xiandian --username root --password bigdata --table xd_phy_course --hcatalog-table xd_phy_course

5.在Hive中创建xd_phy_course数据表,其数据表结构如下表所示。使用 Sqoop工具将MySQL中xiandian数据库下xd_phy_course表导入到Hive数据仓库中的xd_phy_course表中。

[root@master ~]# hive hive> create table xd_phy_course4 (stnamestring,stID int,class string,opt_cour string) row format delimited fields terminated by ‘\t’ lines terminated by ‘\n’;

[root@master ~]# sqoop import --connectjdbc:mysql://localhost:3306/xiandian --username root --password bigdata --tablexd_phy_course --hive-import --hive-overwrite --hive-table xd_phy_course4 -m 1–fields-terminated-by ‘\t’ --lines-terminated-by ‘\n’

Pig题: 1.在master节点安装Pig Clients,打开Linux Shell以MapReduce模式启动它的Grunt,将启动命令和启动结果以文本形式提交到答题框中。

[root@master ~]# pig [root@master ~]# pig -x mapreduce

2.在master节点安装Pig Clients,打开Linux Shell以Local模式启动它的Grunt,将启动命令和启动结果以文本形式提交到答题框中。

[root@master ~]# pig -x local

3.使用Pig工具在Local模式计算系统日志access-log.txt中的IP的点击数,要求使用GROUP BY语句按照IP进行分组,通过FOREACH运算符,对关系的列进行迭代,统计每个分组的总行数,最后使用DUMP语句查询统计结果。将查询命令和查询结果以文本形式提交到答题框中。

[root@master ~]# pig grunt> copyFromLocal /root/access_log.txt /user/root/input/log1.txt

grunt> A =LOAD ‘/user/root/input/log1.txt’ USINGPigStorage (’ ') AS (ip,others);

grunt> group_ip =group A by ip;

grunt> result =foreach group_ip generategroup,COUNT(A);

grunt> dump result;

4.使用Pig工具计算天气数据集temperature.txt中年度最高气温,要求使用GROUP BY语句按照year进行分组,通过FOREACH运算符,对关系的列进行迭代,统计每个分组的最大值,最后使用DUMP语句查询计算结果。将以上查询命令和查询结果以文本形式提交到答题框中。

[root@master ~]# pig grunt> copyFromLocal /root/temp.txt/user/root/temp.txt

grunt> A = LOAD ‘/user/root/temp.txt’ USINGPigStorage(’ ')AS (year:int,temperature:int);

grunt> B = GROUP A BY year;

grunt> C = FOREACH B GENERATEgroup,MAX(A.temperature);

grunt> dump C;

5.使用Pig工具统计数据集ip_to_country中每个国家的IP地址数。要求使用GROUP BY语句按照国家进行分组,通过FOREACH运算符,对关系的列进行 迭代,统计每个分组的 IP 地址数目,最后将统计结果保存到/data/pig/output目录中,并查看数据结果。将以上操作命令和查询结果以文本形式提交到答题框中。

[root@master ~]# pig

grunt> copyFromLocal /root/ip_to_country.txt/user/root/ip_to_country.txt

grunt> ip_countries = LOAD’/user/root/ip_to_country.txt’ AS (ip: chararray, country:chararray);

grunt> country_grpd = GROUP ip_countries BYcountry;

grunt> country_counts = FOREACH country_grpdGENERATE FLATTEN(group),COUNT(ip_countries) as counts;

grunt> STORE country_counts INTO’/data/pig/output’;

Mathout题: 1.在master节点安装Mahout Client,打开Linux Shell运行mahout命令查看Mahout自带的案例程序,将查询结果以文本形式提交到答题框中。

[root@master~]# mahout

2.使用Mahout工具将解压后的20news-bydate.tar.gz文件内容转换成序列文件,保存到/data/mahout/20news/output/20news-seq/目录中,并查看该目录的列表信息,将操作命令和查询结果以文本形式提交到答题框中。

[root@master ~]# mkdir 20news

[root@master ~]# tar -xzf 20news-bydate.tar.gz -C20news

[root@master ~]# hadoop fs -mkdir -p/data/mahout/20news/20news-all

[root@master ~]# hadoop fs -put 20news/*/data/mahout/20news/20news-all

[root@master ~]# mahout seqdirectory -i /data/mahout/20news/20news-all-o /data/mahout/20news/output/20news-seq

[root@master ~]# hadoop fs -ls /data/mahout/20news/output/20news-seq

3.使用Mahout工具将解压后的20news-bydate.tar.gz文件内容转换成序列文件,保存到/data/mahout/20news/output/20news-seq/目录中,使用-text 命令查看序列文件内容(前20行即可),将操作命令和查询结果以文本形式提交到答题框中。 [root@master ~]# mkdir 20news

[root@master ~]# tar -xzf 20news-bydate.tar.gz -C20news

[root@master ~]# hadoop fs -mkdir -p /data/mahout/20news/20news-all

[root@master ~]# hadoop fs -put 20news/*/data/mahout/20news/20news-all

[root@master ~]# mahout seqdirectory -i/data/mahout/20news/20news-all -o /data/mahout/20news/output/20news-seq

[root@master ~]# hadoop fs -text/data/mahout/20news/output/20news-seq/part-m-00000 | head -n 20

4.使用Mahout挖掘工具对数据集user-item-score.txt(用户-物品-得分)进行物品推荐,要求采用基于项目的协同过滤算法,欧几里得距离公式定义,并且每位用户的推荐个数为3,设置非布尔数据,最大偏好值为4,最小偏好值为1,将推荐输出结果保存到output目录中,通过-cat命令查询输出结果 part-r-00000中的内容。将以上执行推荐算法的命令和查询结果以文本形式提交到答题框中。

[hdfs@master ~]$ hadoop fs -mkdir -p /data/mahout/project

[hdfs@master ~]$ hadoop fs -put user-item-score.txt /data/mahout/project

[hdfs@master ~]$ mahout recommenditembased -i /data/mahout/project/user-item-score.txt -o /data/mahout/project/output -n 3 -b false -s SIMILARITY_EUCLIDEAN_DISTANCE --maxPrefsPerUser 4 --minPrefsPerUser 1 --maxPrefsInItemSimilarity 4 --tempDir /data/mahout/project/temp [hdfs@master ~]$ hadoop fs -cat/data/mahout/project/output/part-r-00000

Flume题: 1.在master节点安装启动Flume组件,打开Linux Shell运行flume-ng的帮助命令,查看Flume-ng的用法信息,将查询结果以文本形式提交到答题框中。

[root@master ~]# flume-ng help

2.根据提供的模板log-example.conf文件,使用Flume NG工具收集master节点的系统日志/var/log/secure,将收集的日志信息文件的名称以“xiandian-sec”为前缀,存放于HDFS文件系统的/1daoyun/file/flume目录中,并且定义在HDFS中产生的文件的时间戳为10分钟。进行收集后,查询HDFS文件系统中/1daoyun/file/flume的列表信息。将以上操作命令和结果信息以及修改后的log-example.conf文件内容提交到答题框中。

[root@master ~]# hadoop fs -ls /1daoyun/file/flume [root@master ~]# cat log-example.conf a1.sources.r1.type = exec

a1.sources.r1.command = tail -F /var/log/secure

a1.sources.r1.channels = c1

Use a channel which buffers events in memory

a1.channels.c1.type = memory

a1.channels.c1.capacity = 1000

Describe the sink

a1.sinks.k1.type = hdfs

a1.sinks.k1.channel = c1

a1.sinks.k1.hdfs.path =hdfs://master:8020/1daoyun/file/flume

a1.sinks.k1.hdfs.filePrefix = xiandian-sec

a1.sinks.k1.hdfs.round = true

a1.sinks.k1.hdfs.roundValue = 10

a1.sinks.k1.hdfs.roundUnit = minute

3.根据提供的模板hdfs-example.conf文件,使用Flume NG工具设置master节点的系统路径/opt/xiandian/为实时上传文件至HDFS文件系统的实时路径,设置HDFS文件系统的存储路径为/data/flume/,上传后的文件名保持不变,文件类型为DataStream,然后启动flume-ng agent。将以上操作命令和修改后的hdfs-example.conf文件内容提交到答题框中。 [root@master ~]# flume-ng agent --conf-filehdfs-example.conf --name master -Dflume.root.logger=INFO,cnsole

[root@master ~]# cat hdfs-example.conf

master.sources = webmagic

master.sinks = k1

master.channels = c1

Describe/configure the source

master.sources.webmagic.type = spooldir

master.sources.webmagic.fileHeader = true

master.sources.webmagic.fileHeaderKey = fileName

master.sources.webmagic.fileSuffix = .COMPLETED

master.sources.webmagic.deletePolicy = never

master.sources.webmagic.spoolDir = /opt/xiandian/

master.sources.webmagic.ignorePattern = ^$

master.sources.webmagic.consumeOrder = oldest

master.sources.webmagic.deserializer =org.apache.flume.sink.solr.morphline.BlobDeserializer$Builder

master.sources.webmagic.batchsize = 5

master.sources.webmagic.channels = c1

Use a channel which buffers events in memory

master.channels.c1.type = memory

Describe the sink

master.sinks.k1.type = hdfs

master.sinks.k1.channel = c1

master.sinks.k1.hdfs.path =hdfs://master:8020/data/flume/%{dicName}

master.sinks.k1.hdfs.filePrefix = %{fileName}

master.sinks.k1.hdfs.fileType = DataStream

Spark题: 1.在先电大数据平台部署Spark服务组件,打开Linux Shell启动spark-shell终端,将启动的程序进程信息以文本形式提交到答题框中。

[root@master ~]# spark-shell

2.启动spark-shell后,在scala中加载数据“1,2,3,4,5,6,7,8,9,10”,求这些数据的2倍乘积能够被3整除的数字,并通过toDebugString方法来查看RDD的谱系。将以上操作命令和结果信息以文本形式提交到答题框中。

scala> val num=sc.parallelize(1 to 10)

scala> val doublenum = num.map(_*2)

scala> val threenum = doublenum.filter(_ % 3 == 0)

scala> threenum.collect

scala> threenum.toDebugString

3.启动spark-shell后,在scala中加载Key-Value数据(“A”,1),(“B”,2),(“C”,3),(“A”,4),(“B”,5),(“C”,4),(“A”,3),(“A”,9), (“B”,4),(“D”,5),将这些数据以Key为基准进行升序排序,并以Key为基准进行分组。将以上操作命令和结果信息以文本形式提交到答题框中。

scala> val kv1=sc.parallelize(List((“A”,1),(“B”,2),(“C”,3),(“A”,4),(“B”,5),(“C”,4),(“A”,3), (“A”,9), (“B”,4), (“D”,5)))

scala> kv1.sortByKey().collect

scala> kv1.groupByKey().collect

4.启动spark-shell后,在scala中加载Key-Value数据(“A”,1),(“B”,3),(“C”,5),(“D”,4),(“B”,7),(“C”,4),(“E”,5),(“A”,8), (“B”,4),(“D”,5),将这些数据以Key为基准进行升序排序,并对相同的Key进行Value求和计算。将以上操作命令和结果信息以文本形式提交到答题框中。

scala> valkv2=sc.parallelize(List((“A”,1),(“B”,3),(“C”,5),(“D”,4),(“B”,7),(“C”,4),(“E”,5),(“A”,8),(“B”,4),(“D”,5)))

scala> kv2.sortByKey().collect

scala> kv2.reduceByKey(+).collect

5.启动spark-shell后,在scala中加载Key-Value数据(“A”,4),(“A”,2),(“C”,3),(“A”,4),(“B”,5),(“C”,3),(“A”,4),以Key为基准进行去重操作,并通过toDebugString方法来查看RDD的谱系。将以上操作命令和结果信息以文本形式提交到答题框中。

scala> valkv1=sc.parallelize(List((“A”,4),(“A”,2),(“C”,3),(“A”,4),(“B”,5),(“C”,3),(“A”,4)))

scala> kv1.distinct.collect

scala> kv1.toDebugString

6.启动spark-shell后,在scala中加载两组Key-Value数据(“A”,1),(“B”,2),(“C”,3),(“A”,4),(“B”,5)、(“A”,1),(“B”,2),(“C”,3),(“A”,4),(“B”,5),将两组数据以Key为基准进行JOIN操作,将以上操作命令和结果信息以文本形式提交到答题框中。

scala> val kv5=sc.parallelize(List((“A”,1),(“B”,2),(“C”,3),(“A”,4),(“B”,5)))

scala> val kv6=sc.parallelize(List((“A”,1),(“B”,2),(“C”,3),(“A”,4),(“B”,5)))

scala> kv5.join(kv6).collect

7.登录spark-shell,定义i值为1,sum值为0,使用while循环,求从1加 到100的值,最后使用scala的标准输出函数输出sum值。将上述所有操作命令和返回结果以文本形式提交到答题框。

8.登录spark-shell,定义i值为1,sum值为0,使用for循环,求从1加到 100的值,最后使用scala的标准输出函数输出sum值。将上述所有操作命令和返回结果以文本形式提交到答题框。

scala> var i=1

scala> var sum=0

scala> for(i<- 1 to 100) sum+=i

9.任何一种函数式语言中,都有map函数与faltMap这两个函数:map函数的用法,顾名思义,将一个函数传入map中,然后利用传入的这个函数,将集合中的每个元素处理,并将处理后的结果返回。 而flatMap与map唯一不一样的地方就是传入的函数在处理完后返回值必须 是List,所以需要返回值是List才能执行flat这一步。 (1)登录spark-shell,自定义一个list,然后利用map函数,对这个list进行元素乘2的操作,将上述所有操作命令和返回结果以文本形式提交到答题框。 (2)登录spark-shell,自定义一个 list,然后利用flatMap函数将list转换为单个字母并转换为大写,将上述所有命令和返回结果以文本形式提交到答题框。

scala> import scala.math._

scala> val nums=List(1,2,3,4,5,6,7,8,9)

scala> nums.map(x=>x*2)

scala> val data=List(“Hadoop”,“Java”,“Spark”)

scala> data.flatMap(_.toUpperCase)

10.登录大数据云主机master节点,在root目录下新建一个abc.txt,里面的内容为: hadoop hive solr redis kafka hadoop storm flume sqoop docker spark spark hadoop spark elasticsearch hbase hadoop hive spark hive hadoop spark 然后登录spark-shell,首先使用命令统计abc.txt的行数,接着对abc.txt 文档中的单词进行计数,并按照单词首字母的升序进行排序,最后统计结果行数,将上述操作命令和返回结果以文本形式提交到答题框。

11.登录spark-shell,自定义一个List,使用spark自带函数对这个List进行去重操作,将操作命令和返回结果以文本形式提交到答题框。

12.在Spark-Shell中使用scala语言对sample-data目录中的文件使用flatMap语句进行数据压缩,压缩的所有数据以空格为分隔符,压缩后对字母进行Key:Value计数(字母为Key,出现次数为Value),将以上操作命令和结果信息显示如下。

scala> val rdd4 = sc.textFile(“hdfs://10.0.0.115:8020/sample-data/”)

scala> rdd4.toDebugString scala> val words=rdd4.flatMap(.split(" ")) scala> val wordscount=words.map(word=>(word,1)).reduceByKey(+_) scala> wordscount.collect

13.在Spark-Shell中使用scala语言加载search.txt文件数据,其数据结构释义如下表所示。加载完成后过滤掉不足6列的行数据和第四列排名为2、第五列点击顺序号为1的数据,并进行计数。将以上操作命令和结果信息显示如下。

scala> val ardd =sc.textFile("/data/search.txt")

scala> val mapardd =ardd.map((.split(’\t’))).filter(.length >= 6)

scala> val filterardd =mapardd.filter((3).toString!=“2”).filter((4).toString!=“1”)

scala> filterardd.count