/dev/vda1 Inodes that were part of a corrupted orphan linked list found.

/dev/vda1 contains a file system with errors, check forced.
/dev/vda1 Inodes that were part of a corrupted orphan linked list found.
/dev/vda1 UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.

#检查文件系统
1、ext4文件系统
fsck -y /dev/vda1
或者
fsck.ext4 -a /dev/vda1

2、xfs文件系统
xfs_repair -n /dev/vda1 #检查文件系统是否损坏,只检查文件系统是否有损坏

fsck.ext4 [-panyrcdfvtDFV] [-b superblock] [-B blocksize]
[-I inode_buffer_blocks] [-P process_inode_size]
[-l|-L bad_blocks_file] [-C fd] [-j external_journal]
[-E extended-options] device

Emergency help:
-p Automatic repair (no questions)
-n Make no changes to the filesystem
-y Assume "yes" to all questions
-c Check for bad blocks and add them to the badblock list
-f Force checking even if filesystem is marked clean
-v Be verbose
-b superblock Use alternative superblock
-B blocksize Force blocksize when looking for superblock
-j external_journal Set location of the external journal
-l bad_blocks_file Add to badblocks list
-L bad_blocks_file Set badblocks list

Usage: xfs_repair [options] device
Options:
-f The device is a file
-L Force log zeroing. Do this as a last resort.
-l logdev Specifies the device where the external log resides.
-m maxmem Maximum amount of memory to be used in megabytes.
-n No modify mode, just checks the filesystem for damage.
-P Disables prefetching.
-r rtdev Specifies the device where the realtime section resides.
-v Verbose output.
-c subopts Change filesystem parameters - use xfs_admin.
-o subopts Override default behaviour, refer to man page.
-t interval Reporting interval in seconds.
-d Repair dangerously.
-V Reports version and exits.
https://support.microsoft.com/en-in/help/3213321/linux-recovery-cannot-ssh-to-linux-vm-due-to-file-system-errors-fsck

给CentOS6.x的GRUB 加密 和 CentOS7.x的GRUB2 加密

给CentOS6.x的GRUB 加密 和 CentOS7.x的GRUB2 加密

CentOS6.x GRUB 加密 (正常引导不需要密码,在启动项编辑GRUB需要输入密码)/boot/grub/grub.conf

通过在 grub.conf 中的启动配置中加入参数对grub进行加密:
1:加密的密码可以通过 grub-md5-crypt 生成
#grub-md5-crypt (回车,输入密码)
grub-md5-crypt
Password:
Retype password:
2:vi /boot/grub/grub.conf
3:在splashimage=(hd0,0)/grub/splash.xpm.gz后面 编辑插入 password --md5 $1$zoCS20$tuerHhzJGBVMdOA3uuQWZ0
4:在引导菜单修改引导配置的时候,则需要先输入密码,按p 输入密码

CentOS7.x GRUB2 加密 (正常引导不需要密码,在启动项编辑GRUB需要输入密码)/boot/grub2/grub.cfg
与CentOS6不同CentOS7采用的是grub2,而不是grub在CentOS7中,把grub的主要配置文件放在以下三个地方。
/boot/grub2/grub.cfg (/etc/grub2.cfg 是/boot/grub2/grub.cfg 文件的符号链接,lrwxrwxrwx. 1 root root 22 Sep 18 17:53 /etc/grub2.cfg -> ../boot/grub2/grub.cfg)
/etc/grub.d/ (ls /etc/grub.d/ 00_header 00_tuned 01_users 10_linux 20_linux_xen 20_ppc_terminfo 30_os-prober 40_custom 41_custom README)
/etc/default/grub (-rw-r--r--. 1 root root 197 Sep 18 17:54 /etc/default/grub)
这三个配置文件之间的关系是 grub.cfg 里通过 ####BEGIN ##### 这种格式按照顺序调用 /etc/grub.d 里面的脚本实现不同的功能,在grub.d 目录里有很多数字开头的脚本,按从小到大的顺序执行。

1、使用root用户生成grup2加密密码
grub2-mkpasswd-pbkdf2

2、 vi /etc/grub.d/01_users
cat <<EOF
set superusers="root"
password_pbkdf2 root grub.pbkdf2.sha512.10000.8A673CE3A2512ED267EB9E275B15D8430AECFAC29893EC278BF382EFCEB11FA5E3B679C8595F19BE2FAAC07C038B9C0CC4FF81462526BD1CFC98E15F75A4CC15.17D3A434DC8A97FCBB124CDCB7044F266164C647F0F917420128219E4B8FB62F9EDA9D9E6F4D9AC4F8F2D13565C803D347B631E18B2C231EE884563F345D3CF1
EOF

