国内无法拉取github时

在国内同步github上内容时,总有各种异常,比如:Clone failed RPC failed; curl 56 GnuTLS recv error (-54): Error in the pull function.

此时也可能很无奈,但方法总是比困难多,设置http/https代理可以轻松解决此问题

设置方法:

git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'

关闭方法

git config --global --unset http.proxy
git config --global --unset https.proxy

ubuntu20.04系统默认sources.list

由于GFW的存在,在很多时候会选择国内源作为加速系统更新,但也不排除这其中有很多深坑,所以建议在做系统更新的时候,强烈建议使用ubuntu官方源,可以排除很多诡异的问题。

下面Ubuntu20.04官方源可作为参考:

#deb cdrom:[Ubuntu 20.04 LTS _Focal Fossa_ - Release amd64 (20200423)]/ focal main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://cn.archive.ubuntu.com/ubuntu/ focal main restricted
# deb-src http://cn.archive.ubuntu.com/ubuntu/ focal main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://cn.archive.ubuntu.com/ubuntu/ focal-updates main restricted
# deb-src http://cn.archive.ubuntu.com/ubuntu/ focal-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://cn.archive.ubuntu.com/ubuntu/ focal universe
# deb-src http://cn.archive.ubuntu.com/ubuntu/ focal universe
deb http://cn.archive.ubuntu.com/ubuntu/ focal-updates universe
# deb-src http://cn.archive.ubuntu.com/ubuntu/ focal-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://cn.archive.ubuntu.com/ubuntu/ focal multiverse
# deb-src http://cn.archive.ubuntu.com/ubuntu/ focal multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ focal-updates multiverse
# deb-src http://cn.archive.ubuntu.com/ubuntu/ focal-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://cn.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
# deb-src http://cn.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu focal partner
# deb-src http://archive.canonical.com/ubuntu focal partner

deb http://security.ubuntu.com/ubuntu focal-security main restricted
# deb-src http://security.ubuntu.com/ubuntu focal-security main restricted
deb http://security.ubuntu.com/ubuntu focal-security universe
# deb-src http://security.ubuntu.com/ubuntu focal-security universe
deb http://security.ubuntu.com/ubuntu focal-security multiverse
# deb-src http://security.ubuntu.com/ubuntu focal-security multiverse

# This system was installed using small removable media
# (e.g. netinst, live or single CD). The matching "deb cdrom"
# entries were disabled at the end of the installation process.
# For information about how to configure apt package sources,
# see the sources.list(5) manual.

limits.conf详解

1. /etc/security/limits.conf

limits.conf的格式如下:

分成四个段落domain,type,item,value

[domain] [type] [item] [value]

domain

username|@groupname 设置需要被限制的用户名或组,组名前面加@和用户名区别;
也可以用通配符*来做所有用户的限制。

type:有 soft,hard 和 –

soft 指的是当前系统生效的设置值(警告)
hard 表明系统中所能设定的最大值(错误)
soft 的限制不能比har 限制高,- 表明同时设置了 soft 和 hard 的值。

item:有以下几种

core - 限制内核文件的大小(KB)
date - 最大数据大小(KB)
fsize - 最大文件大小(KB)
memlock - 最大锁定内存地址空间(KB)
nofile - 打开的文件描述符的最大数目**(经常设置)**
rss - 最大持久设置大小(KB)
stack - 最大堆栈大小(KB)
cpu - 最大CPU时间(min)
noproc - 过程最大数量
as - 地址空间限制(KB)
maxlogins - 此用户的最大登录数量
maxsyslogins - 在系统上登录的最大数目
priority - 优先级运行用户进程
locks -  文件的最大数量锁定用户可容纳
sigpending - 最大挂起信号的数量
msgqueue - 通过POSIX消息队列使用的最大内存(字节)
nice - 最大不错优先允许提高到值:[-20,19]
rtprio - 最大实时优先

2. ulimit命令

命令参数

-a  显示所有限制
-c  core文件大小的上限
-d  进程数据段大小的上限
-f  shell所能创建的文件大小的上限
-m  驻留内存大小的上限
-s  堆栈大小的上限
-t  每秒可占用的CPU时间上限
-p  管道大小
-n  打开文件数的上限
-u  进程数的上限
-v  虚拟内存的上限

ulimit用法

# 显示所有设置
ulimit -a
# 对某程序的限制
ulimit -s 512
# 限制线程栈大小
ulimit -p 512

除可用Ulimit命令设置外,也可以在/etc/security/limits.conf文件中定义限制。

注:ulimit命令设置只是当时生效,limits.conf配置文件才是永久生效。

不同后缀C++源文件

  • Unix                                  —>            C , cc , cxx, c
  • GNU C++                           —>           C, cc,cxx,cpp,c++
  • Borland C++                     —>           cpp
  • Microsoft Visual C++      —>           cpp,cxx,cc
  • Anroid系统源码中的都以cc为后缀

使用systemd启动服务

在实际运维工作中,我们经常会使用nohup与&结合来启动后台服务,也可能会使用到screen来启动后台服务,但在centos7后系统提供了systemd来管理后台服务。

之前我们是这样子来启动后台服务的:

nohup ./massminer --config conf/chia.json m2 > /dev/null 2>&1 &

看起来比较土一点,但是能解决实际运维问题。这里有几个麻烦的点,你需要重启服务时,必须跟kill命令一起结合指定目标pid才能完成。

使用systemd我们可以这样来定义后台服务,如下:

cat >/lib/systemd/system/massminer.service<<EOF
[Unit]
Description=Mass Miner
Documentation=https://www.massexplorer.org/
After=network.target
[Service]
Type=simple
WorkingDirectory=/home/mass/massminer
ExecStart=/home/mass/massminer/massminer --config /home/mass/massminer/config.json m2 &
KillMode=process
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF

自定义后台服务后,希望systemctl马上能识别,可以通过如下命令进行重载:
systemctl daemon-reload
启动服务:
systemctl start massminer
关闭服务:
systemctl stop massminer
查看服务:
systemctl status massminer
使用systemd来管理后台服务后更加简洁方便。