标签:resolve var 安装 ase error replica 角色 relay_log socket
在现代企业中,数据库显得尤为重要,而储存数据的数据库选择的五花八门,但任何数据库都存在着一种隐患。
想几个问题:
配置步骤:
准备两台数据库:
数据库角色 | IP | 应用系统版本 | 有无数据 |
---|---|---|---|
主数据库 | 192.168.7.10 | radhat7 | 无 |
从数据库 | 192.168.7.11 | radhat7 | 无 |
数据库安装步骤省略。。。。。
主服务器
# mysqldump -uroot -p123 --all-databases > all.sql
# scp all.sql root@192.168.7.11
从服务器
# ls
all.sql
# mysql -uroot -p123 < all.sql
mysql> CREATE USER ‘repl‘@‘192.168.7.11‘ IDENTIFIED BY ‘repl123‘
mysql> GRANT REPLICATION SLAVE ON *.* TO ‘repl‘@‘192.168.7.11‘;
mysql> GRANT REPLICATION SLAVE ON *.* TO ‘repl‘@‘192.168.7.11‘;
# vim /etc/my.cnf
[mysqld]
basedir = /usr/local/mysql
datadir = /opt/data
socket = /tmp/mysql.sock
port = 3306
pid-file = /opt/data/mysql.pid
user = mysql
symbolic-links=0
log-error=/var/log/mysqld.log
server-id=1
log-bin=mysql-bin
skip-name-resolve
# service mysqld restart
# mysql -uroot -p123
mysql> show master status; //数据库状态
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000002 | 154 | | | |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
mysql>
# vim /etc/my.cnf
[mysqld]
basedir = /usr/local/mysql
datadir = /opt/data
socket = /tmp/mysql.sock
port = 3306
pid-file = /opt/data/mysql.pid
user = mysql
server-id=2
relay-log=mysql-relay-bin
symbolic-links=0
log-error=/var/log/mysqld.log
skip-name-resolve
# service mysqld restart
# mysqld -uroot -p123
//配置启动从数据库
mysql> CHANGE MASTER TO
-> MASTER_HOST=‘192.168.7.11‘;
-> MASTER_USER=‘repl‘,
-> MASTER_PASSWORD=‘repl123‘,
-> MASTER_LOG_FILE=‘mysql-bin.000002‘,
-> MASTER_LOG_POS=154;
mysql> start slave;
mysql> show slave status \G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.7.11
Master_User: lzj
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000002
Read_Master_Log_Pos: 154
Relay_Log_File: mysql-relay-bin.000008
Relay_Log_Pos: 367
Relay_Master_Log_File: mysql-bin.000002
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
主mysql
从mysql
标签:resolve var 安装 ase error replica 角色 relay_log socket
原文地址:https://www.cnblogs.com/liuzhijun666/p/13170814.html