Home | 簡體中文 | 繁體中文 | 雜文 | Search | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 知乎專欄 | Email

第 2 章 Replication

目錄

2.1. Primary
2.2. Secondary

2.1. Primary

過程 2.1. Primary configure

  1. installation

    neo@master:~$ sudo apt-get install slapd ldap-utils
    				
  2. slapd.conf

    neo@master:~$ vi /etc/ldap/slapd.conf
    suffix          "dc=example,dc=org"
    replogfile      /var/lib/ldap/replog
    syncrepl        rid=001
                    provider=ldap://192.168.245.131:389/
                    binddn="cn=admin,dc=example,dc=org"
                    bindmethod=simple
                    credentials=chen
                    searchbase="dc=example,dc=org"
                    type=refreshAndPersist
                    retry="5 5 300 5"
    				
  3. initial entries base dn

    neo@master:~$ cat base-dn.ldif
    					
    dn: dc=example,dc=org
    objectclass: dcObject
    objectclass: organization
    o:example.org
    dc: example
    description:Top level of directory
    
    dn: cn=Manager,dc=example,dc=org
    objectclass: organizationalRole
    cn: Manager
    
    dn: cn=admin,dc=example,dc=org
    objectclass: organizationalRole
    cn: admin
    
    dn: cn=root,dc=example,dc=org
    objectclass: organizationalRole
    cn: root					
    				

    Add initial entries to your directory.

    neo@master:~$ ldapadd -x -D "cn=admin,dc=example,dc=org" -W -f base-dn.ldif
    Enter LDAP Password:
    adding new entry "dc=example,dc=org"
    
    adding new entry "cn=Manager,dc=example,dc=org"
    
    adding new entry "cn=admin,dc=example,dc=org"
    
    adding new entry "cn=root,dc=example,dc=org"					
    				

    check

    				
    neo@master:~$ ldapsearch -x -b 'dc=example,dc=org' '(objectclass=*)'
    # extended LDIF
    #
    # LDAPv3
    # base <dc=example,dc=org> with scope subtree
    # filter: (objectclass=*)
    # requesting: ALL
    #
    
    # example.org
    dn: dc=example,dc=org
    objectClass: dcObject
    objectClass: organization
    o: example.org
    dc: example
    description: Top level of directory
    
    # Manager, example.org
    dn: cn=Manager,dc=example,dc=org
    objectClass: organizationalRole
    cn: Manager
    
    # admin, example.org
    dn: cn=admin,dc=example,dc=org
    objectClass: organizationalRole
    cn: admin
    
    # root, example.org
    dn: cn=root,dc=example,dc=org
    objectClass: organizationalRole
    cn: root
    
    # search result
    search: 2
    result: 0 Success
    
    # numResponses: 5
    # numEntries: 4				
    					
    				
  4. Export the database of the master using slapcat. Then copy master.ldif to the slave using scp or other tools.

    neo@master:~$ sudo slapcat -l master.ldif