3、vi/etc/grub.d/01_linux
cat <<EOF
set superusers="zhangfangzhou"
password_pbkdf2 zhangfangzhou 生成的密码加密
EOF

4、最后执行grub2-mkconfig -o /boot/grub2/grub.cfg #重新生成GRUB配置文件 (Generate a GRUB configuration file.)

CentOS 7.x 调整 I/O Scheduler(调度器)优化系统性能

Linux I/O调度器(Linux I/O Scheduler)Linux内核中的一个组成部分,用户可以通过调整这个调度器来优化系统性能,
Linux I/O调度器(Linux I/O Scheduler)是LinuxI/O体系的一个组件,它介于通用块层和块设备驱动程序之间。

目前 Linux 上有如下几种 I/O 调度算法
1.noop(No Operation) - 通常用于内存存储的设备。
2.cfq(Completely Fair Scheduler ) – 完全公平调度器。进程平均使用IO带宽。
3.Deadline – 针对延迟的调度器,每一个 I/O,都有一个最晚执行时间。
4.Anticipatory – 启发式调度,类似 Deadline 算法,但是引入预测机制提高性能。

1、查看CentOS6 CentOS7下IO支持的调度算法
CentOS 6.x
#dmesg | grep -i scheduler
io scheduler noop registered
io scheduler anticipatory registered
io scheduler deadline registered
io scheduler cfq registered (default)

CentOS 7.x
#dmesg | grep -i scheduler
[ 0.739263] io scheduler noop registered
[ 0.739267] io scheduler deadline registered (default)
[ 0.739315] io scheduler cfq registered
看到CentOS 7.x默认支持的是deadline算法,CentOS 6.x下默认支持的cfq算法,而一般我们会在SSD固态盘硬盘环境中使用noop算法

2、查看设备当前的 I/O 调度器
#cat /sys/block//queue/scheduler

假设磁盘名称是 /dev/sda
#cat /sys/block/sda/queue/scheduler
noop [deadline] cfq

3、临时生效的方法
#cat /sys/block/sda/queue/scheduler
noop [deadline] cfq
#echo cfq>/sys/block/sda/queue/scheduler
#cat /sys/block/sda/queue/scheduler
noop deadline [cfq]
CentOS7下默认的算法被调整为cfq了

4、永久生效的方法
CentOS 7.x
#grubby --update-kernel=ALL --args="elevator=deadline"
#reboot
#cat /sys/block/sda/queue/scheduler
noop [deadline] cfq

或者使用vi编辑器修改配置文件,添加elevator= cfq
#vi /etc/default/grub
GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet elevator=noop numa=off"
然后保存文件,重新编译配置文件
BIOS-Based: grub2-mkconfig -o /boot/grub2/grub.cfg
UEFI-Based: grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg

CentOS 6.x
vim /boot/grub/menu.lst 或vim /boot/grub/grub.conf
更改到如下内容
kernel /boot/vmlinuz.......... elevator=deadline rhgb quiet

CentOS7 Yum 安装zabbix-agent 3.4

CentOS7 Yum 安装zabbix-agent 3.4

RHEL 7, Oracle Linux 7, CentOS 7 快速安装zabbix-agent 3.4

1、安装zabbix yum源
rpm -Uvh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
yum install zabbix-agent

2、直接安装zabbix-agent 3.4的rpm包
rpm -Uvh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-agent-3.4.5-1.el7.x86_64.rpm

3、启动服务
chkconfig zabbix_agent on;service zabbix_agent start(和自己编译的不太一样service zabbix_agentd start)

4、设置接收服务器zabbix_server
Received empty response from Zabbix Agent at [193.70.67.100]. Assuming that agent dropped connection because of access permission 出现这样的错误,是zabbix_agentd没有设置zabbix_server的IP地址,导致zabbix_server收不到信息而失败。
/etc/zabbix/zabbix_agentd.conf

sed -i "s/Server=127.0.0.1/Server=116.255.166.1/" /etc/zabbix/zabbix_agentd.conf
sed -i "s/ServerActive=127.0.0.1/ServerActive=116.255.166.1/" /etc/zabbix/zabbix_agentd.conf (主动模式)
116.255.166.1为zabbix_server的IP地址,如果你的server有多个IP地址,使用逗号分隔多个IP地址。

在CentOS 7 / RHEL 7 / Fedora 上安装和配置xrdp详细教程

