简介:
SaltStack是 一个服务器基础架构集中化管理平台,具备配置管理、远程执行、监控等功能,一般可以理解为简化版的puppet和加强版的func。SaltStack基 于Python语言实现,结合轻量级消息队列(ZeroMQ)与Python第三方模块(Pyzmq、PyCrypto、Pyjinjia2、 python-msgpack和PyYAML等)构建。
最近工作比较闲,所以继续学习saltstack,今天就用源码来安装Mysql数据库,学saltstack还是得多实践,废话不多说,上干货。
实验环境:
Master: www.master.com 10.0.4.52 Centos6.5
Slave: www.slave.com 10.0.4.53 Centos6.5
开始部署:
# cat top.sls
base:
'*':
- init.install
- mysql.install
目录结构:
# tree init/
init/
└── install.sls #主要安装mysql数据库需要的依赖库。
# tree mysql/ #文件内容下面会给出。
mysql/
├── init.sh
├── install.sls
├── my.cnf #mysql的主配置文件,自己根据要求来配置。
├── mysql-5.6.14.tar.gz
└── mysqld #mysql的启动脚本,即是/etc/init.d/mysqld。
0 directories, 5 files
初始化配置文件:
# cat init/install.sls
pkg-init:
pkg.installed:
- names:
- gcc
- gcc-c++
- glibc
- make
- autoconf
- libjpeg-turbo
- libjpeg-turbo-devel
- libpng
- libpng-devel
- freetype
- freetype-devel
- libxml2
- libxml2-devel
- zlib
- zlib-devel
- libcurl
- libcurl-devel
- openssl
- openssl-devel
- swig
- cmake
- ncurses
- ncurses-devel
- libtool-ltdl-devel
安装mysql主配置文件:
# cat mysql/install.sls
include:
- init.install
mysql-source-install:
file.managed:
- name: /usr/local/src/mysql-5.6.14.tar.gz
- source: salt://mysql/mysql-5.6.14.tar.gz
- user: root
- group: root
- mode: 755
cmd.run:
- name: cd /usr/local/src/ && tar xf mysql-5.6.14.tar.gz && cd mysql-5.6.14 && cmake -DCMAKE_INSTALL_PREFIX=/usr/local/webserver/mysql5.6/ -DMYSQL_DATADIR=/usr/local/webserver/mysql5.6/data -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci && make && make install
- require:
- file: mysql-source-install
- unless: test -d /usr/local/webserver/mysql5.6
mysql-init:
file.managed:
- name: /usr/local/src/init.sh
- source: salt://mysql/init.sh
- user: root
- group: root
- mode: 755
cmd.script:
- name: /usr/local/src/init.sh
- require:
- cmd: mysql-source-install
(责任编辑:最模板) |