Centos7上安装DBDIFF

参考

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

image.png

安装Git

省略


安装PHP(version 5.4.x)

# 10.254.9.5 环境
[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/

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
# 如果有下面这两行,说明已经安装过了
-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

For CentOS 7 (including remi-release)

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

安装

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%]

查看是否安装成功

[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
# 如下带有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

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*

重新创建本地缓存仓库

yum clean all && yum makecache

安装PHP5.4

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

# 执行完成后,看到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

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

# 如下命令,不确定执行的意义
yum install httpd
# 开起了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 ~]#

安装php(非5.4)

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

安装Composer

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

安装

# 下载 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

# 运行安装器
[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

# 移除安装器:该步骤不要执行!!!
php -r "unlink('composer-setup.php');"

# 查看安装结果:默认是局部安装,安装在本目录下
[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

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

[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

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
由于网络原因,发现下载不下来,只能拿之前的下载了。

将DBDIFF解压后,配置好数据源,执行测试:
image.png
修改dbdiff的权限

 chmod 777 dbdiff

常用命令

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

./dbdiff server1.blazers:server1.blazers_zztest_0608  --output=./output/zebra-diff.sql

image.png
image.png

转载请标明出处:http://www.cnblogs.com/ssslinppp/
原文地址:https://www.cnblogs.com/ssslinppp/p/14886281.html