二进制mariadb多实例
实验环境:
centos7.6 :IP: 192.168.99.110
1、首先下载二进制的压缩包,解压到一个指定的目录/hx/下
[root@centos7 hx]#tar xf mariadb-10.2.23-linux-x86_64.tar.gz
[root@centos7 hx]#ls
mariadb-10.2.23-linux-x86_64 mariadb-10.2.23-linux-x86_64.tar.gz mysqld
[root@centos7 hx]#mv mariadb-10.2.23-linux-x86_64 mysql
2、在/usr/local/mysql/目录内新建多实例数据库的几个目录:这里3个实例的端口号为:3344,3355,3366
[root@centos7 local]#mkdir -p ./mysql/{,,}/{etc,bin,log,socket,data,pid}
3、先创建一个系统用户mysql,然后使用二进制目录里的脚本生成各自的数据目录
[root@centos7 hx]#useradd -r -s /sbin/nolgoin -d /data/mysql mysql
[root@centos7 hx]#getent passwd mysql
mysql:x::::/data/mysql:/sbin/nolgoin
报错:提示缺少一个依赖的库文件,我们使用yum安装一下这个libaio

[root@centos7 hx]#/hx/mysql/scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql//data/ #第一个实例:指定用户和生成数据库的目录
Installing MariaDB/MySQL system tables in '/usr/local/mysql/3344/data/' ...
OK #有提示ok就说明成功了,也可以到/data/目录看一下
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
[root@centos7 hx]#/hx/mysql/scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/3344/data/ #第二个实例
Installing MariaDB/MySQL system tables in '/usr/local/mysql/3344/data/' ...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
[root@centos7 hx]#/hx/mysql/scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/3344/data/ #第三个实例
Installing MariaDB/MySQL system tables in '/usr/local/mysql/3344/data/' ...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
4、拷贝/etc/my.cnf配置文件到3个实例下的etc目录
cp /etc/my.cnf /usr/local/mysql//etc/
vim /usr/local/mysql/3344/etc/ #添加一下几行,修改完后再拷贝到其他几个实例的etc目录内

5、准备个简单的启动脚本,修改相应的参数拷贝到实例的bin目录内,并赋予执行权限
#!/bin/bash
#chkconfig:
port=
mysql_user="root"
mysql_pwd="xu"
cmd_path="/hx/mysql/bin/" #此处设置为二进制mariadb目录的路径
mysql_basedir="/usr/local/mysql/" #设置三个实例的路径
mysql_sock="${mysql_basedir}/${port}/socket/mysql.sock" #指定socket文件路径
function_start_mysql()
{
if [ ! -e "$mysql_sock" ];then
printf "Starting MySQL...\n"
${cmd_path}/mysqld_safe --defaults-file=${mysql_basedir}/${port}/etc/my.cnf &> /dev/null &
else
printf "MySQL is running...\n"
exit
fi
}
function_stop_mysql()
printf "MySQL is stopped...\n"
exit
else
printf "Stoping MySQL...\n"
${cmd_path}/mysqladmin -u ${mysql_user} -S ${mysql_sock} shutdown
fi
}
function_restart_mysql()
{
printf "Restarting MySQL...\n"
function_stop_mysql
sleep
function_start_mysql
}
case $ in
start)
function_start_mysql
;;
stop)
function_stop_mysql
;;
restart)
function_restart_mysql
;;
*)
printf "Usage: ${mysql_basedir}/${port}/bin/mysqld {start|stop|restart}\n"
esac
6、最后设置一下权限:二进制目录和mysql多实例的目录属主和数组都设置为mysql
通过脚本启动数据库,然后查看端口,3344,3355,3366三个实例都已经启动
[root@centos7 ]#ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN *: *:*
LISTEN 127.0.0.1: *:*
LISTEN ::: ### :::*
LISTEN ::: :::*
LISTEN ::: :::*
LISTEN ::: ### :::*
LISTEN ::: ### :::*
可以把二进制目录下的bin目录加入环境变量里,然后直接使用mysql -S 。 登录数据库时需要加 -S 指定socket文件进行登录,

