MySQL5.6多实例安装
MySQL-5.6.36.tar.gz多实例安装
查看官方安装说明
more INSTALL-SOURCE
安装cmake及相关依赖包
yum install -y cmake gcc
[root@vhost1 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.0 (Maipo)
[root@vhost1 ~]# yum install ncurses-devel -y #使应用程序直接控制终端屏幕显示的库
创建用户和组
[root@vhost1 ~]#groupadd -g 200 mysql
[root@vhost1 ~]#useradd mysql -u 200 -s /sbin/nologin -M -g mysql
创建安装MySQL软件目录
[root@vhost1 ~]#mkdir -p /application/mysql-5.6.36
解压编译MySQL
[root@vhost1 ~]#cd mysql-5.6.36
[root@vhost1 mysql-5.6.36]#
cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.6.36 \
-DMYSQL_DATADIR=/application/mysql-5.6.36/data \
-DMYSQL_UNIX_ADDR=/application/mysql-5.6.36/tmp/mysql.sock \
-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITHOUT_PARTITION_STORAGE_ENGINE=1 \
-DWITH_FAST_MUTEXES=1 \
-DWITH_ZLIB=bundled \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_READLINE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DWITH_DEBUG=0 \
-DWITHOUT_PARTITION_STORAGE_ENGINE=0 \
[root@vhost1 mysql-5.6.36]# make && make install
#修改安装目录权限为mysql
[root@vhost1 ~]#cd /application
[root@vhost1 ~]#chown -R mysql .
[root@vhost1 ~]#chgrp -R mysql .
创建实例目录:
[root@vhost1 ~]#mkdir -p /mysqldata/3306/data
[root@vhost1 ~]#mkdir -p /mysqldata/3307/data
拷贝配置文件模板和启动脚本模板
[root@vhost1 mysql]# cp support-files/my-default.cnf /mysqldata/3306/my.cnf
[root@vhost1 mysql]# cp support-files/mysql.server /mysqldata/3306/mysql
修改权限
[root@vhost1 ~]#chown -R mysql.mysql /mysqldata/3306
[root@vhost1 ~]#chmod -R 755 /mysqldata/3306
修改配置文件
[root@vhost1 ~]#vi /mysqldata/3306/my.cnf
[mysqld]
user = mysql
basedir = /application/mysql
datadir = /mysqldata//data
port =
server_id =
socket = /mysqldata//data/mysql3306.sock
log-error = /mysqldata//mysql3306_error.log
pid-file = /mysqldata//mysql3306.pid
my.cnf
#初始化数据库实例
scripts/mysql_install_db --defaults-file=/mysqldata/3306/my.cnf
#启动数据库
bin/mysqld_safe --defaults-file=/mysqldata/3306/my.cnf &
#查看进程
ps aux |grep mysql
#命令行通过socket进入数据库
[root@vhost1 ~]#mysql -uroot -p -S /mysqldata/3306/mysql3306.sock
#修改脚本(官方给的太复杂,问题也多,下面是简化官方后的脚本)
[root@vhost1 ~]#vi /mysqldata/3306/mysql
#!/bin/sh basedir=/application/mysql
datadir=/mysqldata//data bindir=$basedir/bin
service_startup_timeout=
lsb_functions="/lib/lsb/init-functions"
if test -f $lsb_functions ; then
. $lsb_functions
else
log_success_msg()
{
echo " SUCCESS! $@"
}
log_failure_msg()
{
echo " ERROR! $@"
}
fi wait_for_pid () {
verb="$1" # created | removed
pid="$2" # process ID of the program operating on the pid-file
pid_file_path="$3" # path to the PID file. i=
avoid_race_condition="by checking again" while test $i -ne $service_startup_timeout ; do case "$verb" in
'created')
# wait for a PID-file to pop into existence.
test -s "$pid_file_path" && i='' && break
;;
'removed')
# wait for this PID-file to disappear
test ! -s "$pid_file_path" && i='' && break
;;
*)
echo "wait_for_pid () usage: wait_for_pid created|removed pid pid_file_path"
exit
;;
esac # if server isn't running, then pid-file will never be updated
if test -n "$pid"; then
if kill - "$pid" >/dev/null; then
: # the server still runs
else
# The server may have exited between the last pid-file check and now.
if test -n "$avoid_race_condition"; then
avoid_race_condition=""
continue # Check again.
fi # there's nothing that will affect the file.
log_failure_msg "The server quit without updating PID file ($pid_file_path)."
return # not waiting any more.
fi
fi echo $echo_n ".$echo_c"
i=`expr $i + `
sleep done if test -z "$i" ; then
log_success_msg
return
else
log_failure_msg
return
fi
} mysqld_pid_file_path=$datadir/../mysql3306.pid
mode=$ # start or stop
case "$mode" in
'start')
# Start daemon # Safeguard (relative paths, core dumps..)
cd $basedir echo $echo_n "Starting MySQL"
if test -x $bindir/mysqld_safe
then
# Give extra arguments to mysqld with the my.cnf file. This script
# may be overwritten at next upgrade.
$bindir/mysqld_safe --defaults-file=$datadir/../my.cnf >/dev/null >& &
wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$? # Make lock for RedHat / SuSE
if test -w "$lockdir"
then
touch "$lock_file_path"
fi exit $return_value
else
log_failure_msg "Couldn't find MySQL server ($bindir/mysqld_safe)"
fi
;; 'stop')
# Stop daemon. We use a signal here to avoid having to know the
# root password. if test -s "$mysqld_pid_file_path"
then
mysqld_pid=`cat "$mysqld_pid_file_path"` if (kill - $mysqld_pid >/dev/null)
then
echo $echo_n "Shutting down MySQL"
kill $mysqld_pid
# mysqld should remove the pid file when it exits, so wait for it.
wait_for_pid removed "$mysqld_pid" "$mysqld_pid_file_path"; return_value=$?
else
log_failure_msg "MySQL server process #$mysqld_pid is not running!"
rm "$mysqld_pid_file_path"
fi # Delete lock for RedHat / SuSE
if test -f "$lock_file_path"
then
rm -f "$lock_file_path"
fi
exit $return_value
else
log_failure_msg "MySQL server PID file could not be found!"
fi
;; 'restart')
# Stop the service and regardless of whether it was
# running or not, start it again.
if $datadir/../mysql stop $other_args; then
$datadir/../mysql start $other_args
else
log_failure_msg "Failed to stop running server, so refusing to try to start."
exit
fi
;; 'reload'|'force-reload')
if test -s "$mysqld_pid_file_path" ; then
read mysqld_pid < "$mysqld_pid_file_path"
kill -HUP $mysqld_pid && log_success_msg "Reloading service MySQL"
touch "$mysqld_pid_file_path"
else
log_failure_msg "MySQL PID file could not be found!"
exit
fi
;;
'status')
# First, check to see if pid file exists
if test -s "$mysqld_pid_file_path" ; then
read mysqld_pid < "$mysqld_pid_file_path"
if kill - $mysqld_pid >/dev/null ; then
log_success_msg "MySQL running ($mysqld_pid)"
exit
else
log_failure_msg "MySQL is not running, but PID file exists"
exit
fi
else
# Try to find appropriate mysqld process
mysqld_pid=`pidof $libexecdir/mysqld` # test if multiple pids exist
pid_count=`echo $mysqld_pid | wc -w`
if test $pid_count -gt ; then
log_failure_msg "Multiple MySQL running but PID file could not be found ($mysqld_pid)"
exit
elif test -z $mysqld_pid ; then
if test -f "$lock_file_path" ; then
log_failure_msg "MySQL is not running, but lock file ($lock_file_path) exists"
exit
fi
log_failure_msg "MySQL is not running"
exit
else
log_failure_msg "MySQL is running but PID file could not be found"
exit
fi
fi
;;
*)
# usage
echo "Usage: $datadir/../mysql {start|stop|restart|reload|force-reload|status}"
exit
;;
esac exit
mysql启动脚本
#脚本使用方法
[root@vhost1 ~]#chmod u+x /mysqldata/3306/mysql
[root@vhost1 ~]#/mysqldata/3306/mysql stop
MySQL5.6多实例安装的更多相关文章
- MySql5.7.* 多实例安装部署
参考文献: http://blog.csdn.net/tornadojava/article/details/53318773 http://blog.csdn.net/u013948858/arti ...
- mysql5.7多实例安装
[root@vhost1]# cd /opt/source[root@vhost1]#ls mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz[root@vhost1 ...
- mysql5.7单机多实例安装
基于之前的mysql5.7单实例安装 修改/etc/my.cnf文件如下(这里配置4个实例,可自行修改数目) # # 多实例配置文件,可以mysqld_multi --example 查看例子 # [ ...
- windows2008r2环境双实例安装mysql5.6
windows2008r2环境双实例安装mysql5.6 环境:windows2008 r2 标准版 1.默认安装了一个mysql5.6端口为3306 2.使用msi文件安装需要.net4.0支持,安 ...
- MySQL5.5多实例编译安装——多配置文件
一.什么是MySQL多实例?MySQL多实例简单的说就是在一台服务器上安装一套MySQL程序,通过不同的端口对外提供访问,多实例不仅节省物理主机成本,还有效提升了单台物理主机的CPU.磁盘I/O使用效 ...
- mysql5.6.40单实例安装二进制快捷安装
mysql5.6.40单实例安装二进制快捷安装 近期因不同环境需要不同版本的mysql实例,故为了方便操作,特此记录下来,方便自己查找. # 1.1.Centos最小化安装推荐常用依赖包 yum cl ...
- MySQL5.7单实例二进制包安装方法
MySQL5.7单实例二进制包安装方法 一.环境 OS: CentOS release 6.9 (Final)MySQL: mysql-5.7.20-linux-glibc2.12-x86_64.ta ...
- (转)mysql5.6.7多实例安装、配置的详细讲解分析及shell启动脚本的编写
一.mysql安装 1.下载mysql数据库源码包: wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.27.tar.gz 2.安装mys ...
- mysql5.7二进制包进行多实例安装
一.需求 在一台服务器上安装mysql5.7,并且部署两个实例:3306用于本机主库,3307用于其他MYSQL服务器的从库 二.下载mysql二进制包 [root@push-- src]# -lin ...
随机推荐
- Kubernetes kubeadm 安装记录
Kubernetes kubeadm 安装记录 注:比较乱,都是一些预见到的错误 kubernetes yum 源 cat /etc/yum.repos.d/kubernetes.repo [kube ...
- Sentinel限流实现原理
Sentinel限流的神秘面纱: 之前我们学习过限流比较主流的三种算法:漏桶,令牌桶,滑动窗口.而Sentinel采用的是最后一种,滑动窗口来实现限流的. 通过对Sentinel基础Api的使用,我们 ...
- 大牛总结的 Git 使用技巧,写得太好了!
作者:你喜欢吃青椒么 juejin.im/post/5d157bf3f265da1bcc1954e6 前言 本文是参考廖雪峰老师的Git资料再加上我自己对Git的理解,记录我的Git学习历程,作下此文 ...
- Python学习-第二天-字符串和常用数据结构
Python学习-第二天-字符串和常用数据结构 字符串的基本操作 def main(): str1 = 'hello, world!' # 通过len函数计算字符串的长度 print(len(str1 ...
- F. Fixing Banners
http://codeforces.com/gym/102394/problem/F F. Fixing Banners time limit per test 1 second memory lim ...
- (五:NIO系列) Reactor模式
出处:Reactor模式 本文目录 1. 为什么是Reactor模式 2. Reactor模式简介 3. 多线程IO的致命缺陷 4. 单线程Reactor模型 4.1. 什么是单线程Reactor呢? ...
- 输入某人出生日期(以字符串方式输入,如1987-4-1)使用DateTime和TimeSpan类,(1)计算其人的年龄;(2)计算从现在到其60周岁期间,总共多少天。
http://blog.csdn.net/w92a01n19g/article/details/8764116 using System;using System.Collections.Generi ...
- jQuery学习总结04-文档处理
1.append(content|fn) 说明:向每个匹配的元素内部追加内容. 这个操作与对指定的元素执行appendChild方法,将它们添加到文档中的情况类似. content(要追加到目标中的内 ...
- 2018-2-13-win-10-UWP-标签
title author date CreateTime categories win 10 UWP 标签 lindexi 2018-2-13 17:23:3 +0800 2018-2-13 17:2 ...
- kali优化配置(2)
下次再安Java吧...心累小赵在线哭泣... 0x01 安装显卡驱动 安装GPU,加速密码破解: grub--kali的启动器 0x02 并发线程限制 ulimit由于限制当前shell内进程的资源 ...