Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Linux builds mysql master-slave service

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Found more than N information on the Internet, none of them can succeed smoothly, depressed, maybe the level is limited. After continuous research and testing, I complete the realization of starting two Mysql under linux, and have a more in-depth understanding of mysql. No more nonsense, let's go!

The steps are as follows:

First, compile and install two mysql, as follows

Download Mysql, here take Mysql-6.0.11-alpha.tar.gz as an example

Install the first database (primary database)

(the red part is the default database file path, which can be changed to other files such as data, var, etc.)

Tar zxvf mysql-6.0.11-alpha.tar.gz

Cdmysql-6.0.11-alpha

/ configure--prefix=/usr/local/mysql-- sysconfdir=/usr/local/mysql/etc--with-tcp-port=3306-- localstatedir=/usr/local/mysql/localstate--with-unix-socket-path=/tmp/mysql3306.sock-- with-charset=utf8-- with-collation=utf8_general_ci--with-extra-charsets=gbk,gb2312,binary-- enable-thread-safe-client--with-plugins=innobase-- with-mysqld-user=mysql-- with-charset=utf8-- with-client-ldflags=-all-static--with-mysqld-ldflags=-all-static

Make & & make install

Install the second database (from the database)

Tar zxvfmysql-6.0.11-alpha.tar.gz

Cdmysql-6.0.11-alpha

/ configure--prefix=/usr/local/mysql3307-- sysconfdir=/usr/local/mysql3307/etc--with-tcp-port=3307-- localstatedir=/usr/local/mysql3307/localstate-- with-unix-socket-path=/tmp/mysql3307.sock--with-charset=utf8-- with-collation=utf8_general_ci--with-extra-charsets=gbk,gb2312,binary-- enable-thread-safe-client--with-plugins=innobase-- with-mysqld-user=mysql-- with-charset=utf8-- with-client-ldflags=-all-static--with-mysqld-ldflags=-all-static

Make & & make install

To support all character sets to be modified to:-- with-extra-charsets=all

Initialize the database scripts separately (under the compilation directory)

Scripts/mysql_install_db--basedir=/usr/local/mysql/-user=mysql

Scripts/mysql_install_db--basedir=/usr/local/mysql3307/-user=mysql

Note: use the-- datadir=PATH parameter to specify the database file path, which defaults to compile time-- localstatedir

Third, modify the slave configuration file

Copy the configuration file:

Cp/usr/local/software/mysql-6.0.11-alpha/support-files/my-medium.cnf/usr/local/mysql/etc/my.cnf

Cp/usr/local/software/mysql-6.0.11-alpha/support-files/my-medium.cnf/usr/local/mysql3307/etc/my.cnf

4. Modify the my.cnf files of each database

The main contents are as follows:

Add InnoDB support:

[client]

# password = your_password

Port = 3307-- database port number

Socket = / tmp/mysqls.sock--sock file path

Default-character-set=utf8-client UTF8 connection

[mysqld]

Port = 3307-- database port number

Socket = / tmp/mysqls.sock-- sock file path

Default-storage-engine=INNODB

Default-character-set=UTF8-default character set

Init_connect='SETNAMES utf8'-connect with UTF8

Skip-name-resolve-cancel DNS reverse parsing

Lower_case_table_names=1-case-insensitive table names

Start the database (enter their respective directories)

Master:. / mysqld_safe&

From:. / mysqld_safe&

Configure to enable automatic:

Cp/usr/local/software/mysql-6.0.11-alpha/support-files/mysql.server/etc/init.d/mysql

Cp/usr/local/software/mysql-6.0.11-alpha/support-files/mysql.server/etc/init.d/mysql3307

Modify basedir and datadir in / etc/init.d/mysql3007 to be OK.

Basedir=/usr/local/mysql3307

Datadir=/usr/local/mysql3307/var

Stop the database

Master:. / mysqladminshutdown

From:. / mysqladminshutdown

All of the above configurations can be modified to meet business needs.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report