mysql-config:
file.managed:
- name: /usr/local/webserver/mysql5.6/my.cnf
- source: salt://mysql/my.cnf
- user: root
- group: root
- mode: 644
- require:
- file: mysql-init
mysql-service:
file.managed:
- name: /etc/init.d/mysqld
- source: salt://mysql/mysqld
- user: root
- group: root
- mode: 755
cmd.run:
- name: chkconfig --add mysqld
- unless: chkconfig --list |grep mysqld
- require:
- file: mysql-service
service.running:
- name: mysqld
- require:
- cmd: mysql-service
Mysql初始化脚本:
# cat mysql/init.sh
#!/bin/bash
groupadd mysql #saltstack也可以创建mysql用户和组,这里就直接让它引用这个脚本。
useradd -r -g mysql mysql
ln -s /usr/local/webserver/mysql5.6/bin/mysql /usr/bin/
cd /usr/local/webserver/mysql5.6/scripts/ && ./mysql_install_db --basedir=/usr/local/webserver/mysql5.6/ --datadir=/usr/local/webserver/mysql5.6/data/
rm -rf /etc/my.cnf
cp -a /usr/local/webserver/mysql5.6/support-files/my-default.cnf /usr/local/webserver/mysql5.6/my.cnf
chown mysql:mysql /usr/local/webserver/mysql5.6/ -R
好激动,要执行安装了
#salt 'www.slave.com' state.highstate #强烈建议执行这命令之前先执行salt 'www.slave.com' state.highstate test=True来测试实验是否成功。
..........................................................
----------
ID: mysql-service
Function: cmd.run
Name: chkconfig --add mysqld
Result: True
Comment: unless execution succeeded
Started: 11:01:55.890689
Duration: 519.892 ms
Changes:
----------
ID: mysql-service
Function: service.running
Name: mysqld
Result: True
Comment: Started Service mysqld
Started: 11:01:56.414994
Duration: 2598.256 ms
Changes:
----------
mysqld:
True
Summary
-------------
Succeeded: 32 (changed=5)
Failed: 0
-------------
Total states run: 32
minion端查看:
# netstat -anlp |grep mysqld
tcp 0 0 :::3306 :::* LISTEN 29890/mysqld
unix 2 [ ACC ] STREAM LISTENING 897638 29890/mysqld /var/lib/mysql/mysql.sock
从上面看出mysql已经在minion端安装成功了,之前各种报错,各种调试。总算成功了。还是那句话,多动手。
(责任编辑:好模板) |