数据库
linux mysql 5.7 双机热备-凯发ag旗舰厅登录网址下载
第一步:安装mysql
可参考http://www.runoob.com/mysql/mysql-install.html
心得:
rpm -ivh mysql-community-common-5.7.10-1.el6.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-libs-5.7.10-1.el6.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-client-5.7.10-1.el6.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-server-5.7.10-1.el6.x86_64.rpm --force --nodeps
启动
service mysqld start
/etc/init.d/mysqld/etc/init.d/mysqld start
5.7装好mysql
mysql -u用户名 -p密码
默认安装后是登录不进去的,需要跳过登录,直接进入
mysqld_safe --user=mysql --skip-grant-tables --skip-networking&mysql /**进入mysql交互窗口*/
mysql>update mysql.user set authentication_string=password('root') where user='root'; /*5.7之后的版本user表中没有password字段*/
否则:mysql> update user set password=password('newpassword') where user='root';
切记:
只要修改mysql 系统文件就要 刷新权限 mysql> flush privileges;
mysql> exit;
第二步:
修改mysql编码,同时修改密码安全级别:
vi /etc/my.cnf
# reset pass level
validate_password_policy = 0
validate_password_length = 1
validate_password_mixed_case_count = 0
validate_password_number_count = 0
validate_password_special_char_count = 0
character_set_server=utf8
default-storage-engine=innodb
collation-server=utf8_general_ci
[client]
default-character-set=utf8
授权
mysql> grant all privileges on *.* to 'root'@'localhost' identified by 'root' with grant option;本地
mysql>grant all privileges on *.* to ' root'@'%' identified by 'root' with grant option;远程
刷新权限
flush privileges;
第三步:
两台服务器 a服务器(10.69.37.75)
b服务器(10.69.37.122)
service mysqld stop
a服务器(10.69.37.75)
在a服务器的mysql配置文件中添加 server_id=1 log_bin=mysql-bin binlog_ignore_db=information_schema,performance_schema,mysql
vi /etc/my.cnf
# for advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[mysqld]
# binlog_format=mixed
# log-bin=mysql-bin
# server-id=1
# binlog-do-db=starv_hlw,starv_boss
# binlog-ignore-db=mysql
# replicate-do-db=starv_hlw,starv_boss
# replicate-ignore-db=mysql
# log-slave-updates
# sync_binlog=1
# auto_increment_increment=2
# auto_increment_offset=1
#双机热备主要是下面三行
server_id=1
log_bin=mysql-bin
binlog_ignore_db=information_schema,performance_schema,mysql ##排除的数据库,也就是不需要同步的数据库
#
# remove leading # and set to the amount of ram for the most important data
# cache in mysql. start at 70% of total ram for dedicated server, else 10%.
# innodb_buffer_pool_size = 128m
#
# remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# remove leading # to set options mainly useful for reporting servers.
# the server defaults are faster for transactions and fast selects.
# adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128m
# sort_buffer_size = 2m
# read_rnd_buffer_size = 2m
#datadir=/var/lib/mysql
datadir=/data1/mysqldata/mysql
socket=/var/lib/mysql/mysql.sock
#socket=/data1/mysqldata/mysql/mysql.sock
# disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
# reset pass level
validate_password_policy = 0
validate_password_length = 1
validate_password_mixed_case_count = 0
validate_password_number_count = 0
validate_password_special_char_count = 0
character_set_server=utf8
default-storage-engine=innodb
collation-server=utf8_general_ci
[client]
default-character-set=utf8
退出my.cnf
启动 service mysqld start
mysql -root -proot
mysql>
mysql> change master to master_host='10.69.37.75',master_port=3306,master_user='root',master_password='root';
如果不成功
首先在a服务器上连接b服务器数据库看是否能够连接进去
mysql -h10.69.37.122 -uroot -proot
如果不能进入就需要查看b服务的 servie mysqld status
如果成功
首先1.mysql> stop slave
2.mysql> start slave
3.mysql> show slave status \g
上面的红色框,前两者必须是yes,后面是两边数据库同步延迟时间,数值越小越好,大了说明双机热备有问题
连接b服务器(10.69.37.122)
通a服务器(10.69.37.75)一样 master_host='10.69.37.122' 就是修改一下master_host='10.69.37.75' 整个语句如下:
mysql> change master to master_host='10.69.37.75',master_port=3306,master_user='root',master_password='root';
我们在b服务器(10.69.37.122)上创建一个数据库名为lq_122;
后面不演示了,两边相互创建数据库、数据库表、添加表信息、修改表信息、删除信息都成功
可参考 http://blog.csdn.net/huaweitman/article/details/50853075
还可参考网站:http://blog.csdn.net/zwz1984/article/details/45362471
总结
以上是凯发ag旗舰厅登录网址下载为你收集整理的linux mysql 5.7 双机热备_2017年5月5日 星红桉liunx动手实践mysql 主主双机热备的全部内容,希望文章能够帮你解决所遇到的问题。
如果觉得凯发ag旗舰厅登录网址下载网站内容还不错,欢迎将凯发ag旗舰厅登录网址下载推荐给好友。
- 上一篇:
- 下一篇: