├── README.md ├── configuration └── alluxio-env.xml ├── metainfo.xml └── package ├── .hash ├── scripts ├── master.py ├── params.py ├── service_check.py └── slave.py └── templates └── alluxio-env.sh.template /README.md: -------------------------------------------------------------------------------- 1 | ## Alluxio Service for Ambari 2.2 (HDP 2.4) 2 | 3 | Alluxio v 1.0.1 - Deploys on HDP 2.4 4 | 5 | 6 | Install, start/stop, status, service check functional 7 | 8 | 9 | **1. Clone the service into the dir for the Stack you are running in Ambari** 10 | 11 | **- Adding Alluxio to a HDP 2.4 Cluster** 12 | 13 | ``` 14 | # Clone the service deployer 15 | git clone https://github.com/chuyqa/alluxio-ambari-service /var/lib/ambari-server/resources/stacks/HDP/2.4/services/ALLUXIO 16 | 17 | #git has a 100mb file limit, download alluxio source to your stack dir 18 | wget http://alluxio.org/downloads/files/1.0.1/alluxio-1.0.1-bin.tar.gz -P /var/lib/ambari-server/resources/stacks/HDP/2.4/services/ALLUXIO/package/files 19 | 20 | ambari-server restart 21 | 22 | ``` 23 | 24 | 25 | **2. Add service via Ambari ui** 26 | 27 | 28 | 29 | **3. Assign a Alluxio Master And Worker nodes.** 30 | 31 | By default the master will also run a worker 32 | 33 | 34 | Once Service is started, you may access Alluxio Master Web UI on ***alluxio.master.hostname*:19999** 35 | 36 | **Future Work:** 37 | Use non-root user 38 | defaultFS url 39 | Metrics 40 | Fix status check on start 41 | Clean up & Expand alluxio-env 42 | -------------------------------------------------------------------------------- /configuration/alluxio-env.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 20 | 21 | 22 | alluxio.log.dir 23 | Alluxio Log Directory 24 | /var/log/alluxio/ 25 | 26 | 27 | 28 | alluxio.pid.dir 29 | Alluxio pid Directory 30 | /var/run/alluxio 31 | 32 | 33 | 34 | alluxio.archive.file 35 | alluxio archive file 36 | alluxio-1.0.1-bin.tar.gz 37 | 38 | 39 | 40 | alluxio.underfs.address 41 | Alluxio UnderFS Address 42 | hdfs://0.0.0.0:8020 43 | 44 | 45 | 46 | alluxio.worker.memory 47 | Alluxio Worker Memory 48 | 2GB 49 | 50 | 51 | 52 | alluxio_user 53 | alluxio 54 | USER 55 | Alluxio Service Account User 56 | 57 | 58 | -------------------------------------------------------------------------------- /metainfo.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 2.0 4 | 5 | 6 | ALLUXIO 7 | Alluxio 8 | Memory Centric Reliable Distributed Storage 9 | 1.0.1 10 | 11 | 12 | ALLUXIO_MASTER 13 | Alluxio Master 14 | MASTER 15 | 1 16 | 17 | 18 | PYTHON 19 | 500 20 | 21 | 22 | 23 | ALLUXIO_SLAVE 24 | Alluxio Worker 25 | SLAVE 26 | 1+ 27 | 28 | 29 | PYTHON 30 | 300 31 | 32 | 33 | 34 | 35 | 36 | 37 | redhat6 38 | 39 | 40 | 41 | 42 | 43 | PYTHON 44 | 300 45 | 46 | 47 | 48 | alluxio-config 49 | alluxio-env 50 | core-site 51 | hdfs-site 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /package/.hash: -------------------------------------------------------------------------------- 1 | d0490f047c09e767f5e7f1547ae722eb31e66f40 -------------------------------------------------------------------------------- /package/scripts/master.py: -------------------------------------------------------------------------------- 1 | #import status properties defined in -env.xml file from status_params class 2 | import sys, os, pwd, signal, time 3 | from resource_management import * 4 | from resource_management.core.base import Fail 5 | from resource_management.core.exceptions import ComponentIsNotRunning 6 | from subprocess import call 7 | import cPickle as pickle 8 | 9 | class Master(Script): 10 | 11 | #Call setup.sh to install the service 12 | def install(self, env): 13 | 14 | import params 15 | # Install packages listed in metainfo.xml 16 | self.install_packages(env) 17 | 18 | # Create the base_dir/alluxio dir 19 | cmd = '/bin/mkdir' + ' -p ' + params.base_dir 20 | Execute('echo "Running ' + cmd + '"') 21 | Execute(cmd) 22 | 23 | #extract archive and symlink dirs 24 | cmd = '/bin/tar' + ' -zxf ' + params.alluxio_package_dir + 'files/' + params.alluxio_archive_file + ' --strip 1 -C ' + params.base_dir 25 | Execute('echo "Running ' + cmd + '"') 26 | Execute(cmd) 27 | 28 | cmd = '/bin/ln' + ' -s ' + params.base_dir + ' ' + params.usr_base + 'current/alluxio' 29 | Execute('echo "Running ' + cmd + '"') 30 | try: 31 | Execute(cmd) 32 | except: 33 | pass 34 | 35 | self.configure(env) 36 | 37 | def configure(self, env): 38 | import params 39 | 40 | env.set_params(params) 41 | 42 | alluxio_config_dir = params.base_dir + '/conf/' 43 | alluxio_libexec_dir = params.base_dir + '/libexec/' 44 | 45 | File(format("{alluxio_config_dir}/alluxio-env.sh"), 46 | owner='root', 47 | group='root', 48 | mode=0700, 49 | content=Template('alluxio-env.sh.template', conf_dir=alluxio_config_dir) 50 | ) 51 | 52 | 53 | #Call start.sh to start the service 54 | def start(self, env): 55 | import params 56 | 57 | #call format 58 | cmd = params.base_dir + '/bin/alluxio ' + 'format' 59 | 60 | Execute('echo "Running cmd: ' + cmd + '"') 61 | Execute(cmd) 62 | 63 | #execute the startup script 64 | cmd = params.base_dir + '/bin/alluxio-start.sh ' + 'master' 65 | 66 | Execute('echo "Running cmd: ' + cmd + '"') 67 | Execute(cmd) 68 | 69 | # Create pid file - note check_process_status expects a SINGLE int in the file 70 | cmd = "mkdir -p " + params.pid_dir 71 | Execute(cmd) 72 | cmd = "echo `ps -A -o pid,command | grep -i \"[j]ava\" | grep AlluxioMaster | awk '{print $1}'`> " + params.pid_dir + "/AlluxioMaster.pid" 73 | Execute(cmd) 74 | pid_file = format("{params.pid_dir}/AlluxioMaster.pid") 75 | 76 | #Called to stop the service using alluxio provided stop 77 | def stop(self, env): 78 | import params 79 | 80 | #execure the startup script 81 | cmd = params.base_dir + '/bin/alluxio-stop.sh' 82 | 83 | Execute('echo "Running cmd: ' + cmd + '"') 84 | Execute(cmd) 85 | 86 | #Called to get status of the service using the pidfile 87 | def status(self, env): 88 | import params 89 | 90 | pid_file = format("{params.pid_dir}/AlluxioMaster.pid") 91 | check_process_status(pid_file) 92 | 93 | if __name__ == "__main__": 94 | Master().execute() 95 | -------------------------------------------------------------------------------- /package/scripts/params.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/config python 2 | from resource_management import * 3 | from resource_management.libraries.functions.default import default 4 | from resource_management.libraries.functions.version import compare_versions, format_hdp_stack_version 5 | from resource_management.libraries.functions.format import format 6 | 7 | import commands 8 | import os.path 9 | 10 | # config object that holds the configurations declared in the -config.xml file 11 | config = Script.get_config() 12 | tmp_dir = Script.get_tmp_dir() 13 | 14 | # identify archive file 15 | alluxio_archive_file = config['configurations']['alluxio-env']['alluxio.archive.file'] 16 | 17 | # alluxio master address 18 | alluxio_master = config['clusterHostInfo']['alluxio_master_hosts'] 19 | 20 | # alluxio underfs address 21 | underfs_addr = config['configurations']['alluxio-env']['alluxio.underfs.address'] 22 | 23 | # alluxio worker memory alotment 24 | worker_mem = config['configurations']['alluxio-env']['alluxio.worker.memory'] 25 | 26 | # Find current stack and version to push agent files to 27 | stack_name = default("/hostLevelParams/stack_name", None) 28 | stack_version = format_hdp_stack_version(default("/commandParams/version", None)) 29 | 30 | # hadoop params 31 | namenode_address = None 32 | if 'dfs.namenode.rpc-address' in config['configurations']['hdfs-site']: 33 | namenode_rpcaddress = config['configurations']['hdfs-site']['dfs.namenode.rpc-address'] 34 | namenode_address = format("hdfs://{namenode_rpcaddress}") 35 | else: 36 | namenode_address = config['configurations']['core-site']['fs.defaultFS'] 37 | 38 | 39 | 40 | # Set install dir 41 | cmd = "/usr/bin/hdp-select versions" 42 | usr_base = "/usr/hdp/" 43 | base_dir = usr_base + commands.getoutput(cmd) + "/alluxio/" 44 | 45 | # Alluxio archive on agent nodes 46 | alluxio_package_dir = "/var/lib/ambari-agent/cache/stacks/" + stack_name + "/" + stack_version[:3] + "/services/ALLUXIO/package/" 47 | 48 | # alluxio log dir 49 | log_dir = config['configurations']['alluxio-env']['alluxio.log.dir'] 50 | 51 | # alluxio log dir 52 | pid_dir = config['configurations']['alluxio-env']['alluxio.pid.dir'] 53 | 54 | -------------------------------------------------------------------------------- /package/scripts/service_check.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from resource_management import * 3 | import subprocess 4 | 5 | class AlluxioServiceCheck(Script): 6 | # Service check for Alluxio service 7 | def service_check(self, env): 8 | import params 9 | 10 | env.set_params(params) 11 | target_host = format("{alluxio_master}") 12 | print ('Service check host is: ' + target_host) 13 | full_command = [ "ssh", target_host, params.base_dir + "/bin/alluxio", "runTest", "Basic", "CACHE", "CACHE_THROUGH" ] 14 | proc = subprocess.Popen(full_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 15 | (stdout, stderr) = proc.communicate() 16 | response = stdout 17 | 18 | # response is 19 | # Passed the test 20 | # or 21 | # Failed the test! 22 | 23 | if 'Failed' in response: 24 | raise ComponentIsNotRunning() 25 | 26 | if __name__ == "__main__": 27 | AlluxioServiceCheck().execute() 28 | -------------------------------------------------------------------------------- /package/scripts/slave.py: -------------------------------------------------------------------------------- 1 | #import status properties defined in -env.xml file from status_params class 2 | 3 | import sys, os, pwd, signal, time 4 | from resource_management import * 5 | from resource_management.core.base import Fail 6 | from resource_management.core.exceptions import ComponentIsNotRunning 7 | from subprocess import call 8 | import cPickle as pickle 9 | 10 | class Slave(Script): 11 | 12 | #Call setup.sh to install the service 13 | def install(self, env): 14 | import params 15 | 16 | # Install packages listed in metainfo.xml 17 | self.install_packages(env) 18 | 19 | # Create the base_dir/alluxio dir 20 | cmd = '/bin/mkdir' + ' -p ' + params.base_dir 21 | Execute('echo "Running ' + cmd + '"') 22 | Execute(cmd) 23 | 24 | cmd = '/bin/tar' + ' -zxf ' + params.alluxio_package_dir + 'files/' + params.alluxio_archive_file + ' --strip 1 -C ' + params.base_dir 25 | Execute('echo "Running ' + cmd + '"') 26 | Execute(cmd) 27 | 28 | cmd = '/bin/ln' + ' -s ' + params.base_dir + ' ' + params.usr_base + 'current/' 29 | Execute('echo "Running ' + cmd + '"') 30 | 31 | try: 32 | Execute(cmd) 33 | except: 34 | pass 35 | 36 | self.configure(env) 37 | 38 | def configure(self, env): 39 | import params 40 | env.set_params(params) 41 | 42 | alluxio_config_dir = params.base_dir + '/conf/' 43 | alluxio_libexec_dir = params.base_dir + '/libexec/' 44 | 45 | File(format("{alluxio_config_dir}/alluxio-env.sh"), 46 | owner='root', 47 | group='root', 48 | content=Template('alluxio-env.sh.template', conf_dir=alluxio_config_dir) 49 | ) 50 | 51 | #Call start.sh to start the service 52 | def start(self, env): 53 | import params 54 | 55 | #Mount ramfs 56 | cmd = params.base_dir + '/bin/alluxio-start.sh ' + 'worker' + ' Mount' 57 | 58 | Execute('echo "Running cmd: ' + cmd + '"') 59 | Execute(cmd) 60 | 61 | # Create pid file - note check_process_status expects a SINGLE int in the file 62 | cmd = "mkdir -p " + params.pid_dir 63 | Execute(cmd) 64 | cmd = "echo `ps -A -o pid,command | grep -i \"[j]ava\" | grep AlluxioWorker | awk '{print $1}'`> " + params.pid_dir + "/AlluxioWorker.pid" 65 | Execute(cmd) 66 | pid_file = format("{params.pid_dir}/AlluxioWorker.pid") 67 | 68 | 69 | #Called to stop the service using the pidfile 70 | def stop(self, env): 71 | import params 72 | 73 | #execure the startup script 74 | cmd = params.base_dir + '/bin/alluxio-stop.sh' 75 | 76 | Execute('echo "Running cmd: ' + cmd + '"') 77 | Execute(cmd) 78 | 79 | #Check pid file using Ambari check_process_status 80 | def status(self, env): 81 | import params 82 | 83 | pid_file = format("{params.pid_dir}/AlluxioWorker.pid") 84 | check_process_status(pid_file) 85 | 86 | 87 | if __name__ == "__main__": 88 | Slave().execute() 89 | -------------------------------------------------------------------------------- /package/templates/alluxio-env.sh.template: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # This file contains environment variables required to run Alluxio. Copy it as alluxio-env.sh and 4 | # edit that to configure Alluxio for your site. At a minimum, 5 | # the following variables should be set: 6 | # 7 | # - JAVA_HOME, to point to your JAVA installation 8 | # - ALLUXIO_MASTER_ADDRESS, to bind the master to a different IP address or hostname 9 | # - ALLUXIO_UNDERFS_ADDRESS, to set the under filesystem address. 10 | # - ALLUXIO_WORKER_MEMORY_SIZE, to set how much memory to use (e.g. 1000mb, 2gb) per worker 11 | # - ALLUXIO_RAM_FOLDER, to set where worker stores in memory data 12 | 13 | 14 | # Support for Multihomed Networks. 15 | # You can specify a hostname to bind each of services. If a wildcard 16 | # is applied, you should select one of network interfaces and use its hostname to connect the service. 17 | # If no hostname is defined, Alluxio will automatically select an externally visible localhost name. 18 | # The various possibilities shown in the following table: 19 | # 20 | # +--------------------+------------------------+---------------------+ 21 | # | ALLUXIO_*_HOSTNAME | ALLUXIO_*_BIND_HOST | Actual Connect Host | 22 | # +--------------------+------------------------+---------------------+ 23 | # | hostname | hostname | hostname | 24 | # | not defined | hostname | hostname | 25 | # | hostname | 0.0.0.0 or not defined | hostname | 26 | # | not defined | 0.0.0.0 or not defined | localhost | 27 | # +--------------------+------------------------+---------------------+ 28 | # 29 | # Configuration Examples: 30 | # 31 | # Environment variables for service bind 32 | # ALLUXIO_MASTER_BIND_HOST=${ALLUXIO_MASTER_BIND_HOST:-$(hostname -A | cut -d" " -f1)} 33 | # ALLUXIO_MASTER_WEB_BIND_HOST=${ALLUXIO_MASTER_WEB_BIND_HOST:-0.0.0.0} 34 | # ALLUXIO_WORKER_BIND_HOST=${ALLUXIO_WORKER_BIND_HOST:-$(hostname -A | cut -d" " -f1)} 35 | # ALLUXIO_WORKER_DATA_BIND_HOST=${ALLUXIO_WORKER_DATA_BIND_HOST:-$(hostname -A | cut -d" " -f1)} 36 | # ALLUXIO_WORKER_WEB_BIND_HOST=${ALLUXIO_WORKER_WEB_BIND_HOST:-0.0.0.0} 37 | # 38 | # Environment variables for service connection 39 | # ALLUXIO_MASTER_HOSTNAME=${ALLUXIO_MASTER_HOSTNAME:-$(hostname -A | cut -d" " -f1)} 40 | # ALLUXIO_MASTER_WEB_HOSTNAME=${ALLUXIO_MASTER_WEB_HOSTNAME:-$(hostname -A | cut -d" " -f1)} 41 | # ALLUXIO_WORKER_HOSTNAME=${ALLUXIO_WORKER_HOSTNAME:-$(hostname -A | cut -d" " -f1)} 42 | # ALLUXIO_WORKER_DATA_HOSTNAME=${ALLUXIO_WORKER_DATA_HOSTNAME:-$(hostname -A | cut -d" " -f1)} 43 | # ALLUXIO_WORKER_WEB_HOSTNAME=${ALLUXIO_WORKER_WEB_HOSTNAME:-$(hostname -A | cut -d" " -f1)} 44 | 45 | # The following gives an example: 46 | 47 | # Uncomment this section to add a local installation of Hadoop to Alluxio's CLASSPATH. 48 | # The hadoop command must be in the path to automatically populate the Hadoop classpath. 49 | # 50 | # if type "hadoop" > /dev/null 2>&1; then 51 | # export HADOOP_ALLUXIO_CLASSPATH=$(hadoop classpath) 52 | # fi 53 | # export ALLUXIO_CLASSPATH=${ALLUXIO_CLASSPATH:-${HADOOP_ALLUXIO_CLASSPATH}} 54 | 55 | if [[ $(uname -s) == Darwin ]]; then 56 | # Assuming Mac OS X 57 | export JAVA_HOME=${JAVA_HOME:-$(/usr/libexec/java_home)} 58 | export ALLUXIO_RAM_FOLDER=/Volumes/ramdisk 59 | export ALLUXIO_JAVA_OPTS="-Djava.security.krb5.realm= -Djava.security.krb5.kdc=" 60 | else 61 | # Assuming Linux 62 | if [[ -z "$JAVA_HOME" ]]; then 63 | if [ -d /usr/lib/jvm/java-7-oracle ]; then 64 | export JAVA_HOME=/usr/lib/jvm/java-7-oracle 65 | else 66 | # openjdk will set this 67 | if [[ -d /usr/lib/jvm/jre-1.7.0 ]]; then 68 | export JAVA_HOME=/usr/lib/jvm/jre-1.7.0 69 | fi 70 | fi 71 | fi 72 | if [[ -z "${ALLUXIO_RAM_FOLDER}" ]]; then 73 | export ALLUXIO_RAM_FOLDER="/mnt/ramdisk" 74 | fi 75 | fi 76 | 77 | if [[ -z "${JAVA_HOME}" ]]; then 78 | export JAVA_HOME="$(dirname $(which java))/.." 79 | fi 80 | 81 | export JAVA="${JAVA_HOME}/bin/java" 82 | export ALLUXIO_MASTER_ADDRESS=${ALLUXIO_MASTER_ADDRESS:-localhost} 83 | export ALLUXIO_UNDERFS_ADDRESS=${ALLUXIO_UNDERFS_ADDRESS:-${ALLUXIO_HOME}/underFSStorage} 84 | #export ALLUXIO_UNDERFS_ADDRESS=${ALLUXIO_UNDERFS_ADDRESS:-hdfs://localhost:9000/alluxio} 85 | export ALLUXIO_WORKER_MEMORY_SIZE=${ALLUXIO_WORKER_MEMORY_SIZE:-1GB} 86 | 87 | export ALLUXIO_SSH_FOREGROUND=${ALLUXIO_SSH_FOREGROUND:-"yes"} 88 | export ALLUXIO_WORKER_SLEEP=${ALLUXIO_WORKER_SLEEP:-"0.02"} 89 | 90 | # Prepend Alluxio classes before classes specified by ALLUXIO_CLASSPATH 91 | # in the Java classpath. May be necessary if there are jar conflicts 92 | #export ALLUXIO_PREPEND_ALLUXIO_CLASSES=${ALLUXIO_PREPEND_ALLUXIO_CLASSES:-"yes"} 93 | 94 | # Where log files are stored. $ALLUXIO_HOME/logs by default. 95 | #export ALLUXIO_LOGS_DIR=${ALLUXIO_LOGS_DIR:-${ALLUXIO_HOME}/logs} 96 | 97 | CONF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 98 | 99 | export ALLUXIO_JAVA_OPTS+=" 100 | -Dlog4j.configuration=file:${CONF_DIR}/log4j.properties 101 | -Dalluxio.worker.tieredstore.levels=1 102 | -Dalluxio.worker.tieredstore.level0.alias=MEM 103 | -Dalluxio.worker.tieredstore.level0.dirs.path=${ALLUXIO_RAM_FOLDER} 104 | -Dalluxio.worker.tieredstore.level0.dirs.quota=${ALLUXIO_WORKER_MEMORY_SIZE} 105 | -Dalluxio.underfs.address=${ALLUXIO_UNDERFS_ADDRESS} 106 | -Dalluxio.worker.memory.size=${ALLUXIO_WORKER_MEMORY_SIZE} 107 | -Dalluxio.master.hostname=${ALLUXIO_MASTER_ADDRESS} 108 | -Dorg.apache.jasper.compiler.disablejsr199=true 109 | -Djava.net.preferIPv4Stack=true 110 | " 111 | 112 | # Master specific parameters. Default to ALLUXIO_JAVA_OPTS. 113 | export ALLUXIO_MASTER_JAVA_OPTS="${ALLUXIO_JAVA_OPTS}" 114 | 115 | # Worker specific parameters that will be shared to all workers. Default to ALLUXIO_JAVA_OPTS. 116 | export ALLUXIO_WORKER_JAVA_OPTS="${ALLUXIO_JAVA_OPTS}" 117 | --------------------------------------------------------------------------------