2024年5月7日

Linux脚本——判断是否使用root用户

摘要: #!/bin/bash ################################################################## # # Apply For: system init for CentOS/SLES/Ubuntu # Auth Name: wangwei1 阅读全文

posted @ 2024-05-07 23:35 gkhost 阅读(11) 评论(0) 推荐(0) 编辑

Linux脚本——let整型变量赋值及计算

摘要: #!/bin/bash function directory() { let "filenum = 0" let "dirnum = 0" ls $1 echo "" for file in $( ls ) do if [ -d $file ] then let "dirnum = dirnum + 阅读全文

posted @ 2024-05-07 23:29 gkhost 阅读(4) 评论(0) 推荐(0) 编辑

Linux脚本——打印口算题

摘要: #!/bin/bash function print_random() { # for k in {1..10}; # do # echo -e "$k \t $RANDOM" # done min=$1 max=$(($2-$min+1)) num=$(date +%s%N) echo $(($n 阅读全文

posted @ 2024-05-07 23:26 gkhost 阅读(1) 评论(0) 推荐(0) 编辑

Linux脚本——sed字段替换和get_char()暂停函数的使用

摘要: #!/bin/bash # 暂停函数,用于人为介入判断 get_char() { SAVEDSTTY=`stty -g` stty -echo stty cbreak dd if=/dev/tty bs=1 count=1 2> /dev/null stty -raw stty echo stty 阅读全文

posted @ 2024-05-07 23:23 gkhost 阅读(6) 评论(0) 推荐(0) 编辑

Mysql脚本——备份客户自建数据库

摘要: #!/bin/bash DATE=$(date +%F_%H-%M-%S) HOST=127.0.0.1 USER=root PASS=Linux@123 PORT=3306 BACKUP_DIR=./db_backup # 删选客户自建数据库(排除系统库) DB_LIST=$(mysql -u$U 阅读全文

posted @ 2024-05-07 23:18 gkhost 阅读(1) 评论(0) 推荐(0) 编辑

Kubernetes脚本——K8s日志检查

摘要: #!/bin/bash echo "docker日志采用建议的syslog收集检查,期望结果:1 ">log_check_result.txt ansible -i ./hosts all -m shell -a 'sudo find /apps/logs/docker/ -name dockerd 阅读全文

posted @ 2024-05-07 23:09 gkhost 阅读(5) 评论(0) 推荐(0) 编辑

Kubernetes脚本——检查K8S组件/服务/配置/POD

摘要: #!/bin/bash #echo "运维账号是否有执行常用kubectl运维命令的权限,期望结果:输出/apps/bin/kubelet " >k8s_check_result.txt #ansible -i ./hosts k8s -m shell -a "for i in \`sudo -l\ 阅读全文

posted @ 2024-05-07 23:06 gkhost 阅读(26) 评论(0) 推荐(0) 编辑

Kubernetes脚本——检查K8s基础信息

摘要: #!/bin/sh # version # node, master, slave # arch # kernel version # docker version # image # cpu, mem and usage # pod, pod limit # service, nodeport, 阅读全文

posted @ 2024-05-07 22:59 gkhost 阅读(6) 评论(0) 推荐(0) 编辑

Linux脚本——cut按照空格取字段

摘要: #!/bin/bash # 按照空格分段,-f1取第一个字段a,-f2取第二个字段b echo "Hello1 Hello2 Hello3" | cut -d ' ' -f3 echo "a b c" | cut -d ' ' -f2 阅读全文

posted @ 2024-05-07 22:53 gkhost 阅读(14) 评论(0) 推荐(0) 编辑

Linux脚本——检查网卡Mac和UUID

摘要: #!/bin/bash mac=`ifconfig | grep -A5 ens32 | grep ether | awk -F ' ' '{print $2}'` uuid=`nmcli conn show | grep ens32 | awk -F ' ' '{print $2}'` echo 阅读全文

posted @ 2024-05-07 22:47 gkhost 阅读(7) 评论(0) 推荐(0) 编辑

Linux脚本——for循环和array数组

摘要: #!/bin/sh NodeName=( k8s-master-1 k8s-master-2 k8s-master-3 k8s-node-1 k8s-node-2 k8s-node-3 k8s-node-4 k8s-node-5 ) ipv4=( 100.190.110.55 100.190.110 阅读全文

posted @ 2024-05-07 22:44 gkhost 阅读(7) 评论(0) 推荐(0) 编辑

Linux基础——ARM架构主机系统盘乱序问题

摘要: 一、问题描述 裸金属宿主机根据qcow2镜像创建的裸金属服务器,创建裸金属服务器时无法正常将sda盘符落在系统盘上; lsblk发现系统盘定义的盘符漂移到sdc盘,涉及问题裸金属服务器的磁盘slot直连磁盘和Raid块设备的启动顺序, 无法将/dev/sda盘符落在主机直连磁盘上; 二、问题排查 1 阅读全文

posted @ 2024-05-07 18:47 gkhost 阅读(13) 评论(0) 推荐(0) 编辑

导航