Acquira

Nginx_Clustering

Oct 14th, 2020 (edited)
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.82 KB | None | 0 0
  1. #Lab Environment
  2.     web01 : 172.16.137.130
  3.     web02 : 172.16.137.131
  4.     web03 : 172.16.137.132
  5.  
  6. #Web01 / Web02 / Web03
  7.    
  8.     apt install -y ssh
  9.  
  10.         nano /etc/ssh/sshd_config
  11.         PermitRootLogin yes
  12.  
  13.     apt install -y nginx
  14.         echo '<h1> webXX - cluster lab</1>' > /var/www/html/index.nginx-debian.html
  15.         systemctl stop nginx
  16.  
  17.     apt install -y pacemaker corosync crmsh
  18.         systemctl stop corosync
  19.         systemctl stop pacemaker
  20.  
  21. #Web01
  22.     apt install -y haveged
  23.     corosync-keygen
  24.     cd /etc/corosync/
  25.     mv corosync.conf corosync.conf.backup
  26.     nano corosync.conf
  27.  
  28.     # Totem Protocol Configuration
  29.     totem {
  30.         version: 2
  31.         cluster_name: nginx_cluster_1
  32.         transport: udpu
  33.         # Interface configuration for Corosync
  34.         interface {
  35.             ringnumber: 0
  36.             bindnetaddr: 172.16.137.0
  37.             broadcast: yes
  38.             mcastport: 5407
  39.         }
  40.     }
  41.     # Nodelist - Server List
  42.     nodelist {
  43.         node {
  44.             ring0_addr: web01
  45.         }
  46.         node {
  47.             ring0_addr: web02
  48.         }
  49.         node {
  50.             ring0_addr: web03
  51.         }
  52.     }
  53.     # Quorum configuration
  54.     quorum {
  55.         provider: corosync_votequorum
  56.     }
  57.     # Corosync Log configuration
  58.     logging {
  59.         to_logfile: yes
  60.         logfile: /var/log/corosync/corosync.log
  61.         to_syslog: yes
  62.         timestamp: on
  63.     }
  64.     service {
  65.         name: pacemaker
  66.         ver: 0
  67.     }
  68.  
  69. #Copy corosync files from web01 to web02 and web03
  70.     scp /etc/corosync/* root@web02:/etc/corosync/
  71.     scp /etc/corosync/* root@web03:/etc/corosync/
  72.  
  73.  
  74. #Configure the virtual_ip
  75. sudo crm configure primitive virtual_ip \
  76. ocf:heartbeat:IPaddr2 params ip="172.16.137.200" \
  77. cidr_netmask="32" op monitor interval="10s" \
  78. meta migration-threshold="10"
  79.  
  80. sudo crm configure primitive webserver \
  81. ocf:heartbeat:nginx configfile=/etc/nginx/nginx.conf \
  82. op start timeout="40s" interval="0" \
  83. op stop timeout="60s" interval="0" \
  84. op monitor interval="10s" timeout="60s" \
  85. meta migration-threshold="10"
  86.  
  87. crm resource status
Add Comment
Please, Sign In to add comment