Mysql 5.7.21 Single-machine multi-instance installation

Source: Internet
Author: User
Tags mkdir ssl connection

  1. Download MySQL 5.7 Two package
    [[email protected] ~]# wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.21-linux-glibc2.5-x86_64.tar.gz

  2. Unzip the MySQL 5.7 binary package to the specified directory
    [[email protected] ~]# tar zxvf mysql-5.7.21-linux-glibc2.5-x86_64.tar.gz -C /usr/local/

  3. Create a MySQL soft link
    [[email protected] ~]# ln -s /usr/local/mysql-5.7.21-linux-glibc2.5-x86_64 /usr/local/mysql

  4. Create a MySQL user
    [[email protected] ~]# useradd -r -s /sbin/nologin mysql

  5. Create the Mysql-files directory in the MySQL binary package directory [MySQL data import/Export data exclusive directory]

    [[email protected] ~]# mkdir -v /usr/local/mysql/mysql-files mkdir: created directory `/usr/local/mysql/mysql-files‘
  6. Create a multi-instance data Catalog

    [[email protected] ~]# mkdir -vp /data/mysql_data{1..4} mkdir: created directory `/data‘ mkdir: created directory `/data/mysql_data1‘ mkdir: created directory `/data/mysql_data2‘ mkdir: created directory `/data/mysql_data3‘ mkdir: created directory `/data/mysql_data4‘
  7. To modify the user and owning group of the MySQL binary package directory
    [[email protected] ~]# chown root.mysql -R /usr/local/mysql-5.7.21-linux-glibc2.5-x86_64

  8. Modify MySQL Multi-instance data directory with data import/export exclusive directory for the owning user and owning group
    [[email protected] ~]# chown mysql.mysql -R /usr/local/mysql/mysql-files /data/mysql_data{1..4}

  9. Configuring the MySQL configuration file/etc/my.cnf

    [Mysqld_multi] mysqld =/usr/local/mysql/bin/mysqld mysqladmin =/usr/local/mysql/bin/mysqladminlog =/tmp/mysq L_multi.log [Mysqld1] # Set Data directory [must be different in multiple instances] DataDir =/data/mysql_data1# Settings sock store file name [must be different in multiple instances] socket =/tmp/mysql.sock1 # Set listening open port [must be different in multiple instances] port = 3306 # set Run user = MySQL # turn off monitoring performance_schema = off # set InnoDB cache size Innodb_buffer_poo L_size = 32M # Set Listener IP Address bind_address = 0.0.0.0 # Turn off DNS reverse Resolution skip-name-resolve = 0 [mysqld2] datadir =/data/mysql_data2soc Ket =/tmp/mysql.sock2 Port = 3307 user = MySQL Performance_schema = off innodb_buffer_pool_size = 32M bind_address = 0.0. 0.0 skip-name-resolve = 0 [mysqld3] datadir =/data/mysql_data3socket =/tmp/mysql.sock3 Port = 3308 user = MySQL perfor Mance_schema = off innodb_buffer_pool_size = 32M bind_address = 0.0.0.0 skip-name-resolve = 0 [mysqld4] datadir =/data/my Sql_data4socket =/tmp/mysql.sock4 Port = 3309 user = MySQL Performance_schema = off innodb_buffer_pool_size = 32M Bind_ad Dress = 0.0.0.0 Skip-namE-resolve = 0 
  10. Initializes each instance [the initialization completes with a random password in the output log]

      [[email protected] ~]#/usr/local/mysql/bin/mysqld-- Initialize--user=mysql--basedir=/usr/local/mysql--datadir=/data/mysql_data1 [[email protected] ~]#/usr/ Local/mysql/bin/mysqld--initialize--user=mysql--basedir=/usr/local/mysql--datadir=/data/mysql_data2 [[Email  protected] ~]#/usr/local/mysql/bin/mysqld--initialize--user=mysql--basedir=/usr/local/mysql--datadir=/ DATA/MYSQL_DATA3 [[email protected] ~]#/usr/local/mysql/bin/mysqld--initialize--user=mysql--basedir=/usr/ Local/mysql--datadir=/data/mysql_data4  
  11. Each instance turns on SSL connection

    [[email protected] ~]# /usr/local/mysql/bin/mysql_ssl_rsa_setup --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql_data1 [[email protected] ~]# /usr/local/mysql/bin/mysql_ssl_rsa_setup --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql_data2 [[email protected] ~]# /usr/local/mysql/bin/mysql_ssl_rsa_setup --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql_data3 [[email protected] ~]# /usr/local/mysql/bin/mysql_ssl_rsa_setup --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql_data4
  12. Copy the multi-instance script to the service Management directory [/etc/init.d/]
    [[email protected] ~]# cp /usr/local/mysql/support-files/mysqld_multi.server /etc/init.d/mysqld_multi

  13. Add Script Execution permissions
    [[email protected] ~]# chmod +x /etc/init.d/mysqld_multi

  14. Add in service Management
    [[email protected] ~]# chkconfig --add mysqld_multi

  15. Start test
  • Check for multiple instance status

    [[email protected] ~]# /etc/init.d/mysqld_multi report Reporting MySQL servers MySQL server from group: mysqld1 is not running MySQL server from group: mysqld2 is not running MySQL server from group: mysqld3 is not running MySQL server from group: mysqld4 is not running
  • Start Multi-instance
    [[email protected] ~]# /etc/init.d/mysqld_multi start

  • View multi-instance status

    Reporting MySQL servers MySQL server from group: mysqld1 is running MySQL server from group: mysqld2 is running MySQL server from group: mysqld3 is running MySQL server from group: mysqld4 is running
  • viewing instance listening ports

    [[email protected] ~]# netstat -lntp | grep mysqld tcp        0      0 0.0.0.0:3306        0.0.0.0:*                LISTEN      2673/mysqld        tcp        0      0 0.0.0.0:3307        0.0.0.0:*                LISTEN      2676/mysqld        tcp        0      0 0.0.0.0:3308        0.0.0.0:*                LISTEN      2679/mysqld        tcp        0      0 0.0.0.0:3309        0.0.0.0:*                LISTEN      2682/mysqld
    1. Connection test
  • Instance 1

      [[email protected] ~]#/usr/local/mysql/bin/mysql-s/tmp/mysql.sock1-p ' z+ilo*>s : 3kw ' mysql: [Warning] Using a password on the command line interface can is insecure.  Welcome to the MySQL Monitor. Commands End With; or \g. Your MySQL Connection ID is 6 Server version:5.7.18 Copyright (c) $, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of the Oracle Corporation and/or its affiliates. Other names trademarks of their respective owners. Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement. mysql> Set password = ' 123456 '; Query OK, 0 rows Affected (0.00 sec)  
  • Example 2

    [[email protected] ~]# /usr/local/mysql/bin/mysql -S /tmp/mysql.sock2  -p‘b*AHUrTgu1rl‘ mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor.  Commands end with ; or \g. Your MySQL connection id is 7 Server version: 5.7.18 Copyright (c) 2000, 2017, 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> set password = ‘123456‘; Query OK, 0 rows affected (0.00 sec)

    Original link: https://www.linuxidc.com/Linux/2017-07/145343.htm

Mysql 5.7.21 Single-machine multi-instance installation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.