在suse上验证的
- 下载二进制包:https://downloads.mysql.com/archives/community/
tar -xzvf mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.25-linux-glibc2.12-x86_64 /usr/local/mysql
cd /usr/local/mysql
mkdir -p /export/mysql/data
chmod -R 777 /export/mysql/data
groupadd mysql
useradd -g mysql mysql
chown -R mysql:mysql /usr/local/mysql/
chown -R mysql:mysql /export/mysql/data
3.?vim /etc/my.cnf?
[client]
port=3306
socket=/usr/local/mysql/mysql.sock
default-character-set=utf8
[mysqld]
user=mysql
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
port=3306
socket=/usr/local/mysql/mysql.sock
symbolic-links=0
character-set-server=utf8
#character_set_server=utf8mb4
log-error=/usr/local/mysql/data/mysql.err
pid-file=/usr/local/mysql/data/mysql.pid
log_timestamps=system
bind-address=0.0.0.0
explicit_defaults_for_timestamp=true
4.
cd /usr/local/mysql/bin
#./mysqld --initialize --user=mysql
./mysqld --initialize-insecure --user=mysql
./mysql_ssl_rsa_setup --datadir=/export/mysql/data
./mysqld_safe &
netstat -tanp | grep 3306 #确认服务已经启动
./mysqladmin -u root password "helloRoot" #设置密码
5.
./mysql -uroot -p
grant all privileges on *.* to root@'%' identified by 'helloRoot';
flush privileges;
至此mysql服务已经启动成功
参考资料:
https://blog.csdn.net/m0_64684588/article/details/121636825? https://blog.csdn.net/m0_60117382/article/details/121353797
====================以下是主从配置,主节点是172.20.5.27,从节点是172.20.5.19
1.主节点my.conf
[client]
port=3306
socket=/export/mysql/data/mysql.sock
default-character-set=utf8
[mysqld]
user=mysql
basedir=/usr/local/mysql
datadir=/export/mysql/data
port=3306
socket=/export/mysql/data/mysql.sock
symbolic-links=0
character-set-server=utf8
#character_set_server=utf8mb4
log-error=/export/mysql/data/mysql.err
pid-file=/export/mysql/data/mysql.pid
log_timestamps=system
bind-address=0.0.0.0
explicit_defaults_for_timestamp=true
server-id=1
log-bin=mysql-bin
binlog-ignore-db=mysql
binlog-ignore-db=information_schema
binlog-ignore-db=performance_schema
binlog-ignore-db=sys
expire_logs_days=7
sync_binlog = 1
binlog_checksum = none
binlog_format = mixed
max_connections = 1000
2.从节点my.conf
[client]
port=3306
socket=/export/mysql/data/mysql.sock
default-character-set=utf8
[mysqld]
user=mysql
basedir=/usr/local/mysql
datadir=/export/mysql/data
port=3306
socket=/export/mysql/data/mysql.sock
symbolic-links=0
character-set-server=utf8
#character_set_server=utf8mb4
log-error=/export/mysql/data/mysql.err
pid-file=/export/mysql/data/mysql.pid
log_timestamps=system
bind-address=0.0.0.0
explicit_defaults_for_timestamp=true
server-id=2
log-bin=mysql-bin
read-only=1
replicate-ignore-db=mysql
replicate-ignore-db=information_schema
replicate-ignore-db=performance_schema
replicate-ignore-db=sys
slave-skip-errors = all
max_connections = 1000
3. 主从节点都按单节点启动即可
4.主节点启动后,执行如下命令
CREATE USER 'repl'@'172.20.5.%' identified by 'repl@Test123';
grant replication slave on *.* to 'repl'@'172.20.5.%' identified by 'repl@Test123';
flush privileges;
show master status;
reset master;
show master status;
5、从节点启动后执行如下命令
stop slave;?
reset slave;
change master to master_host='172.20.5.27',master_user='repl',master_password='repl@Test123',master_log_file='mysql-bin.000001',master_log_pos=150;
start slave;
show slave status \G;
返回值
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 172.20.5.27
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 150
Relay_Log_File: icbc-poc-06-relay-bin.000002
Relay_Log_Pos: 320
Relay_Master_Log_File: mysql-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB: mysql,information_schema,performance_schema,sys
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 150
Relay_Log_Space: 533
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 1
Master_UUID: 712fc9ab-be28-11ec-869a-fa163ed3870c
Master_Info_File: /export/mysql/data/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
1 row in set (0.00 sec)
ERROR:
No query specified
至此主从已经配置完成
?主从参考:
linux搭建主从mysql - zhaojunjin - 博客园
??????linux mysql 主从数据库_Linux下安装MySQL及MySQL主从同步配置_罗立子的博客-CSDN博客
https://blog.csdn.net/weixin_30825389/article/details/113397233 https://blog.csdn.net/yinjl123456/article/details/123533640 https://blog.csdn.net/qq_45337431/article/details/102526512 https://blog.csdn.net/kxindouhao5491/article/details/115271501
MySQL主从结构搭建_布偶猫爸爸的博客-CSDN博客_mysql主从搭建
其他命令:
停止:./mysqladmin -uroot -p shutdown
查看用户信息:select user,host from mysql.user;
测试log_bin是否成功开启
mysql> show variables like '%log_bin%';
查询service id: show variables like 'server_id';
开机启动
cd /usr/local/mysql/support-files
cp mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --list
如果看到mysql的服务,并且3,4,5都是on的话则成功,如果是off,则键入
chkconfig --level 345 mysqld on
参考资料:
https://blog.csdn.net/thetimelyrain/article/details/109238905 ?http://t.zoukankan.com/shizhijie-p-9696299.html
|