Mysql source code compilation and installation and master-slave asynchronous configuration in centos

Source: Internet
Author: User

Mysql source code compilation and installation and master-slave asynchronous configuration in centos

Installation machine: 10.11.1.193 and 10.11.1.194

Master/Slave synchronization mode: asynchronous Synchronization

Mysql version: mysql community5.6.28

Download the source code and decompress it:

Tar-zxf mysql-5.6.28.tar.gz

Cmake installation:


Environment required for installation and Compilation:

Sudo yum install make gcc-c ++ cmake bison-develncurses-devel libaio-devel net-tools perl


Compile and install mysql

Cmake-DCMAKE_INSTALL_PREFIX =/home/liyuming/mysql/mysqld-DCMAKE_INSTALL_DATADIR =/home/liyuming/mysqld/data-DWITH_DEBUG = 0-DMYSQL_MAINTAINER_MODE = 0

Execute the following commands in the source code directory in sequence.

Make distclean

Make-j 20

Make install

Remember not to execute rm-f CMakeCache.txt!

Initialize Database

Cd/home/liyuming/mysql/mysqld

Scripts/mysql_install_db -- user = mysql -- basedir =/home/liyuming/mysql/mysqld -- datadir =/home/liyuming/mysql/mysqld/data

Start Database

Edit the my. cnf and run. sh files

Run. sh Content:


My. cnf content:

File Path:

Start the Database Server

Sh run. sh server


 

 

Database Client

Sh run. sh client


 

 

Disable Database Server

Sh run. sh stop

Database optimization:

Append the following information to the my. cnf file.

Back_log = 1000

Wait_timeout = 3600

Max_connections = 3000

Thread_concurrency = 48

Default-storage-engine = InnoDB

Key_buffer_size = 8G

Innodb_buffer_pool_size = 40G

Innodb_additional_mem_pool_size = 1G

Innodb_log_buffer_size = 32 M

Query_cache_size = 40G

Read_buffer_size = 20 M

Sort_buffer_size = 20 M

Read_rnd_buffer_size = 20 M

Thread _ cache_size = 640

Restart Database Service after Configuration

Set Database Server initial information

Perform operations under the startup Database Server

Mysqladmin-u root password 'root'


Or

Mysqladmin-h 10.11.1.194-P 13306-u root password 'root'

Test

Mysql-uroot-proot

Mysql-hlocalhost-u root-p

OK

Mysql-h 10.11.1.193-P 13306-u root-p

At this time, jdbc cannot connect to mysql.

Solution:

./Mysqld_safe -- user = mysql -- skip-grant-tables -- skip-networking &


Open another client

In the installed bin directory

Mysql-uroot mysql

Updateuser set host = '%' where user = 'root ';

UPDATE user SET Password = PASSWORD ('root') where USER = 'root' and host = 'root' or host = 'localhost ';

UPDATE user SET Password = PASSWORD ('root') where USER = 'root ';

Deletefrom user where USER = '';

FLUSHPRIVILEGES;


Close the database normally.

Start the database server again, and everything can be used normally

Configure Master/Slave

Master-slave synchronization conditions:

Master:

A. Enable binary logs;

B. Select a server-id.

C. Create a user with the copy permission

Append the following information to the my. cnf file.

Server-id = 1

Log-bin = mysql-bin

Binlog-do-db = test

Binlog-ignore-db = mysql

Run the following command in the database:

Grant replication slave on *. * to 'slave '@ '10. 11.1.194 'identifiedby 'slave ';

Flush privileges;

Restart Database Service

Show masterstatus;


Slave:

A. Enable relay logs

B. Select a unique server-id.

C. Connect to the master server and Start copying data.

 

Append the following information to the my. cnf file.

Server-id = 2

Replicate-do-db = test

Run the following command in the database:

Stop slave;

Change master to master_host = '10. 11.1.193 ', master_port = 13306, master_user = 'slave', master_password = 'slave ';

Start slave;

Show slave status \ G;

Everything is OK!

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.