张小白教你使用OGG实现Oracle 19C到MySQL 5.7的数据同步(2)

举报
张辉 发表于 2022/06/10 06:20:20 2022/06/10
【摘要】 OGG(Oracle-》MySQL)

(三)在MySQL端安装OGG for MySQL

卸载CentOS自带的mariadb:

rpm -qa | grep mariadb

rpm -e --nodeps mariadb-server-5.5.68-1.el7.x86_64 mariadb-5.5.68-1.el7.x86_64 mariadb-libs-5.5.68-1.el7.x86_64

安装MySQL:

cd /usr/local

wget https://cdn.mysql.com/Downloads/MySQL-5.7/mysql-5.7.37-el7-x86_64.tar.gz

解压:

tar -zxvf mysql-*.gz

mv mysql-5.7.37-el7-x86_64 mysql

设置权限:

chown -R mysql:mysql /usr/local/mysql

chmod -R 755 /usr/local/mysql

mkdir -p /data/mysql/data

mkdir -p /data/mysql/logs

mkdir -p /data/mysql/tmp

chown -R mysql:mysql /data/mysql

编辑 /etc/my.cnf 文件:

内容如下:

[client]
port = 3306
socket = /data/mysql/tmp/mysql.sock
[mysqld]
user = mysql
basedir = /usr/local/mysql 
datadir = /data/mysql/data 
port = 3306 
socket = /data/mysql/tmp/mysql.sock
pid-file = /data/mysql/tmp/mysqld.pid
tmpdir = /data/mysql/tmp 
skip_name_resolve = 1
symbolic-links=0
max_connections = 2000
group_concat_max_len = 1024000
sql_mode = NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
lower_case_table_names = 1
log_timestamps=SYSTEM
character-set-server = utf8
interactive_timeout = 1800 
wait_timeout = 1800
max_allowed_packet = 32M
binlog_cache_size = 4M
sort_buffer_size = 2M
read_buffer_size = 4M
join_buffer_size = 4M
tmp_table_size = 96M
max_heap_table_size = 96M
max_length_for_sort_data = 8096
#logs
server-id = 1003306
log-error = /data/mysql/logs/error.log
slow_query_log = 1
slow_query_log_file = /data/mysql/logs/slow.log
long_query_time = 3
log-bin = /data/mysql/logs/binlog
binlog_format = row
expire_logs_days = 15
log_bin_trust_function_creators = 1
relay-log = /data/mysql/logs/relay-bin
relay-log-recovery = 1 
relay_log_purge = 1 
#innodb 
innodb_file_per_table = 1
innodb_log_buffer_size = 16M
innodb_log_file_size = 256M
innodb_log_files_in_group = 2
innodb_io_capacity = 2000
innodb_io_capacity_max = 4000
innodb_flush_neighbors = 0
innodb_flush_method = O_DIRECT
innodb_autoinc_lock_mode = 2
innodb_read_io_threads = 8
innodb_write_io_threads = 8
innodb_buffer_pool_size = 2G

将mysql设置为linux服务:

cd /usr/local/mysql/support-files

cp mysql.server /etc/init.d/mysql

编辑 /etc/init.d/mysql 文件:

设置以下两行:

basedir=/usr/local/mysql
datadir=/data/mysql/data

chkconfig --add mysql

chkconfig --list

编辑环境变量:

echo "PATH=$PATH:/usr/local/mysql/bin " >> /etc/profile

source /etc/profile

rpm -qa|grep libaio

如果没有,则需要安装:yum install libaio-devel.x86_64

/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/data

more /data/mysql/logs/error.log | grep password

重启MySQL:

service stop mysql

service start mysql

得使用

systemctl restart mysql

systemctl status mysql

登录:

mysql -u root -p

输入前面的密码:BOc:CUr?S0aj

修改root密码:

alter user 'root'@'localhost' identified by 'zhanghui';

flush privileges;

quit退出命令行。

ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql

使用新密码zhanghui登录:

mysql -u root -p

create user 'ogg'@'%' identified by 'ogg';

grant all on *.* to 'ogg'@'%';


打开 https://www.oracle.com/middleware/technologies/goldengate-downloads.html

找到 Oracle GoldenGate 21.3.0.0.0 for MySQL-compatible Databases on Linux x86-64 下载:

使用root登录

创建目的端ogg用户:ogg2

useradd ogg2

passwd ogg2

su - ogg2

切换到ogg2用户:su - ogg2

将ogg for mysql安装包 传到/home/ogg2下:

unzip -d ~ ./213000_ggs_Linux_x64_MySQL_64bit.zip

切换到root用户

mkdir /opt/ogg/target_endpoint

chown -R ogg2 /opt/ogg/target_endpoint

切换回ogg2用户:

tar -xvf ggs_Linux_x64_MySQL_64bit.tar -C /opt/ogg/target_endpoint

编辑 ~/.bashrc文件:

export JAVA_HOME=$HOME/jdk1.8.0_141
export PATH=$JAVA_HOME/bin:$PATH

export OGG_HOME=/opt/ogg/target_endpoint
export LD_LIBRARY_PATH=$JAVA_HOME/jre/lib/amd64:$JAVA_HOME/jre/lib/amd64/server:$JAVA_HOME/jre/lib/amd64/libjsig.so:$JAVA_HOME/jre/lib/amd64/server/libjvm.so:$OGG_HOME/lib:$HOME/libs

export PATH=$OGG_HOME:$PATH

source ~/.bashrc使其生效。

(未完待续)

【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。