下载文件mysql 到Hadoop 将其拖拽到 Moba中的/opt/software中
检查是否安装文件 命令:rpm -qa|grep mariadb
删除文件 命令:rpm -e --nodeps mariadb-libs
切换至 cd /opt/module/
创建mysql 命令: mkdir mysql
解压文件mysql 命令: tar -xf /opt/software/mysql(直接tab即可) -C /opt/module/mysql
切换至mysql中 ll
然后输入命令:rpm - ivf my(tap)co(tap)
获取插件 输入命令:yum install -y libaio
如果错误就输入 ping www.daidu.com 检查是否连接到网络
Ctrl+c强制结束ping网
然后出入依次输入命令:sudo rpm -ivh --nodeps mysql-community-common-5.7.36-1.el7.x86_64.rpm
sudo rpm -ivh --nodeps mysql-community-libs-5.7.36-1.el7.x86_64.rpm
sudo rpm -ivh --nodeps mysql-community-libs-compat-5.7.36-1.el7.x86_64.rpm
sudo rpm -ivh --nodeps mysql-community-client-5.7.36-1.el7.x86_64.rpm
sudo rpm -ivh --nodeps mysql-community-server-5.7.36-1.el7.x86_64.rpm
切到etc中 命令: cd /etc
查看my.cnf 命令:cat my.cnf
然后切换到mysql 命令: cd /var/lib/mysql
并删除所有文件 命令:rm -rf
重置mysql 命令: mysqld --initialize --user=mysql
查看生成的随机密码 命令: cat /var/log/mysqld.log (Vi5AR*mpdlrW)
启动MySQL服务 #aaqq!HoM2sZ 命令:systemctl start mysqld
登录MySQL数据库 命令:mysql -uroot -p
Enter password: 输入临时生成的密码
必须先修改root用户的密码,否则执行其他的操作会报错
mysql> set password = password("自己设置的新密码");
修改mysql库下的user表中的root用户允许任意ip连接
mysql> update mysql.user set host='%' where user='root';
mysql> flush privileges;
查看是否创建datadases 命令:show databases;
若没有创建则创建 命令: create database hive;
再次查看是否存在 hive
退出mysql 命令:exit;
进入profile 命令:vi /etc/profile
添加内容 :sudo rpm -ivh --nodeps mysql-community-common-5.7.36-1.el7.x86_64.rpm
sudo rpm -ivh --nodeps mysql-community-libs-5.7.36-1.el7.x86_64.rpm
sudo rpm -ivh --nodeps mysql-community-libs-compat-5.7.36-1.el7.x86_64.rpm
sudo rpm -ivh --nodeps mysql-community-client-5.7.36-1.el7.x86_64.rpm
sudo rpm -ivh --nodeps mysql-community-server-5.7.36-1.el7.x86_64.rpm
切到etc中 命令: cd /etc
查看my.cnf 命令:cat my.cnf
然后切换到mysql 命令: cd /var/lib/mysql
并删除所有文件 命令:rm -rf *
重置mysql 命令: mysqld --initialize --user=mysql
查看生成的随机密码 命令: cat /var/log/mysqld.log (Vi5AR*mpdlrW)
启动MySQL服务 #aaqq!HoM2sZ 命令:systemctl start mysqld
登录MySQL数据库 命令:mysql -uroot -p
Enter password: 输入临时生成的密码
必须先修改root用户的密码,否则执行其他的操作会报错
mysql> set password = password("自己生成的新密码");
修改mysql库下的user表中的root用户允许任意ip连接
mysql> update mysql.user set host='%' where user='root';
mysql> flush privileges;
查看是否创建datadases 命令:show databases;
若没有创建则创建 命令: create database hive;
再次查看是否存在 hive
退出mysql 命令:exit;
进入profile 命令:vi /etc/profile
添加内容 :export HIVE_HOME=/opt/module/apache-hive-3.1.2-bin
export PATH=$PATH:$HADOOP_HOME/sbin:$HIVE_HOME/bin
并确认路径是否正确
重启环境配置 命令:source /etc/profile
切到bin 命令:cd /opt/module/apache-hive-3.1.2-bin/bin
编辑并新增内容 命令:vi hive-config.sh
export JAVA_HOME=/opt/module/jdk1.8.0_212
export HIVE_HOME=/opt/module/apache-hive-3.1.2-bin
export HADOOP_HOME=/opt/module/hadoop-3.1.3
export HIVE_CONF_DIR=/opt/module/apache-hive-3.1.2-bin/conf
切换路径 命令:cd /opt/module/apache-hive-3.1.2-bin/bonf/
创建文件并配置 命令:vi 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.ConnectionDriverName</name>
<value>com.mysql.cj.jdbc.Driver</value>
<description>Driver class name for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
<description>Username to use against metastore database</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>自己设置的密码</value>
<description>password to use against metastore database</description>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://192.168.1.100:3306/hive?useUnicode=true;characterEncoding=utf8;useSSL=false;serverTimezone=GMT</value>
<description>
JDBC connect string for a JDBC metastore.
To use SSL to encrypt/authenticate the connection, provide database-specific SSL flag in the connection URL.
For example, jdbc:postgresql://myhost/db?ssl=true for postgres database.
</description>
</property>
<property>
<name>datanucleus.schema.autoCreateAll</name>
<value>true</value>
<description>Auto creates necessary schema on a startup if one doesn't exist. Set this to false, after creating it once.To enable auto create also set hive.metastore.schema.verification=false. Auto creation is not recommended for production use cases, run schematool command instead.</description>
</property>
<property>
<name>hive.metastore.schema.verification</name>
<value>false</value>
<description>
Enforce metastore schema version consistency.
True: Verify that version information stored in is compatible with one from Hive jars. Also disable automatic
schema migration attempt. Users are required to manually migrate schema after Hive upgrade which ensures
proper metastore schema migration. (Default)
False: Warn if the version information stored in metastore doesn't match with one from in Hive jars.
</description>
</property>
<property>
<name>hive.exec.local.scratchdir</name>
<value>/opt/module/apache-hive-3.1.2-bin/tmp/${user.name}</value>
<description>Local scratch space for Hive jobs</description>
</property>
<property>
<name>system:java.io.tmpdir</name>
<value>/opt/module/apache-hive-3.1.2-bin/iotmp</value>
<description/>
</property>
<property>
<name>hive.downloaded.resources.dir</name>
<value>/opt/module/apache-hive-3.1.2-bin/tmp/${hive.session.id}_resources</value>
<description>Temporary local directory for added resources in the remote file system.</description>
</property>
<property>
<name>hive.querylog.location</name>
<value>/opt/module/apache-hive-3.1.2-bin/tmp/${system:user.name}</value>
<description>Location of Hive run time structured log file</description>
</property>
<property>
<name>hive.server2.logging.operation.log.location</name>
<value>/opt/module/apache-hive-3.1.2-bin/tmp/${system:user.name}/operation_logs</value>
<description>Top level directory where operation logs are stored if logging functionality is enabled</description>
</property>
<property>
<name>hive.metastore.db.type</name>
<value>mysql</value>
<description>
Expects one of [derby, oracle, mysql, mssql, postgres].
Type of database used by the metastore. Information schema & JDBCStorageHandler depend on it.
</description>
</property>
<property>
<name>hive.cli.print.current.db</name>
<value>true</value>
<description>Whether to include the current database in the Hive prompt.</description>
</property>
<property>
<name>hive.cli.print.header</name>
<value>true</value>
<description>Whether to print the names of the columns in query output.</description>
</property>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/opt/hive/warehouse</value>
<description>location of default database for the warehouse</description>
</property>
</configuration>
将mysql-connector-java-8.0.15.zip 拉到 /opt/module/apache-hive-3.1.2-bin/lib/ 中
然后cd到其中 命令:cd /opt/module/apache-hive-3.1.2-bin/lib/
然后输入 :ls ./ | grep gua
查看其中存在几个文件 若只有 guava-27.0-jre.jar 和 jersey-guava-2.25.1.jar即为正确
输入命令: schematool -dbType mysql -initSchema
查看是否启动集群 命令: jps
若没有启动则输入命令: start-all.sh
启动 hive 命令: hive
检测是否启动成功 命令: show databases;
显示 OK即为成功
退出命令为 : exit;