首页
📈统计
📬留言
💘关于
更多
💞友链
📺直播
🎠壁纸
Search
1
docker部署chromium
5 阅读
2
prometheus+alertmanager告警
2 阅读
3
minio部署以及使用挂载
2 阅读
4
typecho背景透明设置
2 阅读
5
httpd文件服务器
1 阅读
🎑Linux
centos
ubuntu
deepin
debian
🎉Typecho
🎻小程序
🍕生活
🍞其他
☸k8s
🤖监控配置
登录
Search
标签搜索
shell
脚本
文档
doc
存储
typecho
chromium
lazy-balancer
Typecho
累计撰写
57
篇文章
累计收到
37
条评论
首页
栏目
🎑Linux
centos
ubuntu
deepin
debian
🎉Typecho
🎻小程序
🍕生活
🍞其他
☸k8s
🤖监控配置
页面
📈统计
📬留言
💘关于
💞友链
📺直播
🎠壁纸
搜索到
32
篇与
的结果
2025-03-05
rsync +infotify实时同步
背景数据备份是每个系统管理员和数据管理者都需要考虑的一个问题,无论是为了防止数据丢失、恢复数据,还是为了数据同步。然而,每个备份方案都有其优缺点。常见的备份方法有增量备份、差异备份、完全备份等。本文将介绍一种基于rsync和inotify实时备份实现方案,该方案具有快速、高效、实时同步等优点。rsync简介rsync是一个远程备份工具,用于在本地和远程计算机之间同步和备份文件。它能够实现增量备份,节省了大量时间和带宽。rsync也支持加密传输和备份,这使得它非常适合用于远程备份,同时也可用于本地备份。rsync的优点:(1)、增量备份:仅备份发生了变化的文件,节省带宽和存储空间。(2)、安全:支持加密传输和备份。(3)、支持备份到远程服务器。notify简介inotify是一个Linux内核特性,用于监控文件系统中的事件。它能够监控文件或目录的创建、删除、修改、移动等事件,通过这些事件触发的钩子,实现实时监控和响应。● inotify的优点:(1)实时性:可以实时检测文件的变化,并且响应快速。(2)精确性:能够准确的检测到文件的修改时间和内容。(3)可靠性:能够检测到文件的修改,无论是人工修改还是软件修改。rsync和inotify实时备份实现方案1、安装rsync和inotifyyum -y install rsync inotify-tools2、编写inotify+rsync脚本,实时监控文件或目录的变化#!/bin/bash while true; do sleep 2 echo "#####################################################" >> /var/log/infotify.log #echo $(date '+%c') >> /var/log/infotify.log inotifywait -r -e modify,create,delete,move /data/nfs-pods/ >> /var/log/infotify.log & rsync -avz /data/nfs-pods/ root@ip:/data/nfs-pods/ >> /var/log/infotify.log & echo " " >> /var/log/infotify.log # 查看日志大小 dus=$(ls -lh /var/log/infotify.log |awk '{print $5}'|grep G|awk -F'M' '{print $1}') b=2 # 判断日志如果大于2个G,那么就删除日志 dateus=$(awk -v num1=${dus} -v num2=${b} 'BEGIN{print(num1>num2)?"0":"1"}') echo ${dateus} if [ ${dateus} -eq 0 ];then echo "" > /var/log/infotify.log else exit 0 fi done > /dev/null 2>&1时间任务sleep 3 && /usr/local/bin/infotify3、将执行脚本放到/usr/local/bin 下mv /data/infotify /usr/local/bin/infotify chmod +x /usr/local/bin/infotify4、测试执行脚本infotify & tail -f /var/log/infotify.log ##################################################### 2023-Jul-21 10:04:07 sending incremental file list sent 289 bytes received 15 bytes 608.00 bytes/sec total size is 0 speedup is 0.00 ##################################################### 2023-Jul-21 10:04:18 sending incremental file list sent 289 bytes received 15 bytes 608.00 bytes/sec total size is 0 speedup is 0.00 ##################################################### 2023-Jul-21 10:04:28 sending incremental file list sent 289 bytes received 15 bytes 608.00 bytes/sec total size is 0 speedup is 0.00 ##################################################### 2023-Jul-21 10:04:38 sending incremental file list sent 289 bytes received 15 bytes 608.00 bytes/sec total size is 0 speedup is 0.00 ##################################################### 2023-Jul-21 10:04:48 sending incremental file list sent 289 bytes received 15 bytes 608.00 bytes/sec total size is 0 speedup is 0.00完成测试,即可使用。耗cpu及内存不高很低的哦!注意事项● rsync需要设置为无密码登录,可以使用ssh密钥实现。具体来说,需要在本地计算机上生成ssh密钥,然后将公钥添加到远程服务器的authorized_keys文件中,这样就可以无密码登录远程服务器。● inotify对监控的目录的子目录监控是有限制的,对于不在监控列表中的子目录,不会自动监控,需要手动添加监控。● 需要避免同步过程中的文件锁定和冲突,可以使用rsync的一些参数进行控制,如–exclude、–exclude-from、–delete等。
2025年03月05日
0 阅读
0 评论
0 点赞
2025-03-05
linux添加swap分区
1. 停用并删除旧的 swap 文件sudo swapoff /data/swapfile 2>/dev/null sudo rm -f /data/swapfile2. 用 dd 创建 20G 的 swap 文件(速度稍慢,但最可靠)bs=1M 每次写入 1M,count=20480 即为 20Gsudo dd if=/dev/zero of=/data/swapfile bs=1M count=10240 status=progress3. 设置正确权限sudo chmod 600 /data/swapfile4. 格式化为 swapsudo mkswap /data/swapfile5. 启用 swapsudo swapon /data/swapfile echo '/data/swapfile none swap sw 0 0' >> /etc/fstab
2025年03月05日
0 阅读
0 评论
0 点赞
2025-03-04
linux tabby sftp 和 PS1设置
添加/etc/profile.d/env.sh 变量vim /etc/profile.d/env.sh PS1="\[\e[32m\][ \[\e[33m\]\t \[\e[37m\]\u\[\e[37m\]@\[\e[35m\]\h \[\e[34m\]\w \[\e[32m\]]\[\e[0m\]\[\e[31m\]\$\[\e[0m\] " export PS1="$PS1\[\e]1337;CurrentDir="'$(pwd)\a\]'运行生效source /etc/profile.d/env.sh
2025年03月04日
0 阅读
0 评论
0 点赞
2024-12-13
telnet测试连通性
创建文件ip:portecho "12.12.12.12:22" > file创建脚本vim telnet.sh #!/usr/bin/env bash # 要读取的文件名 FILE=$1 TIMEOUT_DURATION=5 # 超时时间为 5 秒 if [ -z "$FILE" ]; then echo "Usage: $0 <file_with_ip_and_ports>" exit 1 fi # 检查文件是否存在 if [ ! -f "$FILE" ]; then echo "File not found!" exit 1 fi # 读取文件并逐行处理 while IFS=: read -r HOST PORT; do # 跳过空行 [ -z "$HOST" ] && continue # 使用 timeout 和 /dev/tcp 进行连接尝试 timeout $TIMEOUT_DURATION bash -c "echo > /dev/tcp/$HOST/$PORT" 2>/dev/null if [ $? -eq 0 ]; then echo "$HOST:$PORT telnet successful" else echo "$HOST:$PORT telnet failed" fi done < "$FILE"执行脚本chmod +x telnet.sh ./telnet.sh file
2024年12月13日
0 阅读
4 评论
0 点赞
2024-12-11
docker registry代理
前言 由于阿里云提供的docker镜像加速器,现在需要购买它的产品才能都是用。如下是采用国外服务器搭建的docker 镜像代理,https://my.vultr.com 创建一台centos,搭建好docker配置如下:国外服务器配置● 创建缓存目录/data/docker● https://registry.hub.docker.com 这个地址是Docker Hub API 地址● https://hub.docker.com 这个地址是Docker Hub 网站● 我们只需要使用外网机器代理Docker Hub API 地址即可● 连接方式 IP:5000docker run -d \ -p 5000:5000 \ --restart=always \ --name registry2 \ -v /data/registry:/var/lib/registry \ -e REGISTRY_PROXY_REMOTEURL=https://registry.hub.docker.com \ registry:2国内服务器配置● 部署docker● 配置docker daemon.json● 测试使用daemon.json配置tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["http://外网IP:5000"], "data-root": "/data/docker" } EOF加载daemon.jsonsystemctl daemon-reload && systemctl restart docker测试[root@test-03 ~]# docker pull tomcat Using default tag: latest latest: Pulling from library/tomcat ff65ddf9395b: Pull complete 1fffcd81c86b: Pull complete 23441222f0af: Downloading [==============> ] 46.23MB/157.6MB 23441222f0af: Pull complete 9ad70f2fec4f: Pull complete eb1faaa4cea3: Pull complete 64473b717cff: Pull complete 4f4fb700ef54: Pull complete ed0603f1436c: Pull complete
2024年12月11日
0 阅读
4 评论
0 点赞
2024-12-11
docker常用命令
列出所有镜像以及大小docker images --format "{{.Repository}}:{{.Tag}} {{.Size}}"
2024年12月11日
0 阅读
0 评论
0 点赞
1
...
4
5
6