二进制mariadb多实例的更多相关文章
- 在centos7环境下建立MariaDB多实例
环境全部基于vmware player 12 os: centos7 mariadb: mariadb-10.1.12-linux-x86_64.tar.gz 主要根据MariaDB给出的帮助文档,以 ...
- 将python图片转为二进制文本的实例
https://www.jb51.net/article/155342.htm 写在最前面: 我在研究机器学习的过程中,给的数据集是手写数字图片被处理后的由0,1表达的txt文件,今天写一写关于图片转 ...
- MySQL(mariadb)多实例应用与多实例主从复制
MySQL多实例 mysql多实例,简单理解就是在一台服务器上,mysql服务开启多个不同的端口(如3306.3307,3308),运行多个服务进程.这些 mysql 服务进程通过不同的 socket ...
- mariadb多实例搭建
测试环境基于centos7.2,腾讯云实验室,学习搭建! https://www.qcloud.com/developer 多实例mysql,能更加理解mysql安装的基本过程!及简单使用... ma ...
- MariaDB多实例的安装配置
初始化数据库: mysql_install_db --basedir=/var/lib/mysql --datadir=/data/3306/data --user=mysql mysql_inst ...
- mariadb多实例实现
环境:centos7,yum 安装mariadb5.5 mkdir /mysqldb/{3306,3307.3308}/{etc,socket,pid,log,data} -pv chown -R m ...
- Mariadb多实例启动脚本
#!/bin/bash port=3306 mysql_user="root" mysql_pwd="centos" cmd_path="/app/m ...
- 连接云MariaDB实例
新建实例 MariaDB CVM 内网连接 CVM远程登录测试(同一个VPC下): CVM安装客户端: yum install mysql 连接: mysql -h MariaDB内网ip -u 数据 ...
- MySQL并发复制系列三:MySQL和MariaDB实现对比
http://blog.itpub.net/28218939/viewspace-1975856/ 并发复制(Parallel Replication) 系列三:MySQL 5.7 和MariaDB ...
随机推荐
- Emgu-WPF学习使用 - 颜色映射
原文:Emgu-WPF学习使用 - 颜色映射 string sFile = ""; if (!String.IsNullOrEmpty(AppConstUtils.GDefault ...
- Qt 创建圆角、无边框、有阴影、可拖动的窗口 good
程序窗口的边框,标题栏等是系统管理的,Qt 不能对其进行定制,为了实现定制的边框.标题栏.关闭按钮等,需要把系统默认的边框.标题栏去掉,然后使用 Widget 来模拟它们.这里介绍使用 QSS + Q ...
- 利用WIX制作安装包(2)
原文 利用WIX制作安装包(2) 这一篇文章将为大家介绍如何使用WIX自定义UI.上一篇文章我们讲过WIX为我们提供了五种安装界面.每种安装界面都是由不同的Dialog组成.在这里我们挑选一种比较常用 ...
- 起调UWP的几种方法
原文:起调UWP的几种方法 由于种种原因吧,我需要使用一个WPF程序起调一个UWP程序,下面总结一下,给自己个备份. 启动UWP程序的关键是协议启动 给我们的UWP应用添加一个协议,like this ...
- Qt官方对OpenSSL的编译方法的描述,单独下载的Qt library则一般不带SSL(包括QT FAQ)
https://wiki.qt.io/MSYS2http://wiki.qt.io/Compiling_OpenSSL_with_MinGWhttps://wiki.qt.io/MinGW-64-bi ...
- python chrome selenium
#coding=utf-8 from selenium import webdriver options = webdriver.ChromeOptions() options.add_argumen ...
- WinForm DataGridView制作表格
1. 将背景颜色改为白色 this.dataGridView1.BackgroundColor = Color.White; 或 2. 禁止启用添加,启用编辑,启用删除 this.dataGridV ...
- WPF修改窗体标题栏的颜色
WPF程序通常情况下没办法修改窗体标题栏的样式,包括标题栏的背景颜色. 不过借助一个叫Fluent.Ribbon的第三方控件,貌似可以修改标题栏的背景颜色. 可以通过NuGet来安装这个控件:Inst ...
- Advanced Installer,搜索注册表,根据注册表选择安装路径
原文:Advanced Installer,搜索注册表,根据注册表选择安装路径 又停了一段时间没有更新了,今天上博客,发现有位朋友就打包的时候需要搜索注册表(不同版本注册表路径不一致,需要搜索多次来确 ...
- UWP SQLite的使用
原文:UWP SQLite的使用 1.准备工作 1.首先我们要给项目添加"SQLite for Universal Windows Platform"扩展 点击菜单栏的" ...