[root@server ~]# systemctl enable ypserv Created symlink from /etc/systemd/system/multi-user.target.wants/ypserv.service to /usr/lib/systemd/system/ypserv.service. [root@server ~]# systemctl restart ypserv [root@server ~]# systemctl status ypserv ● ypserv.service - NIS/YP (Network Information Service) Server Loaded: loaded (/usr/lib/systemd/system/ypserv.service; enabled; vendor preset: disabled) Active: active (running) since Sat 2017-05-2009:41:30 CST; 9s ago Main PID:3298 (ypserv) Status:"Processing requests..." CGroup:/system.slice/ypserv.service └─3298/usr/sbin/ypserv-f
May 2009:41:30 server systemd[1]: Starting NIS/YP (Network Information Service) Server... May 2009:41:30 server ypserv[3298]: WARNING: no securenets file found! May 2009:41:30 server systemd[1]: Started NIS/YP (Network Information Service) Server. [root@server ~]#
At this point, we have to construct a list of the hosts which will run NIS servers. serverisin the list of NIS server hosts. Please continue to add the names for the other hosts, one per line. When you are done with the list, type a <control D>. next host to add: server next host to add:
到这里按 ctrl+d
[root@server ~]# /usr/lib64/yp/ypinit -m
At this point, we have to construct a list of the hosts which will run NIS servers. server is in the list of NIS server hosts. Please continue to add the names for the other hosts, one per line. When you are done with the list, type a <control D>. next host to add: server next host to add: The current list of NIS servers looks like this:
server
Is this correct? [y/n: y] y We need a few minutes to build the databases... Building /var/yp/rhce/ypservers... Running /var/yp/Makefile... gmake[1]: Entering directory `/var/yp/rhce' Updating passwd.byname... Updating passwd.byuid... Updating group.byname... Updating group.bygid... Updating hosts.byname... Updating hosts.byaddr... Updating rpc.byname... Updating rpc.bynumber... Updating services.byname... Updating services.byservicename... Updating netid.byname... Updating protocols.bynumber... Updating protocols.byname... Updating mail.aliases... gmake[1]: Leaving directory `/var/yp/rhce'
server has been set up as a NIS master server.
Now you can run ypinit -s server on all slave server. [root@server ~]#
[root@client ~]# su - u1 Last login: Sat May 2010:39:56 CST 2017 on pts/0 su:warning: cannot change directory to /home/u1: No such file or directory -bash-4.2$
配置 nfs
1.nfs 服务端配置
略。。。
2.客户端挂载
[root@client home]# mount -t nfs 172.10.100.129:/home /home [root@client home]# su - u1 Last login: Sat May 2010:53:07 CST 2017 on pts/1
dn: olcDatabase=config,cn=config objectClass: olcDatabaseConfig olcDatabase: config olcAccess: to * by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" manage by * none
删除原有的配置
[root@server~]# rm -rf /etc/openldap/slapd.d/*
将 home 目录的slapd.ldif 加载进配置文件目录中
[root@server home]# slapadd -F /etc/openldap/slapd.d/ -n 0 -l /home/slapd.ldif 591fd54d str2entry: entry -1 has no dn slapadd: could not parse entry (line=724) _################### 99.70% eta none elapsed none spd 3.3 M/s Closing DB...
[root@server slapd.d]# chown -Rv ldap.ldap /etc/openldap/slapd.d/ changed ownership of ‘/etc/openldap/slapd.d/cn=config.ldif’ from root:root to ldap:ldap changed ownership of ‘/etc/openldap/slapd.d/cn=config/cn=schema.ldif’ from root:root to ldap:ldap changed ownership of ‘/etc/openldap/slapd.d/cn=config/cn=schema/cn={0}core.ldif’ from root:root to ldap:ldap changed ownership of ‘/etc/openldap/slapd.d/cn=config/cn=schema/cn={1}collective.ldif’ from root:root to ldap:ldap changed ownership of ‘/etc/openldap/slapd.d/cn=config/cn=schema’ from root:root to ldap:ldap changed ownership of ‘/etc/openldap/slapd.d/cn=config’ from root:root to ldap:ldap ownership of ‘/etc/openldap/slapd.d/’ retained as ldap:ldap
确认下所有者和所属组
[root@server slapd.d]# ll total 4 drwxr-x--- 3 ldap ldap 45 May 20 13:34 cn=config -rw------- 1 ldap ldap 589 May 20 13:34 cn=config.ldif
创建数据库配置文件
[root@server slapd.d]# cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG [root@server slapd.d]# chown -Rv ldap.ldap /var/lib/ldap/DB_CONFIG changed ownership of ‘/var/lib/ldap/DB_CONFIG’ from root:root to ldap:ldap
启动服务
[root@server ~]# systemctl start slapd.service [root@server ~]# systemctl status slapd.service ● slapd.service - OpenLDAP Server Daemon Loaded: loaded (/usr/lib/systemd/system/slapd.service;disabled; vendor preset: disabled) Active: active (running) since Sat 2017-05-2013:44:56 CST;7s ago Docs: man:slapd man:slapd-config man:slapd-hdb man:slapd-mdb file:///usr/share/doc/openldap-servers/guide.html Process:10099 ExecStart=/usr/sbin/slapd -u ldap -h ${SLAPD_URLS} $SLAPD_OPTIONS (code=exited, status=0/SUCCESS) Process:10082 ExecStartPre=/usr/libexec/openldap/check-config.sh (code=exited, status=0/SUCCESS) Main PID: 10102 (slapd) CGroup: /system.slice/slapd.service └─10102/usr/sbin/slapd -u ldap -h ldapi:/// ldap:///
May 2013:44:54 server systemd[1]: Starting OpenLDAP Server Daemon... May 2013:44:54 server runuser[10087]: pam_unix(runuser:session): session opened for user ldap by (uid=0) May 2013:44:54 server slapcat[10093]: DIGEST-MD5 common mech free May 2013:44:55 server slapd[10099]: @(#) $OpenLDAP: slapd 2.4.40 (Nov 6 2016 01:21:28) $ mockbuild@worker1.bsys.centos.org:/builddir/build/BUILD/openld...slapd May 2013:44:56 server slapd[10102]: slapd starting May 2013:44:56 server systemd[1]: Started OpenLDAP Server Daemon. Hint: Some lines were ellipsized, use -l to show in full. [root@server ~]# systemctl enable slapd.service Created symlink from /etc/systemd/system/multi-user.target.wants/slapd.service to /usr/lib/systemd/system/slapd.service.
创建多个用户
[root@server ~]# ./create_user.sh mkdir: created directory ‘/home/ldapuser’ Changing password for userlduser1. passwd: all authentication tokens updated successfully. Changing password for userlduser2. passwd: all authentication tokens updated successfully. Changing password for userlduser3. passwd: all authentication tokens updated successfully. Changing password for userlduser4. passwd: all authentication tokens updated successfully. Changing password for userlduser5. passwd: all authentication tokens updated successfully. Changing password for userlduser6. passwd: all authentication tokens updated successfully.