diff --git a/roles/mariadb/tasks/configure.yml b/roles/mariadb/tasks/configure.yml index 7fe4ac2..5eec907 100644 --- a/roles/mariadb/tasks/configure.yml +++ b/roles/mariadb/tasks/configure.yml @@ -1,115 +1,125 @@ --- # Configure MariaDB - stat: path=/var/local/mysql_reset register: mysql_reset - name: Copy phabricator stop words copy: src=stopwords.txt dest=/srv/stopwords.txt - name: Copy minimal mysql config template: src=my-mini.cnf dest=/etc/my.cnf when: not mysql_reset.stat.exists notify: stop mysql - name: Reset MySQL root password shell: /etc/init.d/mysql start --skip-grant-tables; mysql -u root -e 'flush privileges; SET PASSWORD FOR 'root'@'localhost' = PASSWORD("");'; touch /var/local/mysql_reset; service mariadb stop when: not mysql_reset.stat.exists args: creates: /var/local/mysql_reset - name: Copy mysql config template: src=my.cnf dest=/etc/my.cnf notify: restart mysql - name: Start mysql server service: name=mariadb state=started enabled=true +# Tweaks +- name: Open files and proc limits for mysql user + copy: + dest: /etc/security/limits.d/10-mysql.conf + content: | + mysql hard nofile 100000 + mysql soft nofile 100000 + mysql soft nproc 10000 + mysql hard nproc 10000 + # Configure replication - name: Create database replication user mysql_user: state=present user={{ mysql_repl_user }} password={{ mysql_repl_pass }} priv="*.*:REPLICATION SLAVE" host={{ mysql_host }} run_once: yes - name: Check slave replication status mysql_replication: mode=getslave ignore_errors: true register: slave when: inventory_hostname != groups.dbs[0] - name: Check master replication status mysql_replication: mode=getmaster delegate_to: "{{ groups.dbs[0] }}" register: master when: > inventory_hostname != groups.dbs[0] and slave|failed - name: Configure replication on the slave mysql_replication: mode: changemaster master_host: "{{ groups.dbs[0] }}" master_user: "{{ mysql_repl_user }}" master_password: "{{ mysql_repl_pass }}" master_log_file: "{{ master.File }}" master_log_pos: "{{ master.Position }}" ignore_errors: True when: > inventory_hostname != groups.dbs[0] and slave|failed - name: Start replication mysql_replication: mode=startslave when: > inventory_hostname != groups.dbs[0] and slave|failed # Users - name: Create database app user mysql_user: state=present user={{ mysql_app_user }} password={{ mysql_app_pass }} priv=*.*:ALL host={{ mysql_host }} run_once: yes - name: Create Shibboleth user mysql_user: state=present user={{ mysql_shib_user }} password={{ mysql_shib_pass }} priv={{ mysql_shib_db }}.*:ALL host={{ mysql_host }} run_once: yes # Shibboleth database - name: Copy Shibboleth db schema copy: src: "install_shib.sql" dest: "/tmp/install_shib.sql" run_once: yes - name: Create Shibboleth db mysql_db: name: "{{ mysql_shib_db }}" run_once: yes - name: Check if Shibboleth tables exist shell: "mysql {{ mysql_shib_db }} -e 'show tables' | grep strings" register: tablestatus ignore_errors: yes run_once: yes - name: Populate Shibboleth db mysql_db: name: "{{ mysql_shib_db }}" target: /tmp/install_shib.sql state: import when: "'{{ inventory_hostname }}' == '{{ groups.dbs[0] }}' and tablestatus.rc != 0" diff --git a/roles/mariadb/templates/my.cnf b/roles/mariadb/templates/my.cnf index 036a2d6..6a8fb56 100644 --- a/roles/mariadb/templates/my.cnf +++ b/roles/mariadb/templates/my.cnf @@ -1,31 +1,32 @@ [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock default_storage_engine=InnoDB bind-address=0.0.0.0 sql_mode=STRICT_ALL_TABLES max_allowed_packet=48M symbolic-links=0 -max_connections=800 local_infile=0 +max_connections=5000 +open_files_limit = 100000 ft_stopword_file=/srv/stopwords.txt ft_min_word_len=3 ft_boolean_syntax=' |-><()~*:""&^' innodb_buffer_pool_size=2000M innodb_log_file_size=48M innodb_autoinc_lock_mode=2 innodb_flush_log_at_trx_commit=0 innodb_doublewrite=0 server_id={{ ansible_hostname[-1:]|int+1 }} log-bin="{{ mysql_cluster_name }}" log_slave_updates=0 binlog_format=MIXED sync_binlog=0 expire_logs_days={{ mysql_binlog_expire }} [mysqld_safe] log-error=/var/log/mariadb/mariadb.log pid-file=/var/run/mariadb/mysqld.pid