服务报价 | 域名主机 | 网络营销 | 软件工具| [加入收藏]
 热线电话: #
当前位置: 主页 > 开发教程 > linux教程 >

Centos下用Saltstack源码安装Mysql(2)

时间:2016-10-08 17:52来源:未知 作者:最模板编辑 点击:
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:
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端安装成功了,之前各种报错,各种调试。总算成功了。还是那句话,多动手。
(责任编辑:最模板)
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
栏目列表
热点内容