In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly gives you a brief description of the detailed steps of installing MySQL-5.7 and master-slave building. You can check the relevant professional terms on the Internet or find some related books to supplement them. We will not dabble here. Let's go straight to the topic. I hope this article on the detailed steps of installing MySQL-5.7 and master-slave building can bring you some practical help.
one。 System information
Linux version: 6.8
MySQL version information: / mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz
Two machine IP:
192.168.196.220
192.168.196.221
Description:
Mysql installation directory: / opt/mysql
Mysql data road: / data/mysql
two。 Install MySQL-5.71. Set up hostname
Hostname is currently effective.
~] # hostname MySQL-Master
Hostname permanent settings.
[root@localhost ~] # cat / etc/sysconfig/network
NETWORKING=yes
HOSTNAME=MySQL-Master
Configure to resolve your own hostname
[root@localhost ~] # cat / etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 MySQL-Master
:: 1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.196.220 MySQL-Master
192.168.196.221 MySQL-Slave
The hosts in the cluster must be able to resolve each other, either through the DNS or through the / etc/hosts file. If the number of hosts is not large, we usually choose hosts files for parsing. Because DNS depends on external services.
two。 Download the installation package
~] # wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz
3. Expand mysql tarball
~] # tar xf mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz-C / opt/
Opt] # ln-sv mysql-5.7.20-linux-glibc2.12-x86_64 mysql
4. Create users, as well as data and log directories
~] # useradd-r mysql
~] # install-d-o mysql-g mysql / data/mysql
~] # install-d-o mysql-g mysql / data/log
5. Install the required libnuma.so.1 dynamic libraries
~] # yum-y install numactl
6. Add mysql binaries to the PATH path
~] # vim / etc/profile.d/mysql.sh
Export PATH=/opt/mysql/bin:$PATH
7. Configuration file my.cnf [root@localhost ~] # cat / etc/my.cnf [mysqld] log-error=/data/log/mysqld.logpid-file=/data/mysql/mysqld.piddatadir=/data/mysqlsocket=/data/mysql/mysql.sockuser=mysql# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0innodb_file_per_table = ONskip_name_resolveserver_id = 1log_bin = / data/mysql/bin_ log [mysqld _ safe] log-error=/data/log/mysqld.logpid-file=/data/mysql / mysqld.pid[mysql] socket=/data/mysql/mysql.sock
Note: 1. / etc/my.cnf / data/log is the log directory of mysql, which has been created beforehand. If it is different, please modify it. 2. / data/mysql in etc/my.cnf is the data directory of mysql, which has been created beforehand. If it is different, please modify it. 3. When configuring slave, it is important to note that server_id must be different from master, otherwise it will fail.
8. Copy the startup script
~] # cp / opt/mysql/support-files/mysql.server / etc/init.d/mysqld
Note:
Modify the values of the datadir and basedir directories:
Basedir=/opt/mysql
Datadir=/data/mysql
Because the installation directory of mysql is / opt/mysql. The data directory of mysql is / data/mysql
9. Create mysql data
~] # mysql_install_db-- no-defaults-- datadir=/data/mysql-- user=mysql-- basedir=/opt/mysql
Note:-- no-defautls will cancel the default read path of mysql_instal_db, and the creation will fail if it is not added. And be sure to follow mysql_install_db, or it won't take effect.
10. Set the boot self-startup service
~] # chkconfig-- add mysqld
~] # service mysqld start
11. Test connection to the database
~] # mysql-p "g2roomvaDpB16it"
Note: the password for mysql's root@'localhost' is in the / root/.mysql_secret file.
three。 Configure master and slave 1. Modify root password
Mysql > ALTER USER root@'localhost' IDENTIFIED BY 'mysql_pass'
Note: the mysql-5.7 series must change the user's password before it can be operated to provide security.
two。 Configure master-slave operation
Actions on master
Assign slave permissions to users
Mysql > GRANT REPLICATION CLIENT,REPLICATION SLAVE ON. TO repluser@'192.168.%' IDENTIFIED BY 'replpass'
View binary
Mysql > SHOW MASTER STATUS
+-+
| | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | |
+-+
| | bin_log.000001 | 711 |
+-+
Actions on slave:
Configure synchronized master hosts:
Mysql > CHAMGE MASTE TO MASTER_HOST='192.180.196.220',MASTER_USER='repluser',MASTER_PASSWORD='replpass',MASTER_LOG_FILE='bin_log.000001',MASTER_LOG_POS=711
Start the slave process:
Mysql > start slave
Check to see if slave starts properly:
Mysql > show slave status
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
These two parameters indicate that yes starts normally.
View slave synchronization data
Mysql > SHOW DATABASES
And check to see if you have the data on master.
Install MySQL-5.7 and master-slave building detailed steps to tell you here, for other related issues you want to know can continue to pay attention to our industry information. Our section will capture some industry news and professional knowledge to share with you every day.
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.