ansible二进制部署mysql_实例ansible-role :通过role进行二进制批量部署mariadb从而批量上线sql系统...

总结构

346a9f307f95b28d8a66b2796ac5fe7e.png

1

f5ff624a2b81ef466bdc362701e92643.png

- include: group.yml

- include: user.yml

- include: mkdir.yml

- include: data.yml

- include: link.yml

- include: linkstate.yml

- include: conf.yml

- include: server.yml

2

6ad5dbd3c31c35d4d80dcad268476d1c.png

- name: create group

group: name=mysql system=yes gid=306

3

a2ce79ccda6fece5a0231764c215c160.png

- name: create user

user: name=mysql system=yes uid=306 group=306 home=/data/mysql

4

e123b701ef9b6ddbf62f248d86210833.png

- name: mkdir

file: name=/data/mysql owner=root group=mysql state=directory

5

2da1098bb56c199ab1ff5a608922628a.png

- name: copy data

unarchive: src=mariadb-10.2.23-linux-x86_64.tar.gz dest=/usr/local

6

4ebe51adbefdbed9bbfe29f9f11aad4e.png

- name: link

file: src=/usr/local/mariadb-10.2.23-linux-x86_64 dest=/usr/local/mysql state=link

7

ce1960b90d9047cd41884c9db076ee3e.png

- name: link state

file: name=/usr/local/mysql owner=root group=mysql

8

671675c3b79fccbe18622a747e98b237.png

- name: mkdir conf

file: path=/etc/mysql state=directory

- name: copy conf

template: src=my-large.cnf.j2 dest=/etc/mysql/my.cnf

9

a7e59da9f8fc4eb0f127672d0270d053.png

- name: install

shell: /usr/local/mysql/scripts/mysql_install_db --datadir=/data/mysql --user=mysql

- name: copy service conf

template: src=mysql.server.j2 dest=/etc/rc.d/init.d/mysqld

- name: add service

shell: chkconfig --add mysqld

- name: chmod

shell: chmod +x /etc/init.d/mysqld

- name: start server

shell: service mysqld start

- name: PATH

shell: echo PATH=/usr/local/mysql/bin:$PATH > /etc/profile.d/mysql

- name: source

shell: source /etc/profile.d/mysql

10 安全初始化

#!/usr/bin/expect

set timeout 60

#set password [lindex $argv 0]

spawn mysql_secure_installation

expect {

"enter for none" { send "\r"; exp_continue}

"Change the root password" { send "\r"; exp_continue}

"New password" { send "new passwd\r"; exp_continue}

"Re-enter new password" { send "newpasswd\r"; exp_continue}

"Remove anonymous users" { send "\r"; exp_continue}

"Disallow root login remotely" { send "n\r"; exp_continue}

"Remove test database and access to it" { send "\r"; exp_continue}

"Reload privilege tables now" { send "\r"; exp_continue}

"Cleaning up" { send "\r"}

}

interact ' > mysql_secure_installation.exp

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值