Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

note #1

Open
gobomb opened this issue Aug 20, 2019 · 13 comments
Open

note #1

gobomb opened this issue Aug 20, 2019 · 13 comments

Comments

@gobomb
Copy link
Owner

gobomb commented Aug 20, 2019

Run ansible script in container and get error:

Connection refused Failed to connect to new control master

edit ansible config:

[ssh_connection]
ssh_args = -C -o ControlMaster=auto -o ControlPersist=60s
control_path = /dev/shm/cp%%h-%%p-%%r

refer: semaphoreui/semaphore#309 (comment)

@gobomb gobomb pinned this issue Aug 20, 2019
@gobomb
Copy link
Owner Author

gobomb commented Aug 21, 2019

nginx从静态json文件中响应json数据:

vi /usr/local/etc/nginx/nginx.conf / vi /usr/local/etc/nginx/nginx.d/default.conf

location /getData/ {
    default_type application/json;
    alias /Users/zhangyalin/Downloads/treegrid/;

@gobomb
Copy link
Owner Author

gobomb commented Aug 22, 2019

复用 ssh 连接:

$ vi ~/.ssh/config

Host *
ControlPersist yes
ControlMaster auto
ControlPath ~/.ssh/control-%h-%p-%r

以后只需第一次登陆输入密码,后面的连接会复用第一次的连接而不必再输入密码。原理是有一个master进程在share一个socket:

$ ps -ef | grep ssh
  501 80337     1   0 10:01AM ??         0:00.00 ssh: /Users/cym/.ssh/control-10.10.13.31-22-root [mux]

退出连接:

$ ssh -O exit [email protected]
Exit request sent.

另一个用法:

-N指示不打开shell的情况

-M指定master模式

-f让ssh后台运行

$ ssh -M -N -f [email protected]

可加速git连接

ref:SSH ControlMaster and ControlPath

@gobomb
Copy link
Owner Author

gobomb commented Aug 26, 2019

#k8s

快速通过命令部署和暴露 nginx

$ kubectl run nginx --image=nginx --port=80 

创建 service (加参数可指定service类型 --type=NodePort):

$ kubectl expose `kubectl get pod --selector run=nginx -o name` --port=80 --target-port=80  --name nginx

@gobomb
Copy link
Owner Author

gobomb commented Aug 27, 2019

删除虚拟网卡

$ brctl show
$ ifconfig cni0 down
$ brctl delbr cni0

@gobomb
Copy link
Owner Author

gobomb commented Sep 4, 2019

获取容器进程id,即PID

$ docker ps | grep xxx 获取容器id/name

$ docker inspect --format "{{.State.Pid}}" container_id/name 获取PID

使用nsenter切换网络命名空间

$ nsenter -n -t PID

可在切换前后执行ifconfig来对比变化

@gobomb
Copy link
Owner Author

gobomb commented Sep 5, 2019

etcd 恢复数据

ETCDCTL_API=3 etcdctl --endpoints=https://127.0.0.1:2379 snapshot restore /var/lib/k8s_etcd_backup/etcd_v3_backup_20190905-001104 --data-dir=/var/lib/etcd --cacert=/etc/kubernetes/pki/etcd/ca.crt --cert=/etc/kubernetes/pki/apiserver-etcd-client.crt --key=/etc/kubernetes/pki/apiserver-etcd-client.key

@gobomb
Copy link
Owner Author

gobomb commented Sep 9, 2019

临时关闭swap分区, 重启失效;
$ swapoff -a

永久关闭swap分区

$ sed -ri 's/.*swap.*/#&/' /etc/fstab

@gobomb
Copy link
Owner Author

gobomb commented Sep 9, 2019

centos7 修改 hostname

$ hostnamectl set-hostname [name]

$ vim /etc/hosts127.0.0.1 后添加 [name]

@gobomb
Copy link
Owner Author

gobomb commented Oct 11, 2019

lsns - list namespaces

@gobomb
Copy link
Owner Author

gobomb commented Oct 30, 2019

修改linux时区为utc时区:

删除 /etc/localtime

@gobomb
Copy link
Owner Author

gobomb commented Jan 9, 2020

github下载单个文件

https://raw.githubusercontent.com/{username}/{repo}/{branch}/{file_path}/{file_name}

@gobomb
Copy link
Owner Author

gobomb commented Mar 4, 2020

go拉依赖错误:

go: git.xx.cn/xx/[email protected]: invalid version: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /root/go/pkg/mod/cache/vcs/xxx: exit status 128:
	fatal: could not read Username for 'http://git.xx.cn': terminal prompts disabled

vi ~/.gitconfig

[url "[email protected]:"]
        insteadOf = https://git.cloud2go.cn/
[url "[email protected]:"]
        insteadOf = http://git.cloud2go.cn/

@gobomb
Copy link
Owner Author

gobomb commented Aug 17, 2020

vscode 多行编辑

在Windows上,按住Ctrl + Alt,同时按向上↑或向下↓箭头键添加光标。 在Mac和Linux上,等效项分别为⌥Opt+⌘Cmd+↑/↓和Shift + Alt +↑/↓。

@gobomb gobomb mentioned this issue Mar 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant