Production library automation MYSQL5.6 installation deployment detailed tutorial
Automated operation and maintenance is a technology that a DBA should master.Among them, the automated installation of a database is a basic skill.The installation scripts in this article have passed the test and there is no problem as a production library.In view of the storage planning requirements of each company Different, you can modify the script as needed.
Some basic installation information has been commented in the script
This script enables some new features in 5.6 by default
innodb_buffer_pool_dump_at_shutdown=1 It dumps not the data, but the ID number innodb_buffer_pool_load_at_startup=1
Turn on these two parameters and reload these hot data back when the database is restarted
The hot data block will only be dumped when the library is shut down normally, and not when downtime and kill -9
Some parameters need to be rectified, such as innodb_buffer_pool_size = 512M.The 512M given in this article is generally 50%-80% of the memory.
Look at the specific situation of the script[root@HE3 ~]# cat mysql_auto_install.sh p>
######Binary automatic installation database script root password MANAGER Put the script and installation package in the/root directory ############# ## ######Database directory/usr/local/mysql########## ## ######Data Directory/data/mysql############ ######Log directory/log/mysql############ ######The port number defaults to 3306 and the rest of the parameters are modified as needed ############ ################# #author:[email protected]# ################# #!/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"$isinstallmysql56"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 executing the script, enter the user name and password (default MANAGER) and log in to the database successfully.
wKioL1fOIHTQR5ktAAElfoh_FOg089.jpg-wh_50
The above is a detailed tutorial for the production database automation MySQL5.6 installation and deployment introduced by the editor.I hope it will be helpful to you.If you have any questions, please leave me a message.The editor will reply to you in time.Thank you very much for your support to the website!
0 Comments