MySQL source code installation and master-slave synchronization configuration

MySQL source code installation and master-slave synchronization configuration

Introduction to mysql:

MySQL is a relational database management system. Relative databases store data in different tables instead of putting all the data in a large warehouse, which increases speed and flexibility. The SQL language used by MySQL is the most commonly used standardized language for accessing databases.
The MySQL software adopts a dual-licensing policy. It is divided into a community version and a commercial version. Due to its small size, fast speed, and low total cost of ownership, especially the open source feature, the development of small and medium-sized websites generally chooses MySQL as the website database. Due to the excellent performance of its community version, it can form a good development environment with PHP and Nginx Apache

One, Mysql database installation

    yum  install  mariadb-server mariadb    mariadb-libs -y   CentOS7.x YUM安装                   

Second, the source code installation MYSQ, through cmake, make, make install three steps to achieve.

cd /usu/data/
wget -c http://ftp.ntu.edu.tw/MySQL/Downloads/MySQL-5.7/mysql-5.7.23.tar.gz 
wget -c http://downloads.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz
tar zxvf boost_1_59_0.tar.gz
mv boost_1_59_0 /usr/local/boost
yum install -y gcc-c++ ncurses-devel cmake make perl gcc autoconf automake zlib libxml2 libxml2-devel libgcrypt libtool bison
tar -xzf mysql-5.7.23.tar.gz
cd mysql-5.7.23
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql5/ \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DMYSQL_DATADIR=/data/mysql/ \
-DSYSCONFDIR=/etc \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306 \
-DWITH_XTRADB_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_EXTRA_CHARSETS=1 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DWITH_BIG_TABLES=1 \
-DWITH_DEBUG=0 \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=/usr/local/boost
make 
make install 
/usr/local/mysql5/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql5 --datadir=/data/mysql
cd ..
cd /usr/local/mysql55/ 
\cp support-files/my-large.cnf /etc/my.cnf
\cp support-files/mysql.server /etc/init.d/mysqld 
chkconfig --add mysqld 
chkconfig --level 35 mysqld on
mkdir  -p  /data/mysql
useradd  mysql
/usr/local/mysql55/scripts/mysql_install_db --user=mysql --datadir=/data/mysql/ --basedir=/usr/local/mysql55/
ln  -s  /usr/local/mysql55/bin/* /usr/bin/
 service  mysqld  restart

Three, mysql master-slave configuration

1)然后编辑vi /etc/my.cnf文件把前面# 号去掉

MySQL source code installation and master-slave synchronization configuration

2)重启MYSQL数据库/etc/init.d/mysqld restart
3)在主库上创建用于数据同步的账号并设密码

MySQL source code installation and master-slave synchronization configuration

4)在主库上执行grant replication slave on *.* to tongbu@'192.168.2.129' identified by "123456";授予从库连接主库权限
5) 刷新权限  flushprivileges;  
6)在主库上执行show master status;查看bin-log文件及position点

MySQL source code installation and master-slave synchronization configuration

7)在从库上安装好数据库后并编辑/etc/my.cnf文件如下图

MySQL source code installation and master-slave synchronization configuration

8)重启从库/etc/init.d/mysqld restart 并进入数据库执行如下命令

MySQL source code installation and master-slave synchronization configuration

9)然后执行show slave status \G;查看主从状态
10)在主库上创建bbs数据库然后在从库上查看已经同步过来了

MySQL source code installation and master-slave synchronization configuration

Guess you like

Origin blog.51cto.com/11353391/2486556