节点流量问题:限速 + Telegram 告警 + 自动停机守护

使用 Linux tc 实现流量限速、月流量守护和 Telegram 实时告警

2026-02-18 · 6 min · 1080 words · Garlic Space

升级 OpenSSH

CentOS 7 和 Ubuntu 系统升级 OpenSSH 的完整指南

2025-08-24 · 2 min · 287 words · Garlic Space

docker安装 zookeeper, dubbo-admin

1 . 环境: cenos7(X86_64) + openssh 2 . 安装 配置镜像加速器, 尝试从Docker Hub下载, 速度太慢 /etc/docker/daemon.json 1 2 3 4 5 6 7 { "max-concurrent-downloads":1, "registry-mirrors": [ "https://hub-mirror.c.163.com", "https://mirror.baidubce.com" ] } 抓取zookeeper镜像 1 docker pull zookeeper 抓取dubbo-admin镜像 1 docker pull apache/dubbo-admin 启动zookeeper容器 1 docker run --name zookeeper -p 2181:2181 -d zookeeper 启动duboo-admin容器 1 2 3 4 5 6 docker run -d \ -p 8081:8080 \ -e dubbo.registry.address=zookeeper://192.168.37.201:2181 \ -e dubbo.admin.root.password=root \ -e dubbo.admin.guest.password=guest \ apache/dubbo-admin 验证 浏览器输入 1 http://192.168.37.201:8081/ 参考及引用 http://blog.csdn.net/zxl8899/article/details/107413063 Photo by Steve Johnson from Pexels

2020-12-23 · 1 min · 85 words · Garlic Space

Ext4 布局及inode,block信息统计

inode定义 node 1 2 3 4 5 The inode (index node) is a data structure in a Unix-style file system that describes a file-system object such as a file or a directory. Each inode stores the attributes and disk block locations of the object's data. File-system object attributes may include metadata (times of last change,[2] access, modification), as well as owner and permission data.[3] from inode wiki inode数据结构用于描述文件系统中的文件、目录等, 每一个inode保存了文件系统系统对象memdata如修改时间,访问时间以及权限等。Dennis Ritchie对于inode中i可能代表index,而被访问的文件列表,被组织为存放存放在磁盘上的一维数组。 block ext4文件系统以block为单位分配存储空间。 环境准备 Linux Distributions: CentOS 7 通过fdisk划出一个10M分区, 格式化为ext4 1 2 3 4 5 6 7 8 9 $ fdisk /dev/sdb ... # Start End Size Type Name 1 2048 8390655 4G Linux filesyste 2 8390656 8411135 10M Linux filesyste [root@centosgpt ~]# $ mkfs.ext4 /dev/sdb2 $ mount /dev/sdb2 /root/inode ext4布局 Group 0 Padding ext4 Super Block Group Descriptors Reserved GDT Blocks Data Block Bitmap inode Bitmap inode Table Data Blocks 1024 bytes 1 block many blocks many blocks 1 block 1 block many blocks many more blocks 由于支持Flexible且 Flex block group size:16, 下面通过dumpe2fs输出的信息可以看到 Data Block Bitmap和inode Bitmap 多扩展到了16个block长(实际使用了其中的2个) ...

2020-09-16 · 12 min · 2356 words · Garlic Space

Understanding Linux filesystems: ext4 and beyond

这篇文章Understanding Linux filesystems: ext4 and beyond 是出自opensource opensource.com 作者 Jim Salter 文章主要介绍ext简要历史,ext4一些特性及问题, 以及其他一些文件系统. ext发展过程 ext主要经历了MINIX文件系统, ext,ext2, ext3, ext几个阶段。 Minix文件系统 Andrew Tannenbaum 为了教学的目的而开发了MINIX,并于 1987 年发布。Minix有自己的文件系统, 不过比较简单最多只能处理14个字符的文件名,并且只能处理64MB的存储空间。 ext ext是由一名发过软件开发人员 Rémy Card 1992 年实现,同时他也设计了ext2, ext使用VFS抽象层,并且能够支持2G存储,以及255长度的文件名。关于时间戳,ext只有一个. ext2 Rémy Card 发现了ext的局限性,一年后也就是1993年他便设计出了ext2, ext2支持到GB级别文件大小和TB级别的文件系统大小, 但是磁盘碎片, 数据写入安全性上尚存在不足,比如: 如果在将数据写入磁盘时系统崩溃或断电,则容易发生灾难性损坏. ext3 1998年, Stephen Tweedie 改进ext2, 2001合并如2.4.25内核版本主线。ext3实现了日志来解决异常情况下数据写入不一致问题。 像之前的ext2一样,ext3使用16位内部寻址。 这意味着块大小为4K时,它可以处理的最大文件大小为2 TiB,最大文件系统大小为16 TiB。 ext4 Theodore Ts’o , 中文名曹子德 ext3主要开发人员。 2006年,发布ext4, 两年后加入 2.6.28 内核主线。 ext4比较ext3有很多新的特征:可以参见以下链接, https://ext4.wiki.kernel.org/index.php/New_ext4_features 作者文章发表的时候计划开发特征已经实现, 比如Metadata Checksums 3.1 Multiblock Allocation 3.2 Delayed Allocation 3.3 Exceed 32000 subdirectory limit 3.4 directory Inodes reservation 3.5 nsec timestamps 3.6 inode version on disk 3.7 uninitialized block groups 3.8 journal checksumming 3.9 persistent preallocation (fallocate) 3.10 Online Defragmentation 3.11 First Class Quota Support 3.12 Big Allocation Blocks 3.13 Metadata Checksums 3.14 Large file support 3.15 Large directory support ...

2020-09-16 · 1 min · 148 words · Garlic Space

查看inode相关信息

inode定义 1 2 3 4 5 The inode (index node) is a data structure in a Unix-style file system that describes a file-system object such as a file or a directory. Each inode stores the attributes and disk block locations of the object's data. File-system object attributes may include metadata (times of last change,[2] access, modification), as well as owner and permission data.[3] from inode wiki inode数据结构用于描述文件系统中的文件、目录等, 每一个inode保存了文件系统系统对象memdata如修改时间,访问时间以及权限等。Dennis Ritchie对于inode中i可能代表index,而被访问的文件列表,被组织为存放存放在磁盘上的一维数组。 环境准备 Linux Distributions: CentOS 7 通过fdisk划出一个10M分区, 格式化为ext4 1 2 3 4 5 6 7 8 9 $ fdisk /dev/sdb ... # Start End Size Type Name 1 2048 8390655 4G Linux filesyste 2 8390656 8411135 10M Linux filesyste [root@centosgpt ~]# $ mkfs.ext4 /dev/sdb2 $ mount /dev/sdb2 /root/inode inode查看 ls ls -i 文件名or目录 参数为目录的话,会显示出所有文件inode编号 1 2 3 $ echo hello world > text.txt $ ls -i test.txt 34942335 text.txt debugfs 针对ext2/ext3/ext4 ...

2020-09-15 · 2 min · 298 words · Garlic Space

close-on-exec

简介 Donald E. Porter 教授的 CSE 506: Operating Systems 教材 VFS 部分中提到Linux文件操作使用的一个标识 1 2 CLOSE_ON_EXEC – a bit that prevents file inheritance if a new binary is exec’ed (set by open or fcntl) 这个标识位支持exec执行前关闭其从父进程继承来的文件描述符 使用 设置方法: 通过fcntl 设置FD_CLOEXEC 1 2 3 int flags = fcntl(connfd, F_GETFD); flags |= FD_CLOEXEC; fcntl(connfd, F_SETFD, flags); 通过O_CLOEXEC 1 2 3 4 5 open(path, O_CLOEXEC | flags) socket(DOMAIN, SOCK_CLOEXEC | type, PROTOCOL) accept4(int sockfd, struct sockaddr *addr, \ socklen_t *addrlen, SOCK_CLOEXEC | flags); fopen(path, "re") 可以在以下这种模式下使用, fork后还是dup了父进程的文件描述符,exec后将自动关闭. 1 2 3 4 5 pid_t pid; pid = fork(); if (pid == 0) { exec(...) }; 验证 代码 server.c ...

2020-09-09 · 4 min · 710 words · Garlic Space

Tiny Core Linux 安装配置

