Fedora 15上做主从、双主模型的集群

Fedora 15上做双主模型的集群

拓扑如下所示:
 
-----------     ----------
|   HA1    |____|  HA2   |
|__________|    |________|

HA1:
IP:192.168.1.78/24
HA2:
IP:192.168.1.151/24
VIP:192.168.1.110


一、配置网络属性
HA1:
#ifconfit eth0 192.168.1.78/24
#route add default gw 192.168.1.1
#hostname node1.linuxidc.com
HA2:
#ifconfig eth0 192.168.1.151/24
#route add default gw 192.168.1.1
#hostname node2.linuxidc.com

 

二、配置主机名及两个之间不实用密码能相互通信
#vim /etc/hosts 添加如下内容
192.168.1.78 node1.linuxidc.com node1
192.168.1.151 node2.linuxidc.com node2
同样在HA2上也添加这些内容
#ping node2|node1能解析出来就OK啦

分别在两个HA上生成一对密钥,如下所示
[root@node1 ~]# ssh-keygen -t rsa  //生成公钥和密钥
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
59:71:5d:4d:4c:6d:71:b1:ec:04:17:26:49:cb:27:a1 root@node1.linuxidc.com
The key's randomart image is:
+--[ RSA 2048]----+
|          . o*.@@|
|           oo.X B|
|          .E + * |
|         o    =  |
|        S      . |
|                 |
|                 |
|                 |
|                 |  //这个图案就是所谓的指纹信息吧,呵呵,RedHat上没有
+-----------------+
[root@node1 ~]# ssh-copy-id -i .ssh/id_rsa.pub root@node2    //拷贝公钥到对方机

器上
The authenticity of host 'node2 (192.168.1.151)' can't be established.
RSA key fingerprint is 77:b6:c6:09:51:f9:f4:70:c1:35:81:47:a5:19:f4:d2.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'node2,192.168.1.151' (RSA) to the list of known

hosts.
root@node2's password:     //输入对方机器的密码
Now try logging into the machine, with "ssh 'root@node2'", and check in:

  ~/.ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.
在HA2上做同上的操作,我就不具体演示了!

 

三、配置yum源,我使用的是163做的镜像源

这上面有对应fedora的yum源配置使用的说明,我就不做详细阐述了
如果你没有DNS解析域名,还要在/etc/hosts文件中手动添加解析奥,我的如下:
66.35.62.166   mirrors.fedoraproject.org
213.129.242.84   mirrors.rpmfusion.org
123.58.173.106  mirrors.163.com
这些对应的域名和IP关系大家都会,就是使用ping可以解析出,不解释!

 

四、安装集群软件
两个节点上都要做的
#yum install corosync pacemaker -y //由于是网络镜像,会比较慢,耐心等会吧!

安装完成之后就是配置了,注意配置的时候选择的端口和地址不能跟已存在的集群冲突,所

以我就做了一下简单的设置
#export ais_port=4000
#export ais_mcast=226.94.1.1

接下来就是配置corosync了:
#cd /etc/corosync/
#cp corosync.conf.example corosync.conf
#vim !$ 把配置改成如下
# Please read the corosync.conf.5 manual page
compatibility: whitetank

totem {
 version: 2
 secauth: on
 threads: 0
 interface {
  ringnumber: 0
  bindnetaddr: 192.168.1.0   //指定集群所在的网段的网络号
  mcastaddr: 226.94.1.1  //组播地址
  mcastport: 4000  //端口号
  ttl: 1
 }
}

logging {
 fileline: off
 to_stderr: no
 to_logfile: yes
 to_syslog: no
 logfile: /var/log/cluster/corosync.log
 debug: off
 timestamp: on
 logger_subsys {
  subsys: AMF
  debug: off
 }
}
amf {
 mode: disabled
}
####以下是添加的内容
service {
 ver: 1    //定义pacemaker的版本,fedora上使用版本1,而在redhat上可以

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/wyyzww.html