美文网首页DevOps
corosync集群配置详解--手动构建集群

corosync集群配置详解--手动构建集群

作者: 4e8ea348373f | 来源:发表于2018-04-18 17:46 被阅读4次

一、安装prcemaker和corosync 本次实验使用node[3-4]

[root@node3 ~]# yum install -y pcs pacemaker corosync
[root@node3 ~]# cd /etc/corosync/
[root@node3 corosync]# ll
总用量 12
-rw-r--r-- 1 root root 2881 9月   7 2017 corosync.conf.example
-rw-r--r-- 1 root root  767 9月   7 2017 corosync.conf.example.udpu
-rw-r--r-- 1 root root 3278 9月   7 2017 corosync.xml.example
drwxr-xr-x 2 root root    6 9月   7 2017 uidgid.d
[root@node3 corosync]# cp corosync.conf.example corosync.conf
[root@node3 corosync]# vim corosync.conf

二、修改配置文件 本次消息传递使用组播方式

# Please read the corosync.conf.5 manual page
totem {
        version: 2

        # crypto_cipher and crypto_hash: Used for mutual node authentication.
        # If you choose to enable this, then do remember to create a shared
        # secret with "corosync-keygen".
        # enabling crypto_cipher, requires also enabling of crypto_hash.
        crypto_cipher: aes128
        crypto_hash: sha1
        secauth: on

        # interface: define at least one interface to communicate
        # over. If you define more than one interface stanza, you must
        # also set rrp_mode.
        interface {
                # Rings must be consecutively numbered, starting at 0.
                #环0  服务器有多个网卡,表示第一个网卡,默认不改
                ringnumber: 0
                # This is normally the *network* address of the
                # interface to bind to. This ensures that you can use
                # identical instances of this configuration file
                # across all your cluster nodes, without having to
                # modify this option
                #修改实际的网络地址
                bindnetaddr: 192.168.66.0
                # However, if you have multiple physical network
                # interfaces configured for the same subnet, then the
                # network address alone is not sufficient to identify
                # the interface Corosync should bind to. In that case,
                # configure the *host* address of the interface
                # instead:
                # bindnetaddr: 192.168.1.1
                # When selecting a multicast address, consider RFC
                # 2365 (which, among other things, specifies that
                # 239.255.x.x addresses are left to the discretion of
                # the network administrator). Do not reuse multicast
                # addresses across multiple Corosync clusters sharing
                # the same network.
                mcastaddr: 239.255.1.31
                # Corosync uses the port you specify here for UDP
                # messaging, and also the immediately preceding
                # port. Thus if you set this to 5405, Corosync sends
                # messages over UDP ports 5405 and 5404.
                mcastport: 5405
                # Time-to-live for cluster communication packets. The
                # number of hops (routers) that this ring will allow
                # itself to pass. Note that multicast routing must be
                # specifically enabled on most network routers.
                ttl: 1
        }
}

logging {
        # Log the source file and line where messages are being
        # generated. When in doubt, leave off. Potentially useful for
        # debugging.
        fileline: off
        # Log to standard error. When in doubt, set to no. Useful when
        # running in the foreground (when invoking "corosync -f")
        to_stderr: no
        # Log to a log file. When set to "no", the "logfile" option
        # must not be set.
        to_logfile: yes
        logfile: /var/log/cluster/corosync.log
        # Log to the system log daemon. When in doubt, set to yes.
        #减轻性能
        to_syslog: no
        # Log debug messages (very verbose). When in doubt, leave off.
        debug: off
        # Log messages with time stamps. When in doubt, set to on
        # (unless you are only logging to syslog, where double
        # timestamps can be annoying).
        #获取时间戳,需要发起系统调用,这里关闭
        timestamp: off
        logger_subsys {
                subsys: QUORUM
                debug: off
        }
}

quorum {
        # Enable and configure quorum subsystem (default: off)
        # see also corosync.conf.5 and votequorum.5
        #provider: corosync_votequorum
}
                                                                      

三、生成认证文件

[root@node3 corosync]# corosync-keygen 
Corosync Cluster Engine Authentication key generator.
Gathering 1024 bits for key from /dev/random.
Press keys on your keyboard to generate entropy.
Press keys on your keyboard to generate entropy (bits = 920).
Press keys on your keyboard to generate entropy (bits = 1000).
Writing corosync key to /etc/corosync/authkey.
[root@node3 corosync]# ll
总用量 20
-r-------- 1 root root  128 4月  18 17:16 authkey
-rw-r--r-- 1 root root 2897 4月  18 17:16 corosync.conf
-rw-r--r-- 1 root root 2881 9月   7 2017 corosync.conf.example
-rw-r--r-- 1 root root  767 9月   7 2017 corosync.conf.example.udpu
-rw-r--r-- 1 root root 3278 9月   7 2017 corosync.xml.example
drwxr-xr-x 2 root root    6 9月   7 2017 uidgid.d

四、启动corosync

root@node3 corosync]# systemctl start corosync    

ps:此次启动会失败,因为corosync启动需要3个节点,现在我去准备第三个节点node2 并且要在配置里加入节点

···················未完待续··················

相关文章

网友评论

    本文标题:corosync集群配置详解--手动构建集群

    本文链接:https://www.haomeiwen.com/subject/pcxbkftx.html