binlog2sql安装
3、pip安装
3.1 首先安装setuptools软件包:
(1)下载setuptools包
wget https://pypi.python.org/packages/source/s/setuptools/setuptools-2.0.tar.gz
(2)解压setuptools包
(3)编译setuptools
(4)开始执行setuptools安装
python setup.py install
3.2 安装pip工具
(1)下载PIP安装包
https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz#md5=35f01da33009719497f01a4ba69d63c9
(2)解压pip安装包:
tar -xzvf pip-9.0.1.tar.gz
cd pip-9.0.1
python setup.py install
如果服务器中没有安装setuptools软件包,则会提示以下错误:
提示错误:
Traceback (most recent calllast):
File "setup.py", line 5, in <module>
from setuptools import setup, find_packages
ImportError: Nomodule named setuptools
cd pip-9.0.1/ python setup.py install
安装好pip之后,我们就可以直接使用pip安装其他第三方模块包了:
pip install requests
若安装后pip命令无法使用,搜索系统中pip文件,创建命令链接
ln -s /usr/local/python27/bin/pip /usr/bin/pip
升级pip
pip install --upgrade pip
安装python依赖包:
pip install pymysql
pip install wheel
pip install mysql-replication
安装Python 3后
Python 3.6.1 (default, May 30 2017, 18:13:28)
# yum search # 安装完后导致 yum 不可用
File "/usr/bin/yum", line 30
except KeyboardInterrupt, e:
^
SyntaxError: invalid syntax
解决 yum 不可用:
# vi /usr/bin/yum
#!/usr/bin/python 改成: #!/usr/bin/python_old
# yum search
开始安装完python3.7 pip3一直没有找到,原因是由于python缺少依赖包导致的。
我出现了如下错误:
ModuleNotFoundError: No module named '_ctypes'
(无奈我是下载pip脚本安装报错的,才知道少了依赖包)
下载pip脚本安装(参考:https://tecadmin.net/install-pip-linux/):
curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
可在安装python3.7 之前 执行如下程序
yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel libffi-devel
yum install libffi-devel -y (包在base)
部署成功:binlog2sql.py
步骤1: 1,安装python3.7.3 下载源文件https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
make && make install python3.7 之前 执行如下程序
提示下列错误:ModuleNotFoundError: No module named '_ctypes'
缺少依赖包,安装下列依赖包:
yum install libffi-devel -y (包在base)
libffi-devel
运行make && make install 出现下列提示,说明成功
Successfully installed pip-19.0.3 setuptools-40.8.0
修改以前旧的python:
# mv /usr/bin/python /usr/bin/python_old # 备份旧的python
# ln -s /usr/local/python3/bin/python3 /usr/bin/python # 把新的 python3 链接到 python
pip3 install mysql-replication 提示错误:
"Can't connect to HTTPS URL because the SSL module is not available
修改源为:pip3 install mysql-replication -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
安装pymysql,wheel,mysql-replication就可以使用
测试: python3 binlog2sql.py --flashback -h192.168.60.166 -P18601 -usa -pcc.123 -t tb --start-file='mysql-bin6.000007' > rollback.sql