MySQL source compilation installation and primary and standby asynchronous configuration under CentOS

Source: Internet
Author: User
Tags mysql version

Installation machine: 10.11.1.193, 10.11.1.194

Primary and Standby Synchronization mode: Asynchronous synchronization

MySQL version: MySQL community5.6.28


Download the source code and unzip:

TAR-ZXF mysql-5.6.28.tar.gz



CMake Installation:




Install the required environment for compilation:

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




Compile and install MySQL

cmake-dcmake_install_prefix=/home/liyuming/mysql/mysqld-dcmake_install_datadir=/home/liyuming/mysql/mysqld/ Data-dwith_debug=0-dmysql_maintainer_mode=0

Execute the following command in the source directory in turn

Make Distclean

Make-j 20

Make install

Remember that you cannot perform rm-f cmakecache.txt!


Initializing the database

Cd/home/liyuming/mysql/mysqld

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

Start the database

Edit my.cnf and run.sh files

Content of run.sh:



Content of MY.CNF:



File path:



Start the database server

SH run.sh Server



Database client

SH run.sh Client



Shutting down the database server

SH run.sh stop



Database tuning:

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=32m

query_cache_size=40g

read_buffer_size=20m

sort_buffer_size=20m

read_rnd_buffer_size=20m

thread_cache_size=640

To restart the database service after configuration

Setting Database server Initial information

Operation under Start 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


JDBC is unable to connect to MySQL at this time.


Workaround:

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



Open a client again

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;



Then gracefully shut down the database



Start the database server again, everything is working

Configuring the Master and Standby

Conditions for master-slave synchronization:

Master:

A enable the binary log;

b Select a Server-id

C Create a user with copy permissions

Append the following information to the MY.CNF file

Server-id=1

Log-bin=mysql-bin

Binlog-do-db=test

binlog-ignore-db= MySQL

Execute in the database:

grant replication Slave on * *to ' slave ' @ ' 10.11.1.194 ' identifiedby ' slave ';

Flush privileges;

Restarting the database service

Show Masterstatus;



Slave:

A enable the relay log

B Choose 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

Execute 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;


All ok!

MySQL source compilation installation and primary and standby asynchronous configuration under CentOS

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.