之前尝试在wsl中单节点安装cdh,已经成功安装并启动了cm,并且zk、hadoop、hbase也成功启动了,但hive和hbase老是进不去,提示hdfs处于safemode,暂时还没解决,所以就在wsl上装个伪分布式,用来测试
https://blog.csdn.net/qq_34224565/article/details/125828001
https://blog.csdn.net/qq_34224565/article/details/105261652
使用root,创建/install_files,将安装包放到下面
sudo rpm -ivh oracle-j2sdk1.8-1.8.0+update181-1.x86_64.rpm
sudo vim /etc/profile
在最下面添加
export JAVA_HOME=/usr/java/jdk1.8.0_181-cloudera
export CLASSPATH=$:CLASSPATH:$JAVA_HOME/lib/
export PATH=${JAVA_HOME}/bin:${PATH}
source /etc/profile
然后执行java -version验证
passwd root
官网很慢
https://mirrors.cnnic.cn/apache/hadoop/common/
tar -zxvf hadoop*.tar.gz -C /usr/local #解压到/usr/local目录下
cd /usr/local
mv hadoop* hadoop
vim ~/.bashrc
export HADOOP_HOME=/usr/local/hadoop
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
export JAVA_LIBRAY_PATH=/usr/local/hadoop/lib/native
vim /etc/profile
unset i
unset -f pathmunge
export JAVA_HOME=/usr/java/jdk1.8.0_181-cloudera
export HADOOP_HOME=/usr/local/hadoop
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export JAVA_LIBRAY_PATH=/usr/local/hadoop/lib/native
export CLASSPATH=$:CLASSPATH:$JAVA_HOME/lib/
export PATH=$HADOOP_HOME/bin:$HADOOP_HOME/sbin:${JAVA_HOME}/bin:${PATH}
source /etc/profile
cd /usr/local/hadoop/etc/hadoop
添加hadoop_opts和jdk路径,这一步必须要做,即使hadoop-env.sh的上面已经配过
export JAVA_HOME=/usr/java/jdk1.8.0_181-cloudera
# 解决Unable to load native-hadoop library for your platform...
export HADOOP_OPTS="-Djava.library.path=${HADOOP_HOME}/lib/native"
vim core-site.xml
<configuration>
<property>
<name>hadoop.tmp.dirname>
<value>file:/usr/local/hadoop/tmpvalue>
<description>Abase for other temporary directories.description>
property>
<property>
<name>fs.defaultFSname>
<value>hdfs://localhost:9000value>
property>
configuration>
vim hdfs-site.xml
<configuration>
<property>
<name>dfs.replicationname>
<value>1value>
property>
<property>
<name>dfs.namenode.name.dirname>
<value>file:/usr/local/hadoop/tmp/dfs/namevalue>
property>
<property>
<name>dfs.datanode.data.dirname>
<value>file:/usr/local/hadoop/tmp/dfs/datavalue>
property>
configuration>
直接执行/usr/sbin/sshd即可
ps -e | grep sshd
ssh-keygen
ssh-copy-id localhost
/usr/local/hadoop/bin/hdfs namenode -format
/usr/local/hadoop/sbin/start-dfs.sh
启动完成后,可以通过命令 jps 来判断是否成功启动,若成功启动则会列出如下进程: “NameNode”、”DataNode” 和 “SecondaryNameNode”
http://localhost:50070
修改mapred-site.xml
<configuration>
<property>
<name>mapreduce.framework.namename>
<value>yarnvalue>
property>
<property>
<name>yarn.app.mapreduce.am.envname>
<value>HADOOP_MAPRED_HOME=${HADOOP_HOME}value>
property>
<property>
<name>mapreduce.map.envname>
<value>HADOOP_MAPRED_HOME=${HADOOP_HOME}value>
property>
<property>
<name>mapreduce.reduce.envname>
<value>HADOOP_MAPRED_HOME=${HADOOP_HOME}value>
property>
configuration>
修改yarn-site.xml
<configuration>
<property>
<name>yarn.nodemanager.aux-servicesname>
<value>mapreduce_shufflevalue>
property>
configuration>
/usr/local/hadoop/sbin/start-all.sh
http://localhost:8088/
http://localhost:50070/
因为mysql没啥用,所以这次用hive自带的Derby数据库即可。但最后hivecli总是进不去,后面用mysql就可以了。
https://dlcdn.apache.org/hive/
tar zxvf apache-hive-2.3.9-bin.tar.gz -C /opt
cd /opt/
mv apache-hive-2.3.9-bin/ hive
#hive
export HIVE_HOME=/opt/hive
export PATH=$HIVE_HOME/bin:xxx
source /etc/profile
echo $HIVE_HOME
echo $HADOOP_HOME
验证hadoop fs -mkdir /tmp
hadoop fs -mkdir -p /user/hive/warehouse
hadoop fs -chmod g+w /tmp
hadoop fs -chmod g+w /user/hive/warehouse
cd /opt/hive/bin
schematool -dbType derby -initSchema
beeline是通过hs2连接hive的,相比hivecli,hs2支持多用户,更安全,还有其他更多功能。
#使用窗口还要用,所以后台运行
hiveserver2 &
启动后,使用beeline连接时,报root不能连,
一开始所以创建hive用户,用hive连,发现不起作用。
然后http://www.manongjc.com/detail/25-jwxiitmwxxpyncm.html
根据上篇文章,如果hive.server2.enable.doAs设为false,hs2判断用户是根据运行hs2进程的linux用户,这样root就会被允许了。同时在Impersonation这章中,还有另外2个配置,虽然不知道啥意思,但也一起改了吧。
因为conf下没有hive-site.xml,因为用的是默认的单机模式,单机模式原则上不需要hive-site,hive-site是用来配置hive服务端的,但因为使用了hs2,所以还是要用,这里自己手动建一个:
<configuration>
<property>
<name>hive.server2.enable.doAsname>
<value>falsevalue>
property>
<property>
<name>fs.hdfs.impl.disable.cachename>
<value>truevalue>
property>
<property>
<name>fs.file.impl.disable.cachename>
<value>truevalue>
property>
<property>
<name>hive.metastore.schema.verificationname>
<value>falsevalue>
property>
<property>
<name>hive.server2.thrift.min.worker.threadsname>
<value>5value>
property>
<property>
<name>hive.server2.thrift.max.worker.threadsname>
<value>500value>
property>
<property>
<name>hive.server2.transport.modename>
<value>binaryvalue>
property>
<property>
<name>hive.server2.thrift.http.portname>
<value>10001value>
property>
<property>
<name>hive.server2.thrift.http.max.worker.threadsname>
<value>500value>
property>
<property>
<name>hive.server2.thrift.http.min.worker.threadsname>
<value>5value>
property>
<property>
<name>hive.server2.thrift.http.pathname>
<value>cliservicevalue>
property>
<property>
<name>javax.jdo.option.ConnectionURLname>
<value>jdbc:mysql://localhost:3306/metastore?createDatabaseIfNotExist=true;characterEncoding=UTF-8;useSSL=false;serverTimezone=GMTvalue>
property>
<property>
<name>javax.jdo.option.ConnectionDriverNamename>
<value>com.mysql.cj.jdbc.Drivervalue>
property>
<property>
<name>javax.jdo.option.ConnectionUserNamename>
<value>hivevalue>
property>
<property>
<name>javax.jdo.option.ConnectionPasswordname>
<value>dcdcdcvalue>
property>
<property>
<name>hive.metastore.schema.verificationname>
<value>falsevalue>
property>
<property>
<name>hive.cli.print.current.dbname>
<value>truevalue>
property>
<property>
<name>hive.cli.print.headername>
<value>truevalue>
property>
<property>
<name>hive.server2.thrift.portname>
<value>10000value>
property>
<property>
<name>hive.server2.thrift.bind.hostname>
<value>localhostvalue>
property>
configuration>
重新启动hs2
hiveserver2 &
hive --service metastore &
https://dev.mysql.com/downloads/mysql/
rpm -qa|grep mariadb
rpm -e --nodeps mariadb-libs
rpm -qa|grep mariadb
yum -y install net-tools
yum -y install libaio libmysqlclient.so.18
useradd mysql
passwd mysql
mkdir /mysqldata
chown -R mysql:mysql /mysql;chown -R mysql:mysql /mysqldata
tar zxvf /home/dc/install_source/mysql-8.0.30-el7-x86_64.tar.gz -C /
mv /mysql-8.0.30-el7-x86_64/ /mysql
/etc/my.cnf
[client]
socket=/mysql/mysql.sock
[mysqld]
basedir=/mysql
datadir=/mysqldata
socket=/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
vim mysql.server
if test -z "$basedir"
then
basedir=/mysql
bindir=/mysql/bin
if test -z "$datadir"
then
datadir=/mysqldata
fi
sbindir=/mysql/bin
libexecdir=/mysql/bin
else
bindir="$basedir/bin"
if test -z "$datadir"
then
datadir="$basedir/data"
fi
sbindir="$basedir/sbin"
libexecdir="$basedir/libexec"
fi
cp mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --list mysqld
设了这2步才能用systemctl来操作mysqld
export JAVA_HOME=/usr/java/jdk1.8.0_181-cloudera
#mysql
export MYSQL_HOME=/mysql
export CLASSPATH=$:CLASSPATH:$JAVA_HOME/lib/:$MYSQL_HOME/lib/
export PATH=$MYSQL_HOME/bin:$HIVE_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:${JAVA_HOME}/bin:${PATH}
source /etc/profile
echo $MYSQL_HOME
/mysql/bin/mysqld --initialize --user=mysql --basedir=/mysql --datadir=/mysqldata
i*ZY-wtfO1dd
cd /mysql/support-files
./mysql.server start
Starting MySQL.Logging to '/mysqldata/DCHAO-PC-DESKTOP-001.err'.
SUCCESS!
./mysql -uroot -pghA+w%qmm9uT
alter user 'root'@'localhost' identified by 'dcdcdc';
flush privileges;
use mysql;
create user 'root'@'%' identified by 'dcdcdc';
grant all privileges on *.* to 'root'@'%' with grant option;
create database metastore;
create user 'hive'@'%' identified by 'dcdcdc';
grant all privileges on *.* to 'hive'@'%' with grant option;
flush privileges;
show databases;
上面的hive-derby失败了,所以换mysql试下,这次成功了
https://dlcdn.apache.org/hive/
tar zxvf apache-hive-2.3.9-bin.tar.gz -C /opt
cd /opt/
mv apache-hive-2.3.9-bin/ hive
#hive
export HIVE_HOME=/opt/hive
export PATH=$HIVE_HOME/bin:xxx
source /etc/profile
echo $HIVE_HOME
hadoop fs -mkdir /tmp
hadoop fs -mkdir -p /user/hive/warehouse
hadoop fs -chmod g+w /tmp
hadoop fs -chmod g+w /user/hive/warehouse
<configuration>
<property>
<name>hive.server2.enable.doAsname>
<value>falsevalue>
property>
<property>
<name>fs.hdfs.impl.disable.cachename>
<value>truevalue>
property>
<property>
<name>fs.file.impl.disable.cachename>
<value>truevalue>
property>
<property>
<name>hive.server2.thrift.min.worker.threadsname>
<value>5value>
property>
<property>
<name>hive.server2.thrift.max.worker.threadsname>
<value>500value>
property>
<property>
<name>hive.server2.transport.modename>
<value>binaryvalue>
property>
<property>
<name>hive.server2.thrift.http.portname>
<value>10001value>
property>
<property>
<name>hive.server2.thrift.http.max.worker.threadsname>
<value>500value>
property>
<property>
<name>hive.server2.thrift.http.min.worker.threadsname>
<value>5value>
property>
<property>
<name>hive.server2.thrift.http.pathname>
<value>cliservicevalue>
property>
<property>
<name>javax.jdo.option.ConnectionURLname>
<value>jdbc:mysql://localhost:3306/metastore?createDatabaseIfNotExist=true&allowPublicKeyRetrieval=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=GMTvalue>
property>
<property>
<name>javax.jdo.option.ConnectionDriverNamename>
<value>com.mysql.cj.jdbc.Drivervalue>
property>
<property>
<name>javax.jdo.option.ConnectionUserNamename>
<value>hivevalue>
property>
<property>
<name>javax.jdo.option.ConnectionPasswordname>
<value>dcdcdcvalue>
property>
<property>
<name>hive.metastore.schema.verificationname>
<value>falsevalue>
property>
<property>
<name>hive.metastore.event.db.notification.api.authname>
<value>falsevalue>
property>
<property>
<name>hive.metastore.warehouse.dirname>
<value>/user/hive/warehousevalue>
property>
<property>
<name>hive.cli.print.current.dbname>
<value>truevalue>
property>
<property>
<name>hive.cli.print.headername>
<value>truevalue>
property>
<property>
<name>hive.server2.thrift.portname>
<value>10000value>
property>
<property>
<name>hive.server2.thrift.bind.hostname>
<value>localhostvalue>
property>
<property>
<name>hive.metastore.urisname>
<value>thrift://localhost:9083value>
property>
configuration>
cp mysql-connector-java-8.0.25.jar /opt/hive/lib/
cd /opt/hive/bin
./schematool -dbType mysql -initSchema hive dcdcdc
上面有个warning,在hivecli中也会报错,要更换mysql驱动的类名,所以在hive-site.xml中更换,这样就不会报错了
此时,metastore库中就有了表
不知为何,没有启动metastore服务也可以访问,可能启动hivecli的时候,自动启动了一个metastore
hiveserver2 &
beeline -u jdbc:hive2://localhost:10000
/usr/sbin/sshd
/usr/local/hadoop/sbin/start-all.sh
/mysql/support-files/mysql.server start
hiveserver2 &
/usr/sbin/sshd;/usr/local/hadoop/sbin/start-all.sh;/mysql/support-files/mysql.server start;hive --service metastore &;hiveserver2 &;
验证:
jps
ps -ef | grep hive
netstat -anp | grep 10000
官网提供的ide中没有idea,但实际上idea是最方便的https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients#HiveServer2Clients-JDBC
驱动具体用的哪个也不知道,但我把$HIVE_HOME/lib和/usr/local/hadoop/share/hadoop/common/lib下的jar全复制进去了
cp $HIVE_HOME/lib/*.jar /mnt/d/dcsys/develop/test_env/idea_hive_jars
cp /usr/local/hadoop/share/hadoop/common/lib*.jar /mnt/d/dcsys/develop/test_env/idea_hive_jars
驱动类选HiveDriver
最重要的是,url中不要用locallost要用ifconfig中的ip