简介 Tiny Core Linux是一个mini Linux操作系统,基于 BusyBox和FLTK提供基本功能。 其发行版本在11M-16M 官网上也提供Plus版本也只有106M。它很精致。 安装 操作系统安装 镜像下载 下载页面 http://tinycorelinux.net/downloads.html 我下载了两个版本镜像: x86版本: TinyCore-11.1.iso x86_64位版本:TinyCorePure64-11.1.iso 环境准备 我们使用的vmware 首先新建一个linux虚拟机, 我选的版本是其他Linux5.x或更高版本内核64位, 并添加了两块SATA的硬盘(默认的SCSI硬盘识别似乎有些问题) 开始安装 安装过程主要下面三个步骤 : 光盘启动操作系统; 配置网络 下载安装脚本安装; 1 . 选择镜像: 光盘镜像选择 x86版本:TinyCore-11.1.iso (不影响安装) 2 . 启动系统: 启动后会出现四个选项, 选择第三项 1 2 3 4 Boot TinyCore Boot TinyCore (on slow devices, waitusb=5) Boot Core (command line only) Boot Core (command line only on slow devices, waitusb=5) 可以看到系统后进入命令行窗口,但是这种模式下进行操作重启将全部丢失。要保留我们相关配置,需要挂载硬盘。 3 . 配置网络: 配置网卡地址路由及域名服务器。 1 2 3 sudo ifconfig eth0 192.168.xxx.202 netmask 255.255.255.0 sudo route add default gw 192.168.xxx.1 dev eth0 sudo echo nameserver 192.168.xxx.1 >> /etc/resolv.conf 4 . 下载安装脚本: 会联机下载相关安装包 1 tce-load -wi tc-install.tcz 5 . 安装: 启动安装脚本 1 sudo tc-install.sh 选择c从光盘启动 1 2 3 Core Installation. Install from [R]unning OS, from booted [C]drom, from [I]so file, or from [N]et. (r/c/i/n): c 选择f安装到本地硬盘 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 Select install type for /mnt/sr0/boot/core.gz Frugal * Use for frugal hard drive installations. Note: You will be prompted for disk/partion and formatting options. HDD * Use for pendrives. Your BIOS must support USB-HDD booting. * A single FAT partition will be made. Note: Requires dosfstools extension. Warning: This is a whole drive installation! Zip * Use for pendrives. Drive will be formatted into two FAT partitions. * One small one for USB_ZIP boot compatibility, and used to hold Tiny Core. * The remaining partition will be used for backup & extensions. Note: Requires dosfstools and perl extensions. Warning: This is a whole drive installation! Select Install type [F]rugal, [H]DD, [Z]ip. (f/h/z): f 选择1使用整个硬盘安装 1 2 3 4 5 6 Select Target for Installation of core 1. Whole Disk 2. Partition Enter selection ( 1 - 2 ) or (q)uit: 1 选择1安装到第一块硬盘上 1 2 3 4 5 6 Select disk for core 1. sda 2. sdb Enter selection ( 1 - 2 ) or (q)uit: 1 安装bootloader选择y 1 2 3 4 5 6 Would you like to install a bootloader? Most people should answer yes unless they are trying to embed Core into a different Linux distribution with an existing bootloader. Enter selection ( y, n ) or (q)uit: y Install Extensions from this TCE/CDE Directory: 选择分区格式 ext4 1 2 3 4 5 6 7 8 Select Formatting Option for sda 1. ext2 2. ext3 3. ext4 4. vfat Enter selection ( 1 - 4 ) or (q)uit: 3 设置一些启动选项, 这里先不输入, 直接回车 1 2 Enter space separated boot options: Example: vga=normal syslog showapps waitusb=5 选择y,开始安装 1 2 Last chance to exit before destroying all data on sda Continue (y/..)? 安装完毕后有以下信息回显, 安装完毕. 1 2 3 4 5 6 7 8 9 10 11 12 13 Writing zero's to beginning of /dev/sda Partitioning /dev/sda Formatting /dev/sda1 mke2fs 1.45.4 (23-Sep-2019) 1+0 records in 1+0 records out 440 bytes (440B) copied, 0.000846 seconds, 507.9KB/s UUID="XXXXXXX" Applying syslinux. /mnt/drive/tce/boot/extlinux is device /dev/sda1 Setting up core image on /mnt/sda1 Installation has completed Press Enter key to continue. 按照这个步骤把第二块硬盘也安装一下. 第二块硬盘使用镜像 TinyCorePure64-11.1.iso 安装, 使用umount卸载原有x86镜像,mount重新挂载新的镜像。 ...

