NIS深入了解如何搭建NIS环境.docx
- 文档编号:29173175
- 上传时间:2023-07-21
- 格式:DOCX
- 页数:28
- 大小:217.08KB
NIS深入了解如何搭建NIS环境.docx
《NIS深入了解如何搭建NIS环境.docx》由会员分享,可在线阅读,更多相关《NIS深入了解如何搭建NIS环境.docx(28页珍藏版)》请在冰豆网上搜索。
NIS深入了解如何搭建NIS环境
NIS-深入了解如何搭建NIS环境
1环境准备
操作系统:
CentOS7.2
Yptools和ypbind互相依赖,需要如下方式安装
[python]viewplaincopyprint?
在CODE上查看代码片派生到我的代码片
[root@node2deps-centos72_1511]#rpm-ivhyp-tools-2.14-3.el7.x86_64.rpmypbind-1.37.1-7.el7.x86_64.rpm
网络拓扑:
2搭建
2.1Masterserver端配置
2.1.1设置NIS域名
设置NIS的域名,新增如下内容:
临时设置:
[python]viewplaincopyprint?
在CODE上查看代码片派生到我的代码片
[root@node0nis]#nisdomainnamehikuss
永久设置:
[python]viewplaincopyprint?
在CODE上查看代码片派生到我的代码片
[root@node0nis]#cat/etc/sysconfig/network
#Createdbyanaconda
#设定nis的域名
NISDOMAIN=hikuss
#设定nis固定在1011端口,方便设定防火墙规则
YPSERV_ARGS="-p1011"
2.1.2设置hosts
设定IP地址与主机名的对应关系/etc/hosts,新增如下内容
[python]viewplaincopyprint?
在CODE上查看代码片派生到我的代码片
[root@node0nis]#cat/etc/hosts
192.168.192.90node0
192.168.192.91node1
192.168.192.92node2
2.1.3设置主要配置文件/etc/ypserv.conf
设定server端的主配置文件/etc/ypserv.conf
[python]viewplaincopyprint?
在CODE上查看代码片派生到我的代码片
[root@node0nis]#cat/etc/ypserv.conf
#
#ypserv.confInthisfileyoucansetcertainoptionsfortheNISserver,
#andyoucandenyorrestrictaccesstocertainmapsbased
#ontheoriginatinghost.
#
#Seeypserv.conf(5)foradescriptionofthesyntax.
#
#Someoptionsforypserv.Thisthingsareallnotneeded,if
#youhaveaLinuxnet.
#NIS服务器大多使用于内部局域网络,只要有/etc/hosts即可,不用DNS
dns:
no
#Howmanymapfilehandlesshouldbecached?
#默认会有30个数据库被读入内存当中,账号多的话,可以调大点。
files:
30
#ShouldweregisterypservwithSLP?
#slp:
no
#Afterhowmanysecondsweshouldre-registerypservwithSLP?
#slp_timeout:
3600
#xfrrequestsareonlyallowedfromports<1024
xfr_check_port:
yes
#Thefollowing,whenuncommented,willgiveyoushadowlikepasswords.
#NotethatitwillnotworkifyouhaveslaveNISserversinyour
#networkthatdonotrunthesameserverasyou.
#与master/slave有关,将同步更新的数据库比对所使用的端口,放置于<1024内。
#底下则是设定限制客户端或slaveserver查询的权限,利用冒号隔成四部分:
#[主机名/IP]:
[NIS域名]:
[可用数据库名称map]:
[安全限制security]
#[主机名/IP]:
可以使用network/netmask如192.168.124.0/255.255.255.0
#[NIS域名]:
hikuss
#[可用数据库名称]:
就是由NIS制作出来的数据库名称;
#[安全限制]:
包括没有限制(none)、仅能使用<1024(port)及拒绝(deny)
#一般来说,你可以依照我们的网域来设定成为底下的模样:
#Host:
Domain:
Map:
Security
#
#*:
*:
passwd.byname:
port
#*:
*:
passwd.byuid:
port
127.0.0.0/255.255.255.0:
*:
*:
none
192.168.192.0/255.255.255.0:
*:
*:
none
*:
*:
*:
deny
#星号(*)代表任何数据都接受的意思。
上面三行的意思是,1)开放lo内部接口、
#2)开放内部LAN网域,3)且杜绝所有其他来源的NIS要求的意思。
#还有一个简单作法,你可以先将上面三行批注,然后加入底下这一行即可:
*:
*:
*:
none
#这样会允许任何主机连接到NISserver,可以配合防火墙规则再做过滤。
#Noteverybodyshouldseetheshadowpasswords,notsecure,since
#underMSDOGeverbodyisrootandcanaccessports<1024!
!
!
*:
*:
shadow.byname:
port
*:
*:
passwd.adjunct.byname:
port
#Ifyoucommentoutthenextrule,ypservandrpc.ypxfrdwill
#lookforYP_SECUREandYP_AUTHDESinthemaps.Thiswillmake
#thesecuritycheckalittlebitslower,butyouonlyhaveto
#changethekeysonthemasterserver,nottheconfigurationfiles
#oneachNISserver.
#IfyouhavemapswithYP_SECUREorYP_AUTHDES,youshouldcreate
#aruleforthemabove,that'smuchfaster.
#*:
*:
*:
none
2.1.4设置防火墙
让yppasswdd启动在固定端口,方便防火墙管理
[python]viewplaincopyprint?
在CODE上查看代码片派生到我的代码片
[root@node0nis]#vi/etc/sysconfig/yppasswdd
YPPASSWDD_ARGS="--port1012"
2.1.5启动及开机启动
启动如下命令:
[python]viewplaincopyprint?
在CODE上查看代码片派生到我的代码片
[root@node0nis]#systemctlstartypserv
[root@node0nis]#systemctlstartrpcbind
[root@node0nis]#systemctlstatrtyppasswdd.service
设置开机启动
[python]viewplaincopyprint?
在CODE上查看代码片派生到我的代码片
[root@node0nis]#systemctlenableypserv
Createdsymlinkfrom/etc/systemd/system/multi-user.target.wants/ypserv.serviceto/usr/lib/systemd/system/ypserv.service.
[root@node0nis]#systemctlenablerpcbind
Createdsymlinkfrom/etc/systemd/system/sockets.target.wants/rpcbind.socketto/usr/lib/systemd/system/rpcbind.socket.
[root@node0nis]#systemctlenableyppasswdd.service
Createdsymlinkfrom/etc/systemd/system/multi-user.target.wants/yppasswdd.serviceto/usr/lib/systemd/system/yppasswdd.service.
2.1.6建立NIS账户和资料库
1.新建5个账号
[python]viewplaincopyprint?
在CODE上查看代码片派生到我的代码片
[root@node0nis]#foriin`seq15`;doecho"=====createnisuser$i=====";useradd-u100$inisuser$i;echopassword|passwd--stdinnisuser$i;done
2.建立资料库
ypinit命令初始化主服务器和常见NIS映射表。
默认的ypinit同make命令给出的操作一样。
按照提示ctrl+D,确认即可完成资料库建立。
[python]viewplaincopyprint?
在CODE上查看代码片派生到我的代码片
[root@node0nis]#/usr/lib64/yp/ypinit-m
Atthispoint,wehavetoconstructalistofthehostswhichwillrunNIS
servers.node0isinthelistofNISserverhosts.Pleasecontinuetoadd
thenamesfortheotherhosts,oneperline.Whenyouaredonewiththe
list,typea
nexthosttoadd:
node0
nexthosttoadd:
ThecurrentlistofNISserverslookslikethis:
node0
Isthiscorrect?
[y/n:
y]y
Weneedafewminutestobuildthedatabases...
Building/var/yp/hikuss/ypservers...
Running/var/yp/Makefile...
gmake[1]:
Enteringdirectory`/var/yp/hikuss'
Updatingpasswd.byname...
Updatingpasswd.byuid...
Updatinggroup.byname...
Updatinggroup.bygid...
Updatinghosts.byname...
Updatinghosts.byaddr...
Updatingrpc.byname...
Updatingrpc.bynumber...
Updatingservices.byname...
Updatingservices.byservicename...
Updatingnetid.byname...
Updatingprotocols.bynumber...
Updatingprotocols.byname...
Updatingmail.aliases...
gmake[1]:
Leavingdirectory`/var/yp/hikuss'
node0hasbeensetupasaNISmasterserver.
Nowyoucanrunypinit-snode0onallslaveserver.
[root@node0nis]#
2.1.7更新NIS账户和资料库
在server端新增账号或者删除账号或者修改账号信息后,就得要重新制作数据库,make-C/var/yp
[python]viewplaincopyprint?
在CODE上查看代码片派生到我的代码片
[root@node0nis]#cd/var/yp
[root@node0yp]#make
或者
[python]viewplaincopyprint?
在CODE上查看代码片派生到我的代码片
[root@node0nis]#make-C/var/yp
make:
Enteringdirectory`/var/yp'
gmake[1]:
Enteringdirectory`/var/yp/hikuss'
Updatingnetid.byname...
gmake[1]:
Leavingdirectory`/var/yp/hikuss'
make:
Leavingdirectory`/var/yp'
[root@node0nis]#
把信息写进资料库,让后client端才可以读取到最新信息
2.1.8与Slave相关的设定
当执行了ypinit-m之后,所有的主机上面的账号相关档案会被转成数据库档案,这些数据库会被放置到/var/yp/"nisdomainname"当中,
[python]viewplaincopyprint?
在CODE上查看代码片派生到我的代码片
[root@node0nis]#ls/var/yp/hikuss/
group.bygidhosts.byaddrmail.aliasespasswd.bynameprotocols.bynamerpc.bynameservices.bynameypservers
group.bynamehosts.bynamenetid.bynamepasswd.byuidprotocols.bynumberrpc.bynumberservices.byservicename
[root@node0nis]#
1.若变更了使用者帐号密码参数,针对这个档案进行数据库更新:
[python]viewplaincopyprint?
在CODE上查看代码片派生到我的代码片
[root@node0nis]#cd/var/yp/
[root@node0yp]#makepasswd
或
[root@node0nis]#make-C/var/yppasswd
[python]viewplaincopyprint?
在CODE上查看代码片派生到我的代码片
make:
Enteringdirectory`/var/yp'
Updatingpasswd.byname...
Updatingpasswd.byuid...
make:
Leavingdirectory`/var/yp'
2.开启Slave服务推送
将/var/yp/Makefile中的NOPUSH定义修改为false
[python]viewplaincopyprint?
在CODE上查看代码片派生到我的代码片
[root@node0nis]#grep"NOPUSH="/var/yp/Makefile
#slaveservers(NOPUSH=true).Ifyouhaveslaveservers,changethis
#to"NOPUSH=false"andputallhostnamesofyourslaveserversinthefile
NOPUSH=false
[root@node0nis]#
3.指定Slave服务主机,告诉master要把数据给谁->node1
[python]viewplaincopyprint?
在CODE上查看代码片派生到我的代码片
[root@node0nis]#cat/var/yp/ypservers
node0
node1
[root@node0nis]#
4.启动ypxfrd服务
可以让slave服务器主动链接上ypxfrd来更新数据库,可以免除系统管理原自己手动更新。
[python]viewplaincopyprint?
在CODE上查看代码片派生到我的代码片
[root@node0~]#systemctlstartypxfrd
设置为自动启动
[python]viewplaincopyprint?
在CODE上查看代码片派生到我的代码片
[root@node0~]#systemctlenableypxfrd
此外,如果master机器想要直接将某些特定的数据库直接传给slave主机的话,那么可以使用yppush这个指令。
例如:
#yppush-hslave.abcnispasswd.*
2.2Slaveserver端配置
2.2.1设置NIS域名
设置NIS的域名,新增如下内容
临时设置:
[python]viewplaincopyprint?
在CODE上查看代码片派生到我的代码片
[root@node0nis]#nisdomainnamehikuss
永久设置:
[root@node0nis]#cat/etc/sysconfig/network
[python]viewplaincopyprint?
在CODE上查看代码片派生到我的代码片
#Createdbyanaconda
NISDOMAIN=hikuss
YPSERV_ARGS="-p1011"
2.2.2设置hosts
设定IP地址与主机名的对应关系/etc/hosts,新增如下内容
[python]viewplaincopyprint?
在CODE上查看代码片派生到我的代码片
[root@node0nis]#cat/etc/hosts
192.168.192.90node0
192.168.192.91node1
192.168.192.92node2
2.2.3设置主要配置文件/etc/ypserv.conf
设定server端的主配置文件/etc/ypserv.conf
[python]viewplaincopyprint?
在CODE上查看代码片派生到我的代码片
[root@node0nis]#cat/etc/ypserv.conf
#
#ypserv.confInthisfileyoucansetcertainoptionsfortheNISserver,
#andyoucandenyorrestrictaccesstocertainmapsbased
#ontheoriginatinghost.
#
#Seeypserv.conf(5)foradescriptionofthesyntax.
#
#Someoptionsforypserv.Thisthingsareallnotneeded,if
#youhaveaLinuxnet.
#Howmanymapfilehandlesshouldbecached?
files:
30
#ShouldweregisterypservwithSLP?
#slp:
no
#Afterhowmanysecondsweshouldre-registerypservwithSLP?
#slp_timeout:
3600
#xfrrequestsareonlyallowedfromports<1024
xfr_check_port:
yes
#Thefollowing,whenuncommented,willgiveyoushadowlikepasswords.
#NotethatitwillnotworkifyouhaveslaveNISserversinyour
#networkthatdonotrunthesameserverasyou.
#Host:
Domain:
Map:
Security
#
#*:
*:
passwd.byname:
port
#*:
*:
passwd.byuid:
port
127.0.0.0/255.255.255.0:
*:
*:
none
192.168.192.0/255.255.255.0:
*:
*:
none
*:
*:
*:
deny
#Noteverybodyshouldseetheshadowpasswords,notsecure,since
#underMSDOGeverbodyisrootandcanaccessports<1024!
!
!
*:
*:
shadow.byname:
port
*:
*:
passwd.adjunct.byname:
port
#Ifyoucommentoutthenextrule,ypservandrpc.
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- NIS 深入了解如何搭建NIS环境 深入 了解 如何 搭建 环境