环境
virtualbox下host-only模式的4台Fedora-20机器,均为64位机器
192.168.56.102 Fedora01
192.168.56.103 Fedora02
192.168.56.104 Fedora03
192.168.56.105 Fedora04
把下面脚本放在Fedora01机器上,用于同步目录和文件到其他机器,下面的同步操作均在Fedora01上操作
#!/bin/bash declare -a slaves function abs_path() { if [ $# != 1 ]; then echo "" else echo $(cd $(dirname $1); pwd) fi } function init_slaves() { for ((i=2;i<=4;i++)); do slaves[$(($i-01))]="Fedora0$i" done } function usage() { echo "Usage: $0 file1 [file1] [...]" } function check_input() { for i in $*; do if ! [ -a $i ]; then usage echo -e "\033[31m$i does not exist, nothing syned\033[0m" return 1 fi done return 0 } if [ $# -lt 1 ]; then usage exit 1 fi if ! check_input $*; then exit 1 fi init_slaves for i in ${slaves[*]}; do for j in $*; do echo -e "\033[32mrsync -Pav $j $i:$(abs_path $j)/\033[0m" if ! rsync -Pav $j $i:$(abs_path $j)/;then echo -e "\033[31msync failed\033[0m" exit 1 fi done done
配置/etc/hosts
同步到其他机器:./sync-cluster.sh /etc/hosts
配置ssh无密码访问
1. 在四台机器上分别root登录,执行ssh-keygen,一路回车;
2. 在机器Fedora01执行下面的操作
2.1 在~/.ssh/目录下新建authorized_keys文件,把四台机器下的文件~/.ssh/id_rsa.pub文件内容加入到该文件;
2.2从Fedora01 登录四台机器,这个过程会往~/.ssh/known_hosts添加内容;
2.3 同步~/.ssh/authorized_keys和~/.ssh/known_hosts到其他机器:./sync-cluster.sh ~/.ssh/authorized_keys ~/.ssh/known_hosts
jdk安装
1. 从http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html下载tar.gz格式的,32位和64位机器对应下载,这里下的是64位的
wget http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jdk-7u51-linux-x64.tar.gz
2. 解压到/usr/local
tar -jxvf jdk-7u51-linux-x64.tar.gz -C /usr/local
3. 配置符号链接:cd /usr/local; ln -snf jdk1.7.0_45/ jdk
4. 配置环境变量到~/.bashrc
export JAVA_HOME="/usr/local/jdk"
export PATH="$JAVA_HOME/bin:$PATH"
5. 同步到其他机器: ~/sync-cluster.sh jdk jdk1.7.0_45 ~/.bashrc
scala安装
1. 下载scala-2.9.3,注意spark-0.8.1依赖这个版本的scala,不能用最新的
wget http://www.scala-lang.org/files/archive/scala-2.9.3.tgz
2. 解压到/usr/local
tar -zxvf scala-2.9.3.gz -C /usr/local
3. 符号链接:cd /usr/local; ln -snf scala-2.9.3/ scala
4. 配置环境变量到~/.bashrc
export SCALA_HOME="/usr/local/scala"
export PATH="$SCALA_HOME/bin:$PATH"
5. 同步到其他机器:~/sync-cluster.sh scala scala-2.9.3 ~/.bashrc
6. 测试,先source ~/.bashrc