我正在尝试使用VB和Vagrant设置一个hadoop集群。 我可以加载主从虚拟机,下载hadoop并解压缩内部。 我的问题是,当我尝试添加导出命令来设置hadoop变量时,它似乎不起作用...... 这是我的流浪文件:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.define "nodeA" do |nodeA|
nodeA.vm.box = "ubuntu/trusty64"
nodeA.vm.network "forwarded_port", guest: 8088, host: 8088
nodeA.vm.provision "shell", inline: <<-SHELL
# !!! YOU NEED TO REPLACE HERE CORRECT IP ADDRESS !!!
sudo echo "62.04.97.01 slave" >> /etc/hosts
# Update VM to the latest binaries from distribution
# package.
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install -y vim telnet wget curl htop nmon
# Installing and configuring java.
cp /vagrant/install_java.sh .
./install_java.sh
# Passwordless ssh communication between two virtual nodes.
su vagrant -c "ssh-keygen -t rsa -P '' -f /home/vagrant/.ssh/id_rsa"
mkdir -p /vagrant/files/ssh/
cp /home/vagrant/.ssh/id_rsa.pub /vagrant/files/ssh/master.pub
cp /vagrant/after_startup.sh /home/vagrant/.
# TODO: In order to complete Hadoop configuration you have to
# provide here set of Linux shell commands which completes
# instalation and configuration of Hadoop cluster.
cd /home/vagrant/
wget http://apache.mivzakim.net/hadoop/common/hadoop-2.7.2/hadoop-2.7.2.tar.gz
tar xzf hadoop-2.7.2.tar.gz
cp /vagrant/mysource.sh .
source ./mysource.sh
#hadoop version
#$ hadoop jar $HADOOP_HOME/share/hadoop/mapreduce/hadoop-mapreduceexamples-2.2.0.jar
#HADOOP VARIABLES START
export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_77
export HADOOP_HOME=/home/vagrant/hadoop-2.7.2
export HADOOP_INSTALL=$HADOOP_HOME
export PATH=$PATH:$HADOOP_INSTALL/bin
export PATH=$PATH:$HADOOP_INSTALL/sbin
export HADOOP_MAPRED_HOME=$HADOOP_INSTALL
export HADOOP_COMMON_HOME=$HADOOP_INSTALL
export HADOOP_HDFS_HOME=$HADOOP_INSTALL
export YARN_HOME=$HADOOP_INSTALL
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_INSTALL/lib/native
export HADOOP_OPTS="-Djava.library.path=$HADOOP_INSTALL/lib"
#HADOOP VARIABLES END
#alias hadoop="/home/vagrant/hadoop-2.7.2/bin/hadoop"
echo 'source /vagrant/mysource.sh' >> ~/.bashrc
echo 'source /vagrant/mysource.sh' >> ~/.profile
source /vagrant/mysource.sh
# !!! Fill your commands here !!!
SHELL
end
config.vm.define "nodeB" do |nodeB|
nodeB.vm.box = "ubuntu/trusty64"
nodeB.vm.network "forwarded_port", guest: 8088, host: 9088
nodeB.vm.provision "shell", inline: <<-SHELL
# !!! YOU NEED TO REPLACE HERE CORRECT IP ADDRESS !!!
sudo echo "62.04.97.02 master" >> /etc/hosts
# Update VM to the latest binaries from distribution
# package.
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install -y vim telnet wget curl htop nmon
# Installing and configuring java.
cp /vagrant/install_java.sh .
./install_java.sh
# Passwordless ssh communication between two virtual nodes.
su vagrant -c "ssh-keygen -t rsa -P '' -f /home/vagrant/.ssh/id_rsa"
mkdir -p /vagrant/files/ssh/
cp /home/vagrant/.ssh/id_rsa.pub /vagrant/files/ssh/slave.pub
cp /vagrant/after_startup.sh /home/vagrant/.
cd /home/vagrant/
wget http://apache.mivzakim.net/hadoop/common/hadoop-2.7.2/hadoop-2.7.2.tar.gz
tar xzf hadoop-2.7.2.tar.gz
#hadoop version
#$ hadoop jar $HADOOP_HOME/share/hadoop/mapreduce/hadoop-mapreduceexamples-2.2.0.jar
cp /vagrant/mysource.sh .
source ./mysource.sh
#HADOOP VARIABLES START
export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_77
export HADOOP_HOME=/home/vagrant/hadoop-2.7.2
export HADOOP_INSTALL=$HADOOP_HOME
export PATH=$PATH:$HADOOP_INSTALL/bin
export PATH=$PATH:$HADOOP_INSTALL/sbin
export HADOOP_MAPRED_HOME=$HADOOP_INSTALL
export HADOOP_COMMON_HOME=$HADOOP_INSTALL
export HADOOP_HDFS_HOME=$HADOOP_INSTALL
export YARN_HOME=$HADOOP_INSTALL
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_INSTALL/lib/native
export HADOOP_OPTS="-Djava.library.path=$HADOOP_INSTALL/lib"
#HADOOP VARIABLES END
#alias hadoop="/home/vagrant/hadoop-2.7.2/bin/hadoop"
echo 'source /vagrant/mysource.sh' >> ~/.bashrc
source /vagrant/mysource.sh
# TODO: In order to complete Hadoop configuration you have to
# provide here set of Linux shell commands which completes
# installation and configuration of Hadoop cluster.
# !!! Fill your commands here !!!
SHELL
end
end
当我跑出去时,除了导出命令之外,它会执行所有操作。
我也尝试在脚本中发布导出命令,将其复制到内部并使用source命令运行,尝试使用sudo和sudo -s,但是没有任何工作......