MySQL binary package installation script and batch installation

Source: Internet
Author: User

#!/bin/bash

# # # #需要部署数据库的IP列表 # # #
#ip192.168.1.10
#ip192.168.1.11
#ip192.168.1.12
#ip192.168.1.13
# ip192.168.1.14
#ip192.168.1.15


##### #执行脚本前, please make sure that the Yum source is available, and that it can be used.
Cd/root
myb= mysql-5.6.24-linux-glibc2.5-x86_64.tar.gz
Ml= ' echo $myb |cut-d ' t '-f1|cut-d '. '-f1,2,3,4 '
#wget http:// dev.mysql.com/get/downloads/mysql-5.6/$myb
Mysql1=/opt/mysql
mysqldir=/usr/local
mysqldata=/data/ mysql/mysql3306
mkdir $mysql 1
CD $mysql 1
Tar xvf/root/$myb-C $mysql 1
groupadd MySQL && useradd-g m Ysql-s/sbin/nologin-d/usr/local/mysql mysql
cd $mysqldir
Rm-fr/usr/local/mysql
/bin/ln-s/opt/mysql/$ml m Ysql
Chown-r mysql:mysql mysql/
mkdir-p $mysqldata
CD $mysqldata && mkdir data logs tmp
Chown-r Mys Ql:mysql $mysqldata
Mv/etc/my.cnf/etc/my.cnf.bak &&: >/etc/my.cnf

########################## ############################# #mysql_profiles #####################################################

Cat >>/etc/my.cnf << EOF
[Client]
Port = 3306
Socket =/tmp/mysql.sock

# The MySQL server
[Mysqld]
# Basic
Port = 3306
user = MySQL
Basedir =/usr/local/mysql
DataDir =/data/mysql/mysql3306/data
Tmpdir =/data/mysql/mysql3306/tmp
Socket =/tmp/mysql.sock

Log-bin =/data/mysql/mysql3306/logs/mysql-bin
Log-error = Error.log
Slow-query-log-file = Slow.log
Skip-external-locking
Skip-name-resolve
Log-slave-updates

###############################
# for Percona 5.6
#extra_port = 3345
Gtid-mode = 0
#thread_handling =pool-of-threads
#thread_pool_oversubscribe =8
Explicit_defaults_for_timestamp
###############################

Server-id =3306
Character-set-server = UTF8
Slow-query-log
Binlog_format = row
Max_binlog_size = 128M
Binlog_cache_size = 1M
Expire-logs-days = 5
Back_log = 500
Long_query_time=1
max_connections=1100
max_user_connections=1000
max_connect_errors=1000
wait_timeout=100
interactive_timeout=100
Connect_timeout = 20
Slave-net-timeout=30
Max-relay-log-size = 256M

# InnoDB
Innodb_data_home_dir =/data/mysql/mysql3306/data
Innodb_log_group_home_dir =/data/mysql/mysql3306/logs
Innodb_data_file_path = Ibdata1:10m:autoextend
Innodb_buffer_pool_size = 100M
Innodb_buffer_pool_instances = 8
#innodb_additional_mem_pool_size = 16M
Innodb_log_file_size = 200M

Innodb_purge_threads=1
Innodb_purge_batch_size = 32
Innodb_old_blocks_pct=75
Innodb_change_buffering=all
Innodb_stats_on_metadata=off
[Mysqldump]
Quick
Max_allowed_packet = 128M
#myisam_max_sort_file_size = 10G
[MySQL]
No-auto-rehash
Max_allowed_packet = 128M
prompt = ' (product) \[email protected]\h [\d]> '
Default_character_set = UTF8


[Myisamchk]
Key_buffer_size = 64M
Sort_buffer_size = 512k
Read_buffer = 2M
Write_buffer = 2M


[Mysqlhotcopy]
Interactive-timeout
[Mysqld_safe]
#malloc-lib=/usr/local/mysql/lib/mysql/libjemalloc.so
Eof
############################################################################################################### ##############




Cd/usr/local/mysql
Yum-y Install Libaio
./scripts/mysql_install_db--defaults-file=/etc/my.cnf > $mysqldir/install.txt
Sleep 10
Cp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysql
echo "Export Path=path:mysqldir/mysql/bin" >>/etc/profile
Sed-i ' s#path:mysqldir# $PATH: $mysqldir #g '/etc/profile
Source/etc/profile


/etc/init.d/mysql start && echo "/etc/init.d/mysql start" >>/etc/rc.local

=========================================

Batch installation Scripts

!#/bin/bash

Mkdir/root/ipdir #存放本次操作服务器脚本目录
Sl= ' cat/root/mysqlinstall.sh |grep "#ip" |wc-l ' #IP数量
For i in ' seq 1 $sl ';d o
ip= ' cat/root/mysqlinstall.sh |grep "#ip" |cut-d "P"-f2|sed-n "$i" P "#获取本次操作IP
Cp-r/root/mysqlinstall.sh/root/ipdir# Copy the installation script to this operation server script directory
Sid= ' echo $ip |cut-d '. "-f4 ' #截取本次操作IP最后一位数
Osid= ' cat/root/mysqlinstall.sh |grep server-id '
Sed-r "s/$osid/server-id =" $sid "3306/g"/root/ipdir/mysqlinstall.sh# settings Server-id
Scp-r/root/ipdir/mysqlinstall.sh "$ip":/tmp# Copy the modified script to the remote server
SSH $ip ' chmod +x/tmp/mysqlinstall.sh && sh/tmp/mysqlinstall.sh & '
Done

MySQL binary package installation script and batch installation

Related Article

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.