2019年4月

Ubuntu 18.04更换国内镜像源提高安装更新速度

Ubuntu18.04默认安装完以后镜像是官方的,国内更新速度太慢,更新为阿里云或中科大等其他国内源,速度会明显提高,操作方法如下:
备份原文件:

cp /etc/apt/sources.list /etc/apt/sources.list_bak

将/etc/apt/sources.list文件内容替换为如下:(任意其一即可)
阿里云镜像源

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

网易镜像源

deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse

清华镜像源

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

中科大镜像源

deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

更新系统及软件

sudo apt-get update

sudo apt-get upgrade

后面在安装软件速度就很快了~.

192 MB的VPS上安装ss服务基于Ubuntu16.04

在内存只有192MB小鸡vps上安装ss服务,基于ubuntu16.04精简版,安装脚本命令如下:

apt-get update

pip install -U pip

pip3 install --upgrade pip

pip3 install shadowsocks

pip install --upgrade shadowsocks

pip3 install --upgrade shadowsocks
     
cat <<EOF>> /etc/shadowsocks.json
{
    "server":"vps ipadder",
    "local_address":"127.0.0.1",
    "local_port":8888,
    "port_password":{
         "9001":"password",
         "9002":"password"
    },
    "timeout":600,
    "method":"aes-256-cfb",
    "fast_open": false
}
EOF

/usr/local/bin/ssserver -c /etc/shadowsocks.json >> /ss.log 2>&1 &

---阅读剩余部分---

pip升级后出现"from pip import main" line 9问题的解决方法

在Ubuntu或CentOS中,升级了pip版本,再次使用pip 安装相关的包的时候就出现以下错误

Traceback (most recent call last): 
File “/usr/bin/pip”, line 9, in <module>
from pip import main

解决:pip文件在usr/bin目录下,cd进去,进行以下修改

from pip import main
if __name__ == '__main__':
    sys.exit(main())

换成下面的三行

from pip import __main__
if __name__ == '__main__':
    sys.exit(__main__._main())

然后问题就解决了;
pip3也是一样;

使用国内镜像源 提高pip安装更新速度

不论是使用 pip,还是 Pipenv、Poetry等工具,安装 Python 包的时候会默认从官方的 PyPI 源下载文件,速度比较慢。国内的一些公司和机构提供了 PyPI 镜像源(mirror source),你可以设置让这些工具从国内的镜像源安装 Python 包,以便提高下载速度。

官方 PyPI 源的 URL 为 https://pypi.org/simple (旧的 URL 为 https://pypi.python.org/simple

pip更换临时设置可以通过 -i 选项:

pip install -i https://mirrors.aliyun.com/pypi/simple/ flask

永久更换:
Windows系统:
首先在window的文件夹窗口输入 : %APPDATA%



---阅读剩余部分---

MySQL子查询参数说明

MySQL查询的五种子句

where子句(条件查询):按照“条件表达式”指定的条件进行查询。

group by子句(分组):按照“属性名”指定的字段进行分组。group by子句通常和count()、sum()等聚合函数一起使用。

having子句(筛选):有group by才能having子句,只有满足“条件表达式”中指定的条件的才能够输出。

order by子句(排序):按照“属性名”指定的字段进行排序。排序方式由“asc”和“desc”两个参数指出,默认是按照“asc”来排序,即升序。

limit(限制结果集)。

---阅读剩余部分---

Nginx 414 Request-URI Too Large报错解决方法

症状:前台客户端发送大量请求或发送的数据包太大的时候,nginx会报nginx 414 Request-URI Too Large错误,如下图
1.png
检查Log里面显示有大量报错

2019/04/09 15:03:32 [error] 21197#0: *90489 client intended to send too large body: 1470779 bytes, client: 124.74.25.254, server: zt-test.xxx.cn, request: "POST /cinema/salesman/save HTTP/1.1", host: "zt-test.xxx.cn:8080", referrer: "http://zt-test.xxx.cn:8080/index"
2019/04/09 15:22:37 [error] 21200#0: *90745 client intended to send too large body: 1376065 bytes, client: 114.86.94.252, server: zt-test.xxx.cn, request: "POST /cinema/salesman/save HTTP/1.1", host: "zt-test.xxx.cn:8080", referrer: "http://zt-test.xxx.cn:8080/index"
2019/04/10 09:08:46 [error] 21200#0: *91741 client intended to send too large body: 1470779 bytes, client: 124.74.25.254, server: zt-test.xxx.cn, request: "POST /cinema/salesman/save HTTP/1.1", host: "zt-test.xxx.cn:8080", referrer: "http://zt-test.xxx.cn:8080/index


---阅读剩余部分---

AWS镜像AMI制作

先在本地安装Oracle VM VirtualBox,安装好虚拟机(调整优化系统各个参数)此处不再赘述,IP设置为自动获取,最后关机导出,格式为“开放式虚拟化格式 1.0”,如下图,导出完以后上传到S3存储上;

---阅读剩余部分---

最新

分类

归档

评论

  • 安安: 都是af
  • Liang: 嗯,有点不通顺·
  • 王庭威: “MySQL互为主从...
  • Liang: 贴下编译参数和步骤,...
  • shao3911: 您好,为什么我在编译...
  • aliang: 先看是yum安装还是...
  • aliang: 将原来的nginx安...
  • yen: 3、如果要回滚的话,...
  • yen: 刚好需要升级ngin...
  • 文雨: 一些新的method...

其它