centos7安装MySQL8.0,HIVE(常见题目解决方法)
一、查抄centos中是否安装过Mysqlrpm -qa | grep mysql
如果没有内容,则没有安装过,有过一下类似的,说明Centos安装过MySQL,要先安装新的mysql,需要卸载旧版本。
https://i-blog.csdnimg.cn/direct/38f0bba83d4b4f7c9c869ea88563580b.png
写在之前,先将mysql停止,再卸载。
实行 systemctl stop mysqld.service 在实行 rpm -qa | grep mysql | xargs yum remove -y
查抄是否还存在Mysql的设置文件 ls /etc/cnf
有文件则删除 rm -rf /etc/设置文件
二、安装MySQL
1、安装wget
yum -y install wget
2、下载mysql源包
sudo rpm -Uvh https://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm
3、安装mysql源
sudo yum install mysql-community-server
4、查抄是否安装乐成
yum repolist enabled | grep "mysql.*-community.*"
5、安装MySQL容易报错点
yum install mysql-community-server
报错:
Public key for mysql-community-libs-8.0.39-1.el7.x86_64.rpm is not installed
Failing package is: mysql-community-libs-8.0.39-1.el7.x86_64
GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
密钥:rpm --import file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
报错:实行yum install mysql-community-server 依旧报错
The GPG keys listed for the "MySQL 8.0 Community Server" repository are already installed but they are not correct for this package.
Check that the correct key URLs are configured for this repository.
Failing package is: mysql-community-libs-8.0.39-1.el7.x86_64
GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
解决方法:第一步的题目,获取公钥的题目(2022改成2023就好了,将来改成2024 or 2025)。即rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2023
实行:yum install mysql-community-server
6、设置启动
1、启动mysql
systemctl start mysqld
2、开机自启
systemctl enable mysqld 3、mysql的状态
systemctl status mysqld 7、修改暗码及其权限
1、获取默认暗码
cat /var/log/mysqld.log | grep 'password' 2、登录mysql
mysql -u root -p 3、修改暗码
use mysql;(可以不写,如果报错的话)
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
如果报错,有关暗码不够安全的
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
更改暗码策略设置:
set global validate_password.policy=0;
set global validate_password.length=6; 可能还会报错:ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
解决方法:老老实实的设置符合要求暗码。改完之后,还想更改策略的话,过程如下:
再次更改暗码
set global validate_password.policy=0;
set global validate_password.length=6; ALTER USER 'root'@'localhost' IDENTIFIED BY '123456'; 4、设置长途权限访问
update user set host = '%' where user = 'root' and host='localhost';
GRANT ALL ON *.* TO 'root'@'%' ;
flush privileges; 三、Hive安装
hive3.1.3的下载毗连
Index of /apache/hive/hive-3.1.3 (bfsu.edu.cn)
设置环境变量,hive中的hive-env.sh
export HADOOP_HOME=/home/hadoop/model/model/hadoop-3.3.1
export HIVE_CONF_DIR=/export/server/hive
export HIVE_AUX_JARS_PATH=/export/server/hive/lib 客户端的hive-site.xml文件
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<!--连接数据库地址,名称 -->
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3306/myhive?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false</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.cli.print.header</name>
<value>true</value>
</property>
<!--客户端显示当前数据库名称信息 -->
<property>
<name>hive.cli.print.current.db</name>
<value>true</value>
</property>
<property>
<!--关闭数据库的版本检查-->
<name>hive.metastore.schema.verification</name>
<value>false</value>
</property>
<!-- 连接服务器-->
<property>
<name>hive.server2.thrift.bind.host</name>
<value>node2</value>
</property>
<!-- 连接服务器-->
<property>
<name>hive.metastore.uris</name>
<value>thrift://node2:9083</value>
</property>
<!-- 连接服务器-->
<property>
<name>hive.metastore.event.db.notification.api.auth</name>
<value>false</value>
</property>
</configuration> 初始化数据库
创建一个数据库hive 用来存放 元数据。
./schematool -initSchema -dbType mysql -vervos https://i-blog.csdnimg.cn/direct/ce329f3ebd094717a97a17219733ea06.png乐成!!!
查看数据库hive,出现数据,表明初始化乐成。
https://i-blog.csdnimg.cn/direct/9a7c4ad516884783bdf919ba85edb2e7.pnghttps://i-blog.csdnimg.cn/direct/51bf02d9100d405eb177fb1337e31c3b.png
四、启动hive
现在的操作权限是root,需要改权限
https://i-blog.csdnimg.cn/direct/541ea8029d4d481098aea90ca31f9d81.png
chown -R hadoop:hadoop apache-hive-3.1.3-bin hive 然后,到hive文件夹下创建logs日志文件甲。
mkdir logs
hive有两大组件:1.SQL剖析器 2元数据管理服务
启动元数据管理服务
有前台启动和背景启动两种启动方法。
前台:bin/hive --server metastore
背景:nohup bin/hive --server metastore >> logs/metastore.log 2>&1 &
启动客户端:
两种方法:
hive shell(可直接写SQL):bin/hive
hive thriftServer方式(不可直接写SQL,需要外部客户链接利用):
bin/hive --server hiveserver2
1.先启动集群+yarn
2.启动元数据管理服务
3.启动客户端
bin/hive
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页:
[1]