Red Hat Training
A Red Hat training course is available for Red Hat Enterprise Linux
7.5.2. 在集群中添加集群服务
要在集群中添加集群服务,请按照本小节中的步骤执行。
- 在集群的任意节点中打开
/etc/cluster/cluster.conf。 - 为每个服务在
rm元素中添加service部分。例如:<rm> <service autostart="1" domain="" exclusive="0" name="" recovery="restart"> </service> </rm> - 在
service元素中配置以下参数(属性):autostart— 指定是否在集群启动时自动启动该服务。使用‘1’启用,‘0’禁用,默认为启用。domain— 指定故障切换域(如果需要)。exclusive— 指定该服务只在没有其它服务运行的节点中的策略。recovery— 为该服务指定恢复策略。选项为 relocate、restart、disable 或者 restart-disable 该服务。
- 根据您要使用的资源类型使用全局或者具体服务资源部署该服务。例如:这里是使用全局资源的 Apache 服务:
<rm> <resources> <fs name="web_fs" device="/dev/sdd2" mountpoint="/var/www" fstype="ext3"/> <ip address="127.143.131.100" monitor_link="yes" sleeptime="10"/> <apache config_file="conf/httpd.conf" name="example_server" server_root="/etc/httpd" shutdown_wait="0"/> </resources> <service autostart="1" domain="example_pri" exclusive="0" name="example_apache" recovery="relocate"> <fs ref="web_fs"/> <ip ref="127.143.131.100"/> <apache ref="example_server"/> </service> </rm>例如:这里是具体服务资源使用的 Apache 服务:<rm> <service autostart="0" domain="example_pri" exclusive="0" name="example_apache2" recovery="relocate"> <fs name="web_fs2" device="/dev/sdd3" mountpoint="/var/www2" fstype="ext3"/> <ip address="127.143.131.101" monitor_link="yes" sleeptime="10"/> <apache config_file="conf/httpd.conf" name="example_server2" server_root="/etc/httpd" shutdown_wait="0"/> </service> </rm>例 7.10 “添加了服务的cluster.conf:一个使用全局资源,一个使用具体服务资源” 演示有两个服务的cluster.conf文件示例:example_apache— 这个服务使用全局资源web_fs、127.143.131.100和example_server。example_apache2— 这个服务使用具体服务资源web_fs2、127.143.131.101和example_server2。
- 增加
config_version属性参数即可更新该参数(例如:从config_version="2"改为config_version="3">)。 - 保存
/etc/cluster/cluster.conf。 - (可选),运行
ccs_config_validate命令,确认根据集群方案(cluster.rng)更新的文件。例如:[root@example-01 ~]#
ccs_config_validateConfiguration validates - 运行
cman_tool version -r命令在其他集群节点中推广该配置。 - 确认推广了更新的文件。
- 执行 第 7.8 节 “验证配置”。
例 7.10. 添加了服务的 cluster.conf:一个使用全局资源,一个使用具体服务资源
<cluster name="mycluster" config_version="3">
<clusternodes>
<clusternode name="node-01.example.com" nodeid="1">
<fence>
<method name="APC">
<device name="apc" port="1"/>
</method>
</fence>
</clusternode>
<clusternode name="node-02.example.com" nodeid="2">
<fence>
<method name="APC">
<device name="apc" port="2"/>
</method>
</fence>
</clusternode>
<clusternode name="node-03.example.com" nodeid="3">
<fence>
<method name="APC">
<device name="apc" port="3"/>
</method>
</fence>
</clusternode>
</clusternodes>
<fencedevices>
<fencedevice agent="fence_apc" ipaddr="apc_ip_example" login="login_example" name="apc" passwd="password_example"/>
</fencedevices>
<rm>
<failoverdomains>
<failoverdomain name="example_pri" nofailback="0" ordered="1" restricted="0">
<failoverdomainnode name="node-01.example.com" priority="1"/>
<failoverdomainnode name="node-02.example.com" priority="2"/>
<failoverdomainnode name="node-03.example.com" priority="3"/>
</failoverdomain>
</failoverdomains>
<resources>
<fs name="web_fs" device="/dev/sdd2" mountpoint="/var/www" fstype="ext3"/>
<ip address="127.143.131.100" monitor_link="yes" sleeptime="10"/>
<apache config_file="conf/httpd.conf" name="example_server" server_root="/etc/httpd" shutdown_wait="0"/>
</resources>
<service autostart="1" domain="example_pri" exclusive="0" name="example_apache" recovery="relocate">
<fs ref="web_fs"/>
<ip ref="127.143.131.100"/>
<apache ref="example_server"/>
</service>
<service autostart="0" domain="example_pri" exclusive="0" name="example_apache2" recovery="relocate">
<fs name="web_fs2" device="/dev/sdd3" mountpoint="/var/www2" fstype="ext3"/>
<ip address="127.143.131.101" monitor_link="yes" sleeptime="10"/>
<apache config_file="conf/httpd.conf" name="example_server2" server_root="/etc/httpd" shutdown_wait="0"/>
</service>
</rm>
</cluster>