Automating the deployment of MySQL 5.6 steps

Source: Internet
Author: User


Preparatory work

First, we need to build ftpserver

Yum Install vsftpd service vsftpd start


So the FTP service is up, here it is simply used, so no configuration file is used. This way we simply place the required files under the/var/ftp/pub/folder, and the anonymous user can copy the files to the machine.

Installing Rpm-build

Build needs to use Rpm-build, which can be installed simply

Yum Install Rpm-build

Start RPM packaging below



Modify Mysql.spec


name:mysql-rpmversion:5.6.21release:renfengjunlicense:gplurl:http://dev.mysql.com/group:applications/ Databasebuildroot:%{_tmppath}/%{name}-%{version}-%{release}-rootbuildrequires:cmakepackager: [email  Protected]autoreq:noprefix:/u01/mysqlsummary:mysql-5.6.21.tar.gz%descriptionthe MySQL (TM) software delivers a very fast,multi-threaded, Multi-user,and Robust SQL (structured Query Language) database server. MySQL Serveris intended for mission-critical, heavy-loadproduction Systems as wellas-embedding into mass-deployed soft Ware. %define mysql_user mysql%define mysql_group mysql%define __os_install_post%{nil}%BUILDCD $OLDPWD/... /cflags= "-o3-g-fno-exceptions-static-libgcc-fno-omit-frame-pointer-fno-strict-aliasing" CXX=g++CXXFLAGS= "-o3-g-                                                  Fno-exceptions-fno-rtti-static-libgcc-fno-omit-frame-pointer-fno-strict-aliasing "Export CFLAGS CXX CXXFLAGS cmake. -dsysconfdir:path=%{prefix}-dcmake_iNstall_prefix:path=%{prefix}-dcmake_build_type:string=release-denable_profiling:                                 Bool=on-dwith_debug:bool=off-dwith_valgrind:bool=off                        -denable_debug_sync:bool=off-dwith_extra_charsets:string=all                              -dwith_ssl:string=bundled-dwith_unit_tests:bool=off -dwith_zlib:string=bundled-dwith_partition_storage_engine:bool=on-d With_innobase_storage_engine:bool=on-dwith_archive_storage_engine:bool=on-dwith_black                                   Hole_storage_engine:bool=on-dwith_perfschema_storage_engine:bool=on-ddefault_charset=utf8                              -ddefault_collation=utf8_general_ci-dwith_extra_charsets=all -denabled_local_infile:bool=on-dwith_embedded_server=0-dinstall_l Ayout:string=standalone-dcommunity_build:bool=on-dmysql_server_suffi x= '-r5436 '; Make-j ' Cat/proc/cpuinfo | grep processor| Wc-l '%INSTALLCD $OLDPWD/... /make destdir= $RPM _build_root install%CLEANRM-RF $RPM _build_root%files%defattr (-,%{mysql_user},%{mysql_group})% attr (755,%{mysql_user},%{mysql_group})%{prefix}/*%premkdir-p/u01/mysql/datamkdir-p/u01/mysql/runmkdir-p/u01/ Mysql/loggroupadd mysqluseradd-g MySQL mysqlchown-r mysql:mysql/u01/mysql/datachown-r mysql:mysql/u01/mysql/ Logchown-r Mysql:mysql/u01/mysql/runecho "exportpath= $PATH:/u01/mysql/bin" >>/home/mysql/.bash_profile% Postln-s%{prefix}/lib%{prefix}/lib64cp/u01/mysql/support-files/mysql.server/etc/init.d/mysqlchkconfig MySQL on% Preunchkconfig--del Mysqlrm-rf/u01userdel MYSQLRM-RF/VAR/SPOOL/MAIL/MYSQLRM-RF/ETC/INIT.D/mysqlrm-rf/home/mysql%changelog  


Execute the Package command

Rpmbuild-bb./mysql.spec

Output:

Requires (PRE):/bin/shrequires (POST):/bin/shrequires (Preun):/bin/shchecking for unpackaged file (s):/usr/lib/rpm/ Check-files/var/tmp/mysql-rpm-5.6.21-renfengjun-rootwarning:could not canonicalize hostname:centos511Wrote:/usr/ Src/redhat/rpms/x86_64/mysql-rpm-5.6.21-renfengjun.x86_64.rpmexecuting (%clean):/bin/sh-e/var/tmp/rpm-tmp.62530 + umask 022+ cd/usr/src/redhat/build+ rm-rf/var/tmp/mysql-rpm-5.6.21-renfengjun-root+ exit 0

