ssslinppp

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

DBDIFF

1 参考

https://dbdiff.github.io/DBDiff/

image.png

2 安装Git

省略


3 YUM配置(非必选)

如果发现yum有问题,可以安装一下阿里的yum源
非常建议配置阿里的yum源,因为下载快。
下面给出两种配置方式,哪个成功使用哪个

3.1 配置方式1 (2021年:使用成功)

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 
yum clean all 
yum makecache

image.png

3.2 配置方式2(2023年:使用成功)

配置阿里yum源,参考: https://developer.aliyun.com/article/848291

rpm -qa | grep yum
rpm -qa | grep yum | xargs rpm -e --nodeps
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm							      
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm							      
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-54.el7_8.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-10.el7.noarch.rpm

rpm -ivh *.rpm  --force --nodeps
cd /etc/yum.repos.d/
vim CentOS-Base.repo 
替换:%s/$releasever/7/g

yum clean all
yum makecache
yum update
yum repolist

4 安装PHP(version 5.4.x)

查看操作系统版本

[root@k8s-master01 dbdiff_install]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
[root@k8s-master01 dbdiff_install]#

参考:
https://www.tecmint.com/install-php-5-4-php-5-5-or-php-5-6-on-centos-6/
https://www.mojowill.com/geek/howto-install-php-5-4-5-5-or-5-6-on-centos-6-and-centos-7/

4.1 For CentOS 7 (including EPEL install)

EPEL介绍
EPEL 是yum的一个软件源,里面包含了许多基本源里没有的软件了,但在我们在使用epel时是需要安装它才可以了,EPEL,即Extra Packages for Enterprise Linux的简称,是为企业级Linux提供的一组高质量的额外软件包,包括但不限于Red Hat Enterprise Linux (RHEL), CentOS and Scientific Linux (SL), Oracle Enterprise Linux (OEL),使用docker之前安装EPEL源。

查看是否已经安装EPEL,如果已经安装了,就不需要重新安装了

[root@k8s-master01 dbdiff_install]# ll /etc/yum.repos.d/
total 56
drwxr-xr-x 2 root root 4096 Jun 19  2019 bak
drwxr-xr-x 2 root root 4096 Jun 19  2019 bak.1
drwxr-xr-x 2 root root 4096 Jun 19  2019 bak.2
-rw-r--r-- 1 root root 2523 Jun 16  2018 CentOS-Base.repo
-rw-r--r-- 1 root root  522 Jun 19  2019 CentOS.repo
-rw-r--r-- 1 root root 2640 Dec 12  2019 docker-ce.repo
-rw-r--r-- 1 root root 2142 Jul 24  2017 elrepo.repo
# 5 如果有下面这两行,说明已经安装过了
-rw-r--r-- 1 root root  951 Oct  3  2017 epel.repo
-rw-r--r-- 1 root root 1050 Oct  3  2017 epel-testing.repo

-rw-r--r-- 1 root root  272 Dec 13  2019 kubernetes.repo
-rw-r--r-- 1 root root 1627 Apr  5  2017 mysql-community.repo
-rw-r--r-- 1 root root 1663 Apr  5  2017 mysql-community-source.repo
-rw-r--r-- 1 root root  474 Apr 25  2018 nodesource-el7.repo
-rw-r--r-- 1 root root  192 Jan 20  2016 wandisco-git.repo

如果没有安装,则需要按照EPEL。
下面给出2种方式,自己选择一种即可,如果都不行,请自行搜索 CentOS7配置EPEL

方式1: 2021年使用成功

wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum install epel-release-latest-7.noarch.rpm

方式2:2023年使用成功

//先备份
mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup
mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup

//下载安装
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum install epel-release-latest-7.noarch.rpm  //和下面一个,有1个可以成功,忘记哪个了
yum install -y epel-release.noarch

5.1 For CentOS 7 (including remi-release)

介绍
Remi源大家或许很少听说,不过Remi源GoFace强烈推荐,尤其对于不想编译最新版的linux使用者,因为Remi源中的软件几乎都是最新稳定版。或许您会怀疑稳定不?放心吧,这些都是Linux骨灰级的玩家编译好放进源里的,他们对于系统环境和软件编译参数的熟悉程度毋庸置疑。

安装
如果如下安装方式不行,请自行搜索:CentOS7 配置remi源

方式1: 2021年安装成功

wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