2020-09-01 · 5 min · 873 words · Garlic Space

dhclient error while loading shared libraries libdns-export.so.1102

环境: cenos7(X86_64) 问题: 网站显示无法链接数据库,重启后发现无法链接服务器,通过管理端登录服务器 /var/log/messages显示 1 2 dhclient: error while loading shared libraries: libdns-export.so.1102: cannot open shared object file: No such file or directory 修复: 需要root权限 1 2 3 4 # ldconfig # dhclient --help # systemctl restart NetworkManager.service # ip -a 其他 查找过程及问题: 由于前一阵刚好在服务器上增加了防火墙相关配置,所以当时开始一直判断是防火墙设置问题。关闭防火墙后仍无法访问。 排除防火墙问题后,查看了下网络配置发现eth0没有相关IP信息。 在到/var/log/messages中查看错误信息,最终通过error定位到dhclient错误. 当然还是决定改为静态方式配置IP, 我用的是eth0, 修改下面配置即可 1 2 3 4 5 6 7 8 9 /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE="eth0" BOOTPROTO="static" ONBOOT="yes" IPADDR=XXX.XXX.XXX.XXX NETMASK=255.255.255.0 GATEWAY=XXX.XXX.XXX.XXX DNS1=XXX.XXX.XXX.XXX 相关Bug Bug 1726534 与我遇到的问题一样, 大致的意思说就是说安装一些库的时候, 比如libapr虽然安装失败,导致 /etc/ld.so.cache 保存的是老版本libdns-export.so.100 不是新版本的libdns-export.so.1102 导致dhclient载入libdns-export.so.1102失败, 通过ldconfig重新更新一下 /etc/ld.so.cache即可。 ...

2020-08-25 · 1 min · 86 words · Garlic Space

通过alternatives进行多版本间切换

上周在学习单点登录安装CAS Overlay Template要使用指定版本,当时机器上安装了多个版本的jdk使用alternatives命令进行了切换. 如果需要在多个版本应用间切换并进行管理可以使用这个命令。 alternative 前身是 Debian Linux的一个用 Perl实现的工具 update-alternatives 后续Red Hat重写了并重新命名使用在 Red Hatand CentOS版本中. alternative统一了有多个版本应用,但在UNIX中更认可通过环境变量来设置 通常定义在 /etc/profile 或 $HOME/.profile 下面用一个例子演示一下 如果有有一个应用 em ,他的新版本 nem, 由于习惯原因, 我们更习惯敲em, 可以通过下面步骤设置一下 创建 先创建两个脚本做为代表em nem应用 1 2 3 4 5 6 [root@centosgpt alternatives]# cat em #!/bin/bash echo " This is em " [root@centosgpt alternatives]# cat nem #!/bin/bash echo " This is nem " 生成一个alternative需要下面四个要素: alternatives --install <link> <name> <path> <priority> link : 统一应用名称,一个链接文件 name : alternative 的名称便于记忆 path : 实际版本的路径 priority :优先级 1 2 3 4 5 6 7 8 9 10 [root@centosgpt alternatives]# sudo alternatives --install /usr/bin/em uemacs /root/alternatives/em 1 [root@centosgpt alternatives]# sudo alternatives --install /usr/bin/em uemacs /root/alternatives/nem 99 [root@centosgpt alternatives]# alternatives --config uemacs There are 2 programs which provide 'uemacs'. Selection Command ----------------------------------------------- + 1 /root/alternatives/em * 2 /root/alternatives/nem 验证 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 [root@centosgpt ~]# em This is nem [root@centosgpt ~]# alternatives --config uemacs There are 2 programs which provide &#039;uemacs&#039;. Selection Command ----------------------------------------------- 1 /root/alternatives/em *+ 2 /root/alternatives/nem Enter to keep the current selection[+], or type selection number: 1 [root@centosgpt ~]# em This is em 移除 alternatives --remove <name> <path> ...

2020-06-28 · 2 min · 393 words · Garlic Space