42n4

XENGLUSTERLVM

Feb 6th, 2016
704
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 19.23 KB | None | 0 0
  1. #USE IT IN COMMAND LINE (without #):
  2. #curl  http://pastebin.com/raw/EFcqQZdv > xenglusterfs.sh; tr -d "\015" < xenglusterfs.sh > xenglusterfsnew.sh
  3. #chmod 755 xenglusterfsnew.sh; . ./xenglusterfsnew.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/EFcqQZdv
  8. #Removing local storage and configuring ctdb, /etc/hosts:
  9. #http://pastebin.com/yKCtrCmB
  10. #At the end you should:
  11. #gluster peer probe servers and
  12. #init_gluster4 "xenserverhw" "06" "08" "03" "04" "vol0" 4 #replica 4 at the end!
  13. #create SR nfs and iso, make vm and install xen tools and enable ha with 3 failovers.
  14. #You are encouraged to send some patches or opinions newfuntek(at)gmail.com
  15. #Here are some screenshots of the glusterfs sr in the xenserver pool:
  16. #http://s19.postimg.org/4pr7i3m2r/glusterfsxenserv01.jpg
  17. #http://s19.postimg.org/g0tv6gsxv/glusterfsxenserv02.jpg
  18. #http://s19.postimg.org/fzjxd1r43/glusterfsxenserv03.jpg
  19. #Internet help
  20. #Xenserver doc links
  21. #http://www.poppelgaard.com/citrix-xenserver-6-5
  22. #http://www.gluster.org/community/documentation/index.php/GlusterFS_Documentation
  23. #xenserver tutorials and cheatsheets
  24. #http://www.admin-magazine.com/HPC/Articles/GlusterFS
  25. #http://www.slashroot.in/gfs-gluster-file-system-complete-tutorial-guide-for-an-administrator
  26. #https://virtualizationandstorage.wordpress.com/2010/11/15/xenserver-commands/
  27. #http://krypted.com/unix/using-the-xensource-command-line-interface/
  28. #http://funwithlinux.net/2013/02/glusterfs-tips-and-tricks-centos/
  29. #http://xmodulo.com/category/xenserver
  30. #compilation of xenserver
  31. #https://discussions.citrix.com/topic/372069-does-libvmi-work-on-xenserver/
  32. #glusterfs slides info
  33. #http://rajesh-joseph.blogspot.com/2015/11/usenix-lisa-2015-tutorial-on-glusterfs.html
  34. #https://github.com/gluster/gluster-tutorial/blob/master/LISA-GlusterFS-Introduction.pdf
  35. #https://github.com/gluster/gluster-tutorial/blob/master/LISA-GlusterFS-Hands-on.pdf
  36. #compilation of glusterfs
  37. #http://majentis.com/?p=319
  38. #różne możliwości glusterfs jak w RAID
  39. #http://sysadm.pp.ua/linux/glusterfs-setup.html
  40. #glusterfs performance
  41. #https://blog.secretisland.de/xenserver-mit-glusterfs/
  42. #http://blog.dradmin.co.in/?tag=glusterfs-how-to
  43. #https://gluster.readthedocs.org/en/latest/Administrator%20Guide/Managing%20Volumes/
  44. #https://www.mail-archive.com/users@ovirt.org/msg31079.html
  45. #http://www.gluster.org/community/documentation/index.php/Performance_Testing
  46. #glusterfs on lvm
  47. #https://support.rackspace.com/how-to/getting-started-with-glusterfs-considerations-and-installation/
  48. #glusterfs profiling (delays in ops)
  49. #https://gluster.readthedocs.org/en/latest/Administrator%20Guide/Monitoring%20Workload/
  50. #xenserver glusterfs discussion - they said not possible ;)
  51. #http://discussions.citrix.com/topic/366729-about-xenserver-glusterfs/page-2
  52. #xenserver ha
  53. #http://docs.citrix.com/de-de/xencenter/6-1/xs-xc-protection/xs-xc-pools-ha/xs-xc-pools-ha-about.html
  54. #http://xapi-project.github.io/features/HA/HA.html
  55. #https://support.citrix.com/servlet/KbServlet/download/21018-102-664364/High%20Availability%20for%20Citrix%20XenServer.pdf
  56. #https://xen-orchestra.com/blog/xenserver-and-vm-high-availability/
  57. #https://discussions.citrix.com/topic/367150-ntp-ha-self-fencing/page-2#entry1884695
  58. #http://discussions.citrix.com/topic/333343-need-help-interpreting-xha-logs/
  59. #failure ha restart
  60. #http://support.citrix.com/article/CTX128275
  61. #http://citrixtechs.com/blog/help-my-citrix-xenserver-poolmaster-is-down-2/
  62. #http://discussions.citrix.com/topic/292757-local-storage-unplugged-and-un-repairable/
  63. #xenserver iscsi
  64. #http://gluster.readthedocs.org/en/latest/Administrator%20Guide/GlusterFS%20iSCSI/#Running_the_target_on_the_gluster_client
  65. #xenserver multipath
  66. #http://docs.citrix.com/content/dam/docs/en-us/xenserver/xenserver-61/xs-design-multipathing-config.pdf
  67. #xenserver iptables discussion
  68. #http://discussions.citrix.com/topic/235974-cannot-add-new-nfs-virtual-disk-sr-can-add-iso-library-nfs-sr/page-2
  69. #rebalance nics (bond for glusterfs)
  70. #http://www.gluster.org/pipermail/gluster-users/2014-November/019463.html
  71. #http://www.gluster.org/pipermail/gluster-users/2014-November/019466.html
  72. #multi nic splitnetwork for gluster in near future
  73. #https://www.gluster.org/pipermail/gluster-users/2015-May/021815.html
  74. #http://www.gluster.org/community/documentation/index.php/Features/SplitNetwork
  75. #http://pl.atyp.us/hekafs.org/index.php/2013/01/split-and-secure-networks-for-glusterfs/
  76. #host in vm inside vm config
  77. #https://wiki.openstack.org/wiki/XenServer/VirtualBox
  78. #reinstall xenserver host
  79. #http://support.citrix.com/article/CTX136342
  80. #discuss rejoin xenserver
  81. #http://discussions.citrix.com/topic/303468-server-removed-from-pool-after-failure-now-that-it-is-back-it-can-not-rejoin-pool-and-emergency-master-reset-does-not-work/
  82. #increase dom0 memory
  83. #http://support.citrix.com/article/CTX134951
  84. #find rpm
  85. #http://rpm.pbone.net/
  86. #win admin
  87. #win7-10: Net user administrator /active:yes
  88. #umount /dev/v/l
  89. #e2fsck -f /dev/v/l
  90. #resize2fs -p /dev/v/l 4G
  91. #lvreduce -L -8.9G /dev/
  92.  
  93. #turn off nfs i iptables
  94. chkconfig nfs off
  95. service nfs stop
  96. rm -f /etc/exports
  97. service ntpd restart
  98. chkconfig ntpd on
  99. service iptables stop
  100. chkconfig iptables off
  101.  
  102.  
  103. #new package update lists
  104. #https://discussions.citrix.com/topic/372069-does-libvmi-work-on-xenserver/
  105. #yum install epel-release
  106. #http://www.tecmint.com/how-to-enable-epel-repository-for-rhel-centos-6-5/
  107. #http://elrepo.org/tiki/tiki-index.php
  108. rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
  109. rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
  110. wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
  111. rpm -ivh epel-release-7-5.noarch.rpm
  112. rpm -Uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm
  113. rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
  114. rpm -Uvh http://repo.webtatic.com/yum/el7/webtatic-release.rpm
  115. #sed -i -e "s/enabled=0/enabled=1/" /etc/yum.repos.d/epel-testing.repo
  116. sed -i -e "/baseurl=http:\/\/www.uk/d" /etc/yum.repos.d/CentOS-Base.repo
  117. sed -i -e "/mirrorlist/d" /etc/yum.repos.d/CentOS-Base.repo
  118. sed -i -e "s/^#base/base/" /etc/yum.repos.d/CentOS-Base.repo
  119. sed -i -e "s/enabled=0/enabled=1/" /etc/yum.repos.d/CentOS-Base.repo
  120. sed -i -e "s/\$releasever/7/" /etc/yum.repos.d/CentOS-Base.repo
  121. sed -i -e "s/enabled=1/enabled=0/" /etc/yum.repos.d/Citrix.repo
  122.  
  123. yum clean all
  124. yum repolist enabled
  125. yum -y install deltarpm
  126. yum -y install vim-enhanced mc yum-utils curl e4fsprogs epel-rpm-macros
  127. curl ix.io/client > /usr/local/bin/ix
  128. chmod +x /usr/local/bin/ix
  129.  
  130. #update systemu i dodatkowe pakiety potrzebne do kompilacji glusterfs (mogą być jakieś nadmiarowe)
  131. yum update --skip-broken -y
  132. #yum upgrade
  133. yum install gcc make automake git bison flex python-ctypes fusermount readline rpm-build libibverbs-devel gcc-c++ libtool dev86 mock texinfo -y
  134. useradd -s /sbin/nologin mockbuild
  135. yum install scsi-target-utils ctdb samba nc tdb-tools -y
  136. #yum install targetcli targetd -y
  137. yum install e2fsprogs-devel openssl-devel yajl-devel libaio-devel cairo-devel python-devel uuid-devel glib2-devel lzma-devel xz-compat-libs libacl-devel sqlite-devel libxml2-devel userspace-rcu-devel readline-devel librdmacm-devel fuse-devel lvm2 audit-libs-devel gettext-devel pam-devel popt-devel libutempter-devel libuser-devel libcap-ng-devel json-c-devel libestr-devel python-docutils ibgcrypt-devel libcurl-devel libee-devel liblognorm-devel libdbi-devel mysql mysql-devel postgresql-devel librelp-devel gnutls-devel net-snmp-devel libnet-devel attr dlm-devel sanlock-devel corosynclib-devel resource-agents libgcrypt-devel libtalloc-devel libtdb-devel libtevent-devel -y
  138. yum update --skip-broken -y
  139.  
  140. #kompilacja util-linux, rsyslog, lvm2, gdyż nie udało się dodanie pakietów z devel
  141. #dodamy devel skompilowane, aby skompilować glusterfs
  142. echo "%__make /usr/bin/make -j 8" > ~/.rpmmacros
  143. cd
  144. wget ftp://ftp.icm.edu.pl/vol/rzm5/linux-slc/centos/7.2.1511/os/Source/SPackages/util-linux-2.23.2-26.el7.src.rpm
  145. rpm -ivh util-linux-2.23.2-26.el7.src.rpm
  146. rpmbuild -ba rpmbuild/SPECS/util-linux.spec
  147.  
  148. cd rpmbuild/RPMS/x86_64/
  149. rpm --force -ivh libuuid-2.23.2-26.el7.centos.x86_64.rpm
  150. rpm --force -ivh libblkid-2.23.2-26.el7.centos.x86_64.rpm
  151. rpm --force -ivh libmount-2.23.2-26.el7.centos.x86_64.rpm
  152. rpm --force -ivh libuuid-devel-2.23.2-26.el7.centos.x86_64.rpm
  153. rpm --force -ivh libblkid-devel-2.23.2-26.el7.centos.x86_64.rpm
  154. rpm --force -ivh libmount-devel-2.23.2-26.el7.centos.x86_64.rpm
  155. rpm --force -ivh util-linux-2.23.2-26.el7.centos.x86_64.rpm
  156. rpm --force -ivh uuidd-2.23.2-26.el7.centos.x86_64.rpm
  157. rpm --force -ivh util-linux-debuginfo-2.23.2-26.el7.centos.x86_64.rpm
  158. cd
  159. mv rpmbuild rpmbuild-util-linux
  160.  
  161. wget ftp://ftp.icm.edu.pl/vol/rzm5/linux-slc/centos/7.2.1511/os/Source/SPackages/rsyslog-7.4.7-12.el7.src.rpm
  162. rpm -ivh rsyslog-7.4.7-12.el7.src.rpm
  163. rpmbuild -ba rpmbuild/SPECS/rsyslog.spec
  164. cd rpmbuild/RPMS/x86_64/
  165. rpm -ivh rsyslog-7.4.7-12.el7.centos.x86_64.rpm rsyslog-crypto-7.4.7-12.el7.centos.x86_64.rpm rsyslog-debuginfo-7.4.7-12.el7.centos.x86_64.rpm rsyslog-doc-7.4.7-12.el7.centos.x86_64.rpm rsyslog-elasticsearch-7.4.7-12.el7.centos.x86_64.rpm rsyslog-gnutls-7.4.7-12.el7.centos.x86_64.rpm rsyslog-gssapi-7.4.7-12.el7.centos.x86_64.rpm rsyslog-libdbi-7.4.7-12.el7.centos.x86_64.rpm rsyslog-mmaudit-7.4.7-12.el7.centos.x86_64.rpm rsyslog-mmjsonparse-7.4.7-12.el7.centos.x86_64.rpm rsyslog-mmnormalize-7.4.7-12.el7.centos.x86_64.rpm rsyslog-mmsnmptrapd-7.4.7-12.el7.centos.x86_64.rpm rsyslog-mysql-7.4.7-12.el7.centos.x86_64.rpm rsyslog-pgsql-7.4.7-12.el7.centos.x86_64.rpm rsyslog-relp-7.4.7-12.el7.centos.x86_64.rpm rsyslog-snmp-7.4.7-12.el7.centos.x86_64.rpm rsyslog-udpspoof-7.4.7-12.el7.centos.x86_64.rpm --force
  166. cd
  167. mv rpmbuild rpmbuild-rsyslog
  168.  
  169. wget ftp://ftp.icm.edu.pl/vol/rzm5/linux-slc/centos/7.2.1511/os/Source/SPackages/lvm2-2.02.130-5.el7.src.rpm
  170. rpm -ivh lvm2-2.02.130-5.el7.src.rpm
  171. rpmbuild -ba rpmbuild/SPECS/lvm2.spec
  172. cd rpmbuild/RPMS/x86_64
  173. rpm -ivh cmirror-2.02.130-5.el7.centos.x86_64.rpm cmirror-standalone-2.02.130-5.el7.centos.x86_64.rpm device-mapper-1.02.107-5.el7.centos.x86_64.rpm device-mapper-devel-1.02.107-5.el7.centos.x86_64.rpm device-mapper-event-1.02.107-5.el7.centos.x86_64.rpm device-mapper-event-devel-1.02.107-5.el7.centos.x86_64.rpm device-mapper-event-libs-1.02.107-5.el7.centos.x86_64.rpm device-mapper-libs-1.02.107-5.el7.centos.x86_64.rpm lvm2-2.02.130-5.el7.centos.x86_64.rpm lvm2-debuginfo-2.02.130-5.el7.centos.x86_64.rpm lvm2-devel-2.02.130-5.el7.centos.x86_64.rpm lvm2-libs-2.02.130-5.el7.centos.x86_64.rpm lvm2-lockd-2.02.130-5.el7.centos.x86_64.rpm lvm2-python-libs-2.02.130-5.el7.centos.x86_64.rpm lvm2-sysvinit-2.02.130-5.el7.centos.x86_64.rpm --force
  174. cd
  175. mv rpmbuild rpmbuild-lvm2
  176. sed -i -e "s/metadata_read_only = 1/metadata_read_only = 0/" /etc/lvm/lvm.conf
  177.  
  178. #wget http://download.gluster.org/pub/gluster/glusterfs/3.7/LATEST/EPEL.repo/epel-7/SRPMS/glusterfs-3.7.6-1.el7.src.rpm
  179. #wget http://download.gluster.org/pub/gluster/glusterfs/3.7/3.7.6/EPEL.repo/epel-7/SRPMS/glusterfs-3.7.6-1.el7.src.rpm
  180. gfsversion="3.7.8-4"
  181. wget http://download.gluster.org/pub/gluster/glusterfs/3.7/3.7.8/CentOS/epel-7/SRPMS/glusterfs-${gfsversion}.el7.src.rpm
  182. rpm -ivh glusterfs-${gfsversion}.el7.src.rpm
  183. #sed -i -e "/lvm2-devel/d" rpmbuild/SPECS/glusterfs.spec
  184. rpmbuild -ba rpmbuild/SPECS/glusterfs.spec
  185. cd rpmbuild/RPMS/x86_64/
  186. rpm -ivh glusterfs-libs-${gfsversion}.el7.centos.x86_64.rpm
  187. rpm -ivh glusterfs-${gfsversion}.el7.centos.x86_64.rpm
  188. rpm -ivh glusterfs-client-xlators-${gfsversion}.el7.centos.x86_64.rpm
  189. rpm -ivh glusterfs-fuse-${gfsversion}.el7.centos.x86_64.rpm
  190. rpm -ivh glusterfs-cli-${gfsversion}.el7.centos.x86_64.rpm
  191. rpm -ivh glusterfs-api-${gfsversion}.el7.centos.x86_64.rpm
  192. rpm -ivh glusterfs-server-${gfsversion}.el7.centos.x86_64.rpm
  193. cd
  194. mv rpmbuild rpmbuild-glusterfs -f
  195.  
  196. systemctl unmask rpcbind.socket
  197.  
  198. #uruchomienie serwisu glusterfs
  199. service glusterd start
  200. service glusterd status
  201. service glusterfsd start
  202. service glusterfsd status
  203. chkconfig glusterd on
  204. chkconfig glusterfsd on
  205.  
  206. mkdir rpmbuild/SPECS -p; curl http://ix.io/oh7 > rpmbuild/SPECS/ctdb.spec
  207. wget https://download.samba.org/pub/ctdb/ctdb-2.5.5.tar.gz -P rpmbuild/SOURCES
  208. yum install libtalloc-devel libtdb-devel libtevent-devel nc tdb-tools samba -y
  209. rpmbuild -bp rpmbuild/SPECS/ctdb.spec
  210. sed -i "s/SCHED_FIFO/SCHED_OTHER/"  rpmbuild/BUILD/ctdb-2.5.5/common/system_util.c  
  211. sed -i "s/p.sched_priority = 1/p.sched_priority = 0/"  rpmbuild/BUILD/ctdb-2.5.5/common/system_util.c  
  212. rpmbuild -bc --short-circuit  rpmbuild/SPECS/ctdb.spec --noclean
  213. rpmbuild -bi --short-circuit  rpmbuild/SPECS/ctdb.spec --noclean
  214. rpmbuild -bb --short-circuit  rpmbuild/SPECS/ctdb.spec --noclean
  215. rpm -ivh rpmbuild/RPMS/x86_64/ctdb-* --nodeps --force
  216. sed -i "s/^# CTDB_LOGFILE/CTDB_LOGFILE/" /etc/sysconfig/ctdb
  217. sed -i "s/^# CTDB_NODES/CTDB_NODES/" /etc/sysconfig/ctdb  
  218. sed -i "s/^CTDB_RECOVERY_LOCK/# CTDB_RECOVERY_LOCK/" /etc/sysconfig/ctdb
  219. sed -i 's/Restart=no/Restart=always/' /usr/lib/systemd/system/ctdb.service
  220. service smb stop
  221. chkconfig smb off
  222.  
  223. wget http://halizard.org/release/noSAN-combined/halizard_nosan_installer_1.4.7
  224. chmod 755 halizard_nosan_installer_1.4.7  
  225. sed -i 's/`uname -r`/3.10.0+2/' halizard_nosan_installer_1.4.7
  226.  
  227. sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/sysconfig/selinux
  228. #curl http://ix.io/oxr > /etc/ntp.conf.ix
  229. #curl http://ix.io/ojO > /etc/ntp.conf.ix
  230. curl http://ix.io/op8 > /etc/ntp.conf.ix
  231. #curl http://ix.io/oKN > /etc/ntp.conf.ix
  232. tr -d "\015" < /etc/ntp.conf.ix > /etc/ntp.conf
  233. echo OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -x" > /etc/sysconfig/ntpd
  234. echo SYNC_HWCLOCK=yes >> /etc/sysconfig/ntpd
  235. service ntpd stop
  236. service ntpd start
  237. ntpstat -s
  238. ntpq -p
  239. ntpstat -s
  240.  
  241. echo "#/opt/xensource/bin/xe-toolstack-restart" >> /etc/rc.d/rc.local
  242. echo "service glusterd restart" >> /etc/rc.d/rc.local
  243. echo "service glusterfsd restart" >> /etc/rc.d/rc.local
  244. echo "service ctdb restart" >> /etc/rc.d/rc.local
  245. chmod 755  /etc/rc.d/rc.local
  246.  
  247. echo "xe host-emergency-ha-disable force=true" > /usr/local/bin/restartfence
  248. echo "/opt/xensource/bin/xe-toolstack-restart" >> /usr/local/bin/restartfence
  249. echo "service glusterd restart" >> /usr/local/bin/restartfence
  250. echo "service glusterfsd restart" >> /usr/local/bin/restartfence
  251. echo "service ctdb restart" >> /usr/local/bin/restartfence  
  252. chmod 755 /usr/local/bin/restartfence
  253.  
  254. echo "/opt/xensource/bin/xe-toolstack-restart" >> /usr/local/bin/restartoolxen
  255. echo "service glusterd restart" >> /usr/local/bin/restartoolxen
  256. echo "service glusterfsd restart" >> /usr/local/bin/restartoolxen
  257. echo "service ctdb restart" >> /usr/local/bin/restartoolxen
  258. chmod 755 /usr/local/bin/restartoolxen
  259.  
  260. echo "service glusterd restart" > /usr/local/bin/restartdodatki
  261. echo "service glusterfsd restart" >> /usr/local/bin/restartdodatki
  262. echo "service ctdb restart" >> /usr/local/bin/restartdodatki
  263. chmod 755 /usr/local/bin/restartdodatki
  264.  
  265. echo "service glusterd restart" > /usr/local/bin/restartgluster
  266. echo "service glusterfsd restart" >> /usr/local/bin/restartgluster
  267. chmod 755 /usr/local/bin/restartgluster
  268.  
  269. #init_gluster4 "xenserverhw" "06" "08" "03" "04" "vol0" 4
  270. #server="xenserverhw"; host01="06"; host02="08"; host03="03"; host04="04"; volume="vol0"; replica=4;
  271. cat <<__EOF__ > /usr/local/bin/init_gluster4
  272. server=\$1  
  273. host01=\$2  
  274. host02=\$3  
  275. host03=\$4
  276. host04=\$5  
  277. volume=\$6
  278. replica=\$7
  279. gluster peer status
  280. #na dowolnym jednym wykonac
  281. #glusterfs dwa volumeny vol0 (iso) I vol1 (gfs) na sda3 i sda2  
  282. #gluster volume stop \$volume force
  283. #gluster volume delete \$volume force
  284. gluster volume create \$volume replica \$replica \${server}\${host01}:/export/\${server}\${host01}-\$volume \${server}\${host02}:/export/\${server}\${host02}-\$volume \${server}\${host03}:/export/\${server}\${host03}-\$volume \${server}\${host04}:/export/\${server}\${host04}-\$volume force  
  285. gluster volume set \$volume nfs.port 2049  
  286. gluster volume set \$volume performance.cache-size 128MB  
  287. gluster volume set \$volume performance.write-behind-window-size 4MB  
  288. gluster volume set \$volume performance.io-thread-count 64  
  289. gluster volume set \$volume performance.io-cache on  
  290. gluster volume set \$volume performance.read-ahead on  
  291. gluster volume start \$volume  
  292. gluster volume info \$volume  
  293. gluster volume status \$volume  
  294. #montowanie NFS SR pod localhost lub VIP :/vol0 lub vol1  
  295. __EOF__
  296. chmod 755 /usr/local/bin/init_gluster4
  297.  
  298. #init_gluster2 "xen" "1" "2" "vol0" 2
  299. #server="xen"; host01="1"; host02="2"; volume="vol0"; replica=2;
  300. cat <<__EOF__ > /usr/local/bin/init_gluster2
  301. server=\$1  
  302. host01=\$2  
  303. host02=\$3  
  304. volume=\$4
  305. replica=\$5
  306. gluster peer status
  307. #na dowolnym jednym wykonac
  308. #glusterfs dwa volumeny vol0 (iso) I vol1 (gfs) na sda3 i sda2  
  309. #gluster volume stop \$volume force
  310. #gluster volume delete \$volume force
  311. gluster volume create \$volume replica \$replica \${server}\${host01}:/export/\${server}\${host01}-\$volume \${server}\${host02}:/export/\${server}\${host02}-\$volume force  
  312. gluster volume set \$volume nfs.port 2049  
  313. gluster volume set \$volume performance.cache-size 128MB  
  314. gluster volume set \$volume performance.write-behind-window-size 4MB  
  315. gluster volume set \$volume performance.io-thread-count 64  
  316. gluster volume set \$volume performance.io-cache on  
  317. gluster volume set \$volume performance.read-ahead on  
  318. gluster volume start \$volume  
  319. gluster volume info \$volume  
  320. gluster volume status \$volume  
  321. #montowanie NFS SR pod localhost lub VIP :/vol0 lub vol1  
  322. __EOF__
  323. chmod 755 /usr/local/bin/init_gluster2
  324.  
  325. #init_brick "/dev/sdb1" "vol2"
  326. cat <<__EOF__ > /usr/local/bin/init_brick
  327. dev4gfs=\$1  
  328. volume=\$2  
  329. hname=\`hostname\`
  330. mkfs.ext4 -m 0 -j \$dev4gfs
  331. tune2fs -O dir_index -o user_xattr \$dev4gfs
  332. mkdir -p /export/\${hname}-\${volume}
  333. echo  "\$dev4gfs /export/\${hname}-\${volume} ext4 rw,noatime,nodiratime,user_xattr,barrier=0,data=ordered 1 2" >> /etc/fstab
  334. mount -a
  335. __EOF__
  336. chmod 755 /usr/local/bin/init_brick
  337.  
  338. #reformat_brick "/dev/sda2" "vol1"
  339. cat <<__EOF__ > /usr/local/bin/reformat_brick
  340. dev4gfs=\$1  
  341. volume=\$2  
  342. hname=\`hostname\`
  343. umount /export/\${hname}-\${volume}
  344. mkfs.ext4 -m 0 -j \$dev4gfs
  345. tune2fs -O dir_index -o user_xattr \$dev4gfs
  346. mount /export/\${hname}-\${volume}
  347. __EOF__
  348. chmod 755 /usr/local/bin/reformat_brick
  349.  
  350. #removeallandformat "/dev/sdb"
  351. cat <<__EOF__ > /usr/local/bin/removeallandformat
  352. #!/bin/bash
  353. # Script to automatically format all partitions on /dev/sda and create
  354. # a single partition for the whole disk
  355. # Remove each partition
  356. for v_partition in \`parted -s \$1 print|awk '/^ / {print \$1}'\`; do umount \$1\${v_partition}; parted -s \$1 rm \${v_partition}; done
  357. # Find size of disk
  358. v_disk=\`parted -s \$1 print|awk '/^Disk \/dev/ {print \$3}'| sed 's/[Mm][Bb]//'\`
  359. # Create single partition
  360. parted -s \$1 mkpart primary 1 \${v_disk}
  361. # Format the partition
  362. # mke2fs -T ext3 \${1}1
  363. __EOF__
  364. chmod 755  /usr/local/bin/removeallandformat
  365.  
  366. #KONIEC
Add Comment
Please, Sign In to add comment