MySQL5.6 Production Library Automation installation Deployment

Source: Internet
Author: User


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



Some basic installation information has been commented out in the script



This script enables 5.6 new features by default

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

Innodb_buffer_pool_load_at_startup=1

Turn on this two parameter and reload the hot data back after the database restarts.

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

Some parameters are corrected on demand, for example innodb_buffer_pool_size = 512M, this article gives the 512M, generally to the memory of 50%-80%.



Take a look at the specifics of the script
[email protected] ~]# cat mysql_auto_install.sh

######  binary Automatic installation database script root password manager put the script and installation package in the/root directory to #################### #数据库目录/usr/local/mysql############# # # # # # #数据目录/data/mysql################# #日志目录/log/mysql################# #端口号默认3306其余参数按需自行修改 ############ ### ############### #author: [Email protected]####################!/bin/bashpath=/bin:/sbin:/usr/bin:/usr/sbin :/opt/bin:/opt/sbin:~/binexportpath # checkif user is rootif [ $ (Id-u)  !=  "0"  ]; then    echo  "error: you must be " Root to runthis script, please use root to install "     exit 1fi clearecho "=========================================================================" echo "a tool to auto-compile & install mysql 5.6.25 on redhat/ Centos linux "echo" ========================================================================= "cur_dir=$ (pwd )   #setmysql &NBsp;root passwordecho  "==========================="  mysqlrootpwd= "MANAGER" echo -e  " Please input the root password of mysql: "read -p " (Default  Password: manager): " mysqlrootpwdif [ " $mysqlrootpwd " = " " ];  Thenmysqlrootpwd= "MANAGER" fiecho  "===========================" echo  "mysql root password:$ Mysqlrootpwd "echo " =========================== "  #whichMySQL  version do you want  to install?echo "==========================="  isinstallmysql56= "n" echo  "Install MySQL  5.6.25,please input y "read -p " (please input y , n): "  isinstallmysql56 case  "$isinstallmysql"  iny| y| yes| yes|yes|yes|yes| Yes|yes) echo  "you will install mysql 5.6.25" isinstallmysql56= "Y";; *) echo  "INPUT&NBSP;ERROR,YOU&NBSP;WILL&NBSP;EXIT&NBSP;INSTALL&NBSP;MYSQL&NBsp;5.6.25 "isinstallmysql56=" n "    exitesac get_char () {savedstty= ' stty -g ' Stty  -echostty cbreak#dd if=/dev/tty bs=1 count=1 2> /dev/nullstty - rawstty echostty  $SAVEDSTTY}echo  "" echo  "press any key to start...or  press ctrl+c to cancel "char= ' Get_char '   #Initialize   the installation  relatedcontent.functioninitinstall () {cat /etc/issueuname -amemtotal= ' free -m |  grep mem | awk  ' {print  $2} '  echo -e  ' \n memory is:  ${MemTotal} MB  "#Set  timezonerm -rf /etc/localtimeln -s /usr/share/ zoneinfo/asia/shanghai /etc/localtime       #Delete  old mysql  programrpm -qa|grep mysqlrpm -e mysql#yum -y remove mysql-server  mysql mysql-libs#yum -y remove php-mysql  #yum  -y install yum-fastestmirror#yum -y update   #Disable  SeLinuxif [ -s /etc/selinux/config ]; thensed -i  ' s/ Selinux=enforcing/selinux=disabled/g '  /etc/selinux/configfi    setenforce 0   }   #Installationof  depend on and optimization  Options.functioninstalldependsandopt () {cd$cur_dir cat>>/etc/security/limits.conf<<eof*  Softnproc 65535* hardnproc 65535* softnofile 65535* hardnofile 65535eof  echo "fs.file-max=65535"  >> /etc/sysctl.conf}  #InstallMySQLfunctionInstallMySQL56 () { echo "============================install mysql5.6.22==================================" cd$cur_dir # backupold my.cnf#rm -f/etc/my.cnfif [ -s/etc/my.cnf ]; then     mv /etc/my.cnf /etc/my.cnf. 'date+%y%m%d%h%m%s ' .bakfi  #mysqldirectory  configurationgroupaddmysql -g 512useradd -u  512 -g mysql -s /sbin/nologin -d /home/mysql mysqltar xvf / Root/mysql-5.6.25-linux-glibc2.5-x86_64.tar.gzmv /root/mysql-5.6.25-linux-glibc2.5-x86_64 /usr/local /mysqlmkdir -p /data/mysqlmkdir -p /log/mysqlchown -r mysql:mysql /data/ mysqlchown -r mysql:mysql /usr/local/mysqlchown -r mysql:mysql /log  #edit  /etc/my.cnfserverid= ' ifconfig eth0 | grep  "inet addr"  | awk  ' {  print $2} ' | awk -f.  ' { print $4 ' 3306 '} ' cat>>/etc/my.cnf<<eof[ Client]port = 3306socket = /tmp/mysql.sockdefault-character-set=utf8 [mysql] default-character-set=utf8 [mysqld]port = 3306socket = /tmp/mysql.sockbasedir =  /usr/local/mysqldatadir = /data/mysqlopen_files_limit = 3072back_log = 103max_connections =  800max_connect_errors = 100000table_open_cache = 512external-locking = falsemax_ Allowed_packet = 32msort_buffer_size = 2mjoin_buffer_size = 2mthread_cache_size  = 51query_cache_size = 32Mtmp_table_size = 96Mmax_heap_table_size =  96mslow_query_log = 1slow_query_log_file = /log/mysql/slow.loglog-error = /log/ mysql/error.loglong_query_time = 1server-id =  $SERVERIDlog-bin = mysql-binsync_ binlog = 1binlog_cache_size = 4mmax_binlog_cache_size = 8mmax_binlog_size =  1024mexpire_logs_days = 60key_buffer_size = 32mread_buffer_size = 1mread_ Rnd_buffer_size = 16mbulk_insert_buffer_size = 64mcharacter-set-server= utf8default-storage-engine =&Nbsp;innodbbinlog_format = rowinnodb_buffer_pool_dump_at_shutdown = 1innodb_buffer_pool_ load_at_startup = 1binlog_rows_query_log_events = 1explicit_defaults_for_timestamp =  1  #log_slave_updates =1#gtid_mode=on#enforce_gtid_consistency=1  #innodb_write_io_threads  =  8#innodb_read_io_threads = 8#innodb_thread_concurrency = 0 transaction_ Isolation = repeatable-readinnodb_additional_mem_pool_size = 16minnodb_buffer_pool_size  = 512minnodb_data_file_path = ibdata1:1024m:autoextendinnodb_flush_log_at_trx_commit  = 1innodb_log_buffer_size = 16minnodb_log_file_size = 512minnodb_log_files_in_ Group = 2innodb_max_dirty_pages_pct = 50innodb_file_per_table = 1innodb_locks_ unsafe_for_binlog = 0wait_timeout = 14400interactive_timeout =  14400skip-name-resolve[mysqldump]quickmax_allowed_packet = 32m eof    /usr/local/mysql/scripts/mysql_install_db -- Basedir=/usr/local/mysql --datadir=/data/mysql --defaults-file=/etc/my.cnf --user=mysql cp  /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqldchmod 700 /etc/init.d/ Mysqldchkconfig --add mysqldchkconfig --level 2345 mysqld on cat>>  /etc/ld.so.conf.d/mysql-x86_64.conf<<eof/usr/local/mysql/libeofldconfig if [ -d   "/proc/vz"  ];thenulimit -s unlimitedfi /etc/init.d/mysqld start  cat  >> /etc/profile <<eofexport path= $PATH:/usr/local/mysql/binexport ld_ Library_path= $LD _library_path:/usr/local/mysql/libeofsource /etc/profile /usr/local/mysql/bin/ mysqladmin -u root password  $mysqlrootpwd  cat > /tmp/mysql_sec_script <<eofuse mysql;delete from mysql.user where user!= ' root '  or host!= ' localhost '; grant all privileges  on *.* to   ' sys_admin ' @ '% '  identified by  ' MANAGER ';flush  privileges; eof /usr/local/mysql/bin/mysql -u root -p$mysqlrootpwd -h localhost <  /tmp/mysql_sec_script  #rm  -f /tmp/mysql_sec_script  /etc/init.d/mysqld  Restart    echo "============================mysql 5.6.25 install completed= ======================== "}  function checkinstall () {echo " ================================ ===== check install =================================== "clearismysql=" "echo" Checking ... "  if [ -s /usr/local/mysql/bin/mysql ] && [ -s /usr/local/mysql/ bin/mysqld_safe ] && [ -s /etc/my.cnf ]; then  echo  "Mysql: oK "  ismysql=" OK "  else  echo " error: /usr/local/mysql not  Found!!! Mysql install failed. " fi if [  "$ismysql"  =  "OK"  ]; thenecho  "install mysql 5.6.25"  completed! enjoy it. " echo  "=========================================================================" Netstat -ntlelseecho   "sorry,failed to install mysql!" echo  "You can tail /root/mysql-install.log from your server." fi}  #Theinstallation  loginitinstall 2>&1 | tee /root/ mysql-install.logcheckanddownloadfiles 2>&1 | tee -a /root/ mysql-install.loginstalldependsandopt 2>&1 | tee -a /root/ mysql-install.loginstallmysql56 2>&1 | tee -a /root/ Mysql-install.logcheckinstall 2>&1 | tee -a /root/mysql-instAll.log 


After executing the script, enter the user name password (the default manager) and log on to the database successfully.


650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M02/86/E1/wKioL1fOIHTQR5ktAAElfoh_FOg089.jpg-wh_500x0-wm_3 -wmp_4-s_2600275540.jpg "title=" capture. JPG "alt=" Wkiol1foihtqr5ktaaelfoh_fog089.jpg-wh_50 "/>


At this point, the MySQL5.6 installation is complete.

This article is from the "Age volt" blog, please make sure to keep this source http://suifu.blog.51cto.com/9167728/1846671

MySQL5.6 Production Library Automation installation Deployment

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.