Production Library Automation MySQL5.6 installation Deployment Detailed tutorial _mysql

Source: Internet
Author: User
Tags mkdir

Automated operations is a technology that DBAs should master, where automating the installation of databases is a basic skill, the installation scripts in this article have been tested, and as a production library there is no problem, and as each company's storage planning requirements are different, you can modify the script on demand.

Some basic installation information has been commented on in the script

The script defaults to enabling the 5.6-part new feature

Innodb_buffer_pool_dump_at_shutdown=1 It dump is not data, is the ID number
innodb_buffer_pool_load_at_startup=1

Turn on the two parameters and reload the hot data back when the database restarts.

Only normal Guanqu will dump hot data blocks, downtime and kill-9 will not

Some of the parameters on-demand rectification, such as Innodb_buffer_pool_size = 512M, this article gives 512M, generally to memory of 50%-80%.

Look at the specifics of the script [Root@he3 ~]# cat mysql_auto_install.sh

##### #二进制自动安装数据库脚本root密码MANAGER将脚本和安装包放在/root directory can ############### ##### #数据库目录/usr/local/mysql############ ###### Data Directory/data/mysql############ ##### #日志目录/log/mysql############ ##### #端口号默认3306其余参数按需自行修改 ############ ############## # #author: rrhelei@126.com# ################## #!/bin/bash Path=/bin:/sbin:/usr/bin:/usr/sbin:/opt/bin:/opt/sbin : ~/bin export PATH #Check ifuserisroot if[$ (id-u)!= "0"];then Echo error:youmustberoottorun Thisscript, Pleaseuseroottoinstall "Exit1 fi clear Echo" ====================================================================== = = = "echo" Atooltoauto-compile&installmysql5.6.25onredhat/centoslinux "echo" =================================
======================================== "cur_dir=$ (pwd) #set mysqlrootpassword echo" =========================== "
Mysqlrootpwd= "MANAGER" Echo-e "Pleaseinputtherootpasswordofmysql:" Read-p "(Defaultpassword:manager):" Mysqlrootpwd if["$mysqlrootpwd" = "];then mysqlrootpwd=" MANAGER "fi echo" =========================== "echo" MysqlrooTpassword: $mysqlrootpwd "echo" =========================== "#which mysqlversiondoyouwanttoinstall? echo "===========================" isinstallmysql56= "n" "echo" Installmysql5.6.25,pleaseinputy "Read-p" (Pleaseinputy , n): "Isinstallmysql56 case" $isinstallmysql "in y| y| yes| yes|yes|yes|yes|
Yes|yes) echo "YouwillinstallMySQL5.6.25" isinstallmysql56= "Y";
*) echo "inputerror,youwillexitinstallmysql5.6.25" isinstallmysql56= "n" Exit Esac Get_char () {savedstty= ' stty-g ' Stty-echo sttycbreak #ddif =/dev/ttybs=1count=12>/dev/null stty-raw sttyecho Stty$savedstty} echo "echo"
Pressanykeytostart...orpressctrl+ctocancel "Char= ' Get_char" # initializetheinstallationrelated content. function Initinstall () {cat/etc/issue uname-a memtotal= ' Free-m|grepmem|awk ' {print$2} ' echo-e ' \nmemoryis:${memtotal
}MB "#Settimezone rm-rf/etc/localtime ln-s/usr/share/zoneinfo/asia/shanghai/etc/localtime #DeleteOldMysqlprogram Rpm-qa|grepmysql rpm-emysql #yum-yremovemysql-servermysqlmysql-libs #yum-yremovephp-mysql #yum-yiNstallyum-fastestmirror #yum-yupdate #DisableSeLinux if[-s/etc/selinux/config];then sed-i ' s/selinux=enforcing/
Selinux=disabled/g '/etc/selinux/config fi setenforce0} #Installation ofdependonandoptimizationoptions.
function installdependsandopt () {CD $cur _dir cat >>/etc/security/limits.conf<>/etc/sysctl.conf} #Install MySQL function InstallMySQL56 () {echo "============================installmysql 5.6.22============================= ===== "CD $cur _dir #Backup oldmy.cnf #rm-F/etc/my.cnf if[-s/etc/my.cnf];then mv/etc/my.cnf/etc/my.cnf. ' Date +%Y%m%d%H%
m%s '. bak fi #mysql directoryconfiguration groupadd mysql-g512 useradd-u512-gmysql-s/sbin/nologin-d/home/mysqlmysql Tarxvf/root/mysql-5.6.25-linux-glibc2.5-x86_64.tar.gz mv/root/mysql-5.6.25-linux-glibc2.5-x86_64/usr/local/
MySQL mkdir-p/data/mysql mkdir-p/log/mysql chown-rmysql:mysql/data/mysql chown-rmysql:mysql/usr/local/mysql Chown-rmysql:mysql/log #edit/etc/my.cnf serverid= ' ifconfigeth0|grep ' inetaddr ' |awk ' {print$2} ' |awk-F. ' {Print$4 "3306"} ' cat >>/etc/my.cnf<>/etc/ld.so.conf.d/mysql-x86_64.conf<>/etc/profile</tmp/ Mysql_sec_script<&1|tee/root/mysql-install.log checkanddownloadfiles2>&1|tee-a/root/ Mysql-install.log Installdependsandopt2>&1|tee-a/root/mysql-install.log InstallMySQL562>&1|tee-a/ Root/mysql-install.log Checkinstall2>&1|tee-a/root/mysql-install.log

After the script is executed, the login database succeeds after entering the username password (default manager).

Wkiol1foihtqr5ktaaelfoh_fog089.jpg-wh_50

The above is a small set for you to introduce the production of automated MySQL5.6 installation deployment Detailed tutorial, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

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.