由于公司不同网段的区分,导致互访很不方便。别的网段的用户要访问我们的服务器,通过端口映射是比较方便的方式。
PC A: eth0  10.10.1.11,  eth1 192.168.0.11
PC B:    eth1  192.168.0.20

要使访问A的10.10.1.11:8000端口能访问到B的8000端口,通过iptables就能简单实现。命令如下:

iptables -t nat -A PREROUTING -d 10.10.1.11 -p tcp --dport 8000 -j DNAT --to-destination 192.168.0.20:8000
iptables -t nat -A POSTROUTING -d 192.168.0.20 -p tcp --dport 8000 -j SNAT --to 192.168.0.11
iptables -A FORWARD -o eth1 -d 192.168.0.20 -p tcp --dport 8000 -j ACCEPT
iptables -A FORWARD -i eth1 -s 192.168.0.20 -p tcp --sport 8000 -j ACCEPT

其中前面两条是必须的,如果你的iptables还有其他规则,或者默认策略为drop,最好加上后面两条。
还有一个不得不改的地方是 /etc/sysctl.conf,将net.ipv4.ip_forward的值改为1。
为了使设置生效,可以使用 sysctl -p 命令刷新。有些教程说要重启系统才可以,其实就是没用这个命令。还有些教程说要修改 /proc/sys/net/ipv4/ip_forward,其实和sysctl -p的作用是一样的。

————————————华丽的分割线——————————————

除了用iptables外,还可以用软件rinetd。

rinetd的下载地址: http://www.boutell.com/rinetd/http/rinetd.tar.gz

下载之后解压:tar -zxvf rinetd.tar.gz,之后就是简单的make, make install。安装时会提示没有/usr/man/ 文件夹,手动创建一个再试即可。在centos5下编译会提示警告,可以无视。

编辑/etc/rinetd.conf,按如下格式添加
绑定地址 绑定端口 目的地址 目的端口
例如
10.10.1.11 8000 192.168.0.20 8000
如果要绑定主机上的所有IP,可以用0.0.0.0代替。
完成后启动rinetd。
rinetd -c /etc/rinetd.conf
关闭rinetd
pkill rinetd

 

今天ERP系统运行超慢,前几天才重启的系统,运行的反而比重启之前还慢了。磁盘IO高的离谱,一直在90%以上,不时飙到100%。请教高人,原来AIX 5 的lru_file_repage 参数默认是1,需要设置为0。简单说来这个参数是控制分页替换策略的,在大多数环境下,计算性分页的使用率更高,所以要尽量保留在内存中,设置为0也就更加合理。在AIX6中这个参数的默认值已经是0。

还有几个参数maxperm%、minperm%、maxclient%也值得关注。

PS:查看磁盘IO情况可以用filemon -o /tmp/filemon.out -O all 输出到/tmp/filemon.out,用trcstop停掉

深入学习:AIX 分页替换技术入门

 

适用于CentOS5.5的服务器

chkconfig acpid off
chkconfig anacron off
chkconfig atd off
chkconfig bluetooth off
chkconfig cups off
chkconfig firstboot off
chkconfig hidd off
chkconfig ip6tables off
chkconfig iptables off
chkconfig kudzu off
chkconfig mcstrans off
chkconfig microcode_ctl off
chkconfig restorecond off
chkconfig sendmail off
chkconfig setroubleshoot off
chkconfig yum-updatesd off

acpid : linux新型电源管理标准,建议笔记本使用
anacron :和 cron 相似的任务调度器,只不过它并不要求系统持续运行
atd :运行用户用at命令调度的任务,需要用到at的得留着
bluetooth :蓝牙的,没有就关了
cups :不做打印服务器的就关了吧
firstboot :系统安装后第一次启动的配置工具
hidd :蓝牙的输入支持
ip6tables :ipv6防火墙
iptables :内网的话就懒得配置防火墙了
kudzu :新增硬件检测
mcstrans :主要用于SELinux,不开SELinux的话就关了
microcode_ctl :IA32微码驱动程序
restorecond :SELinux用于监控文件
sendmail :邮件程序,如果不是邮件服务器就关了
setroubleshoot :SELinux Troubleshooting
yum-updatesd :连不上外网,关了

 

Linux下的LVM是个好东东,调整分区非常方便。网上很多文章都提到用lvresize来分配分区大小,但是都没有提到需要用resize2fs来使设置生效,不知道是不是linux版本的原因。我的使用环境是CentOS5.5,ext3的文件格式。贴一下过程以备忘。

[root@ou ~]# df -h
文件系统              容量  已用 可用 已用% 挂载点
/dev/mapper/VG01-LV_ROOT
 9.7G  3.9G  5.3G  43% /
/dev/sda1              99M   12M   82M  13% /boot
tmpfs                 506M     0  506M   0% /dev/shm
/dev/mapper/VG01-LV_APPS
 2.0G   68M  1.9G   4% /apps
[root@ou ~]# vgdisplay
 --- Volume group ---
 VG Name               VG01
 System ID
 Format                lvm2
 Metadata Areas        1
 Metadata Sequence No  14
 VG Access             read/write
 VG Status             resizable
 MAX LV                0
 Cur LV                2
 Open LV               2
 Max PV                0
 Cur PV                1
 Act PV                1
 VG Size               18.88 GB
 PE Size               32.00 MB
 Total PE              604
 Alloc PE / Size       384 / 12.00 GB
 Free  PE / Size       220 / 6.88 GB
 VG UUID               Mk4SOE-0ydq-8Kov-QdDw-d4eL-MXaF-G5i6bv
[root@ou ~]# lvresize -L +2G /dev/mapper/VG01-LV_APPS
 Extending logical volume LV_APPS to 4.00 GB
 Logical volume LV_APPS successfully resized
[root@ou ~]# df -h
文件系统              容量  已用 可用 已用% 挂载点
/dev/mapper/VG01-LV_ROOT
 9.7G  3.9G  5.3G  43% /
/dev/sda1              99M   12M   82M  13% /boot
tmpfs                 506M     0  506M   0% /dev/shm
/dev/mapper/VG01-LV_APPS
 2.0G   68M  1.9G   4% /apps
[root@ou ~]# resize2fs /dev/mapper/VG01-LV_APPS
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/mapper/VG01-LV_APPS is mounted on /apps; on-line resizing required
Performing an on-line resize of /dev/mapper/VG01-LV_APPS to 1048576 (4k) blocks.
The filesystem on /dev/mapper/VG01-LV_APPS is now 1048576 blocks long.

[root@ou ~]# df -h
文件系统              容量  已用 可用 已用% 挂载点
/dev/mapper/VG01-LV_ROOT
 9.7G  3.9G  5.3G  43% /
/dev/sda1              99M   12M   82M  13% /boot
tmpfs                 506M     0  506M   0% /dev/shm
/dev/mapper/VG01-LV_APPS
 4.0G   69M  3.7G   2% /apps
© 2012 一起去看海 Suffusion theme by Sayontan Sinha