Home >Database >Mysql Tutorial >MySQL主从搭建实现

MySQL主从搭建实现

WBOY
WBOYOriginal
2016-06-07 17:13:43993browse

MySQL是应用广泛的关系型数据库,当数据规模逐渐扩大,并且重要性不断提高的情况下,单数据库的可靠性和性能受到严重挑战,所以就

MySQL是应用广泛的关系型数据库,当数据规模逐渐扩大,并且重要性不断提高的情况下,单数据库的可靠性和性能受到严重挑战,所以就会有了主从,读写分离等需求了。

首先在2台linux下安装mysql,最好是内网机器,可以用内网网卡做主从同步,,网络质量和安全都可以得到保证。

1、安装一些常用包:

yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers

yum -y install perl perl-URI perl-DBI perl-String newt-perl

2、下载并安装mysql

wget ://mysql.he.net/

tar -zxf mysql-5.5.3-m3.tar.gz

3、编译安装mysql

cd mysql-5.5.3-m3

./configure --prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=partition,innobase,myisammrg &&make &&make install

4、建立mysql用户和数据文件夹等

/usr/sbin/groupadd mysql

/usr/sbin/useradd -g mysql mysql

chown -R mysql:mysql /usr/local/mysql
mkdir -p /home/mysql/data

mkdir -p /home/mysql/binlog
mkdir -p /home/mysql/relaylog

chown -R mysql:mysql /home/mysql/*

5、初始化数据库

/usr/local/mysql/bin/mysql_install_db --basedir=/usr/local/mysql --datadir=/home/mysql/data --user=mysql

6、建立mysql启动 关闭脚本:vim /etc/init.d/mysql 如下:

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn