mysql补充内容:
show variables like server_id ''; //查看server_id
配置主从复制时,在从服务器上不在单独获取公钥:
mysql -h主数据库的ip -u用户名 -P端口号 -p密码 --get-server-public-key
change master to
---->master_host
---->master_user
---->master_password
---->master_port
---->master_log_file
---->master_log_pos
---->get_master_public_key= 1 使用这条命令直接获取公钥
基于代码层级的读写分离
搭建mysql的主从复制
master_mysql:192.168.118.20
slave_mysql:192.168.118.30
python代码的读写分离
1.安装pymysql,是python管理mysql的驱动,或者成为连接器
[root@python01 ~]# pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
Writing to /root/.config/pip/pip.conf
[root@python01 ~]# pip3 install pymysql
2.在python3的命令行界面引入pymysql
[root@python01 ~]# python3
>>> import pymysql<