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 ~]# ls
cmake-2.8.8.tar.gz  mysql-5.6.36.tar.gz
[root@vhost1 ~]# tar xf cmake-2.8.8.tar.gz
[root@vhost1 ~]# cd cmake-2.8.8
#cmake has bootstrapped.
[root@vhost1 cmake-2.8.8]# ./configure
[root@vhost1 cmake-2.8.8]# gmake
[root@vhost1 cmake-2.8.8]# gmake install

[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

[root@vhost1 ~]#ln -s /application/mysql-5.6.36/ /application/mysql

#修改安装目录权限为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多实例安装的更多相关文章

  1. MySql5.7.* 多实例安装部署

    参考文献: http://blog.csdn.net/tornadojava/article/details/53318773 http://blog.csdn.net/u013948858/arti ...

  2. mysql5.7多实例安装

    [root@vhost1]# cd /opt/source[root@vhost1]#ls mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz[root@vhost1 ...

  3. mysql5.7单机多实例安装

    基于之前的mysql5.7单实例安装 修改/etc/my.cnf文件如下(这里配置4个实例,可自行修改数目) # # 多实例配置文件,可以mysqld_multi --example 查看例子 # [ ...

  4. windows2008r2环境双实例安装mysql5.6

    windows2008r2环境双实例安装mysql5.6 环境:windows2008 r2 标准版 1.默认安装了一个mysql5.6端口为3306 2.使用msi文件安装需要.net4.0支持,安 ...

  5. MySQL5.5多实例编译安装——多配置文件

    一.什么是MySQL多实例?MySQL多实例简单的说就是在一台服务器上安装一套MySQL程序,通过不同的端口对外提供访问,多实例不仅节省物理主机成本,还有效提升了单台物理主机的CPU.磁盘I/O使用效 ...

  6. mysql5.6.40单实例安装二进制快捷安装

    mysql5.6.40单实例安装二进制快捷安装 近期因不同环境需要不同版本的mysql实例,故为了方便操作,特此记录下来,方便自己查找. # 1.1.Centos最小化安装推荐常用依赖包 yum cl ...

  7. MySQL5.7单实例二进制包安装方法

    MySQL5.7单实例二进制包安装方法 一.环境 OS: CentOS release 6.9 (Final)MySQL: mysql-5.7.20-linux-glibc2.12-x86_64.ta ...

  8. (转)mysql5.6.7多实例安装、配置的详细讲解分析及shell启动脚本的编写

    一.mysql安装 1.下载mysql数据库源码包: wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.27.tar.gz 2.安装mys ...

  9. mysql5.7二进制包进行多实例安装

    一.需求 在一台服务器上安装mysql5.7,并且部署两个实例:3306用于本机主库,3307用于其他MYSQL服务器的从库 二.下载mysql二进制包 [root@push-- src]# -lin ...

随机推荐

  1. 信息收集【采集点OWASP CHINA】网址http://www.owasp.org.cn/

    以下部分源于 安全家 http://www.anquanjia.net.cn/newsinfo/729480.html 资源虽多,优质却少.不要被信息海迷惑的心智,新人要想入门,除了优质的系统教学资源 ...

  2. [19/05/05-星期日] JDBC(Java DataBase Connectivity,java数据库连接)_mysql基本知识

    一.概念 (1).是一种开放源代码的关系型数据库管理系统(RDBMS,Relational Database Management System):目前有很多大公司(新浪.京东.阿里)使用: (2). ...

  3. 一个 Java 字符串到底有多少个字符?

    来源:http://dwz.win/jqd 依照Java的文档, Java中的字符内部是以UTF-16编码方式表示的,最小值是 \u0000 (0),最大值是\uffff(65535), 也就是一个字 ...

  4. MS COCO 数据集学习笔记(Common Objects in COntext)

    一.数据来源 COCO中图片资源均引用自Flickr图片网站 二.数据集创建目的 进行图像识别训练,主要针对以下三个方向: (1)object instances (2)object keypoint ...

  5. 最好用的 Kafka Json Logger Java客户端,赶紧尝试一下

    最好用的 Kafka Json Logger Java客户端. slf4j4json 最好用的 Kafka Json Logger 库:不尝试一下可惜了! Description 一款为 Kafka ...

  6. k3 cloud支付申请单下推付款单时候提示未将对象引用设置到对象的实例

    项目支付申请部门没有币别没有填写,没有把币别带过来才

  7. [译]理解 SwiftUI 里的属性装饰器@State, @Binding, @ObservedObject, @EnvironmentObject

    原文地址:https://mecid.github.io/2019/06/12/understanding-property-wrappers-in-swiftui/ @States 通过使用 @St ...

  8. 获取用户真实IP:(模拟:客户端--F5--nginx--tomcat 后端获取用户真实IP)

    模拟:客户端--F5--nginx--tomcat 后端获取用户真实IP 192.168.109.137 :nginx01(充当第一层代理==F5)192.168.109.138 :nginx02(二 ...

  9. MySQL concat函数里面单引号的使用

    通过concat拼字符串的时候,如果语句里面需要使用单引号,可以使用两个单引号来代替一个引号

  10. Springboot 默认cache

    1:Springboot 默认缓存为ConcurrentMapCacheManager(spring-context) 2:再启动类上开启缓存 @SpringBootApplication //相当于 ...