分类目录归档:一些经验

工作中的一些经验

RTNETLINK answers: no such process

双线双ip,碰到的问题,RTNETLINK answers: no such process,电信能通,但是网通不通,网上找的解决办法,如下:
1.当前路由表是否齐全

cat /etc/iproute2/rt_tables

2.相应ip配置是否正确

ip ro add default via 192.168.0.1 dev eth0
注意:当前eth0 一定要有192.168.0.0/24网段的ip

3.当前网卡物理连接是否正常
ethtool eth0

异常处理:

1。清空iptables

2。重启机器

鸡鸡哥的nginx优化参数一backlog=8192

nginx服务器报错:
“connect() to unix:/dev/shm/fcgi.sock failed (11: Resource temporarily unavailable) while connecting to upstream”
解决:
修改
1、cat /proc/sys/net/core/somaxconn查看somaxconn的值,默认是128,
echo 8192 > /proc/sys/net/core/somaxconn,放到/etc/rc.local中
2、修改nginx配置文件,添加如下
继续阅读

nginx反向代理未备案网站时碰到的问题总结

关于未备案,通过nginx反向代理访问网站的问题
域名:www.hardwork.cn
idc提供:vhost1000.idc.com二级域名可以访问网站,其它任何端口,使用域名www.hardwork.cn无法访问到网站,均提示,未备案

解决:
1、nginx反向代理配置,容易
如proxy_pass http://vhost1000.idc.com即可

2、问题:页面中的连接全部变成了类似于:http://vhost1000.idc.com/img/logo.gif,虽然通过www.hardwork.cn能访问到页面
解决,使用nginx的sub_filter模块来替换页面上的vhost1000.idc.com二级域名为www.hardwork.cn
如下:
继续阅读

sort+uniq计算重复行

1.对于重复行的不同处理:

sort和uniq都可以去除重复行,
sort是去除所有重复行
uniq是去除连续的重复行,中间不能隔和其他信息

2.uniq中的-c选项:打印每一重复行出现的次数,导致我们统计的时候会直接使用这一命令,而不用编写或者使用复杂的命令。
但是它对重复行的定义是连续的,所有我们就用到的sort来排序,使相同的行连续起来。再利用uniq统计数量。

这就是著名的”sort | uniq -c”统计数量了。你也可以”sort | uniq -c | sort -nr”来排序。

当然sort和uniq还有许多不同的选项,选择在不同的时候,使用合适的命令才是我们最后的选择。

sshd超时断开问题

1、echo $TMOUT
如果显示空白,表示没有设置, 等于使用默认值0, 一般情况下应该是不超时. 如果大于0, 可以在如/etc/profile之类文件中设置它为0.
Definition: TMOUT: If set to a value greater than zero, the value is interpreted as the number of seconds to wait for input after issuing the primary prompt. Bash terminates after waiting for that number of seconds if input does not arrive

2、修改/etc/ssh/sshd_config文件,将ClientAliveInterval 0和ClientAliveCountMax 3的注释符号去掉,将ClientAliveInterval对应的0改成60,ClientAliveInterval指定了服务器端向客户端请求消息的时间间隔, 默认是0, 不发送.而ClientAliveInterval 60表示每分钟发送一次, 然后客户端响应, 这样就保持长连接了.ClientAliveCountMax, 使用默认值3即可.ClientAliveCountMax表示服务器发出请求后客户端没有响应的次数达到一定值, 就自动断开. 正常情况下, 客户端不会不响应.

想参考更多,请输入man sshd_config了解更多信息

deflate ddos防火墙

linux下被ddos,如果你实在没办法,试试这个吧,也许能帮你忙

http://deflate.medialayer.com/

上面的防火墙上了,还是不行,继续研究
发现被ddos有个规律,一旦断网,服务器的php-cgi马上到100%,内网是通的,外网就断了
当php-cgi占用cpu下来时,网络通了,网站也能正常打开,于是有了下面的脚本
#!/bin/bash
while true
do

PIDS=`top -bn 1 | grep "^ *[1-9]" | awk '{ if ( $2 == "www" && $9>80 ) print $1}'`
for PID in $PIDS
do
kill $PID
done
sleep 10

done

xwindows远程连接centos

http://www.netsarang.com/products/xmg_faq.html#a-1

其实就是官方的faq文档:

For XDMCP connection to Red Hat 7, Red Hat 8, Red Hat 9, Red Hat 3.0 AS
1. XDM Configuration
1. Change runlevel to 5

Open/etc/inittab and set the initial runlevel to 5 as following:
id:5:initdefault:

 

2. Enable XDMCP 
   For GDM:
 
Open /etc/X11/gdm/gdm.conf and set the Enable entry to 1 in the [xdmcp] section as following.
[xdmcp]
Enable=1

 

   For KDM:
 
Open /etc/X11/xdm/xdm-config comment out the “requestPort” option as following:
DisplayManager.requestPort: 0 ==>
!DisplayManager.requestPort: 0
Open /etc/X11/xdm/Xaccess and remove the initial “#” character for the following line:
#* #any host can get a login window ==>
* #any host can get a login window
Open /etc/kde/kdm/kdmrc and set the Enable entry to true in the [xdmcp] section as following.
[xdmcp]
Enable=true

 

2. Firewall (TCP/UDP Ports) Configuration
Open UDP port 177 from the PC to the remote host direction.
Open incoming TCP ports 6000~6010 from the remote host to your PC.
3. Reboot the remote host and start Xmanager
# init 3; init 5
For XDMCP connection to Red Hat 5 EL
1. XDM Configuration
1. Change runlevel to 5

Open/etc/inittab and set the initial runlevel to 5 as following:
id:5:initdefault:

 

2. Enable XDMCP 
   For GDM:
 
Open /etc/gdm/custom.conf and set the Enable entry to 1 in the [xdmcp] section as following.
[xdmcp]
Enable=1

 

   For KDM:
 
Open /usr/share/config/kdm/Xaccess and remove the initial “#” character for the following line:
#* #any host can get a login window ==>
* #any host can get a login window
Open /usr/share/config/kdm/kdmrc and set the Enable entry to true in the [xdmcp] section as following.
[xdmcp]
Enable=true

 

2. Firewall (TCP/UDP Ports) Configuration
Open UDP port 177 from the PC to the remote host direction.
Open incoming TCP ports 6000~6010 from the remote host to your PC.
3. Reboot the remote host and start Xmanager
# init 3; init 5
For XDMCP connection to Red Hat 4 EL
1. XDM Configuration
1. Change runlevel to 5

Open/etc/inittab and set the initial runlevel to 5 as following:
id:5:initdefault:

 

2. Enable XDMCP 
   For GDM:
 
Open /etc/X11/gdm/gdm.conf set the Enable entry to true in the [xdmcp] section as following.
[xdmcp]
Enable=true

 

   For KDM:
 
Open /usr/share/config/kdm/Xaccess and remove the initial “#” character for the following line:
#* #any host can get a login window ==>
* #any host can get a login window
Open /usr/share/config/kdm/kdmrc and set the Enable entry to true in the [xdmcp] section as following.
[xdmcp]
Enable=true

 

2. Firewall (TCP/UDP Ports) Configuration
Open UDP port 177 from the PC to the remote host direction.
Open incoming TCP ports 6000~6010 from the remote host to your PC.
3. Reboot the remote host and start Xmanager
# init 3; init 5

没看明白的给我留言,我来翻译。呵呵。