使用版本:
软件名称 | 版本 |
---|---|
MySQL | 5.5.40 |
JDK | 1.8 |
Hadoop | 3.2.1 |
Hive | 3.1.2 |
Sqoop | 1.4.47 |
Flume | 1.9.0 |
# 镜像比较大, 需要准备一个网络稳定的环境
# 其中--mirror Aliyun代表使用阿里源
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
# 下载安装包, 拖动安装即可
https://hub.docker.com/editions/community/docker-ce-desktop-mac/
# win10家庭版 【参考】
https://docs.docker.com/docker-for-windows/install-windows-home/
# win10专业版、商业版或教育版 【参考】
https://docs.docker.com/docker-for-windows/install/
docker pull centos:7
docker run -itd --privileged --name singleNode -h singleNode \
-p 2222:22 \
-p 3306:3306 \
-p 8020:8020 \
-p 9870:9870 \
-p 19888:19888 \
-p 8088:8088 \
-p 9083:9083 \
-p 10000:10000 \
-p 2181:2181 \
-p 9092:9092 \
-p 8091:8091 \
-p 8080:8080 \
-p 16010:16010 \
-p 4000:4000 \
-p 3000:3000 \
centos:7 /usr/sbin/init
# 其中端口号解释
2222:22# SSH
3306:3306 #MySQL
8020:8020 # HDFS RPC
9870:9870 # HDFS web UI
19888:19888 # Yarn job history
8088:8088 # Yarn web UI
9083:9083 # Hive metastore
10000:10000 # HiveServer2
2181:2181 # zk
9092:9092 # kafka
8091:8091 # flink
docker exec -it singleNode /bin/bash
yum clean all
yum -y install unzip bzip2-devel vim bashname
yum install kde-l10n-Chinese -y
yum install glibc-common -y
localedef -c -f UTF-8 -i zh_CN zh_CN.utf8
echo "export LANG=zh_CN.UTF-8" >> /etc/locale.conf
echo "LC_ALL zh_CN.UTF-8" >> ~/.bashrc
# 修改root密码passwd root # 输入两次密码# 安装必要SSH服务yum install -y openssh openssh-server openssh-clients openssl openssl-devel # 生成秘钥ssh-keygen -t rsa -f ~/.ssh/id_rsa -P '' # 配置免密cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys# 方式2: ssh-copy-id# 启动SSH服务systemctl start sshd
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
yum -y install firewalldsystemctl stop firewalldsystemctl disable firewalld
cd /opt/software/tar xvf MySQL-5.5.40-1.linux2.6.x86_64.rpm-bundle.tar
yum -y install libaio perl
rpm -ivh MySQL-server-5.5.40-1.linux2.6.x86_64.rpmrpm -ivh MySQL-client-5.5.40-1.linux2.6.x86_64.rpm
方式一
# 启动服务systemctl start mysql# 修改MySQL密码/usr/bin/mysqladmin -u root password 'root'# 登陆MySQL设置权限mysql -uroot -proot > update mysql.user set host='%' where host='localhost';> delete from mysql.user where host<>'%' or user='';> flush privileges;
方式二
# 启动服务systemctl start mysql# 执行MySQL的初始化/usr/bin/mysql_secure_installation# 输入一次回车, 两次相同的密码进行修改密码# Remove anonymous users? [Y/n] 是否移除掉anonymous用户 n# Disallow root login remotely? [Y/n] 是否允许root用户远程登录 y# Remove test database and access to it? [Y/n] 是否移除掉test数据库 n# Reload privilege tables now? [Y/n] 是否现在刷新权限 y# 登陆MySQL设置权限mysql -uroot -proot > update mysql.user set host='%' where host='localhost';> delete from mysql.user where host<>'%' or user='';> flush privileges;
tar zxvf /opt/software/jdk-8u171-linux-x64.tar.gz -C /opt/install/ln -s /opt/install/jdk1.8.0_171 /opt/install/java
环境变量配置在 ~/.bashrc 里
vi ~/.bashrc-------------------------------------------export JAVA_HOME=/opt/install/javaexport PATH=$JAVA_HOME/bin:$PATH-------------------------------------------source ~/.bashrc
java -version
tar zxvf hadoop-3.2.1.tar.gz -C /opt/install/ln -s /opt/install/hadoop-3.2.1/ /opt/install/hadoop
# 进入路径cd /opt/install/hadoop/etc/hadoop/
vi core-site.xml-------------------------------------------<configuration> <property> <name>fs.defaultFSname> <value>hdfs://singleNode:8020value> property> <property> <name>hadoop.tmp.dirname> <value>/opt/install/hadoop/datavalue> property> <property> <name>hadoop.proxyuser.root.hostsname> <value>*value> property> <property> <name>hadoop.proxyuser.root.groupsname> <value>*value> property> <property> <name>hadoop.http.staticuser.username> <value>rootvalue> property>configuration>-------------------------------------------
vi hdfs-site.xml-------------------------------------------<configuration> <property> <name>dfs.replicationname> <value>1value> property> <property> <name>dfs.namenode.secondary.http-addressname> <value>singleNode:9868value> property>configuration>-------------------------------------------
vi mapred-site.xml-------------------------------------------<configuration> <property> <name>mapreduce.framework.namename> <value>yarnvalue> property> <property> <name>mapreduce.jobhistory.addressname> <value>singleNode:10020value> property> <property> <name>mapreduce.jobhistory.webapp.addressname> <value>singleNode:19888value> property>configuration>-------------------------------------------
vi yarn-site.xml-------------------------------------------<configuration> <property> <name>yarn.nodemanager.aux-servicesname> <value>mapreduce_shufflevalue> property> <property> <name>yarn.resourcemanager.hostnamename> <value>singleNodevalue> property> <property> <name>yarn.nodemanager.env-whitelistname> <value>JAVA_HOME,HADOOP_COMMON_HOME,HADOOP_HDFS_HOME,HADOOP_CONF_DIR,CLASSPATH_PREPEND_DISTCACHE,HADOOP_YARN_HOME,HADOOP_MAPRED_HOMEvalue> property> <property> <name>yarn.scheduler.minimum-allocation-mbname> <value>512value> property> <property> <name>yarn.scheduler.maximum-allocation-mbname> <value>4096value> property> <property> <name>yarn.nodemanager.resource.memory-mbname> <value>4096value> property> <property> <name>yarn.nodemanager.pmem-check-enabledname> <value>falsevalue> property> <property> <name>yarn.nodemanager.vmem-check-enabledname> <value>falsevalue> property> <property> <name>yarn.log-aggregation-enablename> <value>truevalue> property> <property> <name>yarn.log.server.urlname> <value>http://${yarn.timeline-service.webapp.address}/applicationhistory/logsvalue> property> <property> <name>yarn.log-aggregation.retain-secondsname> <value>604800value> property> <property> <name>yarn.timeline-service.enabledname> <value>truevalue> property> <property> <name>yarn.timeline-service.hostnamename> <value>${yarn.resourcemanager.hostname}value> property> <property> <name>yarn.timeline-service.http-cross-origin.enabledname> <value>truevalue> property> <property> <name>yarn.resourcemanager.system-metrics-publisher.enabledname> <value>truevalue> property>configuration>-------------------------------------------
vi hadoop-env.sh-------------------------------------------export JAVA_HOME=/opt/install/java-------------------------------------------
vi mapred-env.sh-------------------------------------------export JAVA_HOME=/opt/install/java-------------------------------------------
vi yarn-env.sh-------------------------------------------export JAVA_HOME=/opt/install/java-------------------------------------------
vi works-------------------------------------------singleNode-------------------------------------------
vi ~/.bashrc------------------------------------------------export HADOOP_HOME=/opt/install/hadoopexport HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoopexport PATH=$HADOOP_HOME/bin:$PATH------------------------------------------------vi $HADOOP_HOME/sbin/start-dfs.shvi $HADOOP_HOME/sbin/stop-dfs.sh------------------------------------------------HDFS_NAMENODE_USER=root HDFS_DATANODE_USER=root HDFS_SECONDARYNAMENODE_USER=root YARN_RESOURCEMANAGER_USER=root YARN_NODEMANAGER_USER=root------------------------------------------------vi $HADOOP_HOME/sbin/start-yarn.shvi $HADOOP_HOME/sbin/stop-yarn.sh------------------------------------------------YARN_RESOURCEMANAGER_USER=root HADOOP_SECURE_DN_USER=yarn YARN_NODEMANAGER_USER=root------------------------------------------------
hdfs namenode -format
# 启动HDFS$HADOOP_HOME/sbin/start-dfs.sh# 启动yarn$HADOOP_HOME/sbin/start-yarn.sh# 启动历史服务器mapred --daemon start historyserver
查看9870端口
查看8088端口
tar zxvf /opt/software/apache-hive-3.1.2-bin.tar.gz -C /opt/install/ln -s /opt/install/apache-hive-3.1.2-bin/ /opt/install/hive
# 进入路径cd /opt/install/hive/conf/
cp hive-default.xml.template hive-site.xmlvi hive-site.xml-------------------------------------------<configuration> <property> <name>javax.jdo.option.ConnectionURLname> <value>jdbc:mysql://singleNode:3306/metastore?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8value> property> <property> <name>javax.jdo.option.ConnectionDriverNamename> <value>com.mysql.jdbc.Drivervalue> property> <property> <name>javax.jdo.option.ConnectionUserNamename> <value>rootvalue> property> <property> <name>javax.jdo.option.ConnectionPasswordname> <value>rootvalue> property> <property> <name>hive.metastore.warehouse.dirname> <value>/user/hive/warehousevalue> property> <property> <name>hive.metastore.schema.verificationname> <value>falsevalue> property> <property> <name>hive.metastore.urisname> <value>thrift://singleNode:9083value> property> <property> <name>hive.server2.thrift.portname> <value>10000value> property> <property> <name>hive.server2.thrift.bind.hostname> <value>singleNodevalue> property> <property> <name>hive.metastore.event.db.notification.api.authname> <value>falsevalue> property>configuration>-------------------------------------------
cp hive-env.sh.template hive-env.shvi hive-env.sh-------------------------------------------HADOOP_HOME=/opt/install/hadoop-------------------------------------------
cp /opt/software/mysql-connector-java-5.1.31.jar /opt/install/hive/lib/
vi ~/.bashrc------------------------------------------------export HIVE_HOME=/opt/install/hiveexport PATH=$HIVE_HOME/bin:$PATH------------------------------------------------
# 初始化元数据表schematool -dbType mysql -initSchema# 启动hiveserver2服务nohup hive --service hiveserver2 ############报错 Exception in thread "main" java.lang.NoSuchMethodError ################# jar 包冲突, 需要删除低版本包rm -rf /opt/install/hive/lib/guava-19.0.jarcp /opt/install/hadoop/share/hadoop/common/lib/guava-27.0-jre.jar /opt/install/hive/lib/
tar zxvf sqoop-1.4.7.bin__hadoop-2.6.0.tar.gz -C /opt/install/ln -s /opt/install/sqoop-1.4.7.bin__hadoop-2.6.0/ /opt/install/sqoop
cd /opt/install/sqoop/conf/cp sqoop-env-template.sh sqoop-env.shvi sqoop-env.sh-------------------------------------------#Set path to where bin/hadoop is availableexport HADOOP_COMMON_HOME=/opt/install/hadoop#Set path to where hadoop-*-core.jar is availableexport HADOOP_MAPRED_HOME=/opt/install/hadoop#Set the path to where bin/hive is availableexport HIVE_HOME=/opt/install/hive-------------------------------------------
cp /opt/software/mysql-connector-java-5.1.31.jar /opt/install/sqoop/lib/cp /opt/software/commons-lang-2.6.jar /opt/install/sqoop/lib/cp /opt/software/java-json.jar /opt/install/sqoop/lib/
vi ~/.bashrc------------------------------------------------export SQOOP_HOME=/opt/install/sqoopexport PATH=$SQOOP_HOME/bin:$PATH------------------------------------------------
sqoop version
tar zxvf /opt/software/apache-flume-1.9.0-bin.tar.gz -C /opt/install/cd /opt/install/ln -s apache-flume-1.9.0-bin/ flume
cd flume/rm -rf lib/guava-11.0.2.jar
vi ~/.bashrc---------------------export FLUME_HOME=/opt/install/flumeexport PATH=$FLUME_HOME/bin:$PATH---------------------source ~/.bashrc
本文所使用的安装包存放地址:
链接:https://pan.baidu.com/s/1F2lXHEP3-6_mDPp2L5oEjg
提取码:vick