4. Linux 集群安装
1. 配置yum
yum clean all
yum makecache
yum install wget
2.安装JDK
(1) 将jdk-7u60-linux-i586.rpm通过WinSCP上传到虚拟机中
(2) 安装JDK:rpm -ivh jdk-7u65-linux-i586.rpm
(3) 配置jdk相关的环境变量
vi .bashrc export JAVA_HOME=/usr/java/latest export PATH=$PATH:$JAVA_HOME/bin source .bashrc
(4) 测试jdk安装是否成功:java -version
3.安装Perl
yum install -y gcc wget http://www.cpan.org/src/5.0/perl-5.16.1.tar.gz tar -xzf perl-5.16.1.tar.gz cd perl-5.16.1 ./Configure -des -Dprefix=/usr/local/perl make && make test && make install perl -v
4.在4个虚拟机中安装CentOS集群
(1)按照上述步骤,再安装三台一模一样环境的linux机器
(2)另外三台机器的hostname分别设置为eshop-cache02,eshop-cache03,eshop-cache04
(3)安装好之后,在每台机器的hosts文件里面,配置好所有的机器的ip地址到hostname的映射关系
比如说,在eshop-cache01的hosts里面
192.168.0.150 eshop-cache01 192.168.0.152 eshop-cache03 192.168.0.151 eshop-cache02 192.168.0.153 eshop-cache04
5.配置4台CentOS为ssh免密码互相通信
(1)首先在三台机器上配置对本机的ssh免密码登录
ssh-keygen -t rsa
生成本机的公钥,过程中不断敲回车即可,ssh-keygen命令默认会将公钥放在/root/.ssh目录下
cd /root/.ssh
cp id_rsa.pub authorized_keys
将公钥复制为authorized_keys文件,此时使用ssh连接本机就不需要输入密码了
测试:ssh eshop-cache01,ssh eshop-cache03,ssh eshop-cache02,ssh eshop-cache04
成功
(2)接着配置三台机器互相之间的ssh免密码登录
使用ssh-copy-id -i hostname命令将本机的公钥拷贝到指定机器的authorized_keys文件中
Example
eshop-cache01 机器
ssh-copy-id -i eshop-cache02
ssh-copy-id -i eshop-cache03
ssh-copy-id -i eshop-cache04
eshop-cache02 机器
ssh-copy-id -i eshop-cache01
ssh-copy-id -i eshop-cache03
ssh-copy-id -i eshop-cache04
eshop-cache03 机器
ssh-copy-id -i eshop-cache01
ssh-copy-id -i eshop-cache02
ssh-copy-id -i eshop-cache04
eshop-cache04 机器
ssh-copy-id -i eshop-cache01
ssh-copy-id -i eshop-cache02
ssh-copy-id -i eshop-cache03
测试:
eshop-cache04 机器
ssh eshop-cache01 ,免密码直接登录
以上的步骤,还有一些简单的办法。借助SCP 远程拷贝命令
例如:
SCP authorized_keys eshop-cache02:/root/.ssh
SCP authorized_keys eshop-cache03:/root/.ssh
SCP authorized_keys eshop-cache04:/root/.ssh