MySQL multi-instance installation script

Source: Internet
Author: User

#! /bin/bash# v.mysql-5.6.30-linux-glibc2.5-x86_64.tar.gz# only install master  Mysql# time:2016-08-15# pkg dirpkg_dir= ' pwd ' # mysql base dirdata_dir= "/data/ Mysql_root/mysql "base_dir="/usr/local/mysql "# create mysql group and userecho " Start create mysql group and user " >> ${pkg_dir}/install.loggroupadd  mysqluseradd -g mysql mysql  -s /sbin/nologinecho  "End mysql  group and user " >> ${pkg_dir}/install.log# mysql datafile path#  install mysqld # grant privilegesmkdir -p ${data_dir}/data 2>/dev/ Nullchown -r mysql:mysql ${data_dir}/data# un_tar.gz and install mysql  programmerecho  "start un_tar.gz ..."  >> ${pkg_dir}/install.logcd ${pkg_dir } && tar -xf mysql-5.6.30-linux-glibc2.5-x86_64.tar.gz  -c /usr/local && cd  /usr/local && mv mysql-5.6.30-linux-glibc2.5-x86_64 mysql;echo  "End  install mysql "  >> ${pkg_dir}/install.logecho " set mysql my.cnf  params " >> ${pkg_dir}/install.log# stored mysqld multi execute  Logmkdir -p ${base_dir}/multi_log 2>/dev/null# comm parameter of my.cnf  cat<<eof > ${base_dir}/my.cnf# the mysqld multi instance[mysqld_ multi]mysqld = ${base_dir}/bin/mysqld_safemysqladmin = ${base_dir}/bin/mysqladminlog  =${base_dir}/multi_log/mysqld_multi.log[mysqldump]quickmax_allowed_packet = 16m[mysql]no-auto-rehash [Myisamchk]key_buffer_size = 256msort_buffer_size = 256mread_buffer = 2mwrite_ buffer =  2m[mysqlhotcopy]interactive-timeouteof# other my.cnf parameter part pre_install_ Mysqld () {cat<<eof >> ${base_dir}/my.cnf# the mysql server[mysqld${port:2} ]port= ${port} socket= ${data_dir}/data${port}/mysql.socketmax-connections =  800skip-name-resolveskip-external-lockingkey_buffer_size = 384mmax_allowed_packet = 1073m  table_open_cache = 512sort_buffer_size = 512K read_buffer_size =  512kread_rnd_buffer_size = 512kjoin_buffer_size = 128kmyisam_sort_buffer_size =  64mthread_cache_size = 256query_cache_size = 0query_cache_type = 0tmp_table_size  = 64mmax_heap_table_size = 64mbasedir=${base_dir}datadir=${data_dir}/data${port}pid-file  = ${data_dir}/data${port}/mysql.pidlog_error = ${data_dir}/data${port}/mysql.err#  Set binary logging&nBsp;is required for replicationlog-bin=mysql-binbinlog_cache_size = 32m# event_ scheduler shutoff in mysqld slaveevent_scheduler = 1 binlog_format= Rowexpire_logs_days = 3# set slow logslow_query_log = 1long_query_time  = 2#set  character character_set_server = utf8#set  case sensitive lower_case_table_names=1#  Set mysqld server_idserver-id= ${port}# set innodb paramsinnodb_data_home_dir  = ${data_dir}/data${port} innodb_log_group_home_dir = ${data_dir}/data${port}  Innodb_buffer_pool_size = 5972minnodb_additional_mem_pool_size = 10minnodb_log_file_size  = 512Minnodb_log_buffer_size = 16Minnodb_flush_log_at_trx_commit = 2  innodb_flush_method = o_directinnodb_file_per_table = 1innodb_lock_wait_timeout =  10innodb_file_format = bArracudainnodb_file_format_max = barracudainnodb_stats_on_metadata = 0innodb_purge_threads  = 1innodb_read_io_threads = 12innodb_write_io_threads = 12innodb_purge_threads  = 1innodb_open_files = 500innodb_thread_concurrency = 0innodb_io_capacity  = 600[client]default-character-set = utf8eof# initizal mysql db chmod  +x ${base_dir}/scripts/mysql_install_db${base_dir}/scripts/mysql_install_db --basedir=${base_dir}  --datadir=${data_dir}/data${port} --user=mysql --defaults-file=${base_dir}/my.cnf > > ${pkg_dir}/install.logecho  "End mysqld install."  >> ${pkg_dir}/install.log}# mysql datafile pathfor port in 2016  3017 4018 5019 6020 do        # check  mysql base and data dir fOlder        if [ ! -d ${data_dir}/data${port}  ];then                 mkdir -p ${data_dir}/data${port}                 # function mysqld_install to mysql programmer                 pre_install_mysqld   $port         else                 pre_install_mysqld  $port          fidone#mysql datachown -r mysql:mysql ${data_dir}/datachown - r mysql:mysql ${base_dir}/data# environment variable echo  ' export path= $PATH:/usr/local/mysql/bin '  > >  /etc/profilesourCe /etc/profile 


This article from "Do not abandon!" Do not give up "blog, declined reprint!"

MySQL multi-instance installation script

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.