The generated RPM package is here:

/usr/src/redhat/rpms/x86_64/mysql-rpm-5.6.21-renfengjun.x86_64.rpm

Packaging data templates

Remember to turn off MySQL when you pack. Here's a little bit of test data:

Mysql> SELECT * from dexdb.t, +------+------------+| ID   |name       |+------+------------+|    1 |renfengjun |+------+------------+1 row in Set (0.00 sec)


Data template packaging, remember ibdata1 packaging on

Cd/u01/mysql/data

Tar CF Data.tar Ibdata1 mysql/dexdb/performance_schema/test/

Modify MY.CNF

MY.CNF File Contents:

[Mysqld_safe]pid-file=/u01/mysql/run/mysqld.pid#malloc-lib=/u01/mysql/lib/libjemalloc.so [Mysql]port=3306prompt =\\[email protected]\\d \\r:\\m:\\s>default-character-set=gbkno-auto-rehash [client]port=3306socket=/u01 /mysql/run/mysql.sock [mysqld] #dirbasedir =/u01/mysqldatadir=/u01/mysql/datatmpdir=/tmplc_messages_dir=/u01/ mysql/sharelog-error=/u01/mysql/log/alert.logslow_query_log_file=/u01/mysql/log/slow.loggeneral_log_file=/u01/ Mysql/log/general.logsocket=/u01/mysql/run/mysql.sock #innodbinnodb_data_home_dir =/u01/mysql/datainnodb_log_ Group_home_dir=/u01/mysql/datainnodb_data_file_path=ibdata1:12minnodb_buffer_pool_size=10ginnodb_buffer_pool_ Instances=4innodb_log_files_in_group=2innodb_log_file_size=1ginnodb_log_buffer_size=200minnodb_flush_log_at_ Trx_commit=1innodb_additional_mem_pool_size=20minnodb_max_dirty_pages_pct=60innodb_io_capacity=1000innodb_ Thread_concurrency=16innodb_read_io_threads=8innodb_write_io_threads=8innodb_open_files=60000innodb_file_ Format=barracudainnodb_fIle_per_table=1innodb_flush_method=o_directinnodb_change_buffering=insertsinnodb_adaptive_flushing=1innodb_old _blocks_time=1000innodb_stats_on_metadata=0innodb_read_ahead=0innodb_use_native_aio=0innodb_lock_wait_timeout= 5innodb_rollback_on_timeout=0innodb_purge_threads=1innodb_strict_mode=1transaction-isolation=read-committed # MYISAMKEY_BUFFER=64MMYISAM_SORT_BUFFER_SIZE=64MCONCURRENT_INSERT=2DELAYED_INSERT_TIMEOUT=300 # replicationmaster-info-file=/u01/mysql/log/master.inforelay-log=/u01/mysql/log/relaylogrelay_log_info_file=/ u01/mysql/log/relay-log.inforelay-log-index=/u01/mysql/log/mysqld-relay-bin.indexslave_load_tmpdir=/u01/mysql/ tmpslave_type_conversions= "All_non_lossy" Slave_net_timeout=4skip-slave-startsync_master_info=1000sync_relay_ log_info=1000 #binloglog-bin=/u01/mysql/log/mysql-bin#server_id=2552763370binlog_cache_size=32kmax_binlog_cache _size=2gmax_binlog_size=500mbinlog-format=rowsync_binlog=1000log-slave-updates=1expire_logs_days=0 # Serverdefault-storage-engine=innodbcharacter-set-server=gbklower_case_table_names=1skip-external-lockingopen_files_limit= 65536safe-user-createlocal-infile=1#sqlmod= "Strict_all_tables,no_zero_in_date,no_zero_date" performance_schema= 0 log_slow_admin_statements=1log_warnings=1long_query_time=1slow_query_log=1general_log=0 query_cache_type= 0query_cache_limit=1mquery_cache_min_res_unit=1k table_definition_cache=65536#table_cache=65536 thread_stack= 512kthread_cache_size=256read_rnd_buffer_size=128ksort_buffer_size=256kjoin_buffer_size=128kread_buffer_size= 128K Port=3306skip-name-resolveskip-sslmax_connections=4500max_user_connections=4000max_connect_errors=65536max _allowed_packet=128mconnect_timeout=8net_read_timeout=30net_write_timeout=60back_log=1024

