# 生成的镜像以centos镜像为基础 FROM centos MAINTAINER by ytliangc #升级系统 RUN yum -y update #安装openssh-server、client RUN yum -y install openssh-server openssh-clients.x86_64 vim less wget #修改/etc/ssh/sshd_config #RUN sed -i 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config #将密钥文件复制到/etc/ssh/目录中。这里要用root的权限生成key RUN mkdir -p /root/.ssh #生成秘钥、公钥 RUN ssh-keygen -t rsa -b 2048 -P '' -f /root/.ssh/id_rsa RUN cat /root/.ssh/id_rsa.pub > /root/.ssh/authorized_keys RUN cp /root/.ssh/id_rsa /etc/ssh/ssh_host_rsa_key RUN cp /root/.ssh/id_rsa.pub /etc/ssh/ssh_host_rsa_key.pub
$ docker-compose up -d Starting mysql ... done Starting hadoop ... done
1、在数据库启动后,我们还需要链接到数据新建一个名为hive的数据库,给hive使用
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
[root@vmlabmaster-dev hadoop]# docker exec -it mysql bash root@a030f58f915d:/# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands endwith ; or \g. Your MySQL connection id is 2 Server version: 5.7.30 MySQL Community Server (GPL)
Copyright (c) 2000, 2020, 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'toclear the currentinput statement.
#出现提示的话,输入yes即可 [root@73326baf0f61 /]# start-dfs.sh && start-yarn.sh Starting namenodes on [localhost] The authenticity of host 'localhost (127.0.0.1)' can't be established. RSA key fingerprint is SHA256:Aog6oB0HvbmXPR1AyYfPBJ//tcDNp8i3kr5QGzrkQHg. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes localhost: Warning: Permanently added 'localhost' (RSA) to the list of known hosts. localhost: starting namenode, logging to /usr/local/hadoop-2.7.3/logs/hadoop-root-namenode-73326baf0f61.out localhost: starting datanode, logging to /usr/local/hadoop-2.7.3/logs/hadoop-root-datanode-73326baf0f61.out Starting secondary namenodes [0.0.0.0] The authenticity of host '0.0.0.0 (0.0.0.0)' can't be established. RSA key fingerprint is SHA256:Aog6oB0HvbmXPR1AyYfPBJ//tcDNp8i3kr5QGzrkQHg. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes 0.0.0.0: Warning: Permanently added '0.0.0.0' (RSA) to the list of known hosts. 0.0.0.0: starting secondarynamenode, logging to /usr/local/hadoop-2.7.3/logs/hadoop-root-secondarynamenode-73326baf0f61.out starting yarn daemons starting resourcemanager, logging to /usr/local/hadoop-2.7.3/logs/yarn-root-resourcemanager-73326baf0f61.out localhost: starting nodemanager, logging to /usr/local/hadoop-2.7.3/logs/yarn-root-nodemanager-73326baf0f61.out
[root@73326baf0f61 /]# schematool -initSchema -dbType mysql SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/usr/local/apache-hive-2.3.7-bin/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/usr/local/hadoop-2.7.3/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory] Metastore connection URL: jdbc:mysql://172.18.0.2:3306/mysql?useSSL=false Metastore Connection Driver : com.mysql.jdbc.Driver Metastore connection User: root Starting metastore schema initialization to 2.3.0 Initialization script hive-schema-2.3.0.mysql.sql Initialization script completed schemaTool completed