1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
| yum install -y libselinux-python
groupadd mysql useradd mysql -g mysql -s /sbin/nologin -M mkdir -p /home/data
rpm -e --nodeps mysql-libs-5.1.73-8.el6_8.x86_64 rpm -ivh MySQL-devel-5.6.37-1.el6.x86_64.rpm MySQL-client-5.6.37-1.el6.x86_64.rpm MySQL-server-5.6.37-1.el6.x86_64.rpm
cp my.cnf /etc/my.cnf
mv /var/lib/mysql /home/data chown -R mysql:mysql /home/data
service mysql start
chkconfig mysql on
sh setmysql.sh setmysql.sh passwd=`awk -F"time):" '{print $2}' /root/.mysql_secret |awk '{print $1}'` mysql -uroot -p$passwd -b --connect-expired-password <setmysql.sql setmysql.sql SET PASSWORD = PASSWORD('ShSflow!@#123'); create user mysql identified by "ShSflow!@#123"; grant all privileges on *.* to 'mysql'@'%' identified by 'ShSflow!@#123' with grant option; flush privileges;
service mysql restart
iptables -A INPUT -p tcp --dport 3306 -j ACCEPT service iptables save service iptables restart
--- - hosts: ggall remote_user: root tasks: - name: make user,group,dir shell: groupadd mysql; useradd mysql -g mysql -s /sbin/nologin -M; mkdir -p /home/data ;mkdir -p /home/shanghang/soft - name: remove mysql-libs* shell: yum remove mysql-libs* -y - name: install numactl shell: yum install -y numactl - name: copy rpm copy: src=/soft/ansible/MySQL-client-5.6.37-1.el6.x86_64.rpm dest=/home/shanghang/soft/MySQL-client-5.6.37-1.el6.x86_64.rpm - name: copy rpm copy: src=/soft/ansible/MySQL-devel-5.6.37-1.el6.x86_64.rpm dest=/home/shanghang/soft/MySQL-devel-5.6.37-1.el6.x86_64.rpm - name: copy rpm copy: src=/soft/ansible/MySQL-server-5.6.37-1.el6.x86_64.rpm dest=/home/shanghang/soft/MySQL-server-5.6.37-1.el6.x86_64.rpm - name: install rpm shell: rpm -ivh MySQL-devel-5.6.37-1.el6.x86_64.rpm MySQL-client-5.6.37-1.el6.x86_64.rpm MySQL-server-5.6.37-1.el6.x86_64.rpm args: chdir: /home/shanghang/soft/ - name: copy my.cnf copy: src=/soft/ansible/my.cnf dest=/etc/my.cnf - name: move mysqldir to /home/data shell: mv /var/lib/mysql /home/data ; chown -R mysql:mysql /home/data - name: start mysql shell: service mysql start - name: set autorun shell: chkconfig mysql on - name: set autorun shell: chkconfig mysql on - name: copy setmysql.sh copy: src=/soft/ansible/setmysql.sh dest=/home/shanghang/soft/setmysql.sh - name: copy setmysql.sql copy: src=/soft/ansible/setmysql.sql dest=/home/shanghang/soft/setmysql.sql - name: run setmysql.sh shell: sh setmysql.sh args: chdir: /home/shanghang/soft/ - name: restart mysql shell: service mysql restart - name: set iptables shell: iptables -A INPUT -p tcp --dport 3306 -j ACCEPT - name: save iptables shell: service iptables save - name: restart iptables shell: service iptables restart
[client] socket=/home/data/mysql/mysql.sock [mysqld] skip-name-resolve port=3306 basedir=/usr datadir=/home/data/mysql socket=/home/data/mysql/mysql.sock server-id=2 max_allowed_packet = 20M federated
innodb_buffer_pool_size=2G innodb_log_file_size=1G
character-set-server=utf8 collation-server=utf8_general_ci max-connect-errors=6000 max-connections=3000 thread_cache_size = 300 thread_concurrency =32 innodb_thread_concurrency =16 max-connect-errors=6000 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES lower_case_table_names=1
|