MySQL二进制安装,升级,多实例部署

 多实例安装

#mkdir -p /mysqldata/node3

a) 初始化实例 使用脚本mysql_install_db

linuxidc@linuxidc:/tmp/mysqldata/node1$ /usr/local/mysql56/scripts/mysql_install_db --user=linuxidc --basedir=/usr/local/mysql56 --datadir=/tmp/mysqldata/node3 #查看 linuxidc@linuxidc:/tmp/mysqldata/node1$ ls ../node3 ibdata1 ib_logfile0 ib_logfile1 mysql performance_schema test

b) 给node3配置文件

cp my2.cnf my3.cnf vim my3.cnf(修改相关参数) [client] #password = your_password port = 3308 socket = /tmp/mysqldata/node3/mysql.sock [mysqld_safe] user=linuxidc ledir = /usr/local/mysql56/bin #ledir = /usr/local/mysql55/bin nice = 0 # Here follows entries for some specific programs # The MySQL server [mysqld] port = 3308 socket = /tmp/mysqldata/node3/mysql.sock pid-file = /tmp/mysqldata/node3/mysqld.pid basedir = /usr/local/mysql56 #basedir = /usr/local/mysql55 datadir = /tmp/mysqldata/node3 innodb_data_home_dir = /tmp/mysqldata/node3 innodb_log_group_home_dir = /tmp/mysqldata/node3 tmpdir = /tmp/mysqldata/node3 log-error = /tmp/mysqldata/node3/linuxidc.log log-bin = /tmp/mysqldata/node3/mysql-bin.log

c) 使用mysqld_safe,及my3.cnf拉起实例

linuxidc@linuxidc:/tmp/mysqldata/node3$ /usr/local/mysql56/bin/mysqld_safe --defaults-file=/tmp/mysqldata/node3/my3.cnf & [2] 9861 linuxidc@linuxidc:/tmp/mysqldata/node3$ 160806 22:03:17 mysqld_safe Logging to '/tmp/mysqldata/node3/linuxidc.log'. 160806 22:03:17 mysqld_safe Starting mysqld daemon with databases from /tmp/mysqldata/node3

d)查看

 

linuxidc@linuxidc:/tmp/mysqldata/node3$ ps -ef | grep mysqld linuxidc 9121 8547 0 21:29 pts/2 00:00:00 /bin/sh /usr/local/mysql56/bin/mysqld_safe --defaults-file=/tmp/mysqldata/my.cnf linuxidc 9489 9121 0 21:29 pts/2 00:00:02 /usr/local/mysql56/bin/mysqld --defaults-file=/tmp/mysqldata/my.cnf --basedir=/usr/local/mysql56 --datadir=/tmp/mysqldata/node1 --plugin-dir=/usr/local/mysql56/lib/plugin --log-error=/tmp/mysqldata/node1/linuxidc.log --pid-file=/tmp/mysqldata/node1/mysqld.pid --socket=/tmp/mysqldata/node1/mysql.sock --port=3306 linuxidc 9861 8547 0 22:03 pts/2 00:00:00 /bin/sh /usr/local/mysql56/bin/mysqld_safe --defaults-file=/tmp/mysqldata/node3/my3.cnf linuxidc 10327 9861 0 22:03 pts/2 00:00:00 /usr/local/mysql56/bin/mysqld --defaults-file=/tmp/mysqldata/node3/my3.cnf --basedir=/usr/local/mysql56 --datadir=/tmp/mysqldata/node3 --plugin-dir=/usr/local/mysql56/lib/plugin --log-error=/tmp/mysqldata/node3/linuxidc.log --pid-file=/tmp/mysqldata/node3/mysqld.pid --socket=/tmp/mysqldata/node3/mysql.sock --port=3308 linuxidc 10350 8547 0 22:04 pts/2 00:00:00 grep --color=auto mysqld 可以看到有两个端口的mysqld,分别是3306,3308

 

e) 登陆新实例,删除test库,空用户,设置root密码

 

linuxidc@linuxidc:/tmp/mysqldata/node3$ mysql -uroot --socket=/tmp/mysqldata/node3/mysql.sock Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.6.32-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. delete from msyql.user where user=''; delete from mysql.user where host<>'localhost'; set password for root@'localhost'=password('000000'); delete from mysql.db; drop database test; flush privileges;

 

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/2f125dbc76e1f9e006051889dc1bb719.html