标签 redhat 下的文章

作者: reistlin
来源: http://www.reistlin.com/blog/431
更新时间: 2018.01
版权声明: 原创文章.转载请保留作者信息和原文完整.谢绝任何方式的摘要

redhat.pngcentos.png

# install RPM

yum install autoconf automake apr-util bind-utils curl gcc httpd-tools jwhois libtool libgssapi-devel lrzsz make mtr ntsysv openldap-devel openssl-devel pam-devel perl rpm-build screen sysstat tcpdump tcp_wrappers-devel tcp_wrappers-libs vim wget zlib-devel

# add user

useradd -u 500 reistlin; echo "密码" | passwd reistlin --stdin

# disable ipv6

echo "install ipv6 /bin/true" >> /etc/modprobe.d/disable-ipv6.conf
echo "IPV6INIT=no" >> /etc/sysconfig/network

# disable iptables

sed -i "/SELINUX/s/enforcing/disabled/" /etc/selinux/config
/etc/init.d/iptables stop
iptables -P INPUT ACCEPT
iptables -F
chkconfig iptables off
chkconfig ip6tables off

# libraries

echo "/usr/local/lib" >> /etc/ld.so.conf
echo "/usr/local/lib64" >> /etc/ld.so.conf

# DNS

cat >>/etc/resolv.conf <<EOF

# Google DNS
nameserver 8.8.8.8
nameserver 8.8.4.4
EOF

# timezone

cp -a /etc/localtime /etc/localtime.default
rm -f /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

# profile

cat >>/etc/profile <<EOF

# HisttimeFormat
HISTFILESIZE=2048
HISTSIZE=2048
HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S "
export HISTTIMEFORMAT

# Editor
export EDITOR=vim

# LANG
export LANG=zh_CN.UTF-8
EOF

# crontab

cat >>/var/spool/cron/root <<EOF

# m h  dom mon dow   command
#* * * * * /root/crontab/nginx.sh > /dev/null 2>&1
#* * * * * /root/crontab/php-fpm.sh > /dev/null 2>&1
#* * * * * /root/crontab/mysqld.sh > /dev/null 2>&1
#* * * * * /root/crontab/stunnel.sh > /dev/null 2>&1
#* * * * * /root/crontab/squid.sh > /dev/null 2>&1
#* * * * * /root/crontab/ss5.sh > /dev/null 2>&1
#* * * * * /root/crontab/kcp.ss.sh > /dev/null 2>&1
#* * * * * /root/crontab/kcp.squid.sh > /dev/null 2>&1

# NTP
59 1 * * * /usr/sbin/ntpdate 0.centos.pool.ntp.org > /dev/null 2>&1
59 2 * * * /usr/sbin/ntpdate 1.centos.pool.ntp.org > /dev/null 2>&1
59 3 * * * /usr/sbin/ntpdate 2.centos.pool.ntp.org > /dev/null 2>&1
EOF

# sshd

sed -i "s/#Port 22/Port 端口/" /etc/ssh/sshd_config
sed -i "s/#ListenAddress 0.0.0.0/ListenAddress 0.0.0.0/" /etc/ssh/sshd_config
sed -i "s/#PermitRootLogin yes/PermitRootLogin no/" /etc/ssh/sshd_config
sed -i "s/#StrictModes yes/StrictModes yes/" /etc/ssh/sshd_config

# logrotate

sed -i "s/rotate 1/rotate 6/" /etc/logrotate.conf
sed -i "s/rotate 4/rotate 12/" /etc/logrotate.conf

作者: reistlin
来源: http://www.reistlin.com/blog/390
更新时间: 2012.10
版权声明: 原创文章.转载请保留作者信息和原文完整.谢绝任何方式的摘要

redhat.png

troubleshooting_ip_routing.png

一,新建路由表 wan 和 lan

vim /etc/iproute2/rt_tables

255     local
254     main
253     default
252     wan
251     lan

二,配置路由表 wan 和 lan

vim /etc/rc.local

ip route add 202.0.0.64/26 via 202.0.0.66 dev eth1 table wan
ip route add default via 202.0.0.65 dev eth1 table wan
ip rule add from 202.0.0.66 table wan

ip route add 10.0.0.0/24 via 10.0.0.2 dev eth0 table lan
ip route add default via 10.0.0.1 dev eth0 table lan
ip rule add from 10.0.0.2 table lan

三,路由表更新缓存,立即生效

ip route flush cache

作者: reistlin
来源: http://www.reistlin.com/blog/199
更新时间: 2011.03
版权声明: 原创文章.转载请保留作者信息和原文完整.谢绝任何方式的摘要

redhat

1,安装 nfs,portmap 服务:

rpm -ivh nfs-utils-1.0.9-42.el5.i386.rpm nfs-utils-lib-1.0.8-7.6.el5.i386.rpm system-config-nfs-1.3.23-1.el5.noarch.rpm portmap-4.0-65.2.2.1.i386.rpm

2,配置 nfs 目录,权限:/etc/exports

可以通过配置 nfs 目录权限来进行访问控制,包括来源,目录,读写权限。

reistlin:~# vim /etc/exports

/home/nfs/public *(ro)
/home/nfs/domain *.reistlin.com(ro,async)
/home/nfs/backup reistlin(rw,async)

配置说明:

所有用户可以访问 /home/nfs/public 目录(只读);
来自 *.reistlin.com 域的用户可以访问 /home/nfs/domain 目录(只读);
用户 reistlin 可以访问 /home/nfs/backup 目录(读写)。

建议通过映射 UID 和 GID 的方法来设置权限:

anonuid=xxx
将远程访问的所有用户都映射为匿名用户,并指定该用户为本地用户(UID=xxx)

anongid=xxx
将远程访问的所有用户组都映射为匿名用户组,并指定该匿名用户组为本地用户组(GID=xxx)

3,配置 nfs 协议端口:/etc/sysconfig/nfs

因为 rpc 服务,mount TCP/UDP 端口都是随机的,所以会导致默认配置的 nfs 服务器,通过防火墙时无法进行正常挂载,导致 mount 失败(随机端口无法配置防火墙访问策略)

reistlin:~# vim /etc/sysconfig/nfs

RQUOTAD_PORT=875
LOCKD_TCPPORT=32803
LOCKD_UDPPORT=32769
MOUNTD_PORT=892
STATD_PORT=662

版本区别:

如果是 RHEL 5.x 版本,请直接修改 /etc/sysconfig/nfs 将里面的上述内容注释掉,重新启动NFS服务。

如果是 RHEL 4.x 版本,默认没有此文件,所以,请创建一个 nfs 配置文件放到 /etc/sysconfig 目录下。

4,启动 nfs 服务:nfs,portmap

reistlin:~# /etc/init.d/portmap start
Starting portmap:                                          [  OK  ]

reistlin:~# /etc/init.d/nfs start
Starting NFS services:                                     [  OK  ]
Starting NFS quotas:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]
Starting NFS mountd:                                       [  OK  ]

作者: reistlin
来源: http://www.reistlin.com/blog/171
更新时间: 2011.02
版权声明: 原创文章.转载请保留作者信息和原文完整.谢绝任何方式的摘要

redhat

默认安装 RHEL(Red Hat Enterprise Linux Server release 5.4 (Tikanga)),运行 [rkhunter](Rootkit Hunter 1.3.6),误报列表。

测试环境:

Red Hat Enterprise Linux Server release 5.4 (Tikanga)

[root@reistlin.com]# uname -a
Linux VM-RHEL-02 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:54 EDT 2009 i686 i686 i386 GNU/Linux

[root@reistlin.com]# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 5.4 (Tikanga)

Rootkit Hunter 1.3.6

[root@reistlin.com]# ./rkhunter  -V
Rootkit Hunter 1.3.6

Currently under active development by the Rootkit Hunter project team.
Please review your rkhunter.conf before using.
Please review the documentation before posting bug reports or questions.
To report bugs, obtain updates, or provide patches or comments, please go to:
http://rkhunter.sourceforge.net

检查结果:

System checks summary
=====================

File properties checks...
Required commands check failed
Files checked: 136
Suspect files: 6

Rootkit checks...
Rootkits checked : 253
Possible rootkits: 0

Applications checks...
Applications checked: 4
Suspect applications: 2

The system checks took: 8 minutes and 56 seconds

Info: End date is Mon Feb 21 11:24:08 CST 2011

误报文件:

/usr/bin/GET                                      [ Warning ]
Warning: The command '/usr/bin/GET' has been replaced by a script: /usr/bin/GET: perl script text executable

/usr/bin/groups                                   [ Warning ]
Warning: The command '/usr/bin/groups' has been replaced by a script: /usr/bin/groups: Bourne shell script text executable

/usr/bin/ldd                                      [ Warning ]
Warning: The command '/usr/bin/ldd' has been replaced by a script: /usr/bin/ldd: Bourne shell script text executable

/usr/bin/whatis                                   [ Warning ]
Warning: The command '/usr/bin/whatis' has been replaced by a script: /usr/bin/whatis: Bourne shell script text executable

/sbin/ifdown                                      [ Warning ]
Warning: The command '/sbin/ifdown' has been replaced by a script: /sbin/ifdown: Bourne-Again shell script text executable

/sbin/ifup                                        [ Warning ]
Warning: The command '/sbin/ifup' has been replaced by a script: /sbin/ifup: Bourne-Again shell script text executable

文件 MD5 值:

