生產(chǎn)庫自動(dòng)化MySQL5.6安裝部署詳細(xì)教程
自動(dòng)化運(yùn)維是一個(gè)DBA應(yīng)該掌握的技術(shù),其中,自動(dòng)化安裝數(shù)據(jù)庫是一項(xiàng)基本的技能,本文中的安裝腳本已通過測試,作為生產(chǎn)庫來說沒有問題,鑒于每個(gè)公司存儲(chǔ)規(guī)劃要求不同,可以按需自行修改腳本。
腳本中已經(jīng)注釋說明一些基本的安裝信息
本腳本默認(rèn)啟用5.6部分新特性
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ù)重新加載回去
只有正常關(guān)庫才會(huì)dump熱數(shù)據(jù)塊,宕機(jī)和kill -9不會(huì)
部分參數(shù)按需整改,例如innodb_buffer_pool_size = 512M,本文給的512M,一般給內(nèi)存的50%-80%。
來看一下腳本的具體情況[root@HE3 ~]# cat mysql_auto_install.sh
######二進(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ù)庫成功。
wKioL1fOIHTQR5ktAAElfoh_FOg089.jpg-wh_50
以上所述是小編給大家介紹的生產(chǎn)庫自動(dòng)化MySQL5.6安裝部署詳細(xì)教程,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
- MySQL自動(dòng)安裝批處理腳本實(shí)例代碼
- 詳解docker?制作mysql鏡像并自動(dòng)安裝腳本
- mysql8.0.14.zip安裝時(shí)自動(dòng)創(chuàng)建data文件夾失敗服務(wù)無法啟動(dòng)
- Linux下mysql5.6.24(二進(jìn)制)自動(dòng)安裝腳本
- MySQL的源碼安裝及使用UDFs進(jìn)行數(shù)據(jù)自動(dòng)更新的教程
- mysql一鍵安裝教程 mysql5.1.45全自動(dòng)安裝(編譯安裝)
- 集群運(yùn)維自動(dòng)化工具ansible使用playbook安裝mysql
- 分享MySQL的自動(dòng)化安裝部署的方法
- mysql自動(dòng)化安裝腳本(ubuntu and centos64)
- MySQL自動(dòng)安裝腳本代碼實(shí)例分享
相關(guān)文章
淺談mysql數(shù)據(jù)庫中的換行符與textarea中的換行符
下面小編就為大家?guī)硪黄獪\談mysql數(shù)據(jù)庫中的換行符與textarea中的換行符。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-01-01MySQL利用AES_ENCRYPT()與AES_DECRYPT()加解密的正確方法示例
MySQL中AES_ENCRYPT('密碼','鑰匙')函數(shù)可以對字段值做加密處理,AES_DECRYPT(表的字段名字,'鑰匙')函數(shù)解密處理,下面這篇文章主要給大家介紹了關(guān)于MySQL利用AES_ENCRYPT()與AES_DECRYPT()加解密的正確方法,文中給出了詳細(xì)的示例代碼,需要的朋友可以參考下。2017-08-08mysql中用于數(shù)據(jù)遷移存儲(chǔ)過程分享
mysql 數(shù)據(jù)遷移用的一個(gè)存儲(chǔ)過程,需要的朋友可以收藏下。2011-05-05linux下 root 登錄 MySQL 報(bào)錯(cuò)的問題
本文給大家記錄的是個(gè)人在linux下使用root用戶登錄mysql的時(shí)候遇到的一個(gè)錯(cuò)誤的解決方法,非常的簡單實(shí)用,有需要的小伙伴可以參考下。2016-02-02