副标题[/!--empirenews.page--]
我正在尝试使用hadoop和hive创建一个docker容器.这是我的Dockerfile
FROM ubuntu:latest
USER root
RUN apt-get update
#RUN apt-get -y install default-jre
RUN apt-get install -y python-pip python-dev build-essential
RUN apt-get install -y libmysqlclient-dev
RUN apt-get install -y python-mysqldb
RUN apt-get update &&
apt-get upgrade -y &&
apt-get install -y git
ENV HADOOP_HOME /opt/hadoop
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64
# install packages
RUN
apt-get update && apt-get install -y
ssh
rsync
vim
openjdk-8-jdk
# create ssh keys
RUN
ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa &&
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys &&
chmod 0600 ~/.ssh/authorized_keys
RUN DEBIAN_FRONTEND=noninteractive apt install -y mysql-client
RUN DEBIAN_FRONTEND=noninteractive apt install -y mysql-server
RUN chown -R mysql:mysql /var/lib/mysql /var/log/mysql
WORKDIR /opt
# download and extract hadoop,set JAVA_HOME in hadoop-env.sh,update path
RUN wget --no-check-certificate https://www-us.apache.org/dist/hadoop/common/hadoop-2.8.5/hadoop-2.8.5.tar.gz
RUN tar -xzf hadoop-2.8.5.tar.gz
RUN mv hadoop-2.8.5 $HADOOP_HOME
RUN echo "export JAVA_HOME=$JAVA_HOME" >> $HADOOP_HOME/etc/hadoop/hadoop-env.sh
RUN echo "PATH=$PATH:$HADOOP_HOME/bin" >> ~/.bashrc
RUN rm hadoop-2.8.5.tar.gz
ARG HIVE_VERSION
# Set HIVE_VERSION from arg if provided at build,env if provided at run,or default
# https://docs.docker.com/engine/reference/builder/#using-arg-variables
# https://docs.docker.com/engine/reference/builder/#environment-replacement
ENV HIVE_VERSION=${HIVE_VERSION:-2.3.2}
ENV HIVE_HOME /opt/hive
ENV PATH $HIVE_HOME/bin:$PATH
RUN echo "PATH=$PATH:$HIVE_HOME/bin" >> ~/.bashrc
#Install Hive and PostgreSQL JDBC
RUN apt-get update && apt-get install -y wget procps &&
wget --no-check-certificate https://archive.apache.org/dist/hive/hive-$HIVE_VERSION/apache-hive-$HIVE_VERSION-bin.tar.gz &&
tar -xzvf apache-hive-$HIVE_VERSION-bin.tar.gz &&
mv apache-hive-$HIVE_VERSION-bin hive &&
rm apache-hive-$HIVE_VERSION-bin.tar.gz &&
apt-get clean &&
rm -rf /var/lib/apt/lists/*
ADD mysql-connector-java-5.1.47.jar /opt/hive/lib
ADD hive-site.xml /opt/hive/conf
这是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/metastore?createDatabaseIfNotExist=true&autoReconnect=true&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>password</value>
</property>
<property>
<name>datanucleus.autoCreateSchema</name>
<value>true</value>
</property>
<property>
<name>datanucleus.fixedDatastore</name>
<value>true</value>
</property>
<property>
<name>datanucleus.autoCreateTables</name>
<value>True</value>
</property>
</configuration>
我能够构建和运行容器.当我执行到容器中时,我可以轻松地执行
root@c29fa91db6a2:/opt/hive/conf# mysql -uroot -ppassword
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 191
Server version: 5.7.25-0ubuntu0.18.04.2 (Ubuntu)
Copyright (c) 2000,2019,Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql>
但是当我尝试做蜂巢-服务元存储时,我得到了
Caused by: java.sql.SQLException: Unable to open a test connection to the given database. JDBC url = jdbc:mysql://localhost:3306/metastore?createDatabaseIfNotExist=true&autoReconnect=true&useSSL=false,username = root. Terminating connection pool (set lazyInit to true if you expect to start your database after your app). Original Exception: ------
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
在堆栈跟踪的更深处,我看到了
Caused by: java.sql.SQLException: Access denied for user 'root'@'localhost'
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:965) ~[mysql-connector-java-5.1.47.jar:5.1.47]
但是,这是root用户拥有的授予
(编辑:威海站长网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|