Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable to change default datadir in my.cnf #27

Closed
achandel opened this issue Aug 27, 2018 · 12 comments
Closed

Variable to change default datadir in my.cnf #27

achandel opened this issue Aug 27, 2018 · 12 comments

Comments

@achandel
Copy link

If you want to use a different data directory e.g. in case of using an EBS volume to store data. The /templates/etc/mysql/my.cnf.j2 should use a variable for datadir.

mrlesmithjr added a commit that referenced this issue Aug 27, 2018
@mrlesmithjr
Copy link
Owner

@achandel Thanks for this. I have implemented this and you should be good to go now.

@achandel
Copy link
Author

@mrlesmithjr Thanks for this

@mrlesmithjr
Copy link
Owner

@achandel No problem at all.

@achandel
Copy link
Author

achandel commented Aug 29, 2018

This Ansible Role is well written. I am going to use it to deploy a large Galera MariaDB cluster in multi Data center scenario with multiple gmcast.segment. Will keep you posted on any improvements required. Great work!

@mrlesmithjr
Copy link
Owner

@achandel Thanks for the great feedback. Definitely let me know how everything works out for your deployment. And definitely let me know if you find anything that can be improved.

@achandel
Copy link
Author

The role does not work when an data directory different from /var/lib/mysql is specified e.g. mariadb/data. This is an issue when a fresh install of the mariadb is done. This is not required if you are making changed to an existing installation, in this case you just need to make changes in my.cnf

SOLUTION

Once the installation is complete you need to copy the contents of /var/lib/mysql to your data directory. I worked around by adding these two tasks in setup_cluster.yml just after the task setup_cluster | killing lingering mysql processes:

  • name: debian | changing data directory permissions
    command: chown -R mysql:mysql "{{ mariadb_mysql_settings.datadir }}"
    when: mariadb_mysql_settings.datadir != '/var/lib/mysql'

  • name: debian | copying files from default data directory
    synchronize:
    src: "/var/lib/mysql/"
    dest: "{{ mariadb_mysql_settings.datadir }}"
    archive: yes
    become: true
    delegate_to: "{{ inventory_hostname }}"
    when: mariadb_mysql_settings.datadir != '/var/lib/mysql'

@mrlesmithjr
Copy link
Owner

@eRadical Thoughts on this?

@eRadical
Copy link
Collaborator

eRadical commented Oct 18, 2018

I think this will be covered w/ the changes that I'll soon (hopefully very soon) send as per discussion in #29
... and by that way you will not need to do the copy thing... the files will be generated from the beginning in that folder.

While @achandel has a workable solution I'm not quite fond of synchronize as it requires rsync on the machine and it's not a stableinterface... yet! It might also generate confusion as you'll end up with files in your new datadir and also in the old dir

@mrlesmithjr
Copy link
Owner

Thanks for the input @eRadical. I tend to agree on the synchronize point as well.

eRadical added a commit to eRadical/ansible-mariadb-galera-cluster that referenced this issue Nov 4, 2018
@plandolt
Copy link

I came across this issue today and got another solution without altering the role. Before executing the role I create a symlink to my real destination (mounted disk).

@madalinignisca
Copy link

Isn't it more simple to have a few tasks at start to ensure that datadir exists and it is owned by mysql user?

apt can use policy_rc_d: 101 to not start on first node mariadb.

add mariadb configuration files, without galera confs

later when configuration files are currently put, only the galera ones are needed.

@gutleib
Copy link

gutleib commented Nov 24, 2024

Can confirm it's breaking a fresh install to non-standard folder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants