Hadoop:3.1.0
CentOS:7.6
JDK:1.8
这里网上教程很多,就不贴图了
【内存可以尽量大一些,不然Hive运行时内存不够】
创建tools目录,用于存放文件安装包
将Hadoop和JDK的安装包上传上去
创建server目录,存放解压后的文件
解压jdk
配置环境变量
配置免密登录
配置映射,配置ip地址和主机名映射,以后就可以用主机名代替ip地址
生成公钥和私钥
查看生成的公钥和私钥,并将公钥写入授权文件
解压Hadoop
配置Hadoop
修改配置文件
初始化并启动HDFS
关闭防火墙
第一次启动需要先初始化HDFS
配置启动用户
启动HDFS
[root@localhost ~]# start-dfs.sh
验证是否启动成功
方式1:
[root@localhost ~]# jps
58466 Jps
54755 NameNode
55401 SecondaryNameNode
54938 DataNode
方式2:访问这个网址,虚拟机地址:9870端口号
192.168.163.129:9870
配置Hadoop(YARN)环境
修改配置文件mapred-site.xml和yarn-site.xml
[root@localhost ~]# cd /opt/server/hadoop-3.1.0/etc/hadoop/
[root@localhost hadoop]# vim mapred-site.xml
<configuration>
<property>
<name>mapreduce.framework.namename>
<value>yarnvalue>
property>
<property>
<name>yarn.app.mapreduce.am.envname>
<value>HADOOP_MAPRED_HOME=${HADOOP_HOME}value>
property>
<property>
<name>mapreduce.map.envname>
<value>HADOOP_MAPRED_HOME=${HADOOP_HOME}value>
property>
<property>
<name>mapreduce.reduce.envname>
<value>HADOOP_MAPRED_HOME=${HADOOP_HOME}value>
property>
configuration>
[root@localhost hadoop]# vim yarn-site.xml
<configuration>
<property>
<name>yarn.nodemanager.aux-servicesname>
<value>mapreduce_shufflevalue>
property>
configuration>
启动服务
[root@localhost sbin]# pwd
/opt/server/hadoop-3.1.0/sbin
[root@localhost sbin]# vim start-yarn.sh
[root@localhost sbin]# vim stop-yarn.sh
# 在两个文件顶部添加如下内容
YARN_RESOURCEMANAGER_USER=root
HADOOP_SECURE_DN_USER=yarn
YARN_NODEMANAGER_USER=root
[root@localhost ~]# start-yarn.sh
验证是否启动成功
方式1:
[root@localhost ~]# jps
96707 NodeManager
54755 NameNode
55401 SecondaryNameNode
54938 DataNode
96476 ResourceManager
98686 Jps
方式2:访问这个网址,虚拟机地址:8088端口号
192.168.163.129:8088
准备好Hive和MySQL这两个安装包
安装MySQL
卸载CentOS7自带的mariadb
[root@server ~]# rpm -qa|grep mariadb
mariadb-libs-5.5.60-1.el7_5.x86_64
[root@server ~]# rpm -e mariadb-libs-5.5.60-1.el7_5.x86_64 --nodeps
解压mysql
[root@server ~]# mkdir /opt/server/mysql
[root@server mysql]# cd /opt/tools/
[root@server tools]# tar -xvf mysql-5.7.34-1.el7.x86_64.rpm-bundle.tar -C /opt/server/mysql/
执行安装
# 安装依赖
[root@server tools]# yum -y install libaio
[root@server tools]# yum -y install libncurses*
[root@server tools]# yum -y install perl perl-devel
# 切换到安装目录进行安装
[root@server tools]# cd /opt/server/mysql/
[root@server mysql]# rpm -ivh mysql-community-common-5.7.34-1.el7.x86_64.rpm
[root@server mysql]# rpm -ivh mysql-community-libs-5.7.34-1.el7.x86_64.rpm
[root@server mysql]# rpm -ivh mysql-community-client-5.7.34-1.el7.x86_64.rpm
[root@server mysql]# rpm -ivh mysql-community-server-5.7.34-1.el7.x86_64.rpm
启动Mysql
[root@server mysql]# systemctl start mysqld.service
[root@server mysql]# cat /var/log/mysqld.log | grep password
2023-06-15T07:04:14.100925Z 1 [Note] A temporary password is generated for root@localhost: !=qcAerHW5*r
修改初始的临时密码
[root@server mysql]# mysql -u root -p
Enter password: #上边的那个!=qcAerHW5*r
mysql> set global validate_password_policy=0;
mysql> set global validate_password_length=1;
mysql> set password=password('root');
授予远程连接权限
mysql> grant all privileges on *.* to 'root' @'%' identified by 'root';
mysql> flush privileges;
设置开机自启动,并检查是否成功
[root@server mysql]# systemctl enable mysqld
[root@server mysql]# systemctl list-unit-files | grep mysqld
mysqld.service enabled
mysqld@.service disabled
Mysql相关控制命令
#启动、关闭、状态查看
systemctl stop mysqld
systemctl status mysqld
systemctl start mysqld
Hive安装配置
解压Hive
[root@server mysql]# cd /opt/tools
[root@server tools]# ls
apache-hive-3.1.2-bin.tar.gz hadoop-3.1.0.tar.gz jdk-8u371-linux-x64.tar.gz mysql-5.7.34-1.el7.x86_64.rpm-bundle.tar
[root@server tools]# tar -zxvf apache-hive-3.1.2-bin.tar.gz -C /opt/server
添加mysql_jdbc驱动到hive安装包lib目录下
修改hive环境变量文件,指定Hadoop安装路径
cd /opt/server/apache-hive-3.1.2-bin/conf
cp hive-env.sh.template hive-env.sh
vim hive-env.sh
新建hive-site.xml的配置文件,配置存放元数据的MySQL的地址、驱动、用户名
密码等信息
[root@server conf]# vim hive-site.xml
<configuration>
<property>
<name>javax.jdo.option.ConnectionURLname>
<value> jdbc:mysql://server:3306/hive?createDatabaseIfNotExist=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8value>
property>
<property>
<name>javax.jdo.option.ConnectionDriverNamename>
<value>com.mysql.jdbc.Drivervalue>
property>
<property>
<name>javax.jdo.option.ConnectionUserNamename>
<value>rootvalue>
property>
<property>
<name>javax.jdo.option.ConnectionPasswordname>
<value>rootvalue>
property>
configuration>
初始化元数据库
[root@server conf]# cd /opt/server/apache-hive-3.1.2-bin/bin
[root@server conf]# ./schematool -dbType mysql -initSchema
启动Hive
添加环境变量
[root@server conf]# vim /etc/profile
[root@server conf]# source /etc/profile
# 启动前需要先把hadoop相关的启动起来
[root@server ~]# start-dfs.sh
[root@server ~]# start-yarn.sh
# 启动hive
[root@server ~]# hive
hive> create database test;
hive> use test;
hive> create table t_student(id int, name varchar(255));
hive> insert into table t_student values(1,'baobei');