Category: Life

  • systemd使用笔记

    由 chkconfig 转变到 systemd,有点不习惯,查看所有服务

    systemd 是 Linux 内核发起的第一个程序

    systemctl list-unit-files --type=service

    查看具体一个服务信息

    systemctl status keepalived.service

    查看所有服务

    systemctl status

    具体服务的配置文件在

    /usr/lib/systemd/system/mariadb.service

    参考:
    https://linux.cn/article-6888-1.html?utm_source=weibo&utm_medium=weibo

  • 2016年5月面试经历

    车享网 国企
    陆金所
    http://www.chinadep.com/

    杨洋,达达运维岗位,面试时间26号周二上午10:00。面试地址:上海市浦东南路1036号隆宇大厦6楼

    wiwidi

    面试职位:OPS运维工程师

    面试时间:2016年4月26日(周二)上午14:00

    面试地址:上海市徐汇区漕东支路81号漕河泾实业大厦9楼(地铁1号线漕宝路站下,3号口出)

    联系电话:021-6283 8830、14782288717(蔡丽莹)

    地 图:

    ele.me

    [email protected]

    iqiyi

  • kvm 模板配置

    装好系统之后,在关机前,需要把网卡信息清理掉

    http://www.andrewklau.com/device-eth0-does-not-seem-to-be-present-delaying-initialization/

    关机后,压缩模板,使发布过程更快

    qemu-img convert -c g97m01st.img -O qcow2 centos.img
  • 使用 dd 测试 I/O 性能

    使用 dd 并结合不同的参数测试 I/O 性能

    不要在生产环境下用 dd 进行操作,准备一些测试环境进行如下操作。

    dd 参数:

    bs=BYTES 同时读取和写入的字节

    写性能测试,可以有如下 oflag 的值可以选择

    直接写 ( direct )
    同步写 ( dsync, synchronize )
    同步写 ( sync, 包含 metadata )

    对于 dd ,输入可以是 /dev/zero ,输出可以是 空 raid , 磁盘或分区, 也可以是一个文件。当使用文件方式时会比其他方式慢,因为 metadata 也要写入。

    当使用 if=/dev/zero bs=1G 的时候,需要内存有 1G 空余空间。
    要多次进行测试,并模拟日常服务器的异常情况,可以设置一些 cron 任务等,如 updatedb 。

    写 512MB 文件,只写一次,使用 oflag=direct,启用硬盘 cache ( hdparm -W1 /dev/vda )

    dd if=/dev/zero of=/root/testfile bs=512MB count=1 oflag=direct

    关闭磁盘 cache ( hdparm -W0 /dev/vda ),再测一次

    会发现开 cache 比不开 cache 快很多

    再做实验,使用 bs=512 bytes,count=1000 来写文件,总大小 512 KB。这样就模拟了频繁写磁盘的场景,同时根据显示的时间就能知道小文件每次写访问用时。

    参考:https://www.thomas-krenn.com/en/wiki/Linux_I/O_Performance_Tests_using_dd

    补充,使用 dd 测试读性能,首先清空 cache 的数据,然后读文件丢到 /dev/null

    echo 3 > /proc/sys/vm/drop_caches
    dd if=./testfile of=/dev/null bs=8k
    
  • ansible批量添加用户

    有用的 snippet

    ansible all  -l 'web' -m user -a "name=www shell=/bin/bash createhome=yes"
  • git fsck 清理 dangle objects

    经常 commit –amend,merge,rebase,reset –hard 后,会产生一些没有引用的 objects,这些有的可能会恢复你误操作后的修改,但是大部分时间是没用的。想着清理一下。

    先查看有哪些

    git fsck --full

    Dangling blob = A change that made it to the staging area/index, but never got committed. One thing that is amazing with Git is that once it gets added to the staging area, you can always get it back because these blobs behave like commits in that they have a hash too!!

    Dangling commit = A commit that isn’t directly linked to by any child commit, branch, tag or other reference. You can get these back too!

    Dangling tree

    然后查看已经没有的引用

    git reflog expire --expire=now --all

    git reflog: record when refs were update in the local repository, useful for recovering lost commits

    清理

    git gc --prune=now

    git gc: clean up and optimize the local repository

    参考:
    http://www.tekkie.ro/news/howto-remove-all-dangling-commits-from-your-git-repository/
    https://git-scm.com/docs/git-fsck
    https://git-scm.com/book/en/v2/Git-Internals-Maintenance-and-Data-Recovery