Saltstack Official Galera Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

9 年之前
8 年之前
8 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
9 年之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. {%- from "galera/map.jinja" import master with context %}
  2. {%- if master.enabled %}
  3. {%- if grains.os_family == 'RedHat' %}
  4. xtrabackup_repo:
  5. pkg.installed:
  6. - sources:
  7. - percona-release: {{ master.xtrabackup_repo }}
  8. - require_in:
  9. - pkg: galera_packages
  10. # Workaround https://bugs.launchpad.net/percona-server/+bug/1490144
  11. xtrabackup_repo_fix:
  12. cmd.run:
  13. - name: |
  14. sed -i 's,enabled\ =\ 1,enabled\ =\ 1\nexclude\ =\ Percona-XtraDB-\*\ Percona-Server-\*,g' /etc/yum.repos.d/percona-release.repo
  15. - unless: 'grep "exclude = Percona-XtraDB-\*" /etc/yum.repos.d/percona-release.repo'
  16. - watch:
  17. - pkg: xtrabackup_repo
  18. - require_in:
  19. - pkg: galera_packages
  20. {%- endif %}
  21. galera_packages:
  22. pkg.installed:
  23. - names: {{ master.pkgs }}
  24. - refresh: true
  25. galera_log_dir:
  26. file.directory:
  27. - name: /var/log/mysql
  28. - makedirs: true
  29. - mode: 755
  30. - require:
  31. - pkg: galera_packages
  32. {%- if grains.os_family == 'Debian' %}
  33. galera_run_dir:
  34. file.directory:
  35. - name: /var/run/mysqld
  36. - makedirs: true
  37. - mode: 755
  38. - user: mysql
  39. - group: root
  40. - require:
  41. - pkg: galera_packages
  42. {%- endif %}
  43. galera_init_script:
  44. file.managed:
  45. - name: /etc/init.d/mysql
  46. - source: salt://galera/files/mysql
  47. - mode: 755
  48. - require:
  49. - pkg: galera_packages
  50. galera_bootstrap_script:
  51. file.managed:
  52. - name: /usr/local/sbin/galera_bootstrap.sh
  53. - mode: 755
  54. - source: salt://galera/files/bootstrap.sh
  55. - template: jinja
  56. {%- if salt['cmd.run']('test -e /var/lib/mysql/.galera_bootstrap; echo $?') != '0' %}
  57. galera_bootstrap_temp_config:
  58. file.managed:
  59. - name: {{ master.config }}
  60. - source: salt://galera/files/my.cnf.bootstrap
  61. - mode: 644
  62. - template: jinja
  63. - require:
  64. - pkg: galera_packages
  65. - file: galera_init_script
  66. galera_bootstrap_start_service:
  67. cmd.run:
  68. - name: /usr/local/sbin/galera_bootstrap.sh
  69. - require:
  70. - file: galera_bootstrap_temp_config
  71. - file: galera_run_dir
  72. - file: galera_bootstrap_script
  73. galera_bootstrap_set_root_password:
  74. cmd.run:
  75. - name: mysqladmin password "{{ master.admin.password }}"
  76. - require:
  77. - cmd: galera_bootstrap_start_service
  78. mysql_bootstrap_update_maint_password:
  79. cmd.run:
  80. - name: mysql -u root -p{{ master.admin.password }} -e "GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '{{ master.maintenance_password }}';"
  81. - require:
  82. - cmd: galera_bootstrap_set_root_password
  83. galera_bootstrap_stop_service:
  84. service.dead:
  85. - name: {{ master.service }}
  86. - require:
  87. - cmd: mysql_bootstrap_update_maint_password
  88. galera_bootstrap_init_config:
  89. file.managed:
  90. - name: {{ master.config }}
  91. - source: salt://galera/files/my.cnf.init
  92. - mode: 644
  93. - template: jinja
  94. - require:
  95. - service: galera_bootstrap_stop_service
  96. galera_bootstrap_start_service_final:
  97. cmd.run:
  98. - name: /usr/local/sbin/galera_bootstrap.sh
  99. - require:
  100. - file: galera_bootstrap_init_config
  101. - file: galera_bootstrap_script
  102. galera_bootstrap_finish_flag:
  103. file.touch:
  104. - name: /var/lib/mysql/.galera_bootstrap
  105. - require:
  106. - cmd: galera_bootstrap_start_service_final
  107. - watch_in:
  108. - file: galera_config
  109. {%- endif %}
  110. galera_config:
  111. file.managed:
  112. - name: {{ master.config }}
  113. - source: salt://galera/files/my.cnf
  114. - mode: 644
  115. - template: jinja
  116. - require_in:
  117. - service: galera_service
  118. galera_service:
  119. service.running:
  120. - name: {{ master.service }}
  121. - enable: true
  122. - reload: true
  123. {%- endif %}