DEV=venet0
tc qdisc del dev $DEV root
tc qdisc add dev $DEV root handle 1: cbq avpkt 1000 bandwidth 100mbit
tc class add dev $DEV parent 1: classid 1:1 cbq rate 256kbit allot 1500 prio 5 bounded isolated
tc filter add dev $DEV parent 1: protocol ip prio 16 u32 match ip dst X.X.X.X flowid 1:1
tc qdisc add dev $DEV parent 1:1 sfq perturb 10
Monthly Archives: November 2013
tc limit outgoing bandwidth openvz
DEV=eth0
tc qdisc del dev $DEV root
tc qdisc add dev $DEV root handle 1: cbq avpkt 1000 bandwidth 100mbit
tc class add dev $DEV parent 1: classid 1:1 cbq rate 256kbit allot 1500 prio 5 bounded isolated
tc filter add dev $DEV parent 1: protocol ip prio 16 u32 match ip src X.X.X.X flowid 1:1
tc qdisc add dev $DEV parent 1:1 sfq perturb 10
openvz limiting packets per second rate from container
If you didn’t set this limit container can eat all your nic traffic, this is danger:
DEV=eth0
iptables -I FORWARD 1 -o $DEV -s X.X.X.X -m limit –limit 200/sec -j ACCEPT
iptables -I FORWARD 2 -o $DEV -s X.X.X.X -j DROP
centos enable apache worker mpm
Prefork is default for Centos, but you change change this:
vi /etc/sysconfig/httpd
HTTPD=/usr/sbin/httpd.worker
service httpd restart
apache check if gzip, deflate enabled on server
curl -I -H ‘Accept-Encoding: gzip,deflate’ http://www.linuxhow.tk
HTTP/1.1 200 OK
Date: Wed, 13 Nov 2013 18:08:12 GMT
Server: Apache/2.2.15 (CentOS)
X-Powered-By: PHP/5.3.3
Expires: Wed, 06 Nov 2013 18:07:07 GMT
Last-Modified: Wed, 13 Nov 2013 18:08:12 GMT
Cache-Control: no-cache, must-revalidate, max-age=0
Pragma: no-cache
X-Pingback: http://www.linuxhow.tk/xmlrpc.php
Vary: Accept-Encoding,User-Agent
Content-Encoding: gzip
Content-Length: 20
Connection: close
Content-Type: text/html; charset=UTF-8
OSSEC
OSSEC is an open source centralized log monitoring and notification system. OSSEC is often used to meet PCI Compliance central logging and intrusion monitoring requirements with a free and self-managed solution. OSSEC monitors all types of logs such as syslog, apache, maillogs, mysql logs, ftp logs, cisco IOS logs, and more. I’ll show you how to install OSSEC on the latest Red Hat Linux or CentOS 6!
list all tables current engines – mysql
mysql> show table status;
unauthenticated user mysql
mysqladmin -i3 pr
vi /etc/my.cnf
skip-networking
skip-name-resolve
skip-host-cache
skip-locking
mysql top
Mytop is a tool written in Perl for monitoring MySQL databases. Similar to how top monitors system processes, mytop monitors MySQL threads and the database’s overall performance, allowing system administrators or developers to get some insight on how applications are interacting with a database.
Mytop is included in the Fedora repositories, so it is just a yum install away. If you are using Red Hat Enterprise Linux or CentOS, mytop is available via the RPMForge third-party repositories. Other distributions may provide mytop as a package, or you can install it from source by downloading it from the Web site.
Mytop requires credentials to access the database, which can be provided via a prompt, on the command-line, or stored in the configuration file. In the interest of security, the best method is to use the –prompt option to mytop, which asks for the password each time. If you prefer, you can store the password in the configuration file. Avoid using the -p option that allows you to provide the password as one of the command-line arguments; that will display the password in the process list for any user with access to the ps command to view.
The configuration file mytop uses is ~/.mytop
user=root
#pass=sekret
host=localhost
db=test
#port=3306
socket=/var/lib/mysql/mysql.sock
header=1
color=1
MySQL users and their privileges
mysql> select user,host from mysql.user;
mysql> show grants for ‘root’@’%’;
use mysql password from config file
vi ~/.my.cnf
[client]
user=root
password=mysql_root_password
mysql skip networking from outside
bind-address = 127.0.0.1
check mysql config before restart
mysqld –help
This is useful on production servers.
low_priority_updates=1
By default MySQL treats updates as higher priority operations. You can use SELECT HIGH_PRIORITY or UPDATE LOW_PRIORITY to adjust that or you can simply set low_priority_updates option. Anyway default behavior means any UPDATE statement which is blocked by long running select will also block further selects from this table – they will have to wait until UPDATE is executing which is waiting on SELECT to complete. This is often not accounted for and people think – “OK. I write my script so it does short updates so it will not block anything” – it still may cause total block if there are long selects running.
low_priority_updates=1
concurrent_insert=2
apache show real IP after proxy – mod_rpaf
wget -q -O – http://www.atomicorp.com/installers/atomic | sh
yum install mod_rpaf
vi /etc/httpd/conf.d/mod_rpaf.conf
LoadModule rpaf_module modules/mod_rpaf.so
RPAF_Enable On
RPAF_ProxyIPs 127.0.0.1 your_proxy_server_ip
RPAF_Header X-Forwarded-For
RPAF_SetHostName On
RPAF_SetHTTPS On
RPAF_SetPort On