(四)、mysql部署
中小型规模网站集群架构:mysql部署
: Ago linux运维群:https://hankbook.cn
前言
1.数据库需要授权三个用户
create database wordpress;
grant all on wordpress.* to 'wordpress'@'172.16.1.%' identified by "wordpress";
create database dedecms;
grant all on dedecms.* to 'dedecms'@'172.16.1.%' identified by "dedecms";
create database discuz;
grant all on discuz.* to 'discuz'@'172.16.1.%' identified by "discuz";
2.数据库rpm包制作的脚本
#!/bin/sh
ln -s /application/mysql-5.6.34/ /application/mysql
useradd mysql -M -s /sbin/nologin -u 899
chown -R mysql.mysql /application/mysql*
cd /application/mysql
./scripts/mysql_install_db --user=mysql --basedir=/application/mysql --datadir=/application/mysql/data/
\cp support-files/mysql.server /etc/init.d/mysqld
sed -i 's#/usr/local/mysql#/application/mysql#g' /etc/init.d/mysqld
sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe
ln -s /application/mysql/bin/mysql /usr/local/bin/mysql
\cp /application/mysql/my.cnf /etc/my.cnf
/etc/init.d/mysqld start
制作rpm包
fpm -s dir -t rpm -n mysql -v 5.6.34 --post-install /server/scripts/mysql_rpm.sh -f /application/mysql-5.6.34/
一、ansible部署
---
- hosts: 172.16.1.51
tasks:
- name: base
include: /server/files/base.yml
- name: "install mysql"
yum:
name: mysql
state: installed