Chinaunix首页 | 论坛 | 博客

OPS

  • 博客访问: 504856
  • 博文数量: 117
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1210
  • 用 户 组: 普通用户
  • 注册时间: 2015-05-05 14:50
个人简介

hellow 运维

文章分类

全部博文(117)

文章存档

2019年(1)

2018年(1)

2017年(45)

2016年(38)

2015年(32)

我的朋友

分类: 系统运维

2017-07-12 15:10:48

单独MySQL模式
参考我的上一文章:http://blog.chinaunix.net/uid-30234663-id-5767316.html

这里部署的mysql5.7
  只需要把docker pull mariadb改成docker pull mysql:5.7即可
开始部署mysql主服务器
docker run -d -e TIMEZONE=Asia/Shanghai -v $PWD/mysql_master:/var/lib/mysql -v $PWD/my.cnf:/etc/mysql/my.cnf -p 3307:3306 -e MYSQL_ROOT_PASSWORD=hanye1311 -e MASTER=1 -e SERVER_ID=1 -e REPLICATION_PASSWORD=hanye131 --name mysql5.7_master mysql:5.7

从服务器
 doc run -d --name mysql5.7_slave -e TIMEZONE=Asia/Shanghai -v $PWD/mysql_slave:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=hanye1312 -e SLAVE=1 -e SERVER_ID=3  -e REPLICATION_PASSWORD=hanye131 -e MASTER_LOG_FILE=mysql-bin.000003 -e MASTER_LOG_POS=154 -e MASTER_PORT=3306  -e MASTER_HOST=172.17.0.4 -p 4407:3306  mysql:5.7

然后和配置mysql主从配置一样即可
my.cnf

root@debian:~/mysql# cat 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]
#
# 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
socket=/var/lib/mysql/mysql.sock


slow_query_log = 1
long_query_time = 2
slow_query_log_file = /var/lib/mysql/mysql-slow.log
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0


log-error=/var/lib/mysql/mysqld.log
pid-file=/var/lib/mysql/mysqld.pid






server-id = 1


init-connect = 'SET NAMES utf8mb4'
character-set-server = utf8mb4


skip-name-resolve
#skip-networking
back_log = 300


max_connections = 4004
max_connect_errors = 6000
open_files_limit = 65535
table_open_cache = 1024
max_allowed_packet = 4M
binlog_cache_size = 1M
max_heap_table_size = 8M
tmp_table_size = 128M


read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
join_buffer_size = 8M
key_buffer_size = 256M


thread_cache_size = 64


query_cache_type = 1
query_cache_size = 64M
query_cache_limit = 2M


ft_min_word_len = 4


log_bin = mysql-bin
binlog_format = mixed
expire_logs_days = 7




performance_schema = 0
explicit_defaults_for_timestamp


#lower_case_table_names = 1


skip-external-locking


default_storage_engine = InnoDB
#default-storage-engine = MyISAM
innodb_file_per_table = 1
innodb_open_files = 500
innodb_buffer_pool_size = 10G
innodb_write_io_threads = 4
innodb_read_io_threads = 4
innodb_thread_concurrency = 0
innodb_purge_threads = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 120M
innodb_log_file_size = 432M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120


bulk_insert_buffer_size = 188M
#myisam_sort_buffer_size = 64M
#myisam_max_sort_file_size = 10G
#myisam_repair_threads = 1


interactive_timeout = 28800
wait_timeout = 28800


[mysqldump]
quick
max_allowed_packet = 716M



my2.cnf和my.cnf一致,只是server_id不一样


阅读(1235) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~