hadoop-2.7.3+hive-2.3.4+sqoop-1.4.7
hadoop-2.7.3下载.提取:qcqd
为了方便和统一开发环境,一些基础配置如修改主机名和用户名,hosts的ip和主机名映射,配置SSH无密码连接,jdk安装和系统环境变量配置,可参考上一篇文章:
腾讯云服务器搭建hadoop-2.6.0-cdh5.6.0完全分布式环境
root用户执行,所有节点都执行
[root@master ~]# vi /etc/profile
#添加
export HADOOP_HOME=/opt/hadoop-2.7.3
export PATH=$PATH:$HADOOP_HOME/bin
[root@master ~]# source /etc/profile
在主节点master配置好后,再copy到各从节点slave
#添加
export HADOOP_HOME=/opt/hadoop-2.7.3
export JAVA_HOME=/opt/jdk1.8.0_40
fs.defaultFS
hdfs://master:9000
hadoop.tmp.dir
/opt/hadoop-2.7.3/tmp
dfs.replication
1
dfs.permissions
false
dfs.secondary.http.address
master:50090
mapreduce.framework.name
yarn
yarn.resourcemanager.hostname
master
yarn.nodemanager.aux-services
mapreduce_shuffle
#指明运行DataNode、NodeManager的节点,即各从节点
slave1
scp -r /opt/hadoop-2.7.3 hadoop@slave1:/opt
...
同上一篇:腾讯云服务器搭建hadoop-2.6.0-cdh5.6.0完全分布式环境的步骤六和七
hive下载
hive相当于一个客户端,安装在主节点master上
> 安装mariadb客户端和服务器
[root@master ~]# yum -y install mariadb mariadb-server
> 启动mysql服务
[root@master ~]# systemctl start mariadb
> 设置开机启动
[root@master ~]# systemctl enable mariadb
> 简单配置
[root@master ~]# mysql_secure_installation
Enter current password for root (enter for none): <–初次运行直接回车
OK, successfully used password, moving on...
Set root password? [Y/n] <-回车设置密码
New password: <-设置root密码
Re-enter new password: <-再次确认
Password updated successfully!
Remove anonymous users? [Y/n] <-是否删除匿名用户,回车
Disallow root login remotely? [Y/n] <-是否禁止root远程登录,回车
Remove test database and access to it? [Y/n] <-是否删除test数据库,回车
Reload privilege tables now? <– 是否重新加载权限表,回车
...
Thanks for using MariaDB!
> 登陆mysql
[root@master ~]# mysql -u root -p
> 查看数据库
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
> 创建数据库hive,保存hive元数据:
MariaDB [(none)]> create database hive;
> 使操作系统用户hadooop可以通过密码123456操作数据库hive的所有表:
GRANT ALL PRIVILEGES ON hive.* TO hadoop@'master' IDENTIFIED BY '123456';
flush privileges;
#将hive安装包移至/opt,再以hadoop用户在主节点master执行
tar -zxvf /opt/apache-hive-2.3.4-bin.tar.gz
#并改名为hive-2.3.4
不难理解,hive的元数据库就是mysql,而连接mysql需要对应的驱动jar包
添加至/opt/hive-2.3.4/lib文件夹下
百度云盘:MySQL驱动包
提取码:s4w4
#目录在/opt/hive-2.3.4/conf,进入conf
cp hive-env.sh.template hive-env.sh
#1.在hive-env.sh中添加:
export JAVA_HOME=/opt/jdk1.8.0_40
export HADOOP_HOME=/opt/hadoop-2.7.3
export HIVE_CONF_DIR=/opt/hive-2.3.4/conf
export HIVE_AUX_JARS_PATH=/opt/hive-2.3.4/lib
cp hive-default.xml.template ./hive-site.xml
#2.在hive-site.xml中添加:
hive.metastore.local
true
javax.jdo.option.ConnectionURL
jdbc:mysql://master:3306/hive?createDatabaseIfNotExist=true
JDBC connect string for a JDBC metastore
javax.jdo.option.ConnectionDriverName
com.mysql.jdbc.Driver
Driver class name for a JDBC metastore
javax.jdo.option.ConnectionUserName
hadoop
username to use against metastore database
javax.jdo.option.ConnectionPassword
123456
password to use against metastore database
#若不配置以下属性,会出错。
#和hive仓库存储有关,会用到这两个属性,如hive.exec.local.scratchdir中
#可vi hive-site.xml,在命令行模式,输入/搜索内容 来查找
system:java.io.tmpdir
/opt/hive-2.3.4/tmp
system:user.name
hadoop
#root用户在/etc/profile追加
export HIVE_HOME=/opt/hive-2.3.4
export PATH=$PATH:$HIVE_HOME/bin
#source /etc/profile生效
验证如下 :
启动hadoop和mysql,
初始化:
schematool -initSchema -dbType mysql
执行:
hive
在hive命令行,执行创建test表命令,并查询:
create table test(id int);
select count(*) from test;
没有异常并显示0,安装成功。
sqoop-1.4.7下载
同样解压到/opt目录下,更名为sqoop-1.4.7
将mysql-connector-java.jar添加到/opt/sqoop-1.4.7/lib中
export HADOOP_COMMON_HOME=/opt/hadoop-2.7.3
export HADOOP_MAPRED_HOME=/opt/hadoop-2.7.3
export HIVE_HOME=/opt/hive-2.3.4
#root用户在/etc/profile追加
export SQOOP_HOME=/opt/sqoop-1.4.7
export PATH=$PATH:$SQOOP_HOME/bin
#source /etc/profile生效
可执行:
sqoop help
或测试连接:
#hadoop用户在主节点master执行:
sqoop list-databases --connect jdbc:mysql://master:3306/ --username hadoop --password 123456
显示msql数据库中的所有数据库实例,如有hive.