1f3f50b4551dc76eb5568952016005fc  /usr/bin/GET
b37f687b322e9fe7b0ee50408dde8770  /usr/bin/groups
690703166113ae9e73bed53463399bd7  /usr/bin/ldd
677ba807a76f2bbb7cbfcca34e8e4612  /usr/bin/whatis
a9d0955b2e5a60e28e43d59af96f3f73  /sbin/ifdown
2cff944b03ce2a0122e2b902d2cd681a  /sbin/ifup

作者: reistlin
来源: http://www.reistlin.com/blog/127
更新时间: 2011.01
版权声明: 原创文章.转载请保留作者信息和原文完整.谢绝任何方式的摘要

redhat

Part1:配置 label,挂载点目录,系统自动挂载配置文件

1,执行 e2label,配置分区 label 卷标,建议将卷标与挂载点配置一致(标准化):我们准备将 /dev/sdb1 挂载到 /home1,/dev/sdc1 挂载到 /home2

[root@reistlin.com ~]# e2label /dev/sdb1 /home1
[root@reistlin.com ~]# e2label /dev/sdc1 /home2

2,挂载点目录必须存在,所以我们需要建立 /home1 和 /home2 目录

[root@reistlin.com ~]# mkdir /home{1..2}

3,挂载点目录 /home1 和 /home2 创建成功

[root@reistlin.com /]# ls -l
total 160
drwxr-xr-x   2 root root  4096 Jan 21 12:25 home1
drwxr-xr-x   2 root root  4096 Jan 21 12:25 home2

- 阅读剩余部分 -

作者: reistlin
来源: http://www.reistlin.com/blog/126
更新时间: 2011.01
版权声明: 原创文章.转载请保留作者信息和原文完整.谢绝任何方式的摘要

redhat

Part1:格式化,设备 /dev/sdb1 和 /dev/sdc1 均为主分区(1TB)

1,执行 mkfs.ext3(mkfs -t exe3)命令格式化 /dev/sdb1

[root@reistlin.com ~]# mkfs.ext3 /dev/sdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
122109952 inodes, 244190000 blocks
12209500 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
7453 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
        102400000, 214990848

Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

- 阅读剩余部分 -

作者: reistlin
来源: http://www.reistlin.com/blog/125
更新时间: 2011.01
版权声明: 原创文章.转载请保留作者信息和原文完整.谢绝任何方式的摘要

redhat

Part1:关于主分区的配置

1,执行 fdisk -l 显示分区表信息,检查硬盘设备 /dev/sdb(1TB)

[root@reistlin.com ~]# fdisk -l

Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System

2,执行 fdisk /dev/sdb 进行分区

[root@reistlin.com ~]# fdisk /dev/sdb

The number of cylinders for this disk is set to 121601.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
   
Command (m for help):

3,按 m 显示菜单,按 p 显示分区表信息

Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

- 阅读剩余部分 -

作者: reistlin
来源: http://www.reistlin.com/blog/79
更新时间: 2010.12
版权声明: 原创文章.转载请保留作者信息和原文完整.谢绝任何方式的摘要

redhatjuniper.png

[步骤一] 服务器端配置:Redhat Enterprise Linux AS(RHEL)

1,检查 syslogd 系统进程,默认是启动状态,默认参数为:-m 0

reistlin:~# ps aux | grep syslogd
root      2619  0.0  0.0   1728   616 ?        Ss   Nov29   0:18 syslogd -m 0

2,配置 /etc/syslog.conf 文件,定义防火墙日志的 local1(提示:需要与客户端配置对应,0-6 范围,因为 Linux 系统默认使用 7 来保存 boot messages 日志),并且将日志保存到文件:/home/syslog/netscreen.log

reistlin:~# vim /etc/syslog.conf 

# Juniper NetScreen Firewall syslog messages
local1.* /home/syslog/netscreen.log

- 阅读剩余部分 -

作者: reistlin
来源: http://www.reistlin.com/blog/72
更新时间: 2010.11
版权声明: 原创文章.转载请保留作者信息和原文完整.谢绝任何方式的摘要

redhat.png

[FastDFS] 是一个开源的分布式文件系统,她对文件进行管理,功能包括:文件存储、文件同步、文件访问(文件上传、文件下载)等,解决了大容量存储和负载均衡的问题。特别适合以文件为载体的在线服务,如相册网站、视频网站等等。

FastDFS 服务端有两个角色:跟踪器(tracker)和存储节点(storage)。跟踪器主要做调度工作,在访问上起负载均衡的作用。存储节点存储文件,完成文件管理的所有功能:存储、同步和提供存取接口。

1. 环境:

Redhat Enterprise Linux AS 5.4(32bit)
FastDFS_v2.04.tar.gz
libevent-1.4.14b-stable.tar.gz

- 阅读剩余部分 -