[root@rs1 ~]# cp ./anaconda-ks.cfg /mnt/nfs/test.txt
[root@rs2 ~]# showmount -e sto
Export list for sto:
/http *
[root@rs2 ~]# mkdir /mnt/nfs
[root@rs2 ~]# mount sto:/http /mnt/nfs
[root@rs2 ~]# cp ./anaconda-ks.cfg /mnt/nfs/test2.txt
[root@sto http]# ls
test2.txt test.txt
**创建NFS集群**
[root@rs1 ~]# pcs resource create WebFS ocf:heartbeat:Filesystem /
device=’sto:/http’ directory=’/var/www/html’ fstype=’nfs’ /
op monitor interval=20s timeout=40s /
op start timeout=60s op stop timeout=60s
[root@rs1 ~]# pcs resource create WebFS ocf:heartbeat:Filesystem device=’storage:/http’ directory=’/var/www/html’ fstype=’nfs’ op monitor interval=20s timeout=40s > op start timeout=60s op stop timeout=60s
[root@rs1 ~]# pcs status
Cluster name: cluster1
Stack: corosync
Current DC: rs1 (version 1.1.20-5.el7-3c4c782f70) – partition with quorum
Last updated: Sat May 9 02:59:31 2020
Last change: Sat May 9 02:59:22 2020 by root via cibadmin on rs1
2 nodes configured
3 resources configured
Online: [ rs1 rs2 ]
Full list of resources:
VirtualIP (ocf::heartbeat:IPaddr2): Started rs1
WebFS (ocf::heartbeat:Filesystem): Started rs2
Daemon Status:
corosync: active/disabled
pacemaker: active/disabled
pcsd: active/enabled
[root@rs1 ~]# echo NFS > /var/www/html
[root@rs1 ~]# systemctl restart httpd
**创建web集群**
> pcs resource create Wbsite ocf??apache
> httpd="/usr/sbin/httpd" //
> configfile=/etc/httpd/conf/httpd.conf //
> statusurl=“http://localhost/server-status” //
> op monitor interval=1min
**之前碰到的问题是web群集起不来,后来在一篇文章发现要添加httpd="/usr/sbin/httpd" ,也就是httpd命令的位置,这样就可以了**
[root@rs1 html]# pcs status
Cluster name: cluster1
Stack: corosync
Current DC: rs1 (version 1.1.20-5.el7-3c4c782f70) – partition with quorum
Last updated: Sat May 9 03:41:11 2020
Last change: Sat May 9 03:21:45 2020 by root via cibadmin on rs1
2 nodes configured
3 resources configured
Online: [ rs1 rs2 ]
Full list of resources:
VirtualIP (ocf::heartbeat:IPaddr2): Started rs1
WebFS (ocf::heartbeat:Filesystem): Started rs1
Wbsite (ocf::heartbeat:apache): Started rs1
Daemon Status:
corosync: active/disabled
pacemaker: active/disabled
pcsd: active/enabled
**配置组和约束**
通过将资源运行在同一节点上
> /[root@rs1 ~/]# pcs resource group add a VirtualIP WebFS Website
> /[root@rs1 html/]# pcs status Cluster name: cluster1 Stack: corosync
> Current DC: rs1 (version 1.1.20-5.el7-3c4c782f70) - partition with
> quorum Last updated: Sat May 9 03:42:47 2020 Last change: Sat May 9
> 03:42:44 2020 by root via cibadmin on rs1
>
> 2 nodes configured 3 resources configured
>
> Online: /[ rs1 rs2 /]
>
> Full list of resources:
>
> Resource Group: a
> VirtualIP (ocf:??IPaddr2): Started rs1
> WebFS (ocf:??Filesystem): Started rs1
> Wbsite (ocf:??apache): Started rs1
>
> Daemon Status: corosync: active/disabled pacemaker:
> active/disabled pcsd: active/enabled
**通过约束管理资源的启动**
[root@rs1 ~]# pcs constraint order VirtualIP then Website
Adding VirtualIP Wbsite (kind: Mandatory) (Options: first-action=start then-action=start)
[root@rs1 ~]# pcs constraint order WebFS then Website
Adding WebFS Wbsite (kind: Mandatory) (Options: first-action=start then-action=start)
**资源在web1的情况下访问VIP**
# 总结
总体来说,如果你想转行从事程序员的工作,Java开发一定可以作为你的第一选择。但是不管你选择什么编程语言,提升自己的硬件实力才是拿高薪的唯一手段。
如果你以这份学习路线来学习,你会有一个比较系统化的知识网络,也不至于把知识学习得很零散。我个人是完全不建议刚开始就看《Java编程思想》、《Java核心技术》这些书籍,看完你肯定会放弃学习。建议可以看一些视频来学习,当自己能上手再买这些书看又是非常有收获的事了。
**[CodeChina开源项目:【一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频】](https://ali1024.coding.net/public/P7/Java/git)**
![](https://s2.51cto.com/images/20210911/1631299105388519.jpg)
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/149393.html