脚本
超级爱吃肉
这个作者很懒,什么都没留下…
展开
-
删除ELK集群中elasticsearch索引
#!/usr/bin/env python3 import requests import time from datetime import datetime import datetime from elasticsearch import Elasticsearch es = Elasticsearch( [“http://ip:9200/”] ) now_time = datetime.datetime.now() time1=datetime.datetime.now().strftime(’%Y原创 2021-03-02 21:33:16 · 187 阅读 · 0 评论 -
如何监控MySQL主从同步是否异常?
#!/bin/bash # Date:2018-9-27 # Author:zz([email protected]) # version1.0 while true do array=($(mysql -uroot -p'123' -e "show slave status\G" | egrep '_Running | Behind_Master | Last_SQL_Errno' | awk '{print$NF}')) if [ "${array[0]}" == "Yes" -a "${array[1原创 2020-12-23 13:58:55 · 146 阅读 · 0 评论 -
如何实现对Mysql数据库进行分库加分表备份,请用脚本实现
#!/bin/bash user=root pass=test database=`mysql -u$user -p "$pass" -e "show databases;" | sed 1d | grep -v 'schema'` mkdir /mysql_backup mysql -u$user -p "$pass" -e "show databases;" &>/dev/null if [ $?-ne0 ];then read -p "Mysql do not running,start原创 2020-12-23 13:58:05 · 124 阅读 · 0 评论 -
机器巡检之shell脚本
#!/bin/bash #while : #do cat << EOF ╭=========================╮ ║¤╭⌒╮╭⌒╮ 亲情奉献 ║ ║ ╱◥██◣ ╭╭⌒╮ 歡迎您 ║ ╭═══════┤米|共|田*╰-----------------├============================= ╮ ║原创 2020-12-22 17:36:22 · 296 阅读 · 0 评论 -
多台机器部署MySQL脚本
shell脚本实现多机部署mysql数据库 root@localhost ~]# vim mysql_install.sh #!/bin/bash #mysql intall 2 #by tianyun #Yum rm -rf /etc/yum.repos.d/* wget ftp://172.16.8.100/yumrepo/centos7.repo -P /etc/yum.repos.d/ wget ftp://172.16.8.100/yumrepo/mysql57.repo -P /etc/yum原创 2020-12-21 11:26:45 · 306 阅读 · 0 评论 -
平常工作中使用的shell命令
1.显示消耗内存/CPU 最 多的 10 个进程 ps aux | sort -nk +4 | tail ps aux | sort -nk +3 | tail 2. 查看 Apache 的 并 发请求数及其 TCP 连 接状态 netstat -n | awk ‘/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}’ 3.找出 自 己最常用的 10 条命令及使用 次数(或求访问最多的 ip 数) sed -e ‘s/| /\n/g’ ~/.bash原创 2020-12-21 11:18:24 · 100 阅读 · 0 评论 -
设置密码
#!/usr/bin/bash while : do read -p "请输入你的密码: " a pass=123456 if [ -z $a ];then echo "您输入的密码不能为空" exit 1 else if [ $a = $pass ];then echo "登录成功" break else echo "您的密码输入有误,请重新输入"原创 2020-12-21 11:16:17 · 117 阅读 · 0 评论 -
循环执行获取up状态的ip地址
for i in {2..254} do { ip=192.168.198.$i ping -c1 $ip &> /dev/null if [ $? -eq 0 ];then echo "$ip" >> up_ip.txt set timeout 10 /usr/bin/expect <<-EOF #shel原创 2020-12-21 11:13:00 · 152 阅读 · 0 评论 -
for循环批量创建用户
#!/usr/bin/bash read -p “请设置用户名/数量/密码: " prefix num pass cat <<-EOF 用户前缀:prefix用户数量:prefix 用户数量:prefix用户数量:num 用户密码:$pass EOF for i in $(seq 1 num)douser=num) do user=num)douser=prefix$i id $user &> /dev/null if [ ?−eq0];thenecho"? -eq 0 ];the原创 2020-12-21 11:07:05 · 1098 阅读 · 2 评论 -
配置bond脚本
function Bond_V7() { clear echo “Add Bond0” cat /etc/sysconfig/network-scripts/ifcfg-eth2 /etc/sysconfig/network-scripts/ifcfg-eth3 echo “Add Bond1” cat /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth1 echo -n -e “\033[3原创 2020-12-18 14:57:17 · 668 阅读 · 0 评论 -
用脚本查看用户的信息
#! /bin/bash Author:楚尧 Date:2020-12-20 Function:根据用户名查询该用户的所有信息 read -p “请输入要查询的用户名:” A echo “------------------------------” n=cat /etc/passwd | awk -F: '$1~/^'$A'$/{print}' | wc -l if [ n−eq0];thenecho"该用户不存在"echo"−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−"elseecho"原创 2020-12-21 10:08:06 · 421 阅读 · 0 评论