下载mysql地址5.6版本:
Download MySQL Community Serverdev.mysql.com
下载地址:
https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.43-linux-glibc2.12-x86_64.tar.gzdev.mysql.com
解压文件:tar -zxvf mysql-5.6.42-linux-glibc2.12-x86_64.tar-1.gz
增加用户组:groupadd mysql
用户组增加用户:useradd -r -g mysql mysql
修改数据库文件夹名称:mv mysql-5.6.42-linux-glibc2.12-x86_64 mysql
将数据库文件夹移动到/usr/local目录:mv mysql /usr/local
cd /usr/local/mysql
mkdir log
touch /usr/local/mysql/log/mysql.err
chown -R mysql:mysql ./
[client]
port = 3556
socket = /tmp/mysql.sock
default-character-set=utf8
[mysqld]
port = 3556
socket = /tmp/mysql.sock
character_set_server = utf8
skip-external-locking
default-storage-engine=INNODB
key_buffer_size = 384M
max_allowed_packet = 1M
table_open_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 32M
# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 8
skip-name-resolve
skip-symbolic-links
log-slave-updates = 1
#skip-networking
max_allowed_packet = 256M
tmp_table_size=128M
max_heap_table_size=128M
sort_buffer_size = 16M
query_cache_type = 0
query_cache_size = 256M
query_cache_limit = 2M
lower_case_table_names = 1
max_connections=1000
#about myisam
key_buffer_size=128M
log-error = /usr/local/mysql/log/mysql.err
long-query-time = 0.5
slow-query-log = 1
slow-query-log-file = /usr/local/mysql/log/mysql-slow.log
general-log=0
general-log-file = /tmp/mysql.log
server-id = 5
log-bin = mysql-bin
max_binlog_size = 1000M
binlog_format = ROW
expire_logs_days = 10
sync_binlog = 0
#skip-slave-start
#relay-log=mysql-relay
#relay-log-info-file=mysql-relay.info
innodb_data_home_dir = /usr/local/mysql/data
innodb_data_file_path = ibdata1:2000M;ibdata2:10M:autoextend
innodb_log_group_home_dir = /usr/local/mysql/data
innodb_buffer_pool_size = 384M
innodb_file_io_threads = 4
innodb_thread_concurrency = 16
innodb_additional_mem_pool_size = 20M
innodb_log_file_size = 512M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
创建文件my.cnf,并拷贝到/etc目录下
chown -R mysql:mysql /tmp
安装mysql需要的软件
yum install libaio-devel.x86_64
yum -y install numactl.x86_64
yum install perl-Data-Dumper.x86_64
初始化数据库
./scripts/mysql_install_db --user=mysql --defaults-file=/etc/my.cnf
建立软链
ln -s /usr/local/mysql/bin/mysql /usr/bin
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
拷贝之后才可以通过service mysqld restart 重启mysql
修改密码: ./bin/mysqladmin -u root password 'root,123'
如果不能修改成功,通过下面的方式启动来修改密码
./bin/mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
mysql -u mysql mysql -P 3556
mysql > use mysql;
mysql > UPDATE user SET Password=PASSWORD('root,123') where USER='root';
mysql > FLUSH PRIVILEGES;
mysql > quit;
重启数据库:
service mysqld restart
#给客户端授权(通过执行下面命令,可以通过本地远程连接数据库)
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root,123' WITH GRANT OPTION;
#关闭主数据库防火墙
systemctl stop firewalld.service
配置主从:
mysql
> CHANGE MASTER TO MASTER_HOST='主数据库的ip地址',MASTER_PORT=3556,MASTER_USER='root',MASTER_PASSWORD='root,123',MASTER_LOG_FILE='mysql-bin.000008',MASTER_LOG_POS=440;
mysql > start slave;
mysql > show slave status\G;
#都是Yes才算成功
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
数据库备份和还原:(这是全量同步)
./mysqldump -h 数据库ip -P 3556 -u root -p cobra > /usr/local/cobra.dump
全量还原:
mysql -uroot -P 3556 -p
mysql > use cobra;
mysql > source /usr/local/cobra.dump
增量同步需要通过工具:otter
https://github.com/alibaba/otter/wiki/QuickStartgithub.comalibaba/otteralibaba/ottergithub.com
要安装node和manage,具体安装过程参考以上连接内容。
第一步配置数据库数据源:
配置表:
配置canel:
配置channel:
配置pipeline:
配置映射关系:
最后运行channel,就可以完成增量同步。