您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
这期内容当中小编将会给大家带来有关怎么在mysql中使用mysqld_multi部署一个单机,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。
一、mysql编译安装:
cd /usr/local/src wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz tar zxvf mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz mv mysql-5.6.35-linux-glibc2.5-x86_64 /usr/local/mysql cd /usr/local/mysql useradd mysql mkdir -p /data/mysql chown -R mysql:mysql /data/mysql ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql cp support-files/my-default.cnf /etc/my.cnf cp support-files/mysql.server /etc/init.d/mysqld
2.1 创建目录:
mkdir /usr/local/mysql3307 chown -R mysql.mysql /usr/local/mysql3307/ mkdir -p /data/mysql3307 chown -R mysql.mysql /data/mysql3307 mkdir -p /home/data/mysql3307/binlog chown -R mysql.mysql /home/data/mysql3307
2.2 配置文件
[root@zhdya01 ~]# vim /etc/my.cnf # For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the # *** default location during install, and will be replaced if you # *** upgrade to a newer version of MySQL. [mysqld_multi] mysqld = /usr/local/mysql/bin/mysqld_safe mysqladmin =/usr/local/mysql/bin/mysqladmin log =/var/log/mysqld_multi.log [mysqld1] socket = /usr/local/mysql3307/mysql.sock port = 3307 pid-file = /usr/local/mysql3307/mysql.pid datadir = /data/mysql3307 log_bin=/home/data/mysql3307/binlog server-id = 1 innodb_buffer_pool_size = 128M innodb_flush_log_at_trx_commit = 0
2.3 初始化数据库
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql3307
3.1 创建目录:
mkdir /usr/local/mysql3308 chown -R mysql.mysql /usr/local/mysql3308/ mkdir -p /data/mysql3308 chown -R mysql.mysql /data/mysql3308 mkdir -p /home/data/mysql3308/binlog chown -R mysql.mysql /home/data/mysql3308
3.2 配置文件
[root@zhdya01 ~]# vim /etc/my.cnf # For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the # *** default location during install, and will be replaced if you # *** upgrade to a newer version of MySQL. [mysqld_multi] mysqld = /usr/local/mysql/bin/mysqld_safe mysqladmin =/usr/local/mysql/bin/mysqladmin log =/var/log/mysqld_multi.log [mysqld1] socket = /usr/local/mysql3307/mysql.sock port = 3307 pid-file = /usr/local/mysql3307/mysql.pid datadir = /data/mysql3307 log_bin=/home/data/mysql3307/binlog server-id = 1 innodb_buffer_pool_size = 128M innodb_flush_log_at_trx_commit = 0 [mysqld2] socket = /usr/local/mysql3308/mysql.sock port = 3308 pid-file = /usr/local/mysql3308/mysql.pid datadir = /data/mysql3308 log_bin=/home/data/mysql3308/binlog server-id = 2 innodb_buffer_pool_size = 128M innodb_flush_log_at_trx_commit = 0
3.3 初始化数据库
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql3308
/etc/init.d/mysqld start mysqld_multi --defaults-extra-file=/etc/my.cnf start 1,2 [root@zhdya01 bin]# !net netstat -lntp -lntp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1241/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2087/master tcp6 0 0 :::3306 :::* LISTEN 4406/mysqld tcp6 0 0 :::3307 :::* LISTEN 4197/mysqld tcp6 0 0 :::3308 :::* LISTEN 3359/mysqld tcp6 0 0 :::8080 :::* LISTEN 2222/java tcp6 0 0 :::22 :::* LISTEN 1241/sshd tcp6 0 0 ::1:25 :::* LISTEN 2087/master
[root@zhdya01 bin]# mysqld_multi --defaults-extra-file=/etc/my.cnf report Reporting MySQL servers MySQL server from group: mysqld1 is running MySQL server from group: mysqld2 is running
[root@zhdya01 bin]# mysqld_multi --defaults-extra-file=/etc/my.cnf stop 1,2 [root@zhdya01 bin]# mysqld_multi --defaults-extra-file=/etc/my.cnf report Reporting MySQL servers MySQL server from group: mysqld1 is not running MySQL server from group: mysqld2 is not running
[root@zhdya01 bin]# mysql --socket=/usr/local/mysql3307/mysql.sock Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.6.35-log MySQL Community Server (GPL) Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
上述就是小编为大家分享的怎么在mysql中使用mysqld_multi部署一个单机了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注亿速云行业资讯频道。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。