服务器运维常用命令

一、 linux

1. 下载文件

wget -O filename url
# 简单输出下载
wget -nv -O filename url

2. 查看文件前几行

head -n 20 file.txt

3. 查看目录下文件夹的大小

du -d 1 -h

4. centos挂载exFAT磁盘到目录

yum install -y http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
yum install exfat-utils fuse-exfat

fdisk -l

在这里插入图片描述

创建挂载路径,并挂载 

mount.exfat-fuse /dev/sdb1 /pan

卸载

umount /mnt/usb

开机自动挂载

 vi /etc/fstab
# 最后一行增加
/dev/sdb1       /pan   auto defaults 0 0

5. linux开启smb

linux开启smb教程

6. 使用telnet连接redis

telnet redis 5432

7. 增加用户为root权限

# 修改文件为可编辑
chmod -v u+w /etc/sudoers

#编辑文件
vi /etc/sudoers

#内容
## Allow root to run any commands anywhere
root	ALL=(ALL) 	ALL
www-data ALL=(ALL) ALL
transmission-da ALL=(ALL) ALL
plex ALL=(ALL) ALL


#去除编辑权限
chmod -v u-w /etc/sudoers

8. 局域网内测速

安装iperf3,服务端与客户端都需要安装

#比如centos
yum install iperf3

服务端启动

iperf3 -s -i 1 -p 1314

客户端测试

iperf3 -c 192.168.1.20 -t 60 -p 1314

常用参数说明

(1)-s,--server:iperf服务器模式,默认启动的监听端口为5201,eg:iperf -s

(2)-c,--client host:iperf客户端模式,host是server端地址,eg:iperf -c 222.35.11.23

(3)-i,--interval:指定每次报告之间的时间间隔,单位为秒,eg:iperf3 -c 192.168.12.168 -i 2

(4)-p,--port:指定服务器端监听的端口或客户端所连接的端口,默认是5001端口。

(5)-u,--udp:表示采用UDP协议发送报文,不带该参数表示采用TCP协议。

(6)-l,--len:设置读写缓冲区的长度,单位为 Byte。TCP方式默认为8KB,UDP方式默认为1470字节。通常测试 PPS 的时候该值为16,测试BPS时该值为1400。

(7)-b,--bandwidth [K|M|G]:指定UDP模式使用的带宽,单位bits/sec,默认值是1 Mbit/sec。

(8)-t,--time:指定数据传输的总时间,即在指定的时间内,重复发送指定长度的数据包。默认10秒。

(9)-A:CPU亲和性,可以将具体的iperf3进程绑定对应编号的逻辑CPU,避免iperf进程在不同的CPU间调度。

二、 k8s

1. 批量删除pod

kubectl get po -n kube-system | grep Evicted  | awk '{print $1}' | xargs -n1  kubectl delete pod -n kube-system

2. 创建local-pv和pvc

apiVersion: v1
kind: PersistentVolume
metadata:
  name: runner-pv
  labels:
    name: runner-pv
spec:
  accessModes:
  - ReadWriteOnce
  capacity:
    storage: 10Gi
  local:
    path: /file/pv/runner
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
          - 192.168.31.106

---

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: runner-pvc
  namespace: default
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi
  selector:
    matchLabels:
      name: runner-pv

3. 动态修改deployment的pod副本数量

kubectl scale deployment yqcloud-bot-prod --replicas=1 -n yq-demo

三、 docker

1. 查看docker存储情况

docker system df 

2. docker启动容器并直接进入容器

 docker run -it images:tag bash

# 退出后自动移除
docker run -it --rm images:tag bash

# 运行参数
docker run -d \
--name=botpress_server \
--publish 3000:3000 \
--volume /root/botpress/botpress-data:/botpress/data \
botpress/server:v12_22_0

3. docker设置镜像仓库代理/docker修改存储位置

vi /etc/docker/daemon.json

{
  "registry-mirrors": ["https://e6661d5k.mirror.aliyuncs.com"],
  "data-root": "/file/docker/data/docker"
}

4. docker清理

docker system prune命令可以用于清理磁盘,删除关闭的容器、无用的数据卷和网络,以及dangling镜像(即无tag的镜像)。docker system prune -a命令清理得更加彻底,可以将没有容器使用Docker镜像都删掉。注意,这两个命令会把你暂时关闭的容器,以及暂时没有用到的Docker镜像都删掉了……所以使用之前一定要想清楚吶。 

四. maven

1. 拉取指定包

mvn org.apache.maven.plugins:maven-dependency-plugin:get  -Dartifact=io.buildrun:buildrun-starter-oauth-resource:1.3.0-SNAPSHOT  -Dtransitive=false

五、 npm

1.安装指定包

npm install @buildrun/feedback@1.0.0 --registry https://nexus.gobuildrun.com/repository/br_npm/ --sass-binary-site=http://npm.taobao.org/mirrors/node-sass


# 安装指定私库
npm i --registry http://nexus.saas.hand-china.com/repository/yqcloud-npm-group/


# 设置私库配置
npm config set registry  http://nexus.saas.hand-china.com/repository/yqcloud-npm-group/

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值