《Mysql實(shí)例生產(chǎn)庫自動(dòng)化MySQL5.6安裝部署詳細(xì)教程》要點(diǎn):
本文介紹了Mysql實(shí)例生產(chǎn)庫自動(dòng)化MySQL5.6安裝部署詳細(xì)教程,希望對(duì)您有用。如果有疑問,可以聯(lián)系我們。
自動(dòng)化運(yùn)維是一個(gè)DBA應(yīng)該掌握的技術(shù),其中,自動(dòng)化安裝數(shù)據(jù)庫是一項(xiàng)基本的技能,本文中的安裝腳本已通過測試,作為生產(chǎn)庫來說沒有問題,鑒于每個(gè)公司存儲(chǔ)規(guī)劃要求不同,可以按需自行修改腳本.MYSQL必讀
腳本中已經(jīng)注釋說明一些基本的安裝信息MYSQL必讀
本腳本默認(rèn)啟用5.6部分新特性MYSQL必讀
innodb_buffer_pool_dump_at_shutdown=1 它dump的不是數(shù)據(jù),是Id號(hào) innodb_buffer_pool_load_at_startup=1
開啟這個(gè)兩個(gè)參數(shù)當(dāng)數(shù)據(jù)庫重啟后把這些熱數(shù)據(jù)重新加載回去MYSQL必讀
只有正常關(guān)庫才會(huì)dump熱數(shù)據(jù)塊,宕機(jī)和kill -9不會(huì)MYSQL必讀
部分參數(shù)按需整改,例如innodb_buffer_pool_size = 512M,本文給的512M,一般給內(nèi)存的50%-80%.MYSQL必讀
來看一下腳本的具體情況[root@HE3 ~]# cat mysql_auto_install.shMYSQL必讀
######二進(jìn)制自動(dòng)安裝數(shù)據(jù)庫腳本root暗碼MANAGER將腳本和安裝包放在/root目錄即可############### ######數(shù)據(jù)庫目錄/usr/local/mysql############ ######數(shù)據(jù)目錄/data/mysql############ ######日志目錄/log/mysql############ ######端口號(hào)默認(rèn)3306其余參數(shù)按需自行修改############ ################## #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"$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
執(zhí)行腳本后,輸入用戶名暗碼(默認(rèn)MANAGER)后登錄數(shù)據(jù)庫成功.MYSQL必讀
wKioL1fOIHTQR5ktAAElfoh_FOg089.jpg-wh_50
以上所述是小編給大家介紹的生產(chǎn)庫自動(dòng)化MySQL5.6安裝部署詳細(xì)教程,希望對(duì)大家有所贊助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的.在此也非常感謝大家對(duì)維易PHP網(wǎng)站的支持!MYSQL必讀
維易PHP培訓(xùn)學(xué)院每天發(fā)布《Mysql實(shí)例生產(chǎn)庫自動(dòng)化MySQL5.6安裝部署詳細(xì)教程》等實(shí)戰(zhàn)技能,PHP、MYSQL、LINUX、APP、JS,CSS全面培養(yǎng)人才。
轉(zhuǎn)載請(qǐng)注明本頁網(wǎng)址:
http://www.snjht.com/jiaocheng/11961.html