Install MySQL with Saltstack source under CentOS

Source: Internet
Author: User
Tags openssl saltstack

Brief introduction:

Saltstack is a centralized server infrastructure management platform, with configuration management, remote execution, monitoring and other functions, can generally be understood as a simplified version of the puppet and enhanced Func. Saltstack is based on the Python language implementation and is built with a lightweight Message Queuing (ZeroMQ) and Python third-party modules (PYZMQ, Pycrypto, Pyjinjia2, Python-msgpack, and Pyyaml, etc.).


Recently work relatively busy, so continue to learn saltstack, today use the source to install MySQL database, learn saltstack or more practice, nonsense not much said, on dry.


Lab Environment :

Master:www.master.com 10.0.4.52 centos6.5slave:www.slave.com 10.0.4.53 Centos6.5

Start deployment:

# cat Top.sls Base: ' * ':-Init.install-mysql.install

Directory structure:

# Tree Init/init/└──install.sls #主要安装mysql数据库需要的依赖库. # Tree mysql/#文件内容下面会给出. MYSQL/├──INIT.SH├──INSTALL.SLS├──MY.CNF #mysql的主配置文件, CONFIGURED according to your requirements. ├──mysql-5.6.14.tar.gz└──mysqld #mysql的启动脚本, that is/etc/init.d/mysqld. 0 directories, 5 files


Initialize the configuration file:

# 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

install MySQL Master profile:

# cat mysql/install.slsinclude:  - init.installmysql-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.6mysql-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-installmysql-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-initmysql-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 init script:

# cat mysql/init.sh #!/bin/bashgroupadd MySQL #saltstack也可以创建mysql用户和组, here's a direct reference to this script. Useradd-r-G MySQL mysqlln-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.cnfcp-a/usr/local/webserver/mysql5.6/support-files/my-default.cnf/usr/local/ Webserver/mysql5.6/my.cnfchown mysql:mysql/usr/local/webserver/mysql5.6/-R

Very excited to perform the installation

#salt   ' www.slave.com '  state.highstate    #强烈建议执行这命令之前先执行salt   ' www.slave.com '  state.highstate test=true to test whether the experiment was successful. ......----------.........------------------------------           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:                    Truesummary-------------succeeded: 32  (changed=5) failed:     0------------- Total states run:     32

Minion End View:

# NETSTAT-ANLP |grep mysqldtcp 0 0::: 3306:::* LISTEN 29890/ MYSQLD UNIX 2 [ACC] STREAM LISTENING 897638 29890/mysqld/var/lib/mysql/mysql.sock

From the above see MySQL has been installed in the Minion end of the successful, before a variety of errors, various debugging. Finally succeeded. Or that sentence, more hands-on.

This article is from the "Share Linux" blog, so be sure to keep this source http://sharelinux.blog.51cto.com/11163444/1789443

Install MySQL with Saltstack source under CentOS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.