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. MyBatis Generator 生成的example 使用 and or 简单混合查询

    MyBatis Generator 生成的example 使用 and or 简单混合查询 参考博客:https://www.cnblogs.com/kangping/p/6001519.html 简 ...

  2. EasyUI选项卡避免重复打开

    前台代码: <div data-options="region:'west',title:'我的工作平台',split:true,iconCls:'icon-desk'"  ...

  3. 史上最全的ORACLE基础教程

    ORACLE命令和语句挺多,全部记忆下来不现实,况且有不常用的指令.下面把大部分的指令做了记录和详细的注释.建议收藏.转发此篇文章,如果忘记可以翻出来查查.关注公众号it_learn获取更多学习资源 ...

  4. Python 中的 os 模块常见方法?

    os.remove() 删除文件 os.rename() 重命名文件 os.walk() 生成目录树下的所有文件名 os.chdir() 改变目录 os.mkdir/makedirs 创建目录/多层目 ...

  5. neo4j 基本语法笔记(全)

    按照总监要求看了两天的neo4j 数据库的使用.在网上找了一个基础教程类似于w3c.school的网站(英文 ,中文,中文的翻译的不是很好,如果英文不好可以辅助理解),这个教程基础知识很全全面,从数据 ...

  6. Eureka注册中心高可用及常用配置项

    一.前言 前面已经简单的介绍了 Eureka 注册中心的使用以及查看.下面将继续进行 Eureka 的说明以及应用. 二.Eureka 的高可用搭建 在实际生产项目中,为了保证服务的可用性,连续性,一 ...

  7. git Windows终端安装教程

    1.下载网址:https://gitforwindows.org/ 2.双击压缩包出现: 3.点击下一步后,选择安装路径: 根据自己的需求选择路径 4.选择安装的组件,建议全选 [每一条解析:] Ad ...

  8. 帝国CMS模板中的多条件筛选方法

    需求:点击某一条目,调出与该条目关键词相关的类似词条数据 要点: 1.帝国CMS灵动标签使用   [e:loop= 2.专题关键词筛选  enewszt 3.SQL语句筛选   select * fr ...

  9. javaScript基础--概念以及使用

    1.什么javascript? 为什么要学习? 处理网站动态特效 为后期课程打基础 什么是javascript? 是一个客户端的具有安全性的脚本语言. js和h5 的关系 :  都是向静态的元素动起来 ...

  10. sqlserver sp_who2和inputbuffer的使用,连接数

    一.sp_who2的使用 1.存储过程的位置 sp_who官方解释地址:https://docs.microsoft.com/zh-cn/sql/relational-databases/system ...