grep 匹配文件差异
➜ /tmp/test/ cat test1 9 10 a b c ➜ /tmp/test/ cat test2 6 9 10 c x y z ➜ /tmp/test/ grep -F -v -f test1 test2 6 x y z
route del -net 192.168.0.0 netmask 255.255.255.0 dev eth1 # 删除指定网段路由 route add -net 192.168.0.0 netmask 255.255.255.0 dev eth1 # 添加指定网段路由 route add default gw 192.168.0.1 # 增加默认路由 route del default # 删除默认路由 route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.0.1 # 增加静态路由 route del -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.0.1 # 删除静态路由
ip route del 192.168.0.0/24 dev eth1 # 删除指定网段路由 ip route add 192.168.0.0/24 dev eth1 # 添加指定网段路由 ip route del via 10.2.255.254 # 删除默认路由 ip route add via 10.2.255.254 # 增加默认路由 ip route add 192.168.1.0/24 via 192.168.0.1 # 增加静态路由,192.168.0.1 为下一跳地址 ip route del 192.168.1.0/24 via 192.168.0.1 # 删除静态路由
Writing to this will cause thekernel to drop clean caches, dentries and inodes from memory, causing thatmemory to become free.
As this is a non-destructiveoperation and dirty objects are not freeable, the user should runsyncfirst.
echo 0 > /proc/sys/vm/swappiness
默认值 60,对于服务器这是一个糟糕的默认值,这个值只对笔记本适用。服务器应该设置为 0。
# cat /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 TYPE=Ethernet HWADDR=xx:xx:xx:xx:xx:xx BOOTPROTO=none ONBOOT=yes NM_CONTROLLED=no BRIDGE=br0 # cat /etc/sysconfig/network-scripts/ifcfg-br0 DEVICE=br0 TYPE=Bridge IPADDR=xx.xx.xx.xx NETMASK=xx.xx.xx.xx GATEWAY=xx.xx.xx.xx ONBOOT=yes BOOTPROTO=none NM_CONTROLLED=no DELAY=0 # cat /etc/sysconfig/network-scripts/ifcfg-eth1 TYPE=Ethernet DEVICE=eth1 ONBOOT=yes BRIDGE=br1 # cat /etc/sysconfig/network-scripts/ifcfg-br1 DEVICE=br1 TYPE=Bridge BOOTPROTO=none ONBOOT=yes
# cat /etc/network/interfaces auto lo iface lo inet loopback auto eth0 iface eth0 inet manual auto br0 iface br0 inet static address xx.xx.xx.xx netmask xx.xx.xx.xx gateway xx.xx.xx.xx bridge_ports eth0 bridge_stp off bridge_fd 0 bridge_maxwait 0 dns-nameservers xx.xx.xx.xx dns-search xxx.com
# cat /etc/default/grub 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="vconsole.keymap=us crashkernel=auto vconsole.font=latarcyrheb-sun16 net.ifnames=0 biosdevname=0 rhgb quiet" GRUB_DISABLE_RECOVERY="true" # grub2-mkconfig -o /boot/grub2/grub.cfg # mv /etc/sysconfig/network-scripts/{ifcfg-eno16777736,ifcfg-eth0} # reboot
# mkfs.ext3 -n /dev/vda1 # 非挂载情况下查看 mke2fs 1.41.12 (17-May-2010) 文件系统标签= 操作系统:Linux 块大小=1024 (log=0) 分块大小=1024 (log=0) Stride=0 blocks, Stripe width=0 blocks 51200 inodes, 204800 blocks 10240 blocks (5.00%) reserved for the super user 第一个数据块=1 Maximum filesystem blocks=67371008 25 block groups 8192 blocks per group, 8192 fragments per group 2048 inodes per group Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729
# tune2fs -l /dev/vda1 # 挂载非挂载情况都可以查看 tune2fs 1.41.12 (17-May-2010) Filesystem volume name: /boot/ Last mounted on: /boot Filesystem UUID: eaa5734f-5937-47d8-b956-e1b186f4bcd1 Filesystem magic number: 0xEF53 Filesystem revision #: 1 (dynamic) ... ...
# dumpe2fs /dev/vda1 # 可以获取更详细的信息 dumpe2fs 1.41.12 (17-May-2010) Filesystem volume name: /boot/ Last mounted on: /boot Filesystem UUID: eaa5734f-5937-47d8-b956-e1b186f4bcd1 Filesystem magic number: 0xEF53 Filesystem revision #: 1 (dynamic)
touch /forcefsck echo y > forcefsck reboot
注: CentOS 5 可以使用shutdown -rF now强制修复文件系统,但是 CentOS 6 已经失效了,推荐采用上面的方式强制重启修复文件系统
# dmidecode | grep "Product"
# dmidecode| grep "Manufacturer"
# dmidecode | grep "Serial Number"
# dmidecode | grep "CPU"
# dmidecode | grep "Socket Designation: CPU" |wc –l
# dmidecode | grep "Date"
# MegaCli -AdpBbuCmd -GetBbuStatus -aALL |grep "Charger Status"
# MegaCli -AdpBbuCmd -GetBbuStatus –aALL
# MegaCli -AdpBbuCmd -GetBbuCapacityInfo –aALL
# MegaCli -AdpBbuCmd -GetBbuDesignInfo –aALL
# MegaCli -AdpBbuCmd -GetBbuProperties –aALL
# MegaCli -AdpBbuCmd -GetBbuStatus -aALL |grep "Relative State of Charge"
# MegaCli -cfgdsply -aALL |grep "Number of DISK GROUPS:"
# MegaCli -cfgdsply –aALL
# MegaCli -PDList -aALL
# MegaCli -LDInfo -LALL –aAll
# MegaCli -PDRbld -ShowProg -PhysDrv [1:5] -a0
# MegaCli –adpCount
# MegaCli -AdpGetTime –aALL
# MegaCli -AdpAllInfo –aAll
# MegaCli -cfgdsply -aALL |grep Polic
更多参考:DELL磁盘阵列控制卡(RAID卡)MegaCli常用管理命令汇总
/etc/init.d/ 下 root 用户启动的服务还和/etc/sysconfig/init相关,默认 nofile1024「但是该文件不建议修改,可以考虑使用非 root 用户管理服务或者针对相应服务作修改」
$ gem sources --remove https://rubygems.org/ $ gem sources -a https://ruby.taobao.org/ $ gem sources -l *** CURRENT SOURCES *** https://ruby.taobao.org # 请确保只有 ruby.taobao.org $ gem install rails
sh-keygen -y -f .ssh/id_rsa
➜ ~ cat ~/.ssh/config HOST * Port 22 User root controlmaster auto controlPath ~/.ssh/master-%r@%h:%p ServerAliveInterval 30 StrictHostKeyChecking no
mysqldump --hex-blob --single-transaction --alldatabase --master-data=1 > all.sql
Dump binary strings (BINARY, VARBINARY, BLOB) in hexadecimal format (for example, ′abc′ becomes 0x616263). The affected data types are BINARY, VARBINARY, the BLOB types, and BIT.
mysqldump --databases `mysql -uroot --skip-column-names \ -e "SELECT GROUP_CONCAT(schema_name SEPARATOR ' ') \ FROM information_schema.schemata WHERE schema_name \ NOT IN ('mysql','performance_schema','information_schema');"` \ > backup.sql
OR
echo '[mysqldump]' > mydump.cnf mysql -NBe "select concat('ignore-table=', table_schema, '.', table_name) \ from information_schema.tables \ where table_schema in ('mysql', 'personnel', 'buildings')" \ >> mydump.cnf
Now the options file looks like this:
[mysqldump] ignore-table=mysql.db ignore-table=mysql.host ignore-table=mysql.user [...]
mysqldump --defaults-file=./mydump.cnf -u $DBUSER -p$DBPWD --all-databases
mysqldump --no-data --databases ... ...
mysqlbinlog -v -v --base64-output=DECODE-ROWS binlog文件名
mysql> STOP SLAVE; mysql> SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1; # 1 表示跳过 1 个 events mysql> START SLAVE;
mysql> SELECT `table_name`, `row_format` FROM `information_schema`.`tables` WHERE `table_schema`=DATABASE();
mysql> SHOW TABLE STATUS LIKE 'table_name'\G
$ mysql --help | grep '/etc/my.cnf' # 相同选项以最后一个配置文件选项为主 /etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf
server { ... ... location ^~ /test/ { rewrite ^/test/(.*) /$1 break; proxy_pass http://www.test.com; } ... ... }
server { ... ... location / { error_page 404 = @foobar; } location @foobar { rewrite .* / permanent; } ... ... }
server { ... ... listen 80 default; ... ... }
server { listen 80; server_name www.test.com; location / { include uwsgi_params; uwsgi_pass 127.0.0.1:8000; } location /static { alias /data/www/project/app/static; } ... ... }
jekyll 在解析 Markdown 转义的时候会把 {{}} 识别为模板变量,所以需要通过转义解决这个问题:
{% raw %}Hello, my name is {{name}}.{% endraw %}