In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Summary of linux enterprise knowledge points
Mysql master-slave replication and read-write separation schematic diagram
Master-slave replication of Mysql: the slave server automatically synchronizes data on the master server.
Mysql read and write separation: through the amoeba server to control the user to read data from the slave server, write data from the master server, so as to achieve load balancing.
Set up mysql master-slave replication:
V establish a time synchronization environment
# yum-y install ntp
# vim / etc/ntp.conf
Modify the relevant content:
Server 127.127.1.0
Fudge 127.127.1.0 stratum 8
# service ntpd restart
# yum-y install ntpdate
# / usr/sbin/ntpdate 1.1.1.1
V install mysql database
# yum-y install ncurses-devel
# yum-y install cmake
# tar xzvf mysql-5.5.22.tar.gz
# cd mysql-5.5.22
# cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci-DWITH_EXTRA_CHARSETS=all-DSYSCONFDIR=/etc
# make & & make install
# useradd mysql-s / sbin/nologin-M-g mysql
# chown-R mysql.mysql / usr/local/mysql/
# cp / usr/local/mysql/support-files/my-medium.cnf / etc/my.cnf
# cd / usr/local/mysql/scripts/
# / usr/local/mysql/scripts/mysql_install_db-user=mysql-basedir=/usr/local/mysql-datadir=/usr/local/mysql/data
# echo "PATH=$PATH:/usr/local/mysql/bin" > > / etc/profile
#. / etc/profile
# cp / usr/local/mysql/support-files/mysql.server / etc/init.d/mysqld
# chkconfig-add mysqld
# chkconfig mysqld on
# service mysqld start
# mysqladmin-u root password 123
V modify master master server configuration file
# vim / etc/my.cnf
Server-id = 11
Log-bin=master-bin
Log-slave-updates=true
V restart the service
# Service mysqld restart
V log in to the mysql database and authorize the slave server
# mysql-u root-p123
Mysql > GRANT REPLICATION SLAVE ON *. * TO 'ren'@'1.1.1.%' IDENTIFIED BY' 123'
Mysql > FLUSH PRIVILEGES
Mysql > show master status
Note: *. * indicates all tables under all databases
V configure slave server
# vim / etc/my.cnf
Modify the content:
Server-id = 22
Relay-log=relay-log-bin
Relay-log-index=slave-relay-bin.index
Note: the ID number here cannot be the same as the main server
V restart the service
# service mysqld restart
V login mysql configuration synchronization
# mysql-u root-p123
Mysql > change master to master_host=1.1.1.1,master_user=ren, master_password='123'
Master_log_file='master-bin.000001',master_log_pos=339
V start synchronization
Mysql > start slave
Mysql > show slave status\ G
Verification method: create a new database on the master server and check the slave server to see if it is synchronized.
Separation of read and write in Mysql
Set up amoeba server
V install JAVA environment
# chmod + x jdk-6u14-linux-x64.bin
#. / jdk-6u14-linux-x64.bin
# mv jdk1.6.0_14/ / usr/local/jdk1.6
# vim / etc/profile
Add content:
Export JAVA_HOME=/usr/local/jdk1.6
Export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
Export PATH=$JAVA_HOME/lib:$JAVA_HOME/jre/bin:$PATH:$HOME/bin
Export AMOEBA_HOME=/usr/local/amoeba/
Export PATH=$PATH:$AMOEBA_HOME/bin
# source / etc/profile
# java-version
V install amoeba software
# mkdir / usr/local/amoeba
# tar xzvf amoeba-mysql-binary-2.2.0.tar.gz-C / usr/local/amoeba
# chmod-R 755 / usr/local/amoeba
V configure master,slave1,salve2 server to open permissions to amoeba access
Grant all on *. * to test@'1.1.1.%' identified by '123'
V edit the configuration amoeba.xml configuration file, specify the user name and password of the amoeba, and specify the read-write server.
# vim / usr/local/amoeba/conf/amoeba.xml
Amoeba
one hundred and twenty three
${amoeba.home} / conf/access_list.conf
Master
Master
Slaves
V edit the configuration dbservers.xml configuration file, specify the account number and password of the database accessed, and specify the master and slave server
# vim / usr/local/amoeba/conf/dbServers.xml
Test
one hundred and twenty three
1.1.1.1
1.1.1.2
one
Slave1,slave2
V start the amoeba software
# / usr/local/amoeba/bin/amoeba start
Verification method: write data synchronization on the master server to the slave read server, then the slave read server turns off the synchronization, adds the contents of the relevant table itself, and then uses the client connection to test whether the content can be read successfully on the slacve server.
Turn off synchronization: Mysql > stop slave
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.