Mysql 安装配置远程登录
# 更新密钥
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
# 安装Mysql yum库
rpm -Uvh http://repo.mysql.com//mysql57-community-release-el7-7.noarch.rpm
# yum安装Mysql
yum -y install mysql-community-server
# 启动Mysql设置开机启动
systemctl start mysqld
systemctl enable mysqld
# 检查Mysql服务状态
systemctl status mysqld
# 第一次启动mysql,会在日志文件中生成root用户的一个随机密码,使用下面命令查看该密码
grep 'temporary password' /var/log/mysqld.log
# 修改root用户密码
mysql -u root -p -h localhost
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '登录密码';
# 如果你想设置简单密码,需要降低Mysql的密码安全级别
# set global validate_password_policy=LOW; # 密码安全级别低
# set global validate_password_length=4; # 密码长度最低4位即可
# ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
# 授权用户登录密码
grant all privileges on *.* to root@"%" identified by '远程密码' with grant option;
flush privileges;
Hadoop 配置代理权限
# 配置core-site.xml配置权限
[root@test1 /]# su - hadoop
[hadoop@test1 ~]$ cd /export/server/hadoop/etc/hadoop/
[hadoop@test1 hadoop]$ vim core-site.xml
# 在<configuration>里面追加以下配置
<property>
<name>hadoop.proxyuser.hadoop.hosts</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.hadoop.groups</name>
<value>*</value>
</property>
# 重启hdfs
[hadoop@test1 hadoop]$ stop-dfs.sh
[hadoop@test1 hadoop]$ start-dfs.sh
Hive 配置
hive文件包:https://pan.baidu.com/s/1JovpsjZZ9dmwR-NtV8gv-Q?pwd=cd9t
mysql驱动包:链接:https://pan.baidu.com/s/1vkie0sVPxsgqL2lup6pWig?pwd=fwt4
# (1):上传解压 Hive与mysql 驱动包
[hadoop@test1 hadoop]$ cd ~
[hadoop@test1 hadoop]$ rz # 上传HIVE文件夹包
[hadoop@test1 hadoop]$ rz # 上传mysql驱动包
[hadoop@test1 hadoop]$ tar -zxvf apache-hive-3.1.3-bin.tar.gz -C /export/server/ # 解压HIVE
[hadoop@test1 hadoop]$ ln -s /export/server/apache-hive-3.1.3-bin /export/server/hive # 软连接
[hadoop@test1 ~]$ mv mysql-connector-java-5.1.34.jar /export/server/apache-hive-3.1.3-bin/lib/ # 移动mysql驱动到hive的lib目录下
# (2): 配置 hive-env.sh文件
[hadoop@test1 ~]$ cd /export/server/apache-hive-3.1.3-bin/conf/ # 进入conf的包
[hadoop@test1 conf]$ mv hive-env.sh.template hive-env.sh # 修改名称
[hadoop@test1 conf]$ vim hive-env.sh
export HADOOP_HOME=/export/server/hadoop
export HIVE_CONF_DIR=/export/server/hive/conf
export HIVE_AUX_JARS_PATH=/export/server/hive/lib
# (3): 创建 hive-site.xml文件 test1 -自定义,数据库配置(用户名与密码)也是自定义
[hadoop@test1 conf]$ vim hive-site.xml
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://test1:3306/hive?createDatabaseIfNotExist=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8</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>123456</value>
</property>
<property>
<name>hive.server2.thrift.bind.host</name>
<value>test1</value>
</property>
<property>
<name>hive.metastore.uris</name>
<value>thrift://test1:9083</value>
</property>
<property>
<name>hive.metastore.event.db.notification.api.auth</name>
<value>false</value>
</property>
</configuration>
# (4): 初始化元数据库(创建hive数据库)
[hadoop@test1 conf]$ mysql -u root -p
mysql> CREATE DATABASE hive CHARSET UTF8; # 创建hive数据库
[hadoop@test1 hive]$ cd /export/server/hive/bin
[hadoop@test1 bin]$ ./schematool -initSchema -dbType mysql -verbose # 初始化-创建hive所需要的表
[hadoop@test1 bin]$ mysql -u root -p # 登录mysql后查看
mysql> use hive;
Database changed
mysql> show tables;
+-------------------------------+
| Tables_in_hive |
+-------------------------------+
| AUX_TABLE |
| BUCKETING_COLS |
| CDS |
...
# (5): 创建hive日志文件
[hadoop@test1 hive]$ mkdir /export/server/hive/logs
Hive 启动方式一
# 前台启动:/export/server/hive/bin/hive --service metastore
# 后台启动:nohup /export/server/hive/bin/hive --service metastore >> logs/metastore.log 2>&1 &
# 后台启动hive
[hadoop@test1 hive]$ nohup /export/server/hive/bin/hive --service metastore >> logs/metastore.log 2>&1 &
# 启动shell方式一:
[hadoop@test1 hive]$ cd /export/server/hive
[hadoop@test1 hive]$ bin/hive
hive> show databases;
OK
default
Hive 启动方式二(推荐)
#先启动metastore服务 然后启动hiveserver2服务
nohup /export/server/hive/bin/hive --service metastore >> logs/metastore.log 2>&1 &
nohup /export/server/hive/bin/hive --service hiveserver2 >> logs/hiveserver2.log 2>&1 &
[hadoop@test1 hive]$ netstat -anp|grep 10000 # 确保 10000端口是有在监听的
# (1) beeline 如果登录报错重启hdfs
[hadoop@test1 hive]$ bin/beeline
beeline> !connect jdbc:hive2://test1:10000 # 连接到test1的端口,hive2使用HiveServer2
Enter username for jdbc:hive2://test1:10000: hadoop # 用户是启动用户名
Enter password for jdbc:hive2://test1:10000: # 密码直接回车
0: jdbc:hive2://test1:10000> show databases;
+----------------+
| database_name |
+----------------+
| default |
+----------------+
# (2) DataGrip连接(推荐)
创建连接:File -> new -> Data Source -> Apache Hive
Name: 自定义
Host: 192.168.88.101
Port: 10000
User: hadoop
点击Test Connection
OK
标签:test1,hadoop,hive,server,文档,HIVE,版本,mysql,export From: https://www.cnblogs.com/wanghong1994/p/17746005.html