RHEL6 的RHCE考试

来源:互联网 发布:淘宝不按地址发货 编辑:程序博客网 时间:2024/05/16 06:54

RHEL6 的RHCE考试分为RHCSA和RHCE两部分

考试时间:

RHCSA 2个半小时 总分300分,210分pass

RHCE 2个小时 总分300分,210分pass

 

考试环境:考试为上机考试,在一台真实机系统中,已经预安装好虚拟机,要求所有的考试题必须在虚拟机中完成。

 网络必须配置好,如果从网络不能被访问到,则考试也不能通过。

在iptables配置中如需要拒绝访问,请使用REJECT(考试过程中iptables默认策略均为ACCEPT)

考试过程中,可以选择语言环境为繁体中文

注意:所有的光盘中的软件包已经在http://ip/dir/cdom下

 

你可以用真实机来验证虚拟机中的考试实验是否正确完成

 domain40.example.com域是172.24.40.0/24网络

 tracker.com域是172.16.0.0/16网络,一般在题意中被要求拒绝的网络。

1. 开机按方向键,出现如下画面:

 2. 按e

 3. 选择内核kernel一栏,按e

4. 在如下界面输入1 (或者 S 或者 s)并回车

 5. 按b重启,进入单用户模式,并按如下操作

 

过程如下:

runlevel :查看登录级别

getenforce:查看selinux模式,为Enforcing,要改成permissive才能修改root密码

setenforce0:修改selinux模式为permissive

passwd:修改root密码

reboot:重启

RHCSA考试题:(所有的题目必须要在虚拟机里面完成,必须确保物理机起来之后虚拟机也能跟着起来)

打开物理机终端,输入virt-manager进入虚拟机配置界面)(问题:是否要在之前输入virsh aotostart vserver保证虚拟机能自动起来)

1、配置好你的主机名,ip地址,网关,DNS(虚拟机里面配置好网络之后,重启物理机,保证物理机能跟着起来)

 主机名:station.domain40.example.com

 IP:172.24.40.40/24

 网关:172.24.40.1

 DNS:172.24.40.1

答案一:

cd/etc/syscofig/network-scripts/

      ls

      vim ifcfg-eth0(修改IP地址,网关,DNS)

      IPADDR=172.24.40.40

      GATEWAY=172.24.40.1

      DNS1=172.24.40.1

      vim /etc/sysconfig/netwrok(修改主机名)

      HOSTNAME= station.domain40.example.com

答案二:

     图形界面 System->Preference->NetworkConnections 修改IP,GATEWAY,DNS

     Vim /etc/sysconfig/network(修改主机名)

2、添加3个用户,用户harry,natasha,tom,要求harry,natasha用户的附加组为admin组,tom用户的登陆shell为非交互式shell。

 答案:useradd –G admin harry

       useradd –G admin natasha

       useradd –s /sbin/nologin tom

       (id harry;id natasha 查看附加组

       cat /etc/passwd 查看登录shell)

    

3、在/home下创建一个目录,名为admins,要求所属组为admin组,组成员可以读写,其它用户没有任何权限,同组成员在目录下创建的文件的所属组也为admin组

答案:cd /home/

      mkdir admins /

      chown .admin admins/

      chmod 770 admins/

      chmod g+s admins/

  

4、配置任务计划每天的14:23分,执行echo hello 命令

 答案:which echo

       crontab –e

23 14 * ** /bin/echo hello

crontab –l (查看)

 

5、找出harry拥有的文件,拷贝到目录/opt/dir下

        cd /opt/

        mkdir dir

        find / -user harry –exec cp –rfp {} /opt/dir/ \; (-rf 强制递归,-p 拷贝权限)

 

6、从文件/etc/testfile中找出包含abcde的行,写入到文件/tmp/testfile中,要求顺序与/etc/testfile中一致

   grep ‘abcde’ /etc/testfile >/tmp/testfile

 

7、创建一个2G的交换分区,并开机自动生效,但不影响原有的swap分区

  fdisk /dev/sda

p

n

回车

+2G

t

8

l

82

W

partx –a/dev/sda

partprobe

