目录
- 1、Ubuntu 安装
- 2、Ubuntu下安装VMware Tools
- 3、更换镜像源
- 4、连接 Mobax
- 5、Ubuntu Docker安装
- 6、创建容器
- 7、环境准备
- 8、软件安装
1、Ubuntu 安装
1.1、创建Ubuntu虚拟机
创建一个新的虚拟机,此处安装 Ubuntu 版本
1.2、Ubuntu 镜像下载
按照之前安装 Centos 7 的方式设置虚拟机,注意镜像拉取 Ubuntu 的镜像
Ubuntu 镜像、需要的依赖包
下载地址:https://pan.baidu.com/s/1jpqwurCjolkHaXHzn618vQ
提取码:m9pj
1.3、开启虚拟机
开启虚拟机后,选择中文简体,然后开始安装
1.4、安装准备
如下图所示,准备安装
勾选清除整个磁盘后安装
1.5、设置用户
安装准备选好后,继续选择地点,然后继续知道这里设置用户,设置好后继续即可
1.6、进入安装
以下界面是正在安装界面,需要较长时间请耐心等待,安装完成后重启虚拟机
2、Ubuntu下安装VMware Tools
安装 VMware Tools 可以解决粘贴问题
2.1、安装Tools
启动Ubuntu系统,菜单栏 - 虚拟机 - 安装VMware Tools,不启动Ubuntu系统是无法点击安装VMware Tools
选项,如下图所示
2.2、复制Tools安装包
将下图这个文件右击复制到桌面(可以是其他文件路径,需要记住路径)
2.3、解压安装Tools
右击打开终端,进入刚刚的Tools路径下解压安装,在虚拟机中可以右击复制、粘贴
2.4、进入root用户
输入以下命令,然后输入密码,进入root用户
sudo su
2.5、启动命令
以root用户进入到刚刚提取到的vmware-tools-distrib文件夹下,然后输入命令:
./vmware-install.pl
输入以上命令后,根据提示输入yes
,知道出现以下界面,表示安装成功,然后手动重启虚拟机
3、更换镜像源
3.1、备份 source.list
sudo cp /etc/apt/sources.list /etc/apt/sources.list.old
3.2、执行命令打开source.list文件
sudo gedit /etc/apt/source.list
3.3、国内源
将以下任意一个国内源复制到 source.list 文件中,这里建议使用阿里源,使用国内源可以加快下载速度
3.3.1、阿里源
# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
3.3.2、清华大学源
# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security multiverse
3.3.3、东北大学源
deb-src http://mirror.neu.edu.cn/ubuntu/ xenial main restricted #Added by software-properties
deb http://mirror.neu.edu.cn/ubuntu/ xenial main restricted
deb-src http://mirror.neu.edu.cn/ubuntu/ xenial restricted multiverse universe #Added by software-properties
deb http://mirror.neu.edu.cn/ubuntu/ xenial-updates main restricted
deb-src http://mirror.neu.edu.cn/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirror.neu.edu.cn/ubuntu/ xenial universe
deb http://mirror.neu.edu.cn/ubuntu/ xenial-updates universe
deb http://mirror.neu.edu.cn/ubuntu/ xenial multiverse
deb http://mirror.neu.edu.cn/ubuntu/ xenial-updates multiverse
deb http://mirror.neu.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirror.neu.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirror.neu.edu.cn/ubuntu/ xenial-security main restricted
deb-src http://mirror.neu.edu.cn/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirror.neu.edu.cn/ubuntu/ xenial-security universe
deb http://mirror.neu.edu.cn/ubuntu/ xenial-security multiverse
3.4、更新数据源
sudo apt-get update
4、连接 Mobax
4.1、下载ssh
Ubuntu 系统本身是没有 ssh 的,需要下载 ssh 才可以连接 Mobax、Xshell 等工具,使用国内源下载速度更快
sudo apt-get install ssh
4.2、查看 ip
ip addr
ip 如下图所示
4.3、Mobax 连接虚拟机
与 CentOS 7 连接方式相同
ubuntu下使用vi是方向键变乱码 退格键不能使用的解决方法
由于ubuntu预安装的是tiny版本,所以会导致我们在使用上的产生上述的不便。但是,我们安装了vim的full版本之后,键盘的所有键在vi下就很正常了。
#卸载旧版vi
sudo apt-get remove vim-common
#然后安装full版的vim
sudo apt-get install vim
5、Ubuntu Docker安装
5.1、安装 curl 命令
sudo apt install curl
5.2、安装Docker
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
6、创建容器
6.1、拉取镜像
先进入root用户,在执行以下命令,拉取centos:7
镜像
docker pull centos:7
拉取成功,查看结果如下
镜像下载满解决办法:
创建文件夹/etc/docker/daemon.json
vi /etc/docker/daemon.json
在该文件中添加以下内容,并保存退出
{
"registry-mirrors": ["https://hccwwfjl.mirror.aliyuncs.com"]
}
最后需要重启 Docker
systemctl restart docker
6.1.1、镜像其他操作
查看镜像
docker images
删除镜像
docker rmi centos:7
6.2、创建容器
docker run -it singleNode centos:7
docker run -itd --privileged --name singleNode -h singleNode \
-p 2222:22 \
-p 3306:3306 \
-p 50070:50070 \
-p 8088:8088 \
-p 8080:8080 \
-p 10000:10000 \
-p 60010:60010 \
-p 9092:9092 \
centos:7 /usr/sbin/init
参数解析:
run:通过一个镜像运行一个容器
-i:提供一个终端,一般和t或者d连用
–privileged:设置权限,如果不设置,在容器中启动服务时会报错
–name:给容器起名
-h:容器的主机名
-p:端口映射
centos:7:镜像名称
/user/sbin/init:和–privileged参数连用
6.2.1、Mobax 进入容器连接
首先修改 root 密码
passwd root
如下图所示重新连接,注意 Prot 为创建容器是设置的端口映射2222
6.2.2、容器其他操作
关闭容器
docker stop singleNode
启动容器
docker start singleNode
查看容器(查看所有容器,包括没有运行的)
docker ps -a
删除容器
docker rm singleNode
进入容器
docker exec -it singleNode /bin/bash
7、环境准备
7.1、安装必要软件
yum clean all
yum -y install unzip bzip2-devel vim bashname
7.2、配置ssh免密登录
yum install -y openssh openssh-server openssh-clients openssl openssl-devel
ssh-keygen -t rsa -f ~/.ssh/id_rsa -P ''
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
# 启动SSH服务
systemctl start sshd
7.3、设置时区
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
8、软件安装
首先创建两个文件夹,用于存放安装包和安装路径
mkdir -p /opt/software/
mkdir -p /opt/install/
将软件安装包上传到/opt/software/
中,如下图所示
8.1、MySQL安装
8.1.1、解压安装包
cd /opt/software/
tar xvf MySQL-5.5.40-1.linux2.6.x86_64.rpm-bundle.tar
8.1.2、安装必要依赖
yum -y install libaio perl
8.1.3、安装服务端和客户端
rpm -ivh MySQL-server-5.5.40-1.linux2.6.x86_64.rpm
rpm -ivh MySQL-client-5.5.40-1.linux2.6.x86_64.rpm
8.1.4 启动并配置MySQL
systemctl start mysql
/usr/bin/mysqladmin -u root password 'root'
mysql -uroot -proot
#进入mysql命令行
> update mysql.user set host='%' where host='localhost';
> delete from mysql.user where host<>'%' or user='';
> flush privileges;
> quit
8.2、安装JDK
8.2.1、解压安装
解压安装并创建软连接
tar zxvf /opt/software/jdk-8u171-linux-x64.tar.gz -C /opt/install/
ln -s /opt/install/jdk1.8.0_171 /opt/install/java
8.2.2、配置环境变量
vim ~/.bashrc
#添加以下内容
-------------------------------------------
export JAVA_HOME=/opt/install/java
export PATH=$JAVA_HOME/bin:$PATH
-------------------------------------------
8.2.3、生效环境变量
source ~/.bashrc
#查看java版本
java -version
8.3、hadoop安装
8.3.1、解压安装
解压安装并创建软连接
tar zxvf /opt/software/hadoop-2.6.0-cdh5.14.2.tar_2.gz -C /opt/install/
ln -s /opt/install/hadoop-2.6.0-cdh5.14.2 /opt/install/hadoop
8.3.2、修改配置文件
进入/opt/install/hadoop/etc/hadoop/
路径
cd /opt/install/hadoop/etc/hadoop/
配置core-site.xml
vim core-site.xml
-------------------------------------------
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://singleNode:9000</value>
</property>
<property>
<name>hadoop.tmp.dir</name>
<value>/opt/install/hadoop/data/tmp</value>
</property>
</configuration>
-------------------------------------------
配置hdfs-site.xml
vim hdfs-site.xml
-------------------------------------------
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>
-------------------------------------------
配置mapred-site.xml
cp mapred-site.xml.template mapred-site.xml
vim mapred-site.xml
-------------------------------------------
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
<property>
<name>mapreduce.jobhistory.address</name>
<value>singleNode:10020</value>
</property>
<property>
<name>mapreduce.jobhistory.webapp.address</name>
<value>singleNode:19888</value>
</property>
</configuration>
-------------------------------------------
配置yarn-site.xml
vim yarn-site.xml
-------------------------------------------
<configuration>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<property>
<name>yarn.resourcemanager.hostname</name>
<value>singleNode</value>
</property>
<property>
<name>yarn.log-aggregation-enable</name>
<value>true</value>
</property>
<property>
<name>yarn.log-aggregation.retain-seconds</name>
<value>604800</value>
</property>
</configuration>
-------------------------------------------
配置hadoop-env.sh
vim hadoop-env.sh
-------------------------------------------
export JAVA_HOME=/opt/install/java
-------------------------------------------
配置mapred-env.sh
vim mapred-env.sh
-------------------------------------------
export JAVA_HOME=/opt/install/java
-------------------------------------------
配置yarn-env.sh
vim yarn-env.sh
-------------------------------------------
export JAVA_HOME=/opt/install/java
-------------------------------------------
配置slaves
vim slaves
-------------------------------------------
singleNode
-------------------------------------------
8.3.3、配置环境变量
vim ~/.bashrc
-------------------------------------------
export HADOOP_HOME=/opt/install/hadoop
export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop
export PATH=$HADOOP_HOME/bin:$PATH
-------------------------------------------
source ~/.bashrc
8.3.4、HDFS格式化
hdfs namenode -format
8.3.5、启动Hadoop服务
$HADOOP_HOME/sbin/start-all.sh
8.3.6、Web端查看
查看50070端口
查看8088端口
8.4、Hive安装
8.4.1、解压安装
解压安装并添加软连接
tar zxvf /opt/software/hive-1.1.0-cdh5.14.2.tar.gz -C /opt/install/
ln -s /opt/install/hive-1.1.0-cdh5.14.2 /opt/install/hive
8.4.2、修改配置文件
cd /opt/install/hive/conf/
创建hive-site.xml
vim hive-site.xml
-------------------------------------------
<configuration>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/home/hadoop/hive/warehouse</value>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://singleNode:3306/hive?createDatabaseIfNotExist=true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>root</value>
</property>
<property>
<name>hive.exec.scratchdir</name>
<value>/home/hadoop/hive/data/hive-${user.name}</value>
<description>Scratch space for Hive jobs</description>
</property>
<property>
<name>hive.exec.local.scratchdir</name>
<value>/home/hadoop/hive/data/${user.name}</value>
<description>Local scratch space for Hive jobs</description>
</property>
</configuration>
-------------------------------------------
修改hive-env.sh
cp hive-env.sh.template hive-env.sh
vim hive-env.sh
-------------------------------------------
HADOOP_HOME=/opt/install/hadoop
-------------------------------------------
8.4.3、添加依赖包
cp /opt/software/mysql-connector-java-5.1.31.jar /opt/install/hive/lib/
8.4.4、配置环境变量
vim ~/.bashrc
-------------------------------------------
export HIVE_HOME=/opt/install/hive
export PATH=$HIVE_HOME/bin:$PATH
-------------------------------------------
source ~/.bashrc
8.4.5、启动服务并验证
#启动元数据服务
nohup hive --service metastore &
#启动hiveserver2服务
nohup hive --service hiveserver2 &
#jps查看进程
jps
查看进程检查 hive 是否安装并启动成功,启动成功进程如下
8.5、Sqoop安装
8.5.1、解压安装
解压安装并设置软连接
tar zxvf /opt/software/sqoop-1.4.6-cdh5.14.2.tar.gz -C /opt/install/
ln -s /opt/install/sqoop-1.4.6-cdh5.14.2 /opt/install/sqoop
8.5.2、修改sqoop-env.sh
cd /opt/install/sqoop/conf/
cp sqoop-env-template.sh sqoop-env.sh
vim sqoop-env.sh
-------------------------------------------
#Set path to where bin/hadoop is available
export HADOOP_COMMON_HOME=/opt/install/hadoop
#Set path to where hadoop-*-core.jar is available
export HADOOP_MAPRED_HOME=/opt/install/hadoop
#Set the path to where bin/hive is available
export HIVE_HOME=/opt/install/hive
-------------------------------------------
8.5.3、添加依赖包
cp /opt/software/mysql-connector-java-5.1.31.jar /opt/install/sqoop/lib/
cp /opt/software/java-json.jar /opt/install/sqoop/lib/
8.5.4、配置环境变量
vim ~/.bashrc
-------------------------------------------
export SQOOP_HOME=/opt/install/sqoop
export PATH=$SQOOP_HOME/bin:$PATH
-------------------------------------------
source ~/.bashrc
8.5.5、查看版本
查看sqoop版本,检测是否安装成功
sqoop version
如下图所示,则表示安装成功