(eight) Saltstack project installation MySQL

Source: Internet
Author: User
Tags openssl saltstack


1.1 Installing MySQL

2.2 Viewing Salt-master, salt-minion configuration files

[Email protected] ~]# Grep-ev ' ^#|^$ '/etc/salt/master

interface:0.0.0.0

File_roots:

Base

-/data/etc/salt

Prod

-/data/etc/salt/prod

Log_file:/data/logs/salt/master

[Email protected] ~]# Grep-ev ' ^#|^$ '/etc/salt/minion

master:172.168.200.210

Id:node2

Log_file:/data/logs/salt/minion

2.3 Viewing the Salt MySQL directory structure


[Email protected] ~]# Cd/data/etc/salt

[Email protected] salt]# tree mysql/

mysql/

|--Conf.sls, mysql salt configuration file

|--files

| |--my.cnf-a MySQL configuration file

| MySQL Package |--mysql-5.6.32.tar.gz

| '--mysqld MySQL startup script

|--Init.sls, salt initialization file

'--MySQL Install file Install.sls

2.4 Writing MySQL SLS files


[email protected] salt]# cat Top.sls

Base

‘*‘:

-Mysql.init

[Email protected] salt]# CD mysql/

[email protected] mysql]# cat Init.sls

Include

-Mysql.install

-Mysql.conf

[email protected] mysql]# cat Install.sls

#mysql Pkg.install

MYSQL_PKG:

Pkg.installed:

-Names:

-GCC

-Gcc-c++

-Autoconf

-Automake

-OpenSSL

-Openssl-devel

-Zlib

-Zlib-devel

-Ncurses-devel

-Libtool-ltdl-devel

-CMake

#install source MySQL

Mysql_source:

File.managed:

-Name:/usr/local/src/mysql-5.6.32.tar.gz

-Unless:test-e/usr/local/src/mysql-5.6.32.tar.gz

-Source:salt://mysql/files/mysql-5.6.32.tar.gz

#tar source MySQL

Extract_mysql:

Cmd.run:

-CWD:/USR/LOCAL/SRC

-Names:

-Tar zxf mysql-5.6.32.tar.gz

-Chown-r root:root/usr/local/src/mysql-5.6.32

-Unless:tests-d/usr/local/src/mysql-5.6.32

-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 Source Install

Mysql_commpile:

Cmd.run:

-name:cd/usr/local/src/mysql-5.6.32 && CMake. -dcmake_install_prefix=/usr/local/mysql-5.6-dmysql_datadir=/usr/local/mysql-5.6/data-dmysql_unix_addr=/usr/ Local/mysql-5.6/data/mysql.sock-ddefault_charset=utf8-ddefault_collation=utf8_general_ci-denabled_local_infile =on-dwith_innobase_storage_engine=1-dwith_federated_storage_engine=1-dwith-blackhole_storage_engine=1-dwithout _example_storage_engine=1-dwithout_partition_storage_enging=1-dwith_fast_mutexes=1-dwith_zlib=bundled-denabled _local_infil=1-dwith_readline=1-dwith_embedded_server=1-dwith_debug=0 && make && make install && Amp /usr/local/mysql-5.6/scripts/mysql_install_db--basedir=/usr/local/mysql-5.6/--datadir=/usr/local/mysql-5.6/ data/--user=mysql

-Require:

-Cmd:extract_mysql

-Pkg:mysql_pkg

-Unless:test-d/usr/local/mysql-5.6

#mysql Initialize

#mysql_initialize:

# Cmd.run:

#-CWD:/usr/local/mysql-5.6/scripts/

#-Names:

#-./mysql_install_db--basedir=/usr/local/mysql-5.6/--datadir=/usr/local/mysql-5.6/data/--user=mysql

[email protected] mysql]# cat Conf.sls

Include

-Mysql.install

#mysql for Config

MYSQL_CNF:

File.managed:

-Name:/USR/LOCAL/MYSQL-5.6/MY.CNF

-User:root

-mode:755

-SOURCE:SALT://MYSQL/FILES/MY.CNF

#myql Server

Mysql_service:

File.managed:

-Name:/etc/init.d/mysqld

-Source:salt://mysql/files/mysqld

-User:root

-mode:755

Cmd.run:

-Names:

-/sbin/chkconfig--add mysqld

-/sbin/chkconfig--level mysqld on

-Unless:/sbin/chkconfig--list mysqld

2.5 MySQL configuration file


[Email protected] ~]# cd/data/etc/salt/mysql/files/

[email protected] files]# cat MY.CNF

[Mysqld]

Socket=/usr/local/mysql-5.6/data/mysql.sock

Datadir=/usr/local/mysql-5.6/data

Symbolic-links=0

Log-error=/var/log/mysql_error.log

Pid-file=/usr/local/mysql-5.6/data/mysqld.pid

Slow-query-log-file =/var/log/mysql_slow_querys.log

Skip-name-resolve

Skip-grant-tables


2.6 MySQL startup script to add the following path

[email protected] files]# cat mysqld

#!/bin/sh


basedir=/usr/local/mysql-5.6/

datadir=/usr/local/mysql-5.6/data/


2.7 Simulated execution salt

1

[[email protected] salt]# Salt ' node2 ' state.highstate test=true-no error



[[email protected] salt]# Salt ' node2 ' state.highstate start installing MySQL


This article is from the "Bill Linux Operations Notes" blog, please be sure to keep this source http://chenshoubiao.blog.51cto.com/6159058/1884498

(eight) Saltstack project installation MySQL

Related Article

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.