mysql多实例安装脚本
#! /bin/bash
# v.mysql-5.6.30-linux-glibc2.5-x86_64.tar.gz
# only install master mysql
# time:2016-08-15 # pkg dir
pkg_dir=`pwd` # mysql base dir
data_dir="/data/mysql_root/mysql"
base_dir="/usr/local/mysql" # create MySQL group and user
echo "start create mysql group and user" >> ${pkg_dir}/install.log groupadd mysql
useradd -g mysql mysql -s /sbin/nologin echo "end mysql group and user" >> ${pkg_dir}/install.log # mysql datafile path
# install mysqld
# grant privileges
mkdir -p ${data_dir}/data 2>/dev/null
chown -R mysql:mysql ${data_dir}/data
# un_tar.gz and install mysql programmer
echo "start un_tar.gz..." >> ${pkg_dir}/install.log
cd ${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.log echo "set mysql my.cnf params" >> ${pkg_dir}/install.log # stored mysqld multi execute log
mkdir -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_safe
mysqladmin = ${base_dir}/bin/mysqladmin
log =${base_dir}/multi_log/mysqld_multi.log [mysqldump]
quick
max_allowed_packet = 16M [mysql]
no-auto-rehash [myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M [mysqlhotcopy]
interactive-timeout EOF # 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.socket
max-connections = 800
skip-name-resolve
skip-external-locking
key_buffer_size = 384M
max_allowed_packet = 1073M
table_open_cache = 512
sort_buffer_size = 512K
read_buffer_size = 512K
read_rnd_buffer_size = 512K
join_buffer_size = 128K
myisam_sort_buffer_size = 64M
thread_cache_size = 256
query_cache_size = 0
query_cache_type = 0
tmp_table_size = 64M
max_heap_table_size = 64M basedir=${base_dir}
datadir=${data_dir}/data${port} pid-file = ${data_dir}/data${port}/mysql.pid
log_error = ${data_dir}/data${port}/mysql.err # set binary logging is required for replication
log-bin=mysql-bin
binlog_cache_size = 32M # event_scheduler shutoff in mysqld slave
event_scheduler = 1
binlog_format=row
expire_logs_days = 3 # set slow log
slow_query_log = 1
long_query_time = 2 #set 字符
character_set_server = utf8 #set 大小写敏感 lower_case_table_names=1 # set mysqld server_id
server-id = ${port} # set innodb params
innodb_data_home_dir = ${data_dir}/data${port}
innodb_log_group_home_dir = ${data_dir}/data${port}
innodb_buffer_pool_size = 5972M
innodb_additional_mem_pool_size = 10M
innodb_log_file_size = 512M
innodb_log_buffer_size = 16M
innodb_flush_log_at_trx_commit = 2
innodb_flush_method = O_DIRECT
innodb_file_per_table = 1
innodb_lock_wait_timeout = 10
innodb_file_format = Barracuda
innodb_file_format_max = Barracuda
innodb_stats_on_metadata = 0
innodb_purge_threads = 1
innodb_read_io_threads = 12
innodb_write_io_threads = 12
innodb_purge_threads = 1
innodb_open_files = 500
innodb_thread_concurrency = 0
innodb_io_capacity = 600 [client]
default-character-set = utf8 EOF
# 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.log
echo "end mysqld install." >> ${pkg_dir}/install.log
} # mysql datafile path
for 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
fi
done #mysql data
chown -R mysql:mysql ${data_dir}/data
chown -R mysql:mysql ${base_dir}/data #环境变量
echo 'export PATH=$PATH:/usr/local/mysql/bin' >> /etc/profile
source /etc/profile
mysql多实例安装脚本的更多相关文章
- linux下mysql多实例安装
1.MySQL多实例介绍 1.1.什么是MySQL多实例 MySQL多实例就是在一台机器上开启多个不同的服务端口(如:3306,3307),运行多个MySQL服务进程,通过不同的socket监听不同的 ...
- linux下mysql多实例安装(转)
转自:http://www.cnblogs.com/xuchenliang/p/6843990.html 1.MySQL多实例介绍 1.1.什么是MySQL多实例 MySQL多实例就是在一台机器上 ...
- Mysql多实例安装+主从复制+读写分离 -学习笔记
Mysql多实例安装+主从复制+读写分离 -学习笔记 .embody{ padding:10px 10px 10px; margin:0 -20px; border-bottom:solid 1px ...
- Windows下MySQL多实例安装/主从复制/重置密码
Windows创建MySQL多实例 安装MYSQL和实例1 运行mysql-installer-community-5.7.16.0.msi 选择组件 MySQL Server 5.7.16 – X6 ...
- mysql多实例安装与ssl认证
mysql多实例安装有两种形式: 同一数据库版本的多实例安装. 不同数据库版本的多实例安装. 同一数据库的多实例安装: 在同一台机器上安装4台mysql数据库实例. 从官网下载MySQL5.6版本的二 ...
- Mysql多实例 安装以及配置
MySQL多实例 1.什么是MySQL多实例 简单地说,Mysql多实例就是在一台服务器上同时开启多个不同的服务端口(3306.3307),同时运行多个Mysql服务进程,这些服务进程通过不同的soc ...
- MySQL多实例安装教程
目录 MySQL的多实例 实验准备: 准备阶段: 实验阶段 MySQL的多实例 实验准备: 1. 一个干净的centos7系统 2. 关闭防火墙和selinux 3. 之前已经二进制安装过的MySQL ...
- windows下mysql多实例安装
在学习和开发过程中有时候会用到多个MySQL数据库,比如Master-Slave集群.分库分表,开发阶段在一台机器上安装多个MySQL实例就显得方便不少. 在 MySQL教程-基础篇-1.1-Wind ...
- mysql多实例安装详解
首先说明一个场景:我的电脑是ubuntu系统,之前apt-get自动安装过mysql.这也是出现错误最多的原因之一. 安装过程,其中充斥着各种错误: 6.mkdir mysql 7.groupadd ...
随机推荐
- doc2vec 利用gensim 生成文档向量
利用gensim 直接生成文档向量 def gen_d2v_corpus(self, lines): with open("./data/ques2_result.txt", &q ...
- mongodb csv 文件导入数据库,删除特定字段
1. 导入数据库 mongoimport -h host_ip -p port -d db_name -c collection_name --fields name1,name2,name3,nam ...
- android 技术相关Blog
android 技术相关 LVXIANGAN的专栏 http://blog.csdn.net/LVXIANGAN/article/category/1101038 Android NFC 开发实例 h ...
- PHP 连接 MSSQL
1 设置 2 php 代码: <?php header('Content-Type:text/html; charset=GBK'); define('DB_HOST','localhost') ...
- 九度OJ1085
说起这个题呢,就不得不提一种快速求解幂的算法——反复平方法,可以在O(logn)的复杂度完成求幂运算.具体思路我不说,巫泽俊大神翻译的<挑战程序设计竞赛>P123对此有详细描述. 但仅知道 ...
- List<Object>和List<String>
下面的代码在JAVA中是不可以的: import java.util.*; public class Test { public static void main(String[] args) { L ...
- 2013 ACM 通化邀请赛 A. Tutor
A. Tutor Description Lilin was a student of Tonghua Normal University. She is studying at University ...
- Chapter Data Modification & Chapter Data Validation
Chapter Data Modification XF的数据提交,支持单行.集合和多层次的master-details结构的数据. Create 当提交如下数据 <Job> <Id ...
- Js字符串与十六进制的相互转换
开发过程中,字符串与十六进.二进制之间的相互转换常常会用到,尤其是涉及到中文的加密时,就需要把中文转换为十六进制.下面说说具体的转换方法. 1.字符串转换为十六进制 主要使用 charCodeAt() ...
- ASP.NET MVC开发微信(四)