• MySQL多实例配置


    1.1 准备配置文件

    [root@localhost ~]# mkdir /data/330{7..9}/data -p
    
    [root@localhost ~]# mkdir -p /data/mysql/binlog_330{7..9}
    
    [root@localhost ~]# chown -R mysql.mysql /data/*
    
    [root@localhost ~]# cat >> /data/3307/my.cnf <<EOF
    
    > [mysqld]
    
    > user=mysql
    
    > basedir=/usr/local/mysql8
    
    > datadir=/data/3307/data
    
    > socket=/tmp/mysql3307.sock
    
    > server_id=7
    
    > log_bin=/data/mysql/binlog_3307
    
    > port=3307
    
    > EOF
    
     
    
    [root@localhost ~]# cat >> /data/3308/my.cnf <<EOF
    
    > [mysqld]
    
    > user=mysql
    
    > basedir=/usr/local/mysql8
    
    > datadir=/data/3308/data
    
    > socket=/tmp/mysql3308.sock
    
    > server_id=8
    
    > log_bin=/data/mysql/binlog_3308
    
    > port=3308
    
    > EOF
    
     
    
    [root@localhost ~]# cat >> /data/3309/my.cnf <<EOF
    
    > [mysqld]
    
    > user=mysql
    
    > basedir=/usr/local/mysql8
    
    > datadir=/data/3309/data
    
    > socket=/tmp/mysql3309.sock
    
    > server_id=7
    
    > log_bin=/data/mysql/binlog_3309
    
    > port=3309
    
    > EOF

    1.2 初始化数据

    [root@localhost ~]# mysqld --initialize-insecure --user=mysql --datadir=/data/3307/data --basedir=/usr/local/mysql8
    
    [root@localhost ~]# mysqld --initialize-insecure --user=mysql --datadir=/data/3308/data --basedir=/usr/local/mysql8
    
    [root@localhost ~]# mysqld --initialize-insecure --user=mysql --datadir=/data/3309/data --basedir=/usr/local/mysql8

    1.3 准备启动脚本

    [root@localhost ~]# cat >> /etc/systemd/system/mysqld3307.service <<EOF
    
    > [Unit]
    
    > Description=MySQL Server
    
    > Documentation=man:mysqld(8)
    
    > Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
    
    > After=network.target
    
    > After=syslog.target
    
    > [Install]
    
    > WantedBy=multi-user.target
    
    > [Service]
    
    > User=mysql
    
    > Group=mysql
    
    > ExecStart=/usr/local/mysql8/bin/mysqld --defaults-file=/data/3307/my.cnf
    
    > LimitNOFILE = 5000
    
    > EOF
    
     
    
    [root@localhost ~]# cat >> /etc/systemd/system/mysqld3308.service <<EOF
    
    [Unit]
    
    Description=MySQL Server
    
    Documentation=man:mysqld(8)
    
    Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
    
    After=network.target
    
    After=syslog.target
    
    [Install]
    
    WantedBy=multi-user.target
    
    [Service]
    
    User=mysql
    
    Group=mysql
    
    ExecStart=/usr/local/mysql8/bin/mysqld --defaults-file=/data/3308/my.cnf
    
    LimitNOFILE = 5000
    
    EOF
    
     
    
    [root@localhost ~]# cat >> /etc/systemd/system/mysqld3309.service <<EOF
    
    [Unit]
    
    Description=MySQL Server
    
    Documentation=man:mysqld(8)
    
    Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
    
    After=network.target
    
    After=syslog.target
    
    [Install]
    
    WantedBy=multi-user.target
    
    [Service]
    
    User=mysql
    
    Group=mysql
    
    ExecStart=/usr/local/mysql8/bin/mysqld --defaults-file=/data/3309/my.cnf
    
    LimitNOFILE = 5000
    
    EOF

    1.4 启动多实例

    [root@localhost ~]# systemctl start mysqld3307
    
    [root@localhost ~]# systemctl start mysqld3308
    
    [root@localhost ~]# systemctl start mysqld3309
  • 相关阅读:
    Django基础
    Web框架
    JQuery
    16 Javascript
    axios+qs传值序列化时出现数组形式我们该如何修改呢?
    MyBatis 对象中含有对象的查询
    MyBatis 新增获取自增主键的小坑
    List、Set、Map
    事务的隔离级别
    mybatis配置中文参考文档
  • 原文地址:https://www.cnblogs.com/zh-dream/p/12953260.html
Copyright © 2020-2023  润新知