[root@k8s-master01 dbdiff_install]# ll
total 24
-rw-r--r-- 1 root root 23244 Jan  5 00:18 remi-release-7.rpm

[root@k8s-master01 dbdiff_install]# rpm -Uvh remi-release-7*.rpm
warning: remi-release-7.rpm: Header V4 DSA/SHA1 Signature, key ID 00f97f56: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:remi-release-7.9-1.el7.remi      ################################# [100%]

方式2:2023年安装成功

ll /etc/yum.repos.d/

wget https://mirrors.aliyun.com/remi/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm

yum clean all
yum makecache
yum repolist

查看是否安装成功

[root@k8s-master01 dbdiff_install]#  ll /etc/yum.repos.d/
total 112
drwxr-xr-x 2 root root 4096 Jun 19  2019 bak
drwxr-xr-x 2 root root 4096 Jun 19  2019 bak.1
drwxr-xr-x 2 root root 4096 Jun 19  2019 bak.2
-rw-r--r-- 1 root root 2523 Jun 16  2018 CentOS-Base.repo
-rw-r--r-- 1 root root  522 Jun 19  2019 CentOS.repo
-rw-r--r-- 1 root root 2640 Dec 12  2019 docker-ce.repo
-rw-r--r-- 1 root root 2142 Jul 24  2017 elrepo.repo
-rw-r--r-- 1 root root  951 Oct  3  2017 epel.repo
-rw-r--r-- 1 root root 1050 Oct  3  2017 epel-testing.repo
-rw-r--r-- 1 root root  272 Dec 13  2019 kubernetes.repo
-rw-r--r-- 1 root root 1627 Apr  5  2017 mysql-community.repo
-rw-r--r-- 1 root root 1663 Apr  5  2017 mysql-community-source.repo
-rw-r--r-- 1 root root  474 Apr 25  2018 nodesource-el7.repo
# 6 如下带有remi的都是刚刚安装完成的
-rw-r--r-- 1 root root  446 Jan  5 00:14 remi-glpi91.repo
-rw-r--r-- 1 root root  446 Jan  5 00:14 remi-glpi92.repo
-rw-r--r-- 1 root root  446 Jan  5 00:14 remi-glpi93.repo
-rw-r--r-- 1 root root  446 Jan  5 00:14 remi-glpi94.repo
-rw-r--r-- 1 root root  855 Jan  5 00:14 remi-modular.repo
-rw-r--r-- 1 root root  456 Jan  5 00:14 remi-php54.repo
-rw-r--r-- 1 root root 1314 Jan  5 00:14 remi-php70.repo
-rw-r--r-- 1 root root 1314 Jan  5 00:14 remi-php71.repo
-rw-r--r-- 1 root root 1314 Jan  5 00:14 remi-php72.repo
-rw-r--r-- 1 root root 1314 Jan  5 00:14 remi-php73.repo
-rw-r--r-- 1 root root 1314 Jan  5 00:14 remi-php74.repo
-rw-r--r-- 1 root root 1314 Jan  5 00:14 remi-php80.repo
-rw-r--r-- 1 root root 2605 Jan  5 00:14 remi.repo
-rw-r--r-- 1 root root  750 Jan  5 00:14 remi-safe.repo
-rw-r--r-- 1 root root  192 Jan 20  2016 wandisco-git.repo

6.1 Enabling the Repo(remi-repo)

vim /etc/yum.repos.d/remi.repo

#将其中 [remi] 下的enabled=0改为1,保存退出,配置完成。
[remi]
name=Remi's RPM repository for Enterprise Linux 7 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/7/remi/$basearch/
#mirrorlist=https://rpms.remirepo.net/enterprise/7/remi/httpsmirror
mirrorlist=http://cdn.remirepo.net/enterprise/7/remi/mirror
enabled=1  # 将此次修改为1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

需要开启需要按照的php版本,将相应的enable设置为1
image.png

测试下php的软件源信息

yum list php*

6.2 重新创建本地缓存仓库

yum clean all && yum makecache

6.3 安装PHP5.4

这里之所以安装PHP5.4,主要原因在于:Composer的安装依赖php5.4

yum install php54 php54-php php54-php-gd php54-php-mbstring
yum install php54-php-mysqlnd

# 7 执行完成后,看到php54的配置文件
[root@k8s-master01 ~]# ll /etc/httpd/conf.d/php54-php.conf
-rw-r--r-- 1 root root 1225 Oct 22  2019 /etc/httpd/conf.d/php54-php.conf

