实战使用saltstack源码安装配置mysql
环境:
salt_master:192.168.100.228 salt_client1:192.168.100.245
master client 版本一致 [root@salt_server base]# salt --versions-report Salt: 0.17.5 Python: 2.6.6 (r266:84292, Jun 18 2012, 14:18:47) Jinja2: unknown M2Crypto: 0.20.2 msgpack-python: 0.1.13 msgpack-pure: Not Installed pycrypto: 2.0.1 PyYAML: 3.10 PyZMQ: 2.2.0.1 ZMQ: 3.2.3 [root@salt_server base]#
开始安装部署文件:
top.sls文件 [root@salt_server base]# cat top.sls base: ‘salt_client*‘: - nginx [root@salt_server base]#
目录结构:
[root@salt_server base]# tree mysql/ mysql/ ├── conf.sls ├── files │ ├── conf.sh │ ├── my.cnf │ ├── mysql-5.5.22.tar.gz │ ├── mysqld │ └── mysqllns.sh ├── init.sls └── install.sls 1 directory, 8 files [root@salt_server base]# [root@salt_server mysql]# cat init.sls include: - mysql.install - mysql.conf [root@salt_server mysql]#
安装mysql的主配置文件:
[root@salt_server mysql]# cat install.sls #install source mysql mysql_source: file.managed: - name: /home/mysql-5.5.22.tar.gz - unless: test -e /home/mysql-5.5.22.tar.gz - source: salt://mysql/files/mysql-5.5.22.tar.gz #tar source mysql extract_mysql: cmd.run: - cwd: /home - names: - tar xf mysql-5.5.22.tar.gz - chown root:root /home/mysql-5.5.22 -R - unless: test -d /home/mysql-5.5.22 - require: - file: mysql_source #useradd for mysql mysql_user: user.present: - name: mysql - uid: 1024 - createhome: False - gid_from_name: True - shell: /sbin/nologin #mysql pkg.install mysql_pkg: pkg.installed: - pkgs: - gcc - gcc-c++ - autoconf - automake - openssl - openssl-devel - zlib - zlib-devel - ncurses-devel - libtool-ltdl-devel - cmake #mysql source install mysql_commpile: cmd.run: - cwd: /home/mysql-5.5.22 - names: - cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATTON=utf8_cuicode_ci -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_DEBUG=0 - make - make install - require: - cmd.run: extract_mysql - pkg: mysql_pkg - unless: test -d /usr/local/mysql [root@salt_server mysql]#
mysql config 文件:
[root@salt_server mysql]# cat conf.sls include: - mysql.install # mysql for config mysql_cnf: file.managed: - name: /etc/my.cnf - user: root - mode: 755 - source: salt://mysql/files/my.cnf # mysql init salt://mysql/files/conf.sh: cmd.script: - env: - BATCH: ‘yes‘ - require: - cmd.run: mysql_commpile - pkg: mysql_pkg # mysql server mysql_service: file.managed: - name: /etc/init.d/mysqld - user: root - mode: 755 - source: salt://mysql/files/mysqld cmd.run: - names: - /sbin/chkconfig --add mysqld - /sbin/chkconfig --level 35 mysqld on - unless: /sbin/chkconfig --list mysqld service.running: - name: mysqld - enable: True - reload: True [root@salt_server mysql]#
配置文件:
[root@salt_server mysql]# tree files/ files/ ├── conf.sh初始化文件 ├── my.cnf配置文件 ├── mysql-5.5.22.tar.gz安装包 ├── mysqld启动脚本 └── mysqllns.sh软连接 0 directories, 5 files [root@salt_server mysql]# [root@salt_server mysql]# cat files/conf.sh #!/bin/bash /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ [root@salt_server mysql]# cat files/mysqllns.sh #!/bin/bash #lns ln -sv /usr/local/mysql/bin/mysql /usr/bin ln -sv /usr/local/mysql/bin/mysqladmin /usr/bin/ ln -sv /usr/local/mysql/bin/mysqldump /usr/bin/ #mysq competence /bin/chown -R mysql.mysql /usr/local/mysql/ && /bin/chown -R mysql.mysql /usr/local/mysql/data/ [root@salt_server mysql]#
本文出自 “angerdevil” 博客,请务必保留此出处http://devliangel.blog.51cto.com/469347/1547824
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。