Asterisk Cluster on CentOS: Difference between revisions
From KlavoWiki
Jump to navigationJump to search
m David moved page Asterisk Cluster to Asterisk Cluster on CentOS without leaving a redirect |
|||
(8 intermediate revisions by the same user not shown) | |||
Line 39: | Line 39: | ||
The first command will use the username and password of the user account hacluster as created above. | The first command will use the username and password of the user account hacluster as created above. | ||
<pre> | <pre> | ||
pcs cluster auth srv1. | pcs cluster auth srv1.myserver.com srv2.myserver.com | ||
pcs cluster setup --name pbx-cluster srv1. | pcs cluster setup --name pbx-cluster srv1.myserver.com srv2.myserver.com | ||
pcs cluster start --all | pcs cluster start --all | ||
</pre> | </pre> | ||
Line 58: | Line 58: | ||
= Create Asterisk Cluster = | = Create Asterisk Cluster = | ||
<pre> | |||
pcs resource create asterisk ocf:heartbeat:asterisk params user="root" group="root" op monitor timeout="30" | |||
pcs constraint colocation add asterisk with virtual_ip score=INFINITY | |||
pcs constraint order virtual_ip then asterisk | |||
</pre> | |||
If a specific sever is required to be used over another | If a specific sever is required to be used over another | ||
<pre> | <pre> | ||
Line 68: | Line 74: | ||
pcs constraint location asterisk prefers srv2.myserver.com=10 | pcs constraint location asterisk prefers srv2.myserver.com=10 | ||
pcs constraint location asterisk prefers srv3.myserver.com=15 | pcs constraint location asterisk prefers srv3.myserver.com=15 | ||
</pre> | </pre> | ||
Line 93: | Line 92: | ||
<pre> | <pre> | ||
pcs resource move asterisk | pcs resource move asterisk | ||
</pre> | |||
Once the resource has been moved you need to clear the constraint | |||
<pre> | |||
pcs resource clear asterisk | |||
</pre> | |||
== Delete Constraint == | |||
<pre> | |||
pcs constraint list --full | |||
pcs constraint delete <item-ID> | |||
</pre> | </pre> | ||
Line 110: | Line 120: | ||
== Adding/Removing Nodes == | == Adding/Removing Nodes == | ||
<pre> | <pre> | ||
pcs cluster add srv3.myserver.com | pcs cluster auth srv3.myserver.com | ||
pcs cluster node add srv3.myserver.com | |||
</pre> | </pre> | ||
<pre> | <pre> | ||
pcs cluster stop srv2.myserver.com | pcs cluster node stop srv2.myserver.com | ||
pcs cluster remove srv2.myserver.com | pcs cluster node remove srv2.myserver.com | ||
</pre> | </pre> | ||
[[Category : Asterisk]] [[ Category : Linux]] | [[Category : Asterisk]] [[ Category : Linux]] |
Latest revision as of 00:57, 23 June 2017
I have completed the following using CentOS 7.1 and Asterisk 13.4.0
Firewall
Disable firewall or allow the required ports manually. See Firewall_for_Linux
The Cluster
The following needs to be done on both servers.
Install Cluster Apps
yum -y install corosync pcs pacemaker
systemctl enable pcsd systemctl enable corosync systemctl enable pacemaker
systemctl start pcsd
Create Cluster User
Use a 30 plus character random password.
passwd hacluster
Install Asterisk resource agent
wget https://raw.githubusercontent.com/ClusterLabs/resource-agents/master/heartbeat/asterisk -O /usr/lib/ocf/resource.d/heartbeat/asterisk chmod +x /usr/lib/ocf/resource.d/heartbeat/asterisk
Configure Cluster
The following is only required on a single server as it will be replicated across your cluster.
Bind Servers
The first command will use the username and password of the user account hacluster as created above.
pcs cluster auth srv1.myserver.com srv2.myserver.com pcs cluster setup --name pbx-cluster srv1.myserver.com srv2.myserver.com pcs cluster start --all
pcs property set stonith-enabled=false pcs property set no-quorum-policy=ignore
This is creating a clustered IP address of 192.168.25.30
pcs resource create virtual_ip ocf:heartbeat:IPaddr2 ip=192.168.25.30 cidr_netmask=32 op monitor interval=30s
Install Asterisk
Refer to Asterisk_Install if you are not sure how.
Create Asterisk Cluster
pcs resource create asterisk ocf:heartbeat:asterisk params user="root" group="root" op monitor timeout="30" pcs constraint colocation add asterisk with virtual_ip score=INFINITY pcs constraint order virtual_ip then asterisk
If a specific sever is required to be used over another
pcs constraint location asterisk prefers srv1.myserver.com
or if multiple servers
pcs constraint location asterisk prefers srv1.myserver.com=5 pcs constraint location asterisk prefers srv2.myserver.com=10 pcs constraint location asterisk prefers srv3.myserver.com=15
Tools
Status
pcs status pcs status cluster pcs status nodes
pcs constraint
Move
pcs resource move asterisk
Once the resource has been moved you need to clear the constraint
pcs resource clear asterisk
Delete Constraint
pcs constraint list --full pcs constraint delete <item-ID>
Other Details
corosync-cmapctl | grep members pcs status corosync pcs property
Stop/Start a Single Node
pcs cluster stop srv2.myserver.com pcs cluster start srv2.myserver.com
Adding/Removing Nodes
pcs cluster auth srv3.myserver.com pcs cluster node add srv3.myserver.com
pcs cluster node stop srv2.myserver.com pcs cluster node remove srv2.myserver.com