Server basic Environment:
Two centos6.4, iptables diabled, SELinux disabled
The hosts analysis of the two units
MySQL installation (two identical operations):
MySQL Users and Groups
#groupadd MySQL
#useradd-R-G MySQL MySQL
MySQL's various usage directories
Data Catalog mount point:/data
Database Base directory:/usr/local/mysql
Database configuration file Location:/etc/my.cnf
Database Data Catalog:/data/mysql
InnoDB data and InnoDB log directory:/data/mysql
#mkdir/data/mysql
#mkdir/usr/local/mysql
MySQL Decompression
#tar zxvf/home/mysql-5.5.9.tar.gz-c/data
MySQL Compilation
#cmake. \
>-dcmake_install_prefix=/usr/local/mysql/\
>-dmysql_datadir=/data/mysql/\
>-dwith_innobase_storage_engine=1 \
>-denabled_local_infile=1 \
>-dmysql_tcp_port=3306 \
>-dextra_charsets=all \
>-ddefault_charset=utf8 \
>-DDEFAULT_COLLATION=UTF8-GENERAL_CI \
>-dwith_debug=
Enter
#make && make Install
MySQL configuration file
#cd/usr/local/mysql
#cp/data/mysql-5.5.9/support-files/my-medium.cnf/etc/my.cnf
MySQL startup script
#cp/data/mysql-5.5.9/support-files/mysql.server/etc/init.d/mysqld
#chmod +x/etc/init.d/mysqld
Initializing the database
#cd/usr/local/mysql
#./usr/local/mysql/scripts/mysql_install_db--user=mysql--ldata=/data/mysql
Start MySQL
#/etc/init.d/mysqld start
Set Root password
#mysql-uroot-p//At the time is the wood has the password direct return will be OK
Mysql>update Mysql.user set Password=password ("password") where user= "root";
MYSQ is the database name, user is the table name
Mysql>flush privileges;
Master-Slave configuration:
Primary server Configuration
Mysql>grant replication Slave on * * to ' mysql ' @ ' from server IP ' identified by ' password ';
Mysql>show Master status;
#vim/ETC/MY.CNF//need to change two places
Log-bin=mysql-bin//In general This is the display, Log-bin must be set to Mysql-bin, this entry to MySQL will produce many similar mysql-bin.00001 files, these files are mainly used to record data recovery, The operation of synchronizing data between master and slave servers. If you do not make the high availability, this option can be banned, so as not to affect system performance.
Server-id = 144//server-id is the thread used to identify the server, classes such as MySQL are highly available, the master thread and the slave thread use this to indicate. The ID of the master must be different (otherwise your I/O process will fail to communicate), even if it is a master n standby, then the ID of the n is the same.
From server settings
#vim/ETC/MY.CNF//need to change two places
Log-bin=mysql-bin
Server-id = 145
Mysql>change Master to master_host= ' master server IP ', master_user= ' MySQL ', master_password= ' password ';
Mysql>start slave
Mysql>show slave Status\g
I/O Processes and SQL threads must all communicate successfully!!!! Master ready to sync!!!
MySQL High availability (master standby)