Install xrdp on CentOS 7 / RHEL 7 / Fedora
在CentOS 7 / RHEL 7 / Fedora上安装和配置xrdp详细教程

xrdp is an Open Source Remote desktop Protocol server, which allows you to RDP to your Linux server from Windows machine;
xrdp是一个开源的远程桌面协议服务器,它允许你从Windows使用RDP(Remote Desktop Protocol)远程到你的Linux服务器;

更新系统
yum update -y

安装桌面服务
yum groupinstall "X Window System" "GNOME Desktop" -y
systemctl set-default graphical.target

yum install epel-release -y
yum install xrdp -y

rpm -ql xrdp #查看安装文件
主要配置文件
/etc/xrdp/xrdp.ini
[globals]
bitmap_cache=yes 位图缓存
bitmap_compression=yes 位图压缩
port=3389 监听端口,建议修改成其他端口号

/etc/xrdp/sesman.ini
[Security]
AllowRootLogin=1 允许root登陆
MaxLoginRetry=4 最大重试次数

启动服务
systemctl enable xrdp
systemctl enable xrdp-sesman
systemctl start xrdp-sesman
systemctl start xrdp

设置防火墙
firewall-cmd --permanent --zone=public --add-port=3389/tcp
firewall-cmd --reload

或者
iptables -A INPUT -p tcp --dport 3389 -j ACCEPT
service iptables save;service iptables restart

CentOS6.x , CentOS7.x , Windows 部分VPS DD重装后磁盘大小显示不正确

CentOS6.x , CentOS7.x , Windows 部分VPS DD重装后磁盘大小显示不正确,部分VPS重装后磁盘大小显示不对,需要扩展(extend) 文件系统(filesystem)

CentOS6.x
resize2fs /dev/vda1
The resize2fs program will resize ext2, ext3, or ext4 file systems.
resize2fs命令被用来增大或者收缩未加载的“ext2/ext3/ext4”文件系统的大小。

CentOS7.x
如果是 XFS 文件系统,在线拉伸时把 resize2fs 换成 xfs_growfs。
xfs_growfs /dev/vgdemo/lv1

Windows Server
1、在命令提示符下输入 dispart
2、查看磁盘分区 list volume
3、选中需要扩展的磁盘 select volume 2
4、扩展磁盘 extend filesystem

mount: wrong fs type, bad option, bad superblock on /dev/loop0 Curre t

接上一篇文章 自己动手给国内外各种云重装纯净版的CentOS7.x(2)

按照上面的方法给阿里云服务器重装CentOS7.x的时候提示下面的错误
curl: (23) Failed writing body (11904 t= 16384)
loop: module loaded
dracut-initqueue[579]: mount: wrong fs type, bad option, bad superblock on /dev/loop0 Curre t
dracut-initqueue[579]: missing codepage or helper program, or other error
dracut-initqueue[579]: In some cases useful info is found in syslog - try
dracut-initqueue[579]: dmesg I tail or so.
dracut-initqueue[579]:Mumount: /run/initramfs/squashfs: not mounted
dracut-initqueue[579]: /sbin/dmsquash-lice-root: line 273: printf: write error: No space left on device

安装程序还需要系统中至少有 1GB RAM,无论使用图形界面、文本界面以互动方式执行安装,
还是使用 Kickstart 进行自定义安装。安装后,Red Hat Enterprise Linux Atomic Host 还需要 1GB 内存方可运行,
但在裸机硬件中的安装(不是虚拟化主机)需要 2GB RAM。
anaconda-ks.cfg和ks.cfg以及红帽官方手册 https://access.redhat.com/documentation/zh-cn/red_hat_enterprise_linux/7/html/installation_guide/sect-kickstart-syntax#sect-kickstart-commands

将内存升级为2G,则可以安装成功

在CentOS7 RHEL 7 设置GRUB2菜单的超时时间

在CentOS7 RHEL 7 设置GRUB2菜单的超时时间
Update GRUB2 menu timeout on RHEL 7 Linux

系统启动期间GRUB2超时菜单选项的默认设置为5秒。 打开/etc/default/grub grub默认配置文件。
The default settings for the GRUB2 timeout menu selection during the system boot is 5 seconds. To change this value open /etc/default/grub grub default config file. The content of the file looks similar the the one shown below:

GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="rd.lvm.lv=rhel/root crashkernel=auto \
rd.lvm.lv=rhel/swap vconsole.font=latarcyrheb-sun16 vconsole.keymap=us rhgb quiet"
GRUB_DISABLE_RECOVERY="true"