mkswap/dev/sda8

复制UUID

swapon –a

vim/etc/fstab

UUID=XXXXXswap swap defaults 0 0

(swapon –s 查看)

 

8、创建一个用户alex,用户ID为1234,用户密码为alex111

useradd–u 1234 alex

passwdalex

alex111

alex111

(或者echo alex111|passwd –stdin alex)

9、安装一个FTP服务器,要求可以从/var/ftp/pub目录中匿名下载(需要你配置yum指向已经存在的文件服务器)

     配置yum服务器

     cd /etc/yum.repos.d

     vim local.repo

      [local]

      name=local.repo

      baseurl=file:///mnt(本题要求指向指定的文件服务器baseurl=http://)

      enabled=1

      gpgcheck=0(估计可以不用写)

  

      yum install –y vsftpd (vsftpd装好之后默认允许匿名访问) (服务装好之后顺手都chkconfig vsftpd on)

      service vsftpd restart

     

10、配置一个HTTP服务器,通过http://station.domain40.example.com可以被访问到,发布的页面请从http://ip/dir/example.html下载。

   yum install –y httpd

   chkconfig httpd on

   cd /var/www/html

   wget http://ip/dir/example.html

   cp example.com index.html

   vim /etc/httpd/conf/httpd.conf

       NameVirtualHost 192.168.0.254:80

       <VirtualHost 192.168.0.254:80>

         DocumentRoot /var/www/html/

         ServerNamestation.domain40.example.com

        </VirtualHost>

 

11、配置你的主机账号和密码验证方式为LDAP方式,通过ldapuser40可以登录成功,ldapuser40密码为:password。证书可以从下载:http://ip/dir/ldap.crt,用户登录后是没有宿主目录的,除非你配置了后续题目中的autofs

     system-config-authentication

 LDAPServer: ldap://instructor.example.com (写成域名形式ldap服务器)

  

12、配置autofs,实现ldapuser40登录成功后,有家目录/rhome/ldapuser40。家目录在172.24.40.10上被nfs共享为:/rhome/ldapuser40。并且要求,其它的ldap用户登录成功后也能正常使用宿主目录。

          cd /etc/

 vim /etc/auto.master

          /rhome /etc/auto.ldap

         cp auto.misc auto.ldap

         ldapuser40 -rw,soft,intr172.24.40.10:/rhome/ldapuser40

          * -rw,soft,intr172.16.40.10:/rhome/& (注意目录的写法:域名之后加:/ ,而不是://)

        service autofs stop

        server autofs start (autofs的一个bug,不能直接service autofs restart)f

         

13、配置你的系统时间与172.24.40.10同步

     system-config-date

 

14、把名为vo的逻辑卷容量由190M变为300M,大小浮动范围为280~320(此逻辑卷已经事先挂载)

     vgdisplay(查看vg的大小是否大于300M,如果容量不够,需要先创建pv,vgextend,lvextend)

     lvdisplay(查看lv)

  lvextend –L 300M –n /dev/vg0/vo

  resize2fs /dev/vg0/vo

  mount –a (验证)

  (缩小lvm)

  先强制检查文件系统,再减小文件系统,再减磁盘分区。挂载查看验证

  e2fsck –f /dev/vg1/lvm02

  resize2fs –f /dev/vg1/lvm02

  mount /dev/vg1/lvm01 /mnt

  lvreduce –L 1G –n /dev/vg1/lvm02

 lvdisplay(查看)

15、创建一个卷组,16M为一个extends,并在其上划分一个50个extends的逻辑卷lv,制作成ext4文件系统,并开机自动挂载到/mnt/data下

pvcreate/dev/sda7 /dev/sda8

  vgcreate –s 16M vg1 /dev/sda7 /dev/sda8

  lvcreate –l 50 –n lvm02

  mkfs.ext4 /dev/vg1/lvm02

  vim /etc/fstab

  mkdir –p /mnt/data

  mount –a(测试)

  mount

  

16、升级内核为2.6.36.7.1,设置为系统启动默认内核,并保留旧的内核可用。

查看使用的内核

cat/etc/grub.conf

cd /boot

lftp it

getdr/dom/kernel-

 rpm –ivh kernel-

vimgrub.conf

default=0

-------------------------------------------------------

RHCE考试题(注意配置selinux):(装上setroubleshootd,重启)

 注意:你的IP,主机名,网关,DNS已经配置好

 IP:172.24.30.5/24

 主机名:station.domain30.example.com

 你是域domain30.example.com的成员主机,另一个域是t3gg.com---172.25.0.0/16网络

 1、请将selinux状态设置为enforcing状态

   getenforce 1

   vim /etc/sysconfig/selinux

   SELINUX=enforcing

2、请将ip_forward功能打开,并永久生效

   vim /etc/sysctl.conf

   net.ipv4.ip_forward = 1

  sysctl –w (使之立即生效)

 如果sysctl.conf没有这个选项则使用如下命令

 sysctl –a |grep net.ipv4

 sysctl –P net.ipv4.ip_forward = 1

 sysctl -w

3、配置ssh允许harry用户访问,拒绝t3gg.com域访问

   yum install –y sshd

   chkconfig sshd on

   vim /etc/hosts.deny

   sshd: 172.25.0.0/16

   (使用iptables:

   iptables –F

   iptables –X

  iptables –Z

  iptables -nvL

  iptables –A INPUT –s 172.25.0.0/16 –p tcp–-dport 22 –j REJECT

  services iptables save (每次写完一个iptables规则就保存下来)

  iptables –nvL

 (可以使用 cat /etc/services查看端口)

  如果写错了,可以在vim /etc/sysconfig/iptables修改

4、配置ftp允许匿名从/var/ftp/pub目录中下载,拒绝t3gg.com域访问

   yum install –y vsftpd

   chkconfig vsftpd on

   services vsftpd start

   拒绝:可以卸载hosts.deny或者用iptables

   vim /etc/hosts.deny

  vsftpd: 172.25.0.0/16

  iptables –A INPUT –s 172.25.0.0/16 –p tcp–dport 20:21 –j REJECT

  services iptables save

 

5、将/root/cdrom.iso关在到/opt/data下,并设置为开机自动挂载

   cd /opt/

   mkdir data

   mount –t iso9660 –o loop /root/cdrom.iso/opt/data

   vim /etc/fstab

   /root/cdrom.iso /opt/data iso9660defaults,loop 0 0

6、配置web服务器,能被http://station.domain30.example.com访问

     yum install –y httpd

     chkconfig httpd on (成为一个习惯)

     cd /etc/httpd/conf/

   vim httpd.conf

   NameVirtualHost 172.24.30.5:80

   <VirtualHost 172.24.30.5:80>

DocumentRoot/var/www/html/

ServerNametation.domain30.example.com

</VirtualHost>

servicehttpd restart

7、配置web服务器,实现虚拟主机。 http://www.domain30.example.com能访问到/www/virtual目录下的页面,页面从http://ip/dir/example.html下载。并保证,http://station.domain30.example.com同样能被访问到之前的内容。

mkdir –p/www/virtual

cd/www/virtual

wgethttp://ip/dir/example.com

cpexample.com index.html

se managefcontext –a –t httpd_sys_content_t ‘/www(/.*)?’

 restorecon –vRF /www

vim/etc/httpd/conf/httpd.conf 新建一个虚拟主机

   <VirtualHost 172.24.30.5:80>

DocumentRoot/www/virtual/

ServerNamewww.domain30.example.com

</VirtualHost>

servicehttpd restart

用elinks测试

另外的题型:从http://ip/dir/restircted.html下载文件,能被本地用户sisi通过路径

 

   http://dtop30.dn.ws.com/restircted访问到,但是不可以被remote.com域访问。

   htpasswd –cm /etc/httpd/.htpasswd sisi 系统可以不存在此用户

   htpasswd –m /etc/httpd/.htpasswd tami (第二个以后不要有-c)

       <VirtualHost 172.24.30.5:80>

DocumentRoot/www/virtual/

ServerNamewww.domain30.example.com

<Directory“/www/virtual/”>(加上此段内容)

 AuthName “www.domain30.example.com”

 AuthType basic

 AuthUserFile /etc/httpd/.htpasswd

 Require valid-user

 </Directory>

</VirtualHost>

 services httpd restart

 

8、从http://ip/dir/restircted.html下载文件,能被本地用户harry通过路径http://station.domain30.example.com/restircted访问到,但是不可以被t3gg.com域访问。

    cd /var/www/html

wgethttp://ip/dir/restircted.htm

iptables–A INPUT –s 172.25.0.0/16 –p tcp –dport 80 –j REJECT

serviceiptables save

9、配置nfs服务器,将/common目录共享给domain30.example.com域,并允许客户端以root用户访问时,也拥有root用户权限

   yum install –y nfs

   chkconfig nfs on

   chkconfig rpcbind on (顺便加上)

   vim /etc/exports

  /common172.24.30.0/255.255.255.0(rw,no_root_squash)

 

   showmount –e 172.16.30.5

   mount –t nfs 172.16.30.5:/common /mnt(测试)

   

10、配置samba服务器,将/common共享,能被浏览到。用户harry对此共享只读,如果需要,harry用户密码为harryuser。

yuminstall –y postfix

chkconfigsmb on

useraddharry (本地必须有这样一个用户)

smbpasswd–a harry

vim/etc/samba/smb.conf

[common]

            comment = common

            path = /common

            browseable = yes

            read only = yes

testarpm(测试语法)

  getsebool –a |grep samba_share_nfs

  setsebool -P samba_share_nfs=1 (-P使其开机有效)

  services smb restart

  mount –t cifs //172.16.30.5/common /mnt –ousername=harry%harryuser

11、配置一台domian30.example.com域的邮件服务器,要求可以在服务器本地或者通过harry用户从网络上连接到服务器收发邮件。harry用户的邮箱是/var/spool/mail/harry。注意DNS服务器已经帮你做好MX记录的解析。

     yum install –y postfix

     chkconfig postfix on

     vim /etc/postfix/main.cf(修改三个地方)

     inet_interfaces = all(注释掉inet_interface = localhost)

     mydestination = example.com,domain30.example.com, localhost

     mynetworks = 172.16.30.0/24, 127.0.0.1/8

     services postfix restart

     测试:

     netstat –tulnp |grep 25 (有听到25端口就可以了)

     echo hello |mail –s “test”root@example.com

 

12、连接到邮件服务器给admin发邮件,可以被harry用户收到

 vim/etc/aliases

 admin: harry

 newaliases(应该是开机生效的意思)

13、配置内核参数 rhelblq=1,并要求可以通过/proc/cmdline验证到你的内核参数

     Vim /etc/grub.conf

     写在kernel一行的最后面

     重启之后才能看到

14、配置cron不允许tom用户使用

     useradd tom

     vim /etc/cron.deny

     tom

15、写一个脚本/root/program,要求当给脚本输入参数kernel时,脚本返回user,给脚本输入参数user时,脚本返回kernel。而脚本没有参数或者参数错误是,从标准错误输出输出“usage:/root/program kernel|user”

     

      vim /root/program

       #!/bin/bash

       if [ “$1” == “kernel”];then

        echo “user”

      elif [“$1” == “user”];then

        echo “kernel”

      else

       echo “usage:/root/program kernel|user”

       fi

     测试

        chmod a+x /root/program

         .root/program kernel

       ./root/program user

       ./root/program lll

 

16、请你访问iscsi共享存储,存储服务器的地址是172.24.30.100,分出1500M空间,格式化成ext3文件系统,挂载到/mnt/data下,并实现开机自动挂载。

        yum install –y iscsi*

        chkconfig iscsid on

        iscsiadm –m discovery –t st –p172.24.30.100

        iscsiadm –m node –T iqn.2011 –p172.24.30.100 –l

        dmesg|tail

        fdisk /dev/sdb9

        mkfs.ext3 /dev/sdb9

        cd /mnt

        mkdir data

        blkid(查看UUID号,用UUID挂载)

       vim /etc/fstab

                    Defaults,netdev

        mount –a

原创粉丝点击