pcs研究


#安装软件
[root@master data]# dnf install pacemaker pcs psmisc policycoreutils-python -y

#启动pcsd服务
[root@master data]# systemctl start pcsd.service
[root@master data]# systemctl enable pcsd.service
Created symlink /etc/systemd/system/multi-user.target.wants/pcsd.service → /usr/lib/systemd/system/pcervice.


#设转密码为root,用户为hacluster (备注:两个节点都要操作)
[root@master yum.repos.d]# echo root | passwd --stdin hacluster

[root@master yum.repos.d]# pcs cluster auth master backup
Username: hacluster
Password: root
backup: Authorized
master: Authorized

#设置集群
[root@master yum.repos.d]# pcs cluster setup --name mycluster master backup --force
Destroying cluster on nodes: master, backup...
backup: Stopping Cluster (pacemaker)...
master: Stopping Cluster (pacemaker)...
backup: Successfully destroyed cluster
master: Successfully destroyed cluster

Sending 'pacemaker_remote authkey' to 'backup', 'master'
master: successful distribution of the file 'pacemaker_remote authkey'
backup: successful distribution of the file 'pacemaker_remote authkey'
Sending cluster config files to the nodes...
master: Succeeded
backup: Succeeded

Synchronizing pcsd certificates on nodes master, backup...
backup: Success
master: Success
Restarting pcsd on the nodes in order to reload the certificates...
backup: Success
master: Success


#修改配置文件 (两个节点相同配置)
[root@master data]# cd /etc/corosync/
[root@master corosync]# cp corosync.conf.example corosync.conf
[root@master corosync]# vi corosync.conf
# Please read the corosync.conf.5 manual page
compatibility: whitetank
totem {
version: 2
secauth: on
threads: 0
interface {
ringnumber: 0
bindnetaddr: 10.0.0.0
mcastaddr: 226.94.8.8
mcastport: 5405
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
name: pacemaker
}
aisexec {
user: root
group: root
}


#复制文件
[root@master corosync]# scp corosync.conf root@backup:/etc/corosync/

#启动集群
[root@master corosync]# pcs cluster start --all
backup: Starting Cluster...
master: Starting Cluster...
[root@master corosync]# ps -ef|grep corosync
root 5365 1 1 17:06 ? 00:00:00 corosync
root 5383 2053 0 17:06 pts/1 00:00:00 grep --color=auto corosync
[root@master corosync]# ps -ef|grep pacemaker
root 5372 1 0 17:06 ? 00:00:00 /usr/sbin/pacemakerd -f
haclust+ 5373 5372 0 17:06 ? 00:00:00 /usr/libexec/pacemaker/cib
root 5374 5372 0 17:06 ? 00:00:00 /usr/libexec/pacemaker/stonithd
root 5375 5372 0 17:06 ? 00:00:00 /usr/libexec/pacemaker/lrmd
haclust+ 5376 5372 0 17:06 ? 00:00:00 /usr/libexec/pacemaker/attrd
haclust+ 5377 5372 0 17:06 ? 00:00:00 /usr/libexec/pacemaker/pengine
haclust+ 5378 5372 0 17:06 ? 00:00:00 /usr/libexec/pacemaker/crmd
root 5409 2053 0 17:06 pts/1 00:00:00 grep --color=auto pacemaker

#查看集群状态(显示为no faults就是ok)
#master
[root@master corosync]# corosync-cfgtool -s
Printing ring status.
Local node ID 1
RING ID 0
id = 10.0.100.166
status = ring 0 active with no faults

#backup
[root@master corosync]# ssh backup corosync-cfgtool -s
Printing ring status.
Local node ID 2
RING ID 0
id = 10.0.100.167
status = ring 0 active with no faults

#可以查看集群是否有错:
[root@master corosync]# crm_verify -L -V
error: unpack_resources: Resource start-up disabled since no STONITH resources have been defined
error: unpack_resources: Either configure some or disable STONITH with the stonith-enabled option
error: unpack_resources: NOTE: Clusters with shared data need STONITH to ensure data integrity
Errors found during check: config not valid
##因为我们没有配置STONITH设备,所以我们下面要关闭

#仅需master节点操作
[root@master corosync]# pcs property set stonith-enabled=false
[root@master corosync]# crm_verify -L -V
[root@master corosync]# pcs property list
Cluster Properties:
cluster-infrastructure: corosync
cluster-name: mycluster
dc-version: 1.1.16-1.fc25-94ff4df
have-watchdog: false
stonith-enabled: false

 

posted @ 2018-04-28 17:31  努力哥  阅读(943)  评论(0)    收藏  举报