diff --git a/docs/linux/network.md b/docs/linux/network.md index 3eb6a77..6d5d34f 100644 --- a/docs/linux/network.md +++ b/docs/linux/network.md @@ -15,3 +15,33 @@ iptables -L -vn # Fix TTL for mobile network iptables -t mangle -A POSTROUTING -j TTL --ttl-set 65 ``` + +## TC +```bash +#!/bin/bash + + interface=veth0 + + interface_limit=100mbit + download_limit=40mbit + upload_limit=40mbit + + # tc -s -d qdisc show dev veth0 + + tc qdisc show dev $interface | grep -q "qdisc pfifo_fast 0" + [ "$?" -gt "0" ] && tc qdisc del dev $interface root; sleep 1 + + tc qdisc add dev $interface root handle 1: htb default 30 + + tc class add dev $interface parent 1: classid 1:1 htb rate $interface_limit burst 15k + tc class add dev $interface parent 1:1 classid 1:10 htb rate $download_limit burst 15k + tc class add dev $interface parent 1:1 classid 1:20 htb rate $upload_limit burst 15k + + tc qdisc add dev $interface parent 1:10 handle 10: sfq perturb 10 + tc qdisc add dev $interface parent 1:20 handle 20: sfq perturb 10 + + tc filter add dev $interface protocol ip parent 1: prio 1 u32 match ip dst 0.0.0.0/0 flowid 1:10 + tc filter add dev $interface protocol ip parent 1: prio 1 u32 match ip src 0.0.0.0/0 flowid 1:20 + +``` + diff --git a/docs/progs/mariadb.md b/docs/progs/mariadb.md index 28d9456..8e41172 100644 --- a/docs/progs/mariadb.md +++ b/docs/progs/mariadb.md @@ -16,5 +16,9 @@ done ## Append field in table ```sql -ALTER TABLE existsTableName ADD COLUMN `newFieldName` varchar(64) NOT NULL DEFAULT ''; +CREATE TABLE tableName_new AS (SELECT * FROM tableName); + +ALTER TABLE tableName_new ADD COLUMN `newFieldName` varchar(64) NOT NULL DEFAULT '' AFTER `existFieldName`; + +RENAME TABLE tableName TO tableName_old; RENAME TABLE tableName_new TO tableName; ```