# 8 如下语句没有执行,不知道做这个步骤的意义
mv /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php53.off

# 9 如下命令,不确定执行的意义
yum install httpd
# 10 开起了httpd服务后,直接在浏览器输入IP,可以打开相关界面(httpd默认开启了80端口)
service httpd restart


image.png

安装相关截图:
image.png
image.png
image.png
image.png

查看安装结果:

[root@k8s-master01 ~]# php54
php54       php54-cgi   php54-pear  php54-phar
[root@k8s-master01 ~]# php54
php54       php54-cgi   php54-pear  php54-phar
[root@k8s-master01 ~]# php54 -v
PHP 5.4.45 (cli) (built: Oct 22 2019 13:23:07)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
[root@k8s-master01 ~]#

10.1 安装php(非5.4)

下面这个需要安装,因为不安装时,后面会报错

yum install php php-gd php-mysql php-mcrypt

11 安装Composer

11.1 Composer介绍

简单理解,就是类似Java的Maven;
image.png
image.png

11.2 Composer安装

11.2.1 下载 composer

[root@k8s-master01 dbdiff_install]# php54 -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"
[root@k8s-master01 dbdiff_install]# ll
total 84
composer-setup.php就是下载下来的
-rw-r--r-- 1 root root 58468 Jun 15 15:29 composer-setup.php
-rw-r--r-- 1 root root 23244 Jan  5 00:18 remi-release-7.rpm

11.2.2 运行安装器

[root@k8s-master01 dbdiff_install]# php54 composer-setup.php
All settings correct for using Composer
Downloading...

Composer (version 2.1.3) successfully installed to: /home/liulin/dbdiff_install/composer.phar
Use it: php composer.phar

上述步骤可能会执行报错,现在记录一下出现的可能错误
e5bfc9cdefb717683405ddde9d8ce72.png
如果出现上述错误,处理方式

wget http://curl.haxx.se/ca/cacert.pem   --no-check-certificate
mv cacert.pem ca-bundle.crt  | mv ca-bundle.crt /etc/pki/tls/certs/

移除安装器:该步骤不要执行!!!不要执行

php -r "unlink('composer-setup.php');"

11.2.3 局部安装转换为全局安装

查看安装结果:默认是局部安装,安装在本目录下

[root@k8s-master01 dbdiff_install]# ll
total 2288
-rwxr-xr-x 1 root root 2253070 Jun 15 15:34 composer.phar  #安装在本地目录下
-rw-r--r-- 1 root root   58468 Jun 15 15:29 composer-setup.php
-rw-r--r-- 1 root root   23244 Jan  5 00:18 remi-release-7.rpm

移动 composer.phar,这样 composer 就可以进行全局调用:

[root@k8s-master01 dbdiff_install]# cp composer.phar /usr/local/bin/composer

11.2.4 验证安装结果

安装完之后,发现执行如下命令会报错:

[root@k8s-master01 dbdiff_install]# composer -v
/usr/bin/env: php: No such file or directory

应该是因为安装php5.4时,可执行命令是 php54而不是php,
所以做了如下一个操作:
重新安装下php,不指定版本

yum install php php-gd php-mysql php-mcrypt

image.png
image.png

12 DBDIFF安装

12.1 下载DBDIFF

使用如下任何一种方法下载(官方提供的方案):
On the command-line, use git to clone the ssh version:

git clone git@github.com:DBDiff/DBDiff.git

Or use git to clone the https version:

git clone https://github.com/DBDiff/DBDiff.git

Or download the .zip archive and unzip it to a folder of your choosing e.g. dbdiff:

https://github.com/DBDiff/DBDiff/archive/master.zip

Or use composer to include DBDiff as a project dependency:

php composer.phar require "dbdiff/dbdiff:@dev"

Or use composer to install DBDiff globally:

composer global require "dbdiff/dbdiff:@dev"

image.png
由于网络原因,发现下载不下来,只能拿之前的下载了。

12.2 配置数据源,测试DBDIFF命令

将DBDIFF解压后,配置好数据源,执行测试:
image.png

修改dbdiff的权限

 chmod 777 ./dbdiff

image.png

12.3 可能的错误

27f781e452f157957f3424d29ab97f7.png
解决方案:

cd DBDIFF-master  #切换到DBDIFF的目录
mv composer.lock composer.lock.bakbak
composer clearcache
composer install --ignore-platform-reqs
composer update --ignore-platform-reqs

12.4 常用命令

直接查看README文件即可,这里列出经常使用的命令:

# 13 --type=schema:表示只比对表结构,不必对数据,默认可能会比对数据
./dbdiff server1.blazers:server1.blazers_zztest_0608  --output=./output/zebra-diff.sql  --type=schema

image.png
image.png

./dbdiff server1.blazers:server1.blazers_online_0721  --output=./output/blazers-diff.sql
./dbdiff server1.bsh_email_sms:server1.bsh_email_sms_online_0721  --output=./output/bsh_email_sms-diff.sql
./dbdiff server1.bucks:server1.bucks_online_0721  --output=./output/bucks-diff.sql
./dbdiff server1.bulls:server1.bulls_online_0721  --output=./output/bulls-diff.sql
./dbdiff server1.cavaliers:server1.cavaliers_online_0721  --output=./output/cavaliers-diff.sql
./dbdiff server1.clippers:server1.clippers_online_0721  --output=./output/clippers-diff.sql
./dbdiff server1.elephant:server1.elephant_online_0721  --output=./output/elephant-diff.sql
./dbdiff server1.elephant_extension:server1.elephant_extension_online_0721  --output=./output/elephant_extension-diff.sql
./dbdiff server1.grizzlies:server1.grizzlies_online_0721  --output=./output/grizzlies-diff.sql
./dbdiff server1.hornets:server1.hornets_online_0721  --output=./output/hornets-diff.sql
./dbdiff server1.madrids:server1.madrids_online_0721  --output=./output/madrids-diff.sql
./dbdiff server1.madrids_ext:server1.madrids_ext_online_0721  --output=./output/madrids_ext-diff.sql
./dbdiff server1.milans:server1.milans_online_0721  --output=./output/milans-diff.sql
./dbdiff server1.nacos:server1.nacos_online_0721  --output=./output/nacos-diff.sql
./dbdiff server1.nuggets:server1.nuggets_online_0721  --output=./output/nuggets-diff.sql
./dbdiff server1.oauth2:server1.oauth2_online_0721  --output=./output/oauth2-diff.sql
./dbdiff server1.operations:server1.operations_online_0721  --output=./output/operations-diff.sql
./dbdiff server1.pacers:server1.pacers_online_0721  --output=./output/pacers-diff.sql
./dbdiff server1.pelicans:server1.pelicans_online_0721  --output=./output/pelicans-diff.sql
./dbdiff server1.pistons:server1.pistons_online_0721  --output=./output/pistons-diff.sql
./dbdiff server1.quartz:server1.quartz_online_0721  --output=./output/quartz-diff.sql
./dbdiff server1.raptors:server1.raptors_online_0721  --output=./output/raptors-diff.sql
./dbdiff server1.romas:server1.romas_online_0721  --output=./output/romas-diff.sql
./dbdiff server1.suns:server1.suns_online_0721  --output=./output/suns-diff.sql
./dbdiff server1.tyyyoauth2:server1.tyyyoauth2_online_0721  --output=./output/tyyyoauth2-diff.sql
./dbdiff server1.tyyyoperations:server1.tyyyoperations_online_0721  --output=./output/tyyyoperations-diff.sql
./dbdiff server1.warriors:server1.warriors_online_0721  --output=./output/warriors-diff.sql
./dbdiff server1.workflow:server1.workflow_online_0721  --output=./output/workflow-diff.sql
./dbdiff server1.anybackups:server1.anybackups_online_0721  --output=./output/anybackups-diff.sql
./dbdiff server1.kings:server1.kings_online_0721  --output=./output/kings-diff.sql
./dbdiff server1.lakers:server1.lakers_online_0721  --output=./output/lakers-diff.sql
./dbdiff server1.magics:server1.magics_online_0721  --output=./output/magics-diff.sql
./dbdiff server1.mavericks:server1.mavericks_online_0721  --output=./output/mavericks-diff.sql
./dbdiff server1.notice:server1.notice_online_0721  --output=./output/notice-diff.sql
./dbdiff server1.rockets:server1.rockets_online_0721  --output=./output/rockets-diff.sql
./dbdiff server1.spurs:server1.spurs_online_0721  --output=./output/spurs-diff.sql
posted on 2021-06-15 17:11  ssslinppp  阅读(325)  评论(0编辑  收藏  举报