Docker内安装Flume

1. 复制文件到docker(主机内复制到docker内)
root@hadoop:/var/lib/docker/aufs/mnt# sudo docker cp --help

Usage:  docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|-
    docker cp [OPTIONS] SRC_PATH|- CONTAINER:DEST_PATH

Copy files/folders between a container and the local filesystem

Options:
  -L, --follow-link   Always follow symbol link in SRC_PATH
      --help          Print usage
root@hadoop:/var/lib/docker/aufs/mnt# sudo docker cp /home/hadoop/build master:/root/build
2. 解压到/usr/local 
root@master:/usr/local# tar -xvf /root/build/apache-flume-1.7.0-bin.tar.gz -C /usr/local
#要加 -C 再加文件路径 要不会出错
3. 改名为flume
root@master:/usr/local# mv apache-flume-1.7.0-bin/  flume/
4. 配置环境变量  ~/.bashrc
export FLUME_HOME=/usr/local/flume
export PATH=$PATH:$FLUME_HOME/bin
在这个文件中还有
    export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/
    export PATH=$PATH:$JAVA_HOME/bin

    export HADOOP_HOME=/usr/local/hadoop
    #export PATH=$PATH:$HADOOP_HOME/bin 
    #export PATH=$PATH:$HADOOP_HOME/sbin 
    export HADOOP_MAPRED_HOME=$HADOOP_HOME
    export HADOOP_COMMON_HOME=$HADOOP_HOME
    export HADOOP_HDFS_HOME=$HADOOP_HOME
    export YARN_HOME=$HADOOP_HOME
    export HADOOP_COMMON_HOME=$HADOOP_HOME
    export HADOOP_HDFS_HOME=$HADOOP_HOME
    export YARN_HOME=$HADOOP_HOME
    export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
    export HADOOP_OPTS="-Djava.library.path=$HADOOP_HOME/lib"
    export JAVA_LIBRARY_PATH=$HADOOP_HOME/lib/native:$JAVA_LIBRARY_PATH
    export SCALA_HOME=/usr/local/scala
    export PATH=$PATH:$SCALA_HOME/bin


    export SPARK_HOME=/usr/local/spark
    export PATH=$PATH:$SPARK_HOME/bin

    export FLUME_HOME=/usr/local/flume
    export PATH=$PATH:$FLUME_HOME/bin

    /etc/init.d/ssh start
5. 使环境变量生效 
root@master:/usr/local# source ~/.bashrc 
 * Starting OpenBSD Secure Shell server sshd                                             [ OK ] 
root@master:/usr/local# 
6. 验证安装
root@master:/usr/local# flume-ng version
Flume 1.7.0
Source code repository: https://git-wip-us.apache.org/repos/asf/flume.git
Revision: 511d868555dd4d16e6ce4fedc72c2d1454546707
Compiled by bessbd on Wed Oct 12 20:51:10 CEST 2016
From source with checksum 0d21b3ffdc55a07e1d08875872c00523
root@master:/usr/local# 
7. 修改配置文件 将模板复制并改名以进行其他的配置
root@master:/usr/local/flume/conf# ll
total 24
drwxr-xr-x 2 root staff 4096 May  8 13:35 ./
drwxr-xr-x 7 root root  4096 May  8 13:35 ../
-rw-r--r-- 1 root staff 1661 Sep 26  2016 flume-conf.properties.template
-rw-r--r-- 1 root staff 1455 Sep 26  2016 flume-env.ps1.template
-rw-r--r-- 1 root staff 1565 Sep 26  2016 flume-env.sh.template
-rw-r--r-- 1 root staff 3107 Sep 26  2016 log4j.properties
root@master:/usr/local/flume/conf# cp flume-conf.properties.template flume-conf.properties     
root@master:/usr/local/flume/conf# cat flume-conf.properties
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#  http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.


# The configuration file needs to define the sources, 
# the channels and the sinks.
# Sources, channels and sinks are defined per agent, 
# in this case called 'agent'

agent.sources = seqGenSrc
agent.channels = memoryChannel
agent.sinks = loggerSink

# For each one of the sources, the type is defined
agent.sources.seqGenSrc.type = seq

# The channel can be defined as follows.
agent.sources.seqGenSrc.channels = memoryChannel

# Each sink's type must be defined
agent.sinks.loggerSink.type = logger

#Specify the channel the sink should use
agent.sinks.loggerSink.channel = memoryChannel

# Each channel's type is defined.
agent.channels.memoryChannel.type = memory

# Other config values specific to each type of channel(sink or source)
# can be defined as well
# In this case, it specifies the capacity of the memory channel

agent.channels.memoryChannel.capacity = 100

你可能感兴趣的:(大数据)