需要一个wsl环境
- 在windows下控制面板–程序和功能–启用windows功能模块下开启虚拟化平台及子系统,这样子就有了wsl环境
- 通过微软商店安装ubuntu,完成之后点击图标即可访问wsl子系统
修改ssh(我用的root,以下操作也就不使用sudo了)
# 卸载ssh
apt purge openssh-server openssh-client
# 重装
apt install openssh-server openssh-client
# 生成公钥
ssh-keygen -A
# 重启ssh服务
service ssh restart
# 测试ssh是否可以用
ssh localhost # 如果提示输入密码,即服务开启成功
# 免密操作
# 生成新的公钥
ssh-keygen -t rsa
# 拷贝公钥到用户授权列表中
ssh-copy-id localhost
安装mysql 8.0
wsl自带mysql8.0,直接命令安装即可
apt install mysql-server
service mysql restart
mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by 'yourpasswd';
# 推出mysql,对mysql进行安全设置
mysql_secure_installation
安装java
apt install openjdk-8-jdk openjdk-8-jre
# 配置java环境变量,因为测试,我直接操作了/etc/profile文件
export JAVA_HOME=XXXX
export PATH=$PATH:$JAVA_HOME/bin
安装hadoop
# 下载
wget -P /data https://mirrors.ustc.edu.cn/apache/hadoop/common/hadoop-3.3.3/hadoop-3.3.3.tar.gz
# 解压
tar hadoop-3.3.3.tar.gz -C /opt/
# 配置环境变量
export HADOOP_HOME=/opt/hadoop-3.3.3.tar.gz
export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
# 配置core-site.xml
<configuration>
<property>
<name>hadoop.tmp.dir</name>
<value>/data/hadoop/tmp</value>
</property>
<property>
<name>fs.defaultFS</name>
<value>hdfs://0.0.0.0:8020</value>
</property>
<property>
<name>hadoop.proxyuser.root.hosts</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.root.groups</name>
<value>*</value>
</property>
</configuration>
# 配置hdfs-site.xml
<configuration>
<property>
<name>dfs.name.dir</name>
<value>/data/hadoop/dfs/name</value>
</property>
<property>
<name>dfs.data.dir</name>
<value>/data/hadoop/dfs/data</value>
</property>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.http.address</name>
<value>0.0.0.0:50070</value>
</property>
</configuration>
# 配置mapred-site.xml
<configuration>
<property>
<name>mapred.local.dir</name>
<value>/data/hadoop/var</value>
</property>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>
# 配置yarn-site.xml
<configuration>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
</configuration>
# 配置hadoop-env.sh
更改其中的JAVA_HOME值为环境变量当中的路径
# 格式化hdfs
hdfs namenode -format
# 启动命令
start-all.sh
# 观察是否有相关进程没有启动或者启动后又挂掉
共5个进程:NameNode、DataNode、SecondaryNameNode、NodeManager、ResourceManager
安装hive
# 下载
wget -P /data https://mirrors.ustc.edu.cn/apache/hive/hive-3.1.3/apache-hive-3.1.3-bin.tar.gz
# 解压
tar -zxvf apache-hive-3.1.3-bin.tar.gz -C /opt/
# 配置环境变量
export HIVE_HOME=/opt/apache-hive-3.1.2-bin
# 新建一个hive-site.xml文件,内容如下
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true</value>
<description>JDBC connect string for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.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>xxxxxx</value>
<description>password to use against metastore database</description>
</property>
<property>
<name>hive.server2.transport.mode</name>
<value>binary</value>
</property>
<property>
<name>hive.server2.thrift.bind.host</name>
<value>0.0.0.0</value>
</property>
<property>
<name>hive.server2.thrift.port</name>
<value>10000</value>
</property>
<property>
<name>hive.server2.authentication</name>
<value>NOSASL</value>
</property>
<property>
<name>hive.server2.enable.doAs</name>
<value>true</value>
</property>
<property>
<name>hive.server2.thrift.max.worker.threads</name>
<value>1000</value>
</property>
</configuration>
# 下载mysql-jdbc包
在网站:dev.mysql.com/downloads/connector/j/,选择Platform Independent版本的tar文件下载。
解压后找到mysql-connector-java-8.0.29.jar 移动到hive的lib目录下
# 初始化
schematool -dbType mysql -initSchema
Hive元数据库的编码默认为Latin1,后期使用dtagrip建表会出现注释乱码,所以方便使用,此处使用如下语句将编码修改为utf8:
alter table COLUMNS_V2 modify column COMMENT varchar(256) character set utf8;
alter table TABLE_PARAMS modify column PARAM_VALUE mediumtext character set utf8;
# 启动元数据服务
hive --service metastore &
# 启动hiveserver2服务
nohup hiveserver2 &
#通过beeline连接hiveserver2
beeline
!connect jdbc:hive2://localhost:10000/default;auth=noSasl
用户为root,无密码