The ServerID is automatically generated in an automated installation script.

Copy the above Data.tar, MY.CNF, and generated RPM packages to the FTP pub directory

/var/ftp/pub/

Automated Installation Scripts

Auto_install_mysql.sh:

#!/bin/shyum install-y cmake gcc g++ bisonncurses-devel zlib ftp-n<<eofopen 192.168.0.33user Anonymous Dexterbinar YCD pubpromptmget *eof rpm-ivh mysql-rpm-5.6.21-renfengjun.x86_64.rpmtar-xvf data.tar-c/u01/mysql/data/chown-r MySQL : mysql/u01/mysql/unique_id= ' date ' +%y%m%d%m%s "' echo ' server_id= ' $unique _id >> my.cnf CP my.cnf/u01/mysql/


To perform a remote automatic installation command

Execute remote copy (DCLI command is I take out from the inside of the script, py write, in fact, and SCP almost, there is need to send email)

If you are installing in bulk, you need to initialize SSH with the-k option first.

Copy the script to a remote

[Email protected] ~]#/dcli-l root-c192.168.0.36-f./auto_install_mysql.sh

Execute remote command, can also be placed in the background

[Email protected] ~]#./dcli-l root-c192.168.0.36/root/auto_install_mysql.sh

Output:

[[[Email protected] ~]#./dcli-l root-c192.168.0.36/root/get_rpm.sh[email protected] ' s password : 192.168.0.36:address 192.168.0.36 Maps Tolocalhost, but this does no map back to the address-possible break-inattempt !192.168.0.36:loaded plugins:fastestmirror,security192.168.0.36:loading mirror speeds from cachedhostfile192.168.0.36: * base:mirrors.btte.net192.168.0.36: * extras:mirrors.btte.net192.168.0.36: * Updates: Mirrors.yun-idc.com192.168.0.36:setting up Install process192.168.0.36:packagecmake-2.6.4-5.el5.4.x86_64 already Installed and latest Version192.168.0.36:package Gcc-4.1.2-55.el5.x86_64already installed and latest Version192.168.0.36:no Package g++ available.192.168.0.36:package Bison-2.3-2.1.x86_64already installed and latest Version192.168.0.36:packagencurses-devel-5.5-24.20060715.x86_64 already installed and latest version192.168.0.36: Packagencurses-devel-5.5-24.20060715.i386 already installed and latest Version192.168.0.36:package zlib-1.2.3-7.el5.x86_64already installed and latest Version192.168.0.36:package Zlib-1.2.3-7.el5.i386already installed and Latest version192.168.0.36:nothing to Do192.168.0.36:please login with USER and Pass.192.168.0.36:please login with use R and Pass.192.168.0.36:kerberos_v4 rejected as anauthentication type192.168.0.36:interactive mode OFF.192.168.0.36:PR Eparing ################################################# #192.168.0.36:mysql-rpm ###### ############################################.......


End.

Verify

[[email protected] ~]# service mysql startstarting mysql ......... .......  [OK]  [[email protected] ~]# su-mysqlmys[[email protected] ~]$ mysqlwelcome to the MySQL Monitor. Commands End With; or \g.your MySQL connection ID is 1Server version:5.6.21-r5436-log sourcedistribution Copyright (c) d/or itsaffiliates. All rights reserved. Oracle is a registered trademark of oraclecorporation and/or itsaffiliates. Names may trademarks Oftheir Respectiveowners. Type ' help ', ' or ' \h ' for help. Type ' \c ' toclear the current input statement. [Email protected] (none) 12:29:11>show databases; +--------------------+| Database |+--------------------+| Information_schema | | Dexdb | | MySQL | | Performance_schema | | Test |+--------------------+5 rows in Set (0.37 sec) [email protected] (none) 12:29:14>use dexdb;D at Abase changed[email protected] 12:29:17>select * from T; +------+------------+|    ID |name |+------+------------+| 1 |renfengjun |+------+------------+1 row in Set (0.19 sec) [email protected] 12:29:19>quitbye [[email  Protected] ~]# service MySQL stopshutting down MySQL. [OK]


More rough, there is a need to improve the place. Slowly improve it.

Automating the deployment of MySQL 5.6 steps

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.