Rootop 服务器运维与web架构

2018-09-17
发表者 Venus
linux下磁盘分区扩容(非lvm)已关闭评论

linux下磁盘分区扩容(非lvm)

参考阿里云云盘扩容方法:https://help.aliyun.com/document_detail/25452.html

root@eth-public-01:~# fdisk /dev/xvdb

Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): m # 帮助命令

Help:

  DOS (MBR)
   a   toggle a bootable flag
   b   edit nested BSD disklabel
   c   toggle the dos compatibility flag

  Generic
   d   delete a partition
   F   list free unpartitioned space
   l   list known partition types
   n   add a new partition
   p   print the partition table
   t   change a partition type
   v   verify the partition table
   i   print information about a partition

  Misc
   m   print this menu
   u   change display/entry units
   x   extra functionality (experts only)

  Script
   I   load disk layout from sfdisk script file
   O   dump disk layout to sfdisk script file

  Save & Exit
   w   write table to disk and exit
   q   quit without saving changes

  Create a new label
   g   create a new empty GPT partition table
   G   create a new empty SGI (IRIX) partition table
   o   create a new empty DOS partition table
   s   create a new empty Sun partition table

Command (m for help): d # 删除原分区 不会丢失数据
Selected partition 1
Partition 1 has been deleted.

Command (m for help): n # 创建分区
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p  # 主分区
Partition number (1-4, default 1):  # 直接回车
First sector (2048-734003199, default 2048):  # 直接回车
Last sector, +sectors or +size{K,M,G,T,P} (2048-734003199, default 734003199):  # 直接回车

Created a new partition 1 of type 'Linux' and of size 350 GiB.

Command (m for help): wq # 保存退出
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

# ubuntu好像会自动挂载,再手动卸载它。
root@eth-public-01:~# umount /dev/xvdb1
root@eth-public-01:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            7.9G     0  7.9G   0% /dev
tmpfs           1.6G  8.7M  1.6G   1% /run
/dev/xvda1       18G  7.4G  9.2G  45% /
tmpfs           7.9G     0  7.9G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           7.9G     0  7.9G   0% /sys/fs/cgroup
tmpfs           1.6G     0  1.6G   0% /run/user/0

# 检查文件系统
root@eth-public-01:~# e2fsck -f /dev/xvdb1
e2fsck 1.42.13 (17-May-2015)
Pass 1: Checking inodes, blocks, and sizes
resizPass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information  
/dev/xvdb1: 110213/13107200 files (69.6% non-contiguous), 52423642/52428544 blocks
                                                                                                                                             
# 变更文件系统大小
root@eth-public-01:~# resize2fs /dev/xvdb1
resize2fs 1.42.13 (17-May-2015)
Resizing the filesystem on /dev/xvdb1 to 91750144 (4k) blocks.
The filesystem on /dev/xvdb1 is now 91750144 (4k) blocks long.

# 重新挂载即可
root@eth-public-01:~# mount -a # 我这里已经写到/etc/fstab了
root@eth-public-01:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            7.9G     0  7.9G   0% /dev
tmpfs           1.6G  8.7M  1.6G   1% /run
/dev/xvda1       18G  7.4G  9.2G  45% /
tmpfs           7.9G     0  7.9G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           7.9G     0  7.9G   0% /sys/fs/cgroup
tmpfs           1.6G     0  1.6G   0% /run/user/0
/dev/xvdb1      345G  197G  131G  61% /home

这样就实现数据不丢失且实现分区扩容。

2018-09-17
发表者 Venus
ubuntu安装ps命令已关闭评论

ubuntu安装ps命令

docker容器是debian的镜像,没有ps命令,查个进程没法查。

安装procps包

apt-get install procps

2018-09-12
发表者 Venus
钉钉保存文件到桌面提示 xxx找不到文件。请检查文件名是否正确,然后重试。已关闭评论

钉钉保存文件到桌面提示 xxx找不到文件。请检查文件名是否正确,然后重试。

钉钉接收发送的文件到桌面上,然后居然报错了。提示找不到文件。请检查文件名是否正确,然后重试。

但是保存到别的分区没有问题,应该跟钉钉没有关系(刚更新钉钉)。

怀疑是系统自带的defender问题。

找啊找,找到了。依次点击:

开始菜单 – 设置 – 更新和安全 – windows安全 – 病毒和威胁防护 – 勒索软件防护 – 受控制文件夹的访问
改为关闭就可以了。

问题解决。

2018-08-24
发表者 Venus
redis修改dump文件目录已关闭评论

redis修改dump文件目录

问题:
redis启动时,默认的dump文件(dump.rdb)是保存在redis服务启动时当前所在的路径下。
这样安装多个redis后,如果在同一个路径下启动服务,会导致dump文件数据错误。

这样就需要分开保存dump文件。

修改redis配置文件
# dump 数据文件名
dbfilename dump.rdb

# dump文件保存路径
dir /usr/local/redis

这样再启动redis后,dump文件会存在dir定义的目录中。

2018-08-23
发表者 Venus
linux下通过inode索引删除文件名包含乱码的文件或文件夹已关闭评论

linux下通过inode索引删除文件名包含乱码的文件或文件夹

不知道怎么生成的乱码文件夹,用rm删不掉,用xftp也删不掉。最后找到一个解决方法用inode索引
1、首先查看文件夹的inode值

[root@node6 home]# ll -i
total 1483836
21889025 drwxr-xr-x 2 root root 4096 Aug 2 16:08 ?½??ļ???
 8126465 drwxr-xr-x 5 root root 4096 Apr 27 09:20 data
 11 drwx------ 2 root root 16384 Mar 14 14:21 lost+found
23592961 drwxr-xr-x 5 root root 4096 Jul 7 12:24 sailei_api_jar
22806529 drwxr-xr-x 4 root root 4096 May 29 16:51 software
23199745 drwxr-xr-x 8 root root 4096 Jan 10 2018 upload
 12 -rw-r--r-- 1 root root 1519406123 May 29 17:22 upload.tar.gz

2、确认此inode值是乱码的文件夹

[root@node6 home]# find -inum 21889025
./?½??ļ???

3、删除

[root@node6 home]# find -inum 21889025 -delete
[root@node6 home]# ll
total 1483832
drwxr-xr-x 5 root root 4096 Apr 27 09:20 data
drwx------ 2 root root 16384 Mar 14 14:21 lost+found
drwxr-xr-x 5 root root 4096 Jul 7 12:24 sailei_api_jar
drwxr-xr-x 4 root root 4096 May 29 16:51 software
drwxr-xr-x 8 root root 4096 Jan 10 2018 upload
-rw-r--r-- 1 root root 1519406123 May 29 17:22 upload.tar.gz

上面是空文件夹/文件删除,不能删非空目录。

如果是非空文件夹,则用下面方法删除:

[root@node6 home]# find -inum 126943234 -exec rm -rf {} \;

会提示 No such file or directory 但实际已删除