(编辑:jimmy 日期: 2024/11/13 浏览:2)
1.1 什么是Mysql多实例"htmlcode">
mkdir -p /data/{3307,3308} chown –R mysql.mysql /data
1.3.2 编写每个实例的配置文件:
[root@db01 ~]# cat /data/3307/my.cnf [mysqld] basedir=/application/mysql datadir=/data/3307 socket=/data/3307/mysql.sock log-error=/data/3307/mysql.log log_bin=/data/3307/mysql-bin binlog_format=row skip_name_resolve=1 server_id=3307 port=3307
1.3.3 初始化数据:
./mysql_install_db --defaults-file=/data/3307/my.cnf --basedir=/application/mysql --datadir=/data/3307 --user=mysql
1.3.4 启动实例:
sh mysqld_safe --defaults-file=/data/3307/my.cnf --pid-file=/data/3307/3307.pid &
shell脚本管理多实例服务:
#!/bin/bash . /etc/init.d/functions . /etc/profile Start='/application/mysql/bin/mysqld_safe --defaults-file=/data/3307/my.cnf --pid-file=/data/3307/3307.pid' Stop='mysqladmin -uroot -S /data/3307/mysql.sock shutdown' Port=`ss -tunlp|grep 3307|wc -l` function START(){ if [ $Port -ne 1 ];then $Start >/dev/null 2>&1 & sleep 3 if [ $"Usage: $0 {start|stop|restart}" ;; esac