学习linux的笔记(三)

一、telnet安装与学习

1.保障虚拟机可以上网

2.安装telnet及telnet-server,注意,需要root权限来安装

yum install telnet

yum install telnet-server

3.因为装好telnet服务之后,默认是不开启服务的,下面我们需要修改文件来开启服务。

vi /etc/xinetd.d/telnet

修改 disable = yes 为 disable = no

4.需要激活xinetd服务

service xinetd restart

我在使用中第一次有提示错误,第二次运行就没事了

5.需要测试telnet是否成功开启

telnet localhost 如果执行命令后需要你输入用户名就是成功

6.如果不成功,可能是防火墙的问题,关闭防火墙或修改配置

iptables -I INPUT -p tcp --dport 23 -jACCEPT

iptables -I INPUT -p udp --dport 23 -jACCEPT

serivce iptables save

service iptables stop

二、nfs的安装与学习

1.基于yum的安装(能上外网)

yum -y install nfs-utils rpcbind

2 实验方案

使用2台RHEL6.4虚拟机,其中一台作为NFS共享服务器(192.168.100.1)、另外一台作为测试用的NFS客户机(192.168.100.2)

3.实现

3.1.配置NFS共享服务器。

1)安装软件包及创建共享目录。

[root@nfs-server ~]# rpm -q rpcbind nfs-utils

rpcbind-0.2.0-11.el6.x86_64

nfs-utils-1.2.3-36.el6.x86_64

[root@nfs-server ~]# mkdir /nfstest

[root@nfs-server ~]# echo "test file" > /nfstest/nfs.txt  //创建测试文件

[root@nfs-server ~]# ls -ld /nfstest                //查看测试目录权限

drwxr-xr-x. 2 root root 4096 Apr 14 07:18 /nfstest

2)修改nfs主配置文件/etc/exports,添加/nfstest共享设置。

[root@nfs-server ~]# vim /etc/exports

[root@nfs-server ~]# cat /etc/exports

/nfstest 192.168.100.2(rw,sync,no_root_squash) //设置为只对192.168.100.2用户读写权限,并同步写入内存与硬盘,开放客户端使用root身份

3)启用NFS相关服务程序。

rpcbind和nfs服务均启动成功后,执行showmount -e可查看本机当前已发布的共享资源列表:

[root@nfs-server ~]# service rpcbind start

[root@nfs-server ~]# service nfs start

[root@nfs-server ~]# chkconfig rpcbind on    //设置开机启动服务

[root@nfs-server ~]# chkconfig nfs on

[root@nfs-server ~]# chkconfig --list rpcbind  //确保服务开机启动

rpcbind        0:off1:off2:on3:on4:on5:on6:off

[root@nfs-server ~]# chkconfig --list nfs

nfs            0:off1:off2:on3:on4:on5:on6:off

[root@nfs-server ~]# showmount -e localhost    //查看本机发布共享资源

Export list for localhost:

/nfstest 192.168.100.2

3.2使用NFS客户机,查看及访问/nfstest共享。

1)客户端也需要安装相应软件

[root@client01 ~]# rpm -q rpcbind nfs-utils

rpcbind-0.2.0-11.el6.x86_64

nfs-utils-1.2.3-36.el6.x86_64

2)从客户机上查看服务器的NFS共享资源列表。

客户机必须安装了nfs-utils软件包,才能使用showmount命令查看NFS资源:

[root@client01 ~]# showmount -e 192.168.100.1

Export list for 192.168.100.1:

/nfstest 192.168.100.2

3)从客户机192.168.100.2上挂载/nfstest共享,并测试读写权限。

[root@client01 ~]# mount 192.168.100.1:/nfstest /mnt  //将共享目录挂载到本地mnt目录下

[root@client01 ~]# cd /mnt; ls

nfs.txt

[root@client01 mnt]# cd

[root@client01 ~]# cd /mnt;ls

nfs.txt

[root@client01 mnt]# touch aa.txt    //测试写入权限

[root@client01 mnt]# ll

total 4

-rw-r--r--. 1 root root  0 Apr 14 07:40 aa.txt

-rw-r--r--. 1 root root 10 Apr 14 07:18 nfs.txt

4)设置开机后自动挂载NFS共享资源。

[root@client01 ~]# vim /etc/fstab

192.168.100.1:/nfstest  /mnt  nfs  defaults  0 0  //文件类型为nfs

[root@client01 ~]# umount /mnt

[root@client01 ~]# mount -a

[root@client01 ~]# mount | tail -n 1

192.168.100.1:/nfsteston /mnt type nfs (rw,vers=4,addr=192.168.100.1,clientaddr=192.168.100.2) //开机自动挂载成功

猜你喜欢

转载自zcz123.iteye.com/blog/2236977