Pcsd: Unterschied zwischen den Versionen

Aus xinux.net
Zur Navigation springen Zur Suche springen
Zeile 1: Zeile 1:
 
=ubuntu 16.04=
 
=ubuntu 16.04=
 
 
*apt-get update
 
*apt-get update
*apt-get uograde
+
*apt-get upgrade
 
*apt-get install pacemaker corosync pcs
 
*apt-get install pacemaker corosync pcs
 
*gem install orderedhash
 
*gem install orderedhash
 +
 
*sed -i.bak -e "/Host.*=>/s/::/*/" -e "/BindAddress.*=>/s/::/nil/"  /usr/share/pcsd/ssl.rb
 
*sed -i.bak -e "/Host.*=>/s/::/*/" -e "/BindAddress.*=>/s/::/nil/"  /usr/share/pcsd/ssl.rb
  
Zeile 259: Zeile 259:
 
Current DC: francis (version 1.1.14-70404b0) - partition with quorum
 
Current DC: francis (version 1.1.14-70404b0) - partition with quorum
 
2 nodes and 2 resources configured
 
2 nodes and 2 resources configured
 +
201M      0  201M    0% /run/user/0
 +
root@francis:~#
  
 
Online: [ claire francis ]
 
Online: [ claire francis ]
Zeile 333: Zeile 335:
 
=Links=
 
=Links=
 
*http://clusterlabs.org/doc/en-US/Pacemaker/1.1-pcs/html/Clusters_from_Scratch/_configure_corosync.html
 
*http://clusterlabs.org/doc/en-US/Pacemaker/1.1-pcs/html/Clusters_from_Scratch/_configure_corosync.html
 +
 +
=DRBD erstellen=
 +
*apt-get install drbd8-utils
 +
 +
==Die Partionen mit LVM erstellen==

Version vom 26. Oktober 2016, 10:14 Uhr

ubuntu 16.04

  • apt-get update
  • apt-get upgrade
  • apt-get install pacemaker corosync pcs
  • gem install orderedhash
  • sed -i.bak -e "/Host.*=>/s/::/*/" -e "/BindAddress.*=>/s/::/nil/" /usr/share/pcsd/ssl.rb
  • /usr/lib/python2.7/dist-packages/pcs/cluster.py

Zeile 1699

 os.system("find /var/lib -path '/var/lib/lxcfs' -prune -o -name '"+name+"' -exec rm -f \{\} \;") [Unbedingt das Leerzeichen mit kopieren]
                 #os.system("find /var/lib -name '"+name+"' -exec rm -f \{\} \;")
  • mkdir -p 777 /var/log/cluster
  • mkdir /etc/corosync/uidgid.d/
  • systemctl enable pcsd
  • root@adin:~# passwd hacluster
  • root@keks:~# passwd hacluster


root@adin:~# pcs cluster auth adin keks
Username: hacluster
Password: 
keks: Authorized
adin: Authorized
  • root@adin:~# pcs cluster setup --name mycluster adin keks --force
  • root@adin:~# pcs cluster start --all

Die Installation verifizieren

  • root@adin:~# corosync-cfgtool -s
Printing ring status.
Local node ID 1
RING ID 0
	id	= 192.168.50.51
	status	= ring 0 active with no faults
  • root@adin:~# corosync-cmapctl | grep members
runtime.totem.pg.mrp.srp.members.1.config_version (u64) = 0
runtime.totem.pg.mrp.srp.members.1.ip (str) = r(0) ip(192.168.50.51) 
runtime.totem.pg.mrp.srp.members.1.join_count (u32) = 1
runtime.totem.pg.mrp.srp.members.1.status (str) = joined
runtime.totem.pg.mrp.srp.members.2.config_version (u64) = 0
runtime.totem.pg.mrp.srp.members.2.ip (str) = r(0) ip(192.168.50.52) 
runtime.totem.pg.mrp.srp.members.2.join_count (u32) = 1
runtime.totem.pg.mrp.srp.members.2.status (str) = joined

STONEIT deaktivieren

  • pcs property set stonith-enabled=false
  • crm_verify -L

pcs hilfe anzeigen

  • root@adin:~# pcs
Usage: pcs [-f file] [-h] [commands]...
Control and configure pacemaker and corosync.

Options:
    -h, --help  Display usage and exit
    -f file     Perform actions on file instead of active CIB
    --debug     Print all network traffic and external commands run
    --version   Print pcs version information

Commands:
    cluster     Configure cluster options and nodes
    resource    Manage cluster resources
    stonith     Configure fence devices
    constraint  Set resource constraints
    property    Set pacemaker properties
    acl         Set pacemaker access control lists
    status      View cluster status
    config      View and manage cluster configuration
    pcsd        Manage pcs daemon
    node        Manage cluster nodes
  • root@adin:~# pcs status help
Usage: pcs status [commands]...
View current cluster and resource status
Commands:
    [status] [--full | --hide-inactive]
        View all information about the cluster and resources (--full provides
        more details, --hide-inactive hides inactive resources)

    resources
        View current status of cluster resources

    groups
        View currently configured groups and their resources

    cluster
        View current cluster status

    corosync
        View current membership information as seen by corosync

    nodes [corosync|both|config]
        View current status of nodes from pacemaker. If 'corosync' is
        specified, print nodes currently configured in corosync, if 'both'
        is specified, print nodes from both corosync & pacemaker.  If 'config'
        is specified, print nodes from corosync & pacemaker configuration.

    pcsd [<node>] ...
        Show the current status of pcsd on the specified nodes.
        When no nodes are specified, status of all nodes is displayed.

    xml
        View xml version of status (output from crm_mon -r -1 -X)

Eine Ressource (ClusterIP) hinzufügen

  • root@francis:~# pcs resource create ClusterIP ocf:heartbeat:IPaddr2 \
  • > ip=192.168.242.151 cidr_netmask=21 op monitor interval=30s
  • root@francis:~# pcs resource show --full
root@francis:~# pcs resource show --full
 Resource: ClusterIP (class=ocf provider=heartbeat type=IPaddr2)
  Attributes: ip=192.168.242.151 cidr_netmask=21
  Operations: start interval=0s timeout=20s (ClusterIP-start-interval-0s)
              stop interval=0s timeout=20s (ClusterIP-stop-interval-0s)
              monitor interval=30s (ClusterIP-monitor-interval-30s)

Apache2 als Cluster-Service

  • apt-get install apache2
  • vi /var/www/html/index.html
 <html>
 <body>My Test Site - $(hostname)</body>
 </html>
  • vi /etc/apache2/conf-available/status.conf
 <Location /server-status>
    SetHandler server-status
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1
 </Location>
  • cd /etc/apache2/conf-enabled/
  • ln -s ../conf-available/status.conf .
  • pcs resource create WebSite ocf:heartbeat:apache \
  • >configfile=/etc/apache2/apache2.conf \
  • >statusurl="http://localhost/server-status" \
  • >op monitor interval=1min
  • pcs status
Cluster name: underwood
Last updated: Wed Oct 26 11:25:04 2016		Last change: Wed Oct 26 11:23:36 2016 by root via cibadmin on francis
Stack: corosync
Current DC: francis (version 1.1.14-70404b0) - partition with quorum
2 nodes and 2 resources configured

Online: [ claire francis ]

Full list of resources:

 VirtualIP	(ocf::heartbeat:IPaddr2):	Started claire
 WebSite	(ocf::heartbeat:apache):	Started francis

PCSD Status:
  francis: Online
  claire: Online

Daemon Status:
  corosync: active/enabled
  pacemaker: active/enabled
  pcsd: active/enabled

Abhängigkeiten erstellen

  • pcs constraint colocation add WebSite with VirtualIP INFINITY
  • pcs constraint
Location Constraints:
Ordering Constraints:
Colocation Constraints:
  WebSite with VirtualIP (score:INFINITY)
  • pcs status
Cluster name: underwood
Last updated: Wed Oct 26 11:28:03 2016		Last change: Wed Oct 26 11:27:39 2016 by root via cibadmin on francis
Stack: corosync
Current DC: francis (version 1.1.14-70404b0) - partition with quorum
2 nodes and 2 resources configured

Online: [ claire francis ]

Full list of resources:

 VirtualIP	(ocf::heartbeat:IPaddr2):	Started claire
 WebSite	(ocf::heartbeat:apache):	Started claire

PCSD Status:
  francis: Online
  claire: Online

Daemon Status:
  corosync: active/enabled
  pacemaker: active/enabled
  pcsd: active/enabled

Reihenfolge erstellen

  • pcs constraint order VirtualIP then WebSite
Adding VirtualIP WebSite (kind: Mandatory) (Options: first-action=start then-action=start)
  • pcs constraint
Location Constraints:
Ordering Constraints:
  start VirtualIP then start WebSite (kind:Mandatory)
Colocation Constraints:
  WebSite with VirtualIP (score:INFINITY)

Eine bestimmte Node bevorzugen

  • pcs constraint location WebSite prefers francis=50
  • pcs constraint location VirtualIP prefers francis=50
  • pcs constraint
Location Constraints:
  Resource: VirtualIP
    Enabled on: francis (score:50)
  Resource: WebSite
    Enabled on: francis (score:50)
Ordering Constraints:
  start VirtualIP then start WebSite (kind:Mandatory)
Colocation Constraints:
  WebSite with VirtualIP (score:INFINITY)
  • pcs status
Cluster name: underwood
Last updated: Wed Oct 26 11:37:21 2016		Last change: Wed Oct 26 11:35:11 2016 by root via cibadmin on francis
Stack: corosync
Current DC: francis (version 1.1.14-70404b0) - partition with quorum
2 nodes and 2 resources configured
201M       0  201M    0% /run/user/0
root@francis:~# 

Online: [ claire francis ]

Full list of resources:

 VirtualIP	(ocf::heartbeat:IPaddr2):	Started francis
 WebSite	(ocf::heartbeat:apache):	Started francis

PCSD Status:
  francis: Online
  claire: Online

Daemon Status:
  corosync: active/enabled
  pacemaker: active/enabled
  pcsd: active/enabled
  • crm_simulate -sL (zum Anzeigen der placement scores)
Current cluster status:
Online: [ claire francis ]

 VirtualIP	(ocf::heartbeat:IPaddr2):	Started francis
 WebSite	(ocf::heartbeat:apache):	Started francis

Allocation scores:
native_color: VirtualIP allocation score on claire: 0
native_color: VirtualIP allocation score on francis: 100
native_color: WebSite allocation score on claire: -INFINITY
native_color: WebSite allocation score on francis: 50

Manuelles Verschieben einer Resource

  • pcs constraint location WebSite prefers claire=INFINITY
  • pcs constraint
Location Constraints:
  Resource: VirtualIP
    Enabled on: francis (score:50)
  Resource: WebSite
    Enabled on: francis (score:50)
    Enabled on: claire (score:INFINITY)
Ordering Constraints:
  start VirtualIP then start WebSite (kind:Mandatory)
Colocation Constraints:
  WebSite with VirtualIP (score:INFINITY)
  • pcs status
Cluster name: underwood
Last updated: Wed Oct 26 11:44:02 2016		Last change: Wed Oct 26 11:43:18 2016 by root via cibadmin on francis
Stack: corosync
Current DC: francis (version 1.1.14-70404b0) - partition with quorum
2 nodes and 2 resources configured

Online: [ claire francis ]

Full list of resources:

 VirtualIP	(ocf::heartbeat:IPaddr2):	Started claire
 WebSite	(ocf::heartbeat:apache):	Started claire

PCSD Status:
  francis: Online
  claire: Online

Daemon Status:
  corosync: active/enabled
  pacemaker: active/enabled
  pcsd: active/enabled

Links

DRBD erstellen

  • apt-get install drbd8-utils

Die Partionen mit LVM erstellen