张小白教你使用OGG实现Oracle 19C到MySQL 5.7的数据同步(2)
(三)在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使其生效。
(未完待续)
- 点赞
- 收藏
- 关注作者
评论(0)