歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Unix知識 >> 關於Unix

NIS下solaris和linxu的client實現AutoFS


這是我同事(alex)原創,寫的很好,抄過來,大家學習研究分享之用,謝謝!
-----------------------------------------------------------------
這幾天,做了試驗 是用solaris做nis server和 client 用solaris和linux實現auto_home和autofs
找了不少資料,都不完整,自己斷斷續續的寫和裝,可能有狠多錯誤.
slave server 沒做,是網上找的,因為現實用的不多,為了完整湊的
NIS 管理域testdomain
NIS master server ip address: 10.1.100.2 ,hostname:SUN-2
NIS slave server ip address: 10.1.100.1 ,hostname:SUN-1
Default: NIS source files 存放在/etc目錄下,這樣map 的內容會與Master server的local files 相同,建議不要存放在/etc目錄下。可通過修改/var/yp/Makefile,更改/etc換成你想要的directory。


# Set the following variable to "-b" to have NIS servers use the domain
name
# resolver for hosts not in the current domain.
#B=-b
B=
DIR =/etc
#
# If the passwd, shadow and/or adjunct files used by rpc.yppasswdd
# live in directory other than /etc then you'll need to change the
# following line.
# DO NOT indent the line, however, since /etc/init.d/yp attempts
# to find it with grep "^PWDIR" ...
#
PWDIR =/etc
DOM = `domainname`
NOPUSH = ""
ALIASES = /etc/mail/aliases
YPDIR=/usr/lib/netsvc/yp

NIS Master Server ---------solaris
2、#domainname testdomain
3、#domainname >; /etc/defaultdomain
4、#vi /etc/hosts
10.1.100.2 SUN-2
5、# vi /etc/auto_home
SUN-2:/export/home/&(如果 不配置slave server 可以不寫)
6、#touch /etc/ethers /etc/bootparams /etc/netgroup /etc/netmasks. (系統不能建立,不建立可能報錯)
7、#ypinit –m
In order for NIS to operate successfully, we have to construct a list of
the NIS servers. Please continue to add the names for YP servers in order
of preference, one per line. When you are done with the list, type
a ; or a return on a line by itself.
next host to add: SUN-2
next host to add: SUN-1 (如果 不配置slave server 可以不寫)
next host to add:^D
The current list of yp servers looks like this:
server1
Is this correct? [y/n: y] y
Installing the YP database will require that you answer a few questions.
Questions will all be asked at the beginning of the procedure.
Do you want this procedure to quit on non-fatal errors? [y/n: n] n
OK, please remember to go back and redo manually whatever fails. If you
don't, some part of the system (perhaps the yp itself) won't work.
#/usr/lib/netsvc/yp/ypstart
# ypwhich –m :如果能看到Master server的信息說明configure 成功
NIS Client --------solaris
2、#vi /etc/hosts
10.1.100.2SUN-2 loghost
10.1.100.1 SUN-1
3、#domainname testdomain
4、#domainname >; /etc/defaultdomain
5、#ypinit –c
(when prompted for a list of NIS servers,enter the names of the NIS master
and all slave servers)
6、#/usr/lib/netsvc/yp/ypstart
# ypwhich –m :如果能看到Master server的信息說明configure 成功
NIS slave server --------solaris
2、edit the /etc/hosts file to ensure that the NIS master and all
NIS slave servers have been defined
3、#domainname testdomain
4、#domainname >; /etc/defaultdomain
5、#ypinit -c
(when prompted for a list of NIS servers,enter the names of the NIS master
and all slave servers)
(on the NIS master,ensure the ypserv process is running ,we can use
#ps –ef|grep ypserv)
6、#/usr/lib/netsvc/yp/ypstart
7、#ypinit –s
(if you did not add the name of the NIS slave server when you initially
configured the NIS master server,you should run #ypinit –m once more on
the NIS master server)
NIS client--------linux
先看 ypbind是否起來,否則用 rpm 安裝。省略..
ntsysv﹐確定 ypbind 選擇
1/bin/nisdomainname testdomain
domain testdomain
ypserver SUN-2 或主機的ip
3修改 /etc/sysconfig/network
加入
NISDOMAIN=testdomain
4修改 /etc/nsswitch﹐修改
passwd: files nis nisplus
shadow: files nis nisplus
group: files nis nisplus
修改 /etc/passwd﹐在末尾加入﹕
+:::::: # 就是 + 號和6個冒號,(看文檔說的 ,不知道原因,請高手指點)
然後啟動ypbind﹕
service ypbind restart
應該就OK了
AUTOFS—solaris
首先 建立好你要mount的目錄
這裡主要是對Makefile文件的修改 ./var/yp下的
1,vi /var/yp/Makefile(粗體是你要添加的)
all: passwd group hosts ipnodes ethers networks rpc services protocols \
netgroup bootparams aliases publickey netid netmasks c2secure \
timezone auto.master auto.home auto.test\
2
...
auto.master: auto.master.time
auto.home: auto.home.time
auto.test: auto.test.time
auth.attr:auth.attr.time
exec.attr:exec.attr.time
prof.attr:prof.attr.time
user.attr:user.attr.time
audit.user:audit.user.time
$(DIR)/netid:
$(DIR)/timezone:
$(DIR)/auto_master:
$(DIR)/auto_home:
$(DIR)/auto_test:
$(PWDIR)/shadow:
3這個文件要自己添加的,注意 空格,和TAB 是區分的,不然,等會Make你就死的狠難看啊..(當時 痛苦死…)
auto.direct.time: $(DIR)/auto_direct
-@if [ -f $(DIR)/auto_direct ]; then \
sed -e "/^#/d" -e s/#.*$$// $(DIR)/auto_direct \
| $(MAKEDBM) - $(YPDBDIR)/$(DOM)/auto.direct; \
touch auto.direct.time; \
echo "updated auto.direct"; \
if [ ! $(NOPUSH) ]; then \
4
然後,執行
/usr/ccs/bin/make
Atuofs----Linux
確定autofs服務的running.然後運行 ntsysv 選擇 autofs
修改/etc/auto.master ﹐加入如下句子﹕
/home /etc/auto.home --timeout=60
然後 vi /etc/auto.home
* test:/export/home/&
mkdir /home/yphome
最後執行 autofs 和 ypbind 服務﹕
servcie autofs restart
service ypbind restart
注意: 1有時候出現make正常但,autofs不上,我的原因是 域名的原因,請注意,有域名和管理域名的區別吧..
2,可能出現什麼 RPC錯誤的用rpcinfo命令查看,我沒遇到,所以不說了
關於Linux的NFS與Solaris不同點:
1. Solaris的目錄共享設置文件是/etc/dfs/dfstab, 而RadHat Linux共享目錄設置文件是/etc/exports
2. Solaris開機自動mount設置文件是/etc/vfstab, 而RadHat Linux開機自動mount設置文件是/etc/fstab
Copyright © Linux教程網 All Rights Reserved