Install Multiple MySQL servers in a standalone Environment

Source: Internet
Author: User

I finally completed multiple mysqld configurations on a single machine. I used the mysqld_safe command to complete the configuration.

Step 1:

Install the database:

./Configure -- prefix =/usr/local/mysql-master

Make & make install

./Configure -- prefix =/usr/local/mysql-slave

Make & make install

 

Step 2: Copy two my_small.cnf files from the support-files folder of the source code file and put them in the/etc folder named my-master.cnf, my-slave.cnf

Step 3: Modify the mysqld section of the two configuration files. For example, my configuration file is as follows:

My-master.cnf:

 

Port = 3306

Socket =/tmp/mysql. sock

Skip-locking

Key_buffer = 16 K

Max_allowed_packet = 1 M

Table_cache = 4

Sort_buffer_size = 64 K

Read_buffer_size = 256 K

Read_rnd_buffer_size = 256 K

Net_buffer_length = 2 K

Thread_stack = 128 K

Pid-file =/var/run/mysqld. pid

 

Server-id = 1

Log-bin = mysql-bin

 

My-slave.cnf:

 

Port = 3307

Socket =/tmp/mysql2.sock

Skip-locking

Key_buffer = 16 K

Max_allowed_packet = 1 M

Table_cache = 4

Sort_buffer_size = 64 K

Read_buffer_size = 256 K

Read_rnd_buffer_size = 256 K

Net_buffer_length = 2 K

Thread_stack = 128 K

Pid-file =/var/run/mysqld/mysqld2.pid

 

Server-id = 2

 

Step 4: Execute

Sudo./mysql_install_db -- defaults-file =/etc/my-master.cnf

Sudo./mysql_install_db -- defaults-file =/etc/my-slave.cnf

 

Step 5: Modify the data directory permission, chown mysql: mysql-R var

Step 6: Create the pid file directory and modify the permission

Sudo mkdir/var/run/mysqld

Sudo chgrp mysql/var/run/mysqld

Sudo chmod g + w/var/run/mysqld

 

Finally, run the corresponding servers, such as mysql-master:

./Mysqld-safe -- defaults-file =/etc/my-master.cnf

Run the client

./Mysql -- defaults-file =/etc/my-master.cnf

 

Of course, we can also write the corresponding server startup statement into the script to start two servers at a time.

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.