Advertisement
42n4

XENDELOCALSTORAGE

Feb 4th, 2016
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 5.72 KB | None | 0 0
  1. #USE IT IN COMMAND LINE (without #):
  2. #curl http://pastebin.com/raw/2Hez4MYN > xendeletelocalsr.sh; tr -d "\015" < xendeletelocalsr.sh > xendeletelocalsrnew.sh
  3. #sh xendeletelocalsrnew.sh
  4. #I have managed to configure 4 servers of beta dundee with glusterfs and ctdb and fully working ha without SPOF.
  5. #I have four NICs: NIC0 management of xenserver 192.168.10.2*, NIC1 gluster vm client 192.168.10.14*, bond NIC2-3 10.10.10.1*, VIPs #from ctdb 192.168.10.13*. In /etc/hosts I keep only 10.10.10.1x server ips and use them in glusterfs volume creation and in #consequence in glusterfs backend traffic.
  6. #The main compilation script:
  7. #http://pastebin.com/ps1LZaSq
  8. #Removing local storage and configuring ctdb, /etc/hosts:
  9. #http://pastebin.com/2Hez4MYN
  10. #At the end you should:
  11. #gluster peer probe servers
  12. #and
  13. #init_gluster4 "xenserverhw" "06" "08" "03" "04" "vol0" 4 #replica 4 at the end!
  14. #create SR nfs and iso, make vm and install xen tools and enable ha with 3 failovers.
  15. #You are encouraged to send some patches or opinions newfuntek(at)gmail.com
  16. #Here are some screenshots of the glusterfs sr in the xenserver pool:
  17. #http://s17.postimg.org/3y47n8w27/glusterfsxenserv03.jpg
  18. #http://s17.postimg.org/n4heqfcjz/glusterfsxenserv01.jpg
  19. #http://s17.postimg.org/gs29gl9hr/glusterfsxenserv02.jpg
  20. #uuid pbd http://blog.gluster.org/2012/
  21. #usunięcie Local Storage na sda3
  22. #sformatowanie i podmontowanie dwóch wolnych partycji sda2 i sda3 na dwa dyski sieciowe
  23. sed -i -e "s/metadata_read_only = 1/metadata_read_only = 0/" /etc/lvm/lvm.conf
  24. hname=`hostname`
  25. #hname=`echo $hname | tr [:lower:] [:upper:]`
  26. sruuid=`xe sr-list host=$hname name-label=Local\ storage --minimal`
  27. pbduid=`xe pbd-list sr-uuid=$sruuid --minimal`
  28. xe pbd-unplug uuid=$pbduid
  29. xe sr-forget uuid=$sruuid
  30. vgremove `vgdisplay -C | tail -n1 | cut -f3 -d' '` -f
  31. dev4gfs=`pvdisplay -C | tail -n1 | cut -f3 -d' '`
  32. pvremove $dev4gfs -f
  33.  
  34. umount $dev4gfs
  35. init_brick $dev4gfs "vol0"
  36.  
  37. #umount "/dev/sda2"
  38. #init_brick "/dev/sda2" "vol1"
  39.  
  40. removeallandformat "/dev/sdb"
  41. init_brick "/dev/sdb1" "vol2"
  42.  
  43. ###########################################################################
  44. #OnePool
  45. ###########################################################################
  46. server="xenserverhw0"
  47. host01="3"
  48. host02="4"
  49. host03="6"
  50. host04="8"
  51. echo "127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4" > /etc/hosts
  52. echo "10.10.10.1${host01} ${server}${host01}" >> /etc/hosts
  53. echo "10.10.10.1${host02} ${server}${host02}" >> /etc/hosts
  54. echo "10.10.10.1${host03} ${server}${host03}" >> /etc/hosts
  55. echo "10.10.10.1${host04} ${server}${host04}" >> /etc/hosts
  56. echo "10.10.10.1${host01}" > /etc/ctdb/nodes
  57. echo "10.10.10.1${host02}" >> /etc/ctdb/nodes
  58. echo "10.10.10.1${host03}" >> /etc/ctdb/nodes
  59. echo "10.10.10.1${host04}" >> /etc/ctdb/nodes
  60. echo "192.168.10.13${host01}/24 xenbr1" > /etc/ctdb/public_addresses
  61. echo "192.168.10.13${host02}/24 xenbr1" >> /etc/ctdb/public_addresses
  62. echo "192.168.10.13${host03}/24 xenbr1" >> /etc/ctdb/public_addresses
  63. echo "192.168.10.13${host04}/24 xenbr1" >> /etc/ctdb/public_addresses
  64. chkconfig ctdb on
  65. service ctdb start
  66.  
  67. #init_gluster4 "xenserverhw" "06" "08" "03" "04" "vol0" 4
  68. #service ctdb restart
  69. ctdb status
  70.  
  71. #https://serversforhackers.com/an-ansible-tutorial
  72. #http://www.cyberciti.biz/faq/
  73. yum install ansible -y
  74. [ -f /etc/ansible/hosts ] && mv /etc/ansible/hosts /etc/ansible/hosts.orig
  75. echo "[web]" > /etc/ansible/hosts
  76. echo "10.10.10.13" >> /etc/ansible/hosts
  77. echo "10.10.10.14" >> /etc/ansible/hosts
  78. echo "10.10.10.16" >> /etc/ansible/hosts
  79. echo "10.10.10.18" >> /etc/ansible/hosts
  80. #ssh-keygen -t rsa -b 2048 -N '' -f /root/.ssh/id_rsa
  81. #ssh-copy-id -i root@xenserverhw03
  82. #ssh-copy-id -i root@xenserverhw04
  83. #ssh-copy-id -i root@xenserverhw05
  84. #ssh-copy-id -i root@xenserverhw06
  85. #ansible all -s -m shell -a "ctdb status"
  86. echo 'ansible all -s -m shell -a "$1"' > /usr/local/bin/ae
  87. chmod 700 /usr/local/bin/ae
  88. #CRONTAB WORKS for test logs
  89. [ -f /var/log/checktime.log ] && mv /var/log/checktime.log /var/log/checktime.log.old -f
  90. echo 'echo "#########################"' > /usr/local/bin/checktime
  91. echo "date" >> /usr/local/bin/checktime
  92. echo "ntpstat -s" >> /usr/local/bin/checktime
  93. echo "/sbin/gluster volume status vol2" >> /usr/local/bin/checktime
  94. echo "ctdb status" >> /usr/local/bin/checktime
  95. echo "free" >> /usr/local/bin/checktime
  96. chmod 755 /usr/local/bin/checktime
  97. echo "/usr/local/bin/checktime  2>&1 | cat >> /var/log/checktime.log" > /usr/local/bin/cronuserlogs
  98. chmod 755 /usr/local/bin/cronuserlogs
  99. echo "* * * * * /usr/local/bin/cronuserlogs" > ./cronwork
  100. crontab -r
  101. crontab ./cronwork
  102. crontab -l
  103.  
  104. cat <<__EOF__ > /etc/logrotate.d/checktime
  105. /var/log/checktime.log {
  106.     daily
  107.     rotate 3
  108.     compress
  109.     delaycompress
  110.     missingok
  111.     notifempty
  112.     create 644 root root
  113. }
  114. __EOF__
  115.  
  116. echo 'Skonfiguruj NIC1 (192.168.10.13?) i NIC2 (10.10.10.1?)'
  117. echo 'Wykonaj na jednym serwerze:'
  118. echo 'gluster peer probe xenserverhw03'
  119. echo 'gluster peer probe xenserverhw04'
  120. echo 'gluster peer probe xenserverhw06'
  121. echo 'gluster peer probe xenserverhw08'
  122. echo 'init_gluster4 "xenserverhw" "06" "08" "03" "04" "vol0" 4'
  123. echo 'init_gluster4 "xenserverhw" "06" "08" "03" "04" "vol1" 4'
  124. echo 'init_gluster4 "xenserverhw" "06" "08" "03" "04" "vol2" 4'
  125. echo 'Wykonaj na na każdym serwerze:'
  126. echo 'service ctdb restart'
  127. echo 'ctdb status'
  128. #echo 'ip addr show | grep inet'
  129. echo "ssh-keygen -t rsa -b 2048 -N '' -f /root/.ssh/id_rsa"
  130. echo 'ssh-copy-id -i root@xenserverhw03'
  131. echo 'ssh-copy-id -i root@xenserverhw04'
  132. echo 'ssh-copy-id -i root@xenserverhw06'
  133. echo 'ssh-copy-id -i root@xenserverhw08'
  134. echo 'Teraz możesz wykonywać polecenia na wszystkich serwerach z jednego: ae "ctdb status"'
  135. echo 'Pozostało zamontować SR iso, gfs1, gfs2'
  136.  
  137. #KONIEC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement