无法安装python3的连续报错-mysql include软链接问题

作者:matrix 发布时间:2019 年 3 月 12 日 分类:Python

虚拟机ubuntu中自带了Python2,但是想要使用python3需要单独安装。使用add-apt-repository来添加ppa源安装提示command not found,之后进行安装操作sudo apt-get install software-properties-common,错误继续:

$ sudo apt-get install software-properties-common
Reading package lists... Done
Building dependency tree... 50%
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 libmysql++-dev : Depends: libmysqlclient-dev but it is not going to be installed
 software-properties-common : Depends: python3:any (>= 3.3.2-2~)
                              Depends: python3 but it is not going to be installed
                              Depends: python3-gi but it is not going to be installed
                              Depends: gir1.2-glib-2.0 but it is not going to be installed
                              Depends: python-apt-common (>= 0.9) but it is not going to be installed
                              Depends: python3-dbus but it is not going to be installed
                              Depends: python3-software-properties (= 0.96.20.8) but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

继续apt-get update & upgrade & 更换国内源,后面使用apt-get install python3也是相同错误,无济于事。
错误跟踪到libmysql++-dev依赖问题,遂重新安装sudo apt-get install libmysqlclient-dev:

$ sudo apt-get install libmysqlclient-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  libmysqlclient-dev
0 upgraded, 1 newly installed, 0 to remove and 163 not upgraded.
4 not fully installed or removed.
Need to get 0 B/1,167 kB of archives.
After this operation, 7,040 kB of additional disk space will be used.
debconf: delaying package configuration, since apt-utils is not installed
(Reading database ... 51891 files and directories currently installed.)
Preparing to unpack .../libmysqlclient-dev_5.7.25-0ubuntu0.16.04.2_amd64.deb ...
Unpacking libmysqlclient-dev (5.7.25-0ubuntu0.16.04.2) ...
dpkg: error processing archive /var/cache/apt/archives/libmysqlclient-dev_5.7.25-0ubuntu0.16.04.2_amd64.deb (--unpack):
 unable to install new version of '/usr/include/mysql/mysql/plugin_ftparser.h': No such file or directory
Errors were encountered while processing:
 /var/cache/apt/archives/libmysqlclient-dev_5.7.25-0ubuntu0.16.04.2_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

尝试手动安装deb:sudo dpkg -i /var/cache/apt/archives/libmysqlclient-dev_5.7.25-0ubuntu0.16.04.2_amd64.deb失败:

unable to install new version of '/usr/include/mysql/mysql/plugin_ftparser.h': No such file or directory

根源问题

/usr/include/mysql/mysql/plugin_ftparser.h不存在
开始手动查找

$ sudo find / | grep plugin_ftparser.h

图片4456-无法安装python3的连续报错-mysql include软链接问题

该文件只存在与/usr/local/mysql/include/目录中,ls /usr/include/mysql -al查看列表就会发现mysql的软链接出现问题导致的。
图片4458-无法安装python3的连续报错-mysql include软链接问题

解决

重新生成mysql include软连接

$ ln -s /usr/local/mysql/include /usr/include/mysql/mysql #重新生成软连接

图片4460-无法安装python3的连续报错-mysql include软链接问题

此虚拟机中的mysql是之前安装LNMP搭建PHP环境而创建的,很有可能和这个有关系。

参考:
https://askubuntu.com/questions/629448/file-mysql-h-cant-be-found
https://askubuntu.com/questions/773079/fixing-broken-packages-in-ubuntu-repost

PEACE~

更新OpenSSL库至最新版本导致sss服务无法启动

作者:matrix 发布时间:2017 年 4 月 16 日 分类:零零星星

ubuntu升级openssl库到OpenssL 1.1.0e版本,过程倒还好,到底还是成功了。但是reboot重启系统之后发现ss服务无法打开,这可是目前我唯一的科学电梯啊。
不过还好找到报错信息有解决办法。

>ssserver --version
shadowsocks 2.8.2 版本

报错:
root@root-VM:/usr/local/bin# ./ssserver  -c /etc/shadowsocks.json -d start
INFO: loading config from /etc/shadowsocks.json
2017-04-16 19:05:10 INFO     loading libcrypto from libcrypto.so.1.1
Traceback (most recent call last):
  File "./ssserver", line 9, in <module>
    load_entry_point('shadowsocks==2.8.2', 'console_scripts', 'ssserver')()
  File "/usr/local/lib/python2.7/dist-packages/shadowsocks/server.py", line 34, in main
    config = shell.get_config(False)
  File "/usr/local/lib/python2.7/dist-packages/shadowsocks/shell.py", line 262, in get_config
    check_config(config, is_local)
  File "/usr/local/lib/python2.7/dist-packages/shadowsocks/shell.py", line 124, in check_config
    encrypt.try_cipher(config['password'], config['method'])
  File "/usr/local/lib/python2.7/dist-packages/shadowsocks/encrypt.py", line 44, in try_cipher
    Encryptor(key, method)
  File "/usr/local/lib/python2.7/dist-packages/shadowsocks/encrypt.py", line 83, in __init__
    random_string(self._method_info[1]))
  File "/usr/local/lib/python2.7/dist-packages/shadowsocks/encrypt.py", line 109, in get_cipher
    return m[2](method, key, iv, op)
  File "/usr/local/lib/python2.7/dist-packages/shadowsocks/crypto/openssl.py", line 76, in __init__
    load_openssl()
  File "/usr/local/lib/python2.7/dist-packages/shadowsocks/crypto/openssl.py", line 52, in load_openssl
    libcrypto.EVP_CIPHER_CTX_cleanup.argtypes = (c_void_p,)
  File "/usr/lib/python2.7/ctypes/__init__.py", line 378, in __getattr__
    func = self.__getitem__(name)
  File "/usr/lib/python2.7/ctypes/__init__.py", line 383, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /usr/lib/ssl/lib/libcrypto.so.1.1: undefined symbol: EVP_CIPHER_CTX_cleanup

说到底都是升级openssl导致无法使用,旧版EVP_CIPHER_CTX_cleanup函数被弃用改为EVP_CIPHER_CTX_reset

办法

定位到/usr/local/lib/python2.7/dist-packages/shadowsocks/crypto/openssl.py文件:
修改52,111行处的EVP_CIPHER_CTX_cleanupEVP_CIPHER_CTX_reset 重启服务,解决。

实际情况根据自己的ss版本查找修改相关文件

参考:http://blog.csdn.net/blackfrog_unique/article/details/60320737

PEACE

ububntu 搭建sss服务无法开机自启动

作者:matrix 发布时间:2016 年 12 月 29 日 分类:零零星星

搭建方法:http://www.jianshu.com/p/b5c4fbadbfae

apt-get update
apt-get install python-pip
pip install shadowsocks

添加:/etc/shadowsocks.json

{
"server":"my_server_ip",
"server_port":8388,
"local_address": "127.0.0.1",
"local_port":1080,
"password":"mypassword",
"timeout":300,
"method":"aes-256-cfb",
"fast_open": false
}

ssserver -c /etc/shadowsocks.json -d start

我用ubuntu按照上面链接的方法来搭建的服务,安装运行到是ok,但是reboot重启Ubuntu的时候就发现出现问题。

编辑/etc/rc.local

添加开机自启动的命令失败:

ssserver -c /etc/shadowsocks.json -d start

Ubuntu下/etc/rc.local  文件修改之后没有成功。
实际上系统是执行了/etc/rc.local里面的命令,只是没有设置好ssserver命令的环境变量,系统当然无法执行。
我们需要做的就是给运行/etc/rc.local 的脚本里面添加环境变量就可以。

修改/etc/init.d/rc.local文件

vi /etc/init.d/rc.local
然后按i键执行vi编辑器的插入口令
将原本的PATH=/sbin:/usr/sbin:/bin:/usr/bin 修改为 PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
按esc键输入:wq!保存退出
重启Ubuntu
reboot
然后系统就会成功执行 ssserver -c /etc/shadowsocks.json -d start 命令启动服务
重启:ssserver -c /etc/shadowsocks.json -d restart

加速

vps是kvm虚拟技术,可提升扶墙效率

https://github.com/ToyoDAdoubi/doubi

  • 安装锐速hack版
    https://github.com/91yun/serverspeeder

  • 安装Google BBR

$ bash -c "$(curl -sSL https://github.com/teddysun/across/raw/master/bbr.sh)" #安装bbr
$ bash -c "$(curl -sSL https://raw.githubusercontent.com/chiakge/Linux-NetSpeed/master/tcp.sh)" #bbr plus

$ lsmod | grep bbr #检测
  • 腾讯TCPA(仅限centOS)
 bash <(curl -L -s http://down.08mb.com/tcp_opz/tcpa/tcpa.sh) #安装

参考:
http://www.jianshu.com/p/f88424fd4ab3

http://blog.csdn.net/zhe_d/article/details/50312967
http://www.jianshu.com/p/b5c4fbadbfae
http://www.jianshu.com/p/94445ee49df0

小众化工具 brook
https://github.com/txthinking/brook