赞
踩
wget http://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm
2. 如果不是root用户需要先切换到root用户,安装第1步下载的rpm包
yum -y install mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql-community-server
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
安装完后再次执行第3步操作就可以安装成功
systemctl start mysqld.service
启动后状态如下图所示
cat /var/log/mysqld.log | grep 'password'
mysql -u root -p
执行以下命令进行密码更改,注意密码有复杂度要求
在MySQL 5.7中,密码策略在安装时已默认启用,并定义了以下要求:
alter user 'root'@'localhost' identified by '新密码';
exit;命令退出MySql shell
wget http://archive.apache.org/dist/hive/hive-3.1.0/apache-hive-3.1.0-bin.tar.gz
解压安装包
tar xvf apache-hive-3.1.0-bin.tar.gz -C /home/hadoop/software/
下载驱动
wget https://downloads.mysql.com/archives/get/p/3/file/mysql-connector-java-5.1.47.tar.gz
解压驱动
tar xvf mysql-connector-java-5.1.47.tar.gz -C /home/hadoop/software
mv /home/hadoop/software/apache-hive-3.1.0-bin /home/hadoop/software/hive
由于环境变量配置文件只有root用户有权限更改,使用sudo命令获取超管权限,执行以下命令,将环境变量配置写入配置文件
sudo echo 'export PATH=$PATH:/home/hadoop/software/hive/bin' >> /etc/profile
执行以下命令使环境变量生效
source /etc/profile
cp /home/hadoop/software/mysql-connector-java-5.1.47/mysql-connector-java-5.1.47-bin.jar /home/hadoop/software/hive/lib
vi hive-site.xml
将以下内容添加到文件中
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <configuration> <!-- MySQL配置 --> <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://localhost:3306/hive?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>MySQL的root用户登录密码</value> </property> <property> <name>datanucleus.readOnlyDatastore</name> <value>false</value> </property> <property> <name>datanucleus.fixedDatastore</name> <value>false</value> </property> <property> <name>datanucleus.autoCreateSchema</name> <value>true</value> </property> <property> <name>datanucleus.schema.autoCreateAll</name> <value>true</value> </property> <property> <name>datanucleus.autoCreateTables</name> <value>true</value> </property> <property> <name>datanucleus.autoCreateColumns</name> <value>true</value> </property> <property> <name>hive.metastore.local</name> <value>true</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.exec.local.scratchdir</name> <value>/home/hadoop/sofatware/hive</value> <description>Local scratch space for Hive jobs</description> </property> <!-- 自定义目录start --> <property> <name>hive.downloaded.resources.dir</name> <value>/home/hadoop/sofatware/hive/hive-downloaded-addDir/</value> <description>Temporary local directory for added resources in the remote file system.</description> </property> <property> <name>hive.querylog.location</name> <value>/home/hadoop/sofatware/hive/querylog-location-addDir/</value> <description>Location of Hive run time structured log file</description> </property> <property> <name>hive.server2.logging.operation.log.location</name> <value>/home/hadoop/sofatware/hive/hive-logging-operation-log-addDir/</value> <description>Top level directory where operation logs are stored if logging functionality is enabled</description> </property> </configuration>
schematool -dbType mysql -initSchema
hive
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。