时间:2021-07-01 10:21:17 帮助过:4人阅读
关闭selinux和firewalld,iptables开放4505和4506端口
目的:通过salt-master实现对salt-minion的批量自动安装mysql
步骤(都在master执行):
1,检测连通性
salt ‘*‘ test.ping
2,下载mysql的源码包至/srv/salt/mysql/files/
/srv/salt/mysql/files/mysql-5.6.22.tar.gz
3,编辑安装文件:/srv/salt/mysql/
[20:33:20-root@jack mysql]#tree -L 1
.
├── cmake.sls
├── conf
├── files
└── mysql.sls
主要cmake.sls和mysql.sls文件
cmake.sls安装编译软件包
mysql.sls编译安装mysql
[20:33:29-root@jack mysql]#cat cmake.sls
cmake-install:
pkg.installed:
source: salt://mysql/files/mysql-5.6.22.tar.gz
cmd.run:
creates: /usr/local/mysql
#####:一定要注意语法格式和缩进
4,执行安装
[20:40:06-root@jack mysql]#salt ‘*‘ state.sls mysql.cmake
[20:41:01-root@jack mysql]#salt ‘*‘ state.sls mysql.mysql
执行时间会很长,如果语法或者没有依赖包,会报错,飘红的
5,更改配置,亦可以在本地改好,直接用cp.get_file/cp.get_dir,批量发送
由于配置简单,这边直接更改了:
[20:41:01-root@jack mysql]#cat conf
salt ‘‘ cmd.run "cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf"
salt ‘‘ cmd.run "sed -i ‘/mysqld/a\datadir = /data/mysql‘ /etc/my.cnf"
salt ‘‘ cmd.run "sed -i ‘/datadir=/s#\/var\/lib\/mysql#\/data\/mysql#g‘ /etc/my.cnf"
salt ‘‘ cmd.run "cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld"
salt ‘‘ cmd.run "chmod 755 /etc/init.d/mysqld;chkconfig --add mysqld;chkconfig mysqld on"
salt ‘‘ cmd.run "echo ‘export PATH=/usr/local/mysql/bin:$PATH‘ >> /etc/profile.d/mysqld.sh"
salt ‘*‘ cmd.run "/etc/init.d/mysqld restart"
*:这边是所有机器安装,如何阁下做了主机群分组,可以使用:-N G1 指定分组执行安装
6,检测安装版本号
[20:21:04-root@jack ~]#salt ‘*‘ cmd.run "/usr/local/mysql/bin/mysql --version"
jack-6:
/usr/local/mysql/bin/mysql Ver 14.14 Distrib 5.6.22, for Linux (x86_64) using EditLine wrapper
jack-6-1:
/usr/local/mysql/bin/mysql Ver 14.14 Distrib 5.6.22, for Linux (x86_64) using EditLine wrapper
jack-7:
/usr/local/mysql/bin/mysql Ver 14.14 Distrib 5.6.22, for Linux (x86_64) using EditLine wrapper
如何需要安装其他版本:http://mirrors.sohu.com/mysql/
saltstack全编译安装mysql5.6.22
标签:linux mysqld get c++ mys man ast evel oca