1. 程式人生 > >CentOs叢集搭建

CentOs叢集搭建

CentOs叢集

虛擬機器安裝linux
1. 啟動virtualbox
2. 點選新建,新建名稱eshop-cache01, eshop-cache02, eshop-cache03
3. 選擇linux,redhat32bit
4. 選擇檔案目錄,下一步建立完成
5. 配置虛擬機器網絡卡設定橋接
6. 點選啟動,選擇系統

Centos環境配置
1. 配置網路
[[email protected]~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
Type=Ethernet
ONBOOT=yes
BOOTPROTO=dbcp
[

[email protected] ~]# service network restart
[[email protected] ~]# ifconfig
[[email protected] ~]# 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
[[email protected]
~]# service network restart
[[email protected] ~]# vi /etc/hosts
192.168.100.212 eshop-cache01
2. 防火牆關閉
[[email protected] local]# service iptables stop
[[email protected] local]# service ip6tables stop
[[email protected] local]# chkconfig iptables off
[[email protected] local]# chkconfig ip6tables off
[
[email protected]
local]# vi /etc/selinux/config
SELINUX=disabled
3. 配置yum
[[email protected]che01 local]# yum clean all
[[email protected] local]# yum makecache
[[email protected] local]# yum install -y wget

Java環境的安裝
1. Jdk的安裝
[[email protected] local] rpm –ivh jdk-7u65-linux-i586.rpm
2. 環境變數的配置
[[email protected] local] vi ~/.bashrc
export JAVA_HOME=/usr/java/latest
export PATH=PATH:JAVA_HOME/bin
//source命令通常用於重新執行剛修改的初始化檔案,使之立即生效,而不必登出並重新登入。
[[email protected] local]# source ~/.bashrc
[[email protected] 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依賴)
[[email protected] local]# wget http://www.cpan.org/src/5.0/perl-5.16.1.tar.gz
[[email protected] local]# tar -zxvf perl-5.16.1.tar.gz
[[email protected] local]# cd perl-5.16.1/
[[email protected] perl-5.16.1]# cd ..
[[email protected] perl-5.16.1]# yum install –y gcc

[[email protected] local]# yum install -y build-essential
[[email protected] perl-5.16.1]# ./Configure -des -Dprefix=/usr/local/perl

[[email protected] perl-5.16.1]# make && make test && make install
[[email protected] 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下
[[email protected] ~]# cd /root/.ssh
[[email protected] .ssh]# cp id_rsa.pub authorized_keys
[[email protected] .ssh]# ssh eshop-cache01 //免密連線
b. 配置四臺Linux互相免密登陸
[[email protected] ~]# ssh-copy-id -i eshop-cache02
[[email protected] ~]# ssh-copy-id -i eshop-cache03
c.依次類推