CentOs集群搭建

CentOs集群

虚拟机安装linux
1. 启动virtualbox
2. 点击新建,新建名称eshop-cache01, eshop-cache02, eshop-cache03
3. 选择linux,redhat32bit
4. 选择文件目录,下一步创建完成
5. 配置虚拟机网卡设置桥接
6. 点击启动,选择系统

Centos环境配置
1. 配置网络
[root@eshop-cache01~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
Type=Ethernet
ONBOOT=yes
BOOTPROTO=dbcp
[root@eshop-cache01 ~]# service network restart
[root@eshop-cache01 ~]# ifconfig
[root@eshop-cache01 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
Type=Ethernet
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.100.xxxx
NETMASK=255.255.255.0
GATEWAY=192.168.100.1
[root@eshop-cache01 ~]# service network restart
[root@eshop-cache01 ~]# vi /etc/hosts
192.168.100.212 eshop-cache01
2. 防火墙关闭
[root@eshop-cache01 local]# service iptables stop
[root@eshop-cache01 local]# service ip6tables stop
[root@eshop-cache01 local]# chkconfig iptables off
[root@eshop-cache01 local]# chkconfig ip6tables off
[root@eshop-cache01 local]# vi /etc/selinux/config
SELINUX=disabled
3. 配置yum
[root@eshop-cache01 local]# yum clean all
[root@eshop-cache01 local]# yum makecache
[root@eshop-cache01 local]# yum install -y wget

Java环境的安装
1. Jdk的安装
[root@eshop-cache01 local] rpm –ivh jdk-7u65-linux-i586.rpm
2. 环境变量的配置
[root@eshop-cache01 local] vi ~/.bashrc
export JAVA_HOME=/usr/java/latest
export PATH= PATH: JAVA_HOME/bin
//source命令通常用于重新执行刚修改的初始化文件,使之立即生效,而不必注销并重新登录。
[root@eshop-cache01 local]# source ~/.bashrc
[root@eshop-cache01 local]# java -version
java version “1.7.0_65”
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) Client VM (build 24.65-b04, mixed mode, sharing

perl的安装
1. perl的安装(lua依赖)
[root@eshop-cache01 local]# wget http://www.cpan.org/src/5.0/perl-5.16.1.tar.gz
[root@eshop-cache01 local]# tar -zxvf perl-5.16.1.tar.gz
[root@eshop-cache01 local]# cd perl-5.16.1/
[root@eshop-cache01 perl-5.16.1]# cd ..
[root@eshop-cache01 perl-5.16.1]# yum install –y gcc

[root@eshop-cache01 local]# yum install -y build-essential
[root@eshop-cache01 perl-5.16.1]# ./Configure -des -Dprefix=/usr/local/perl

[root@eshop-cache01 perl-5.16.1]# make && make test && make install
[root@eshop-cache01 local]# perl –v
配置集群
1. 再安装3台一模一样的环境的linux环境
2. 在4台机器中hosts文件里,配置hostname和ip的对应关系
192.168.100.212 eshop-cache01
192.168.100.139 eshop-cache02
192.168.100.141 eshop-cache03
192.168.100.142 eshop-cache04
3. 配置4台centos互相免密通信
a. 首先在四台机器上配置对本机的ssh免密码登录
ssh –keygen –t rsa
生成本机的公钥,过程中不断回车,默认在/root/.ssh下
[root@eshop-cache01 ~]# cd /root/.ssh
[root@eshop-cache01 .ssh]# cp id_rsa.pub authorized_keys
[root@eshop-cache01 .ssh]# ssh eshop-cache01 //免密连接
b. 配置四台Linux互相免密登陆
[root@eshop-cache01 ~]# ssh-copy-id -i eshop-cache02
[root@eshop-cache01 ~]# ssh-copy-id -i eshop-cache03
c.依次类推

你可能感兴趣的:(Linux)