如何克隆 OpenLDAP 数据库 [英] How do I clone an OpenLDAP database

查看:15
本文介绍了如何克隆 OpenLDAP 数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这更像是一个 serverfault 问题而不是 stackoverflow 问题,但由于 serverfault 尚未启动,我开始吧:

我应该将应用程序从一台 redhat 服务器移动到另一台服务器,并且没有很好地了解应用程序的内部工作原理,我将如何将 OpenLDAP 数据库从一台机器移动到另一台机器,以及模式和所有.

我需要复制哪些文件?我相信设置是相当标准的.

解决方案

SourceRebels 答案的问题是 slapcat(8) 不保证 ldapadd(1)/ldapmodify(1) 的数据是有序的.从手册页:

<上一页>此工具生成的 LDIF 适合与 slapadd(8) 一起使用.由于条目是按数据库顺序排列的,而不是优先顺序,它们如果不先重新排序,则无法使用 ldapadd(1) 加载.

加上使用一个工具,使用后端文件转储数据库,然后使用一个通过ldap协议加载ldif的工具,不是很一致.

我建议使用 slapcat(8)/slapadd(8) OR ldapsearch(1) 的组合/ldapmodify(1).我更喜欢后者,因为它不需要 shell 访问 ldap 服务器或移动文件.

例如,从 dc=master,dc=com 下的主服务器转储数据库并将其加载到备份服务器中

<上一页>$ ldapsearch -Wx -D "cn=admin_master,dc=master,dc=com" -b "dc=master,dc=com" -H ldap://my.master.host -LLL > ldap_dump-20100525-1.ldif$ ldapadd -Wx -D "cn=admin_backup,dc=backup,dc=com" -H ldap://my.backup.host -f ldap_dump-20100525-1.ldif

上面的 -W 标志提示输入 ldap admin_master 密码,但是由于我们将输出重定向到一个文件,您不会看到提示 - 只是一个空行.继续并输入您的 ldap admin_master 密码,它就会起作用.在运行 ldapadd 之前,需要删除输出文件的第一行(输入 LDAP 密码:).

最后一个提示,ldapadd(1) 是一个到 ldapmodify(1) 的硬链接,并且打开了 -a(添加)标志.

I know this is more like a serverfault question than a stackoverflow question, but since serverfault isn't up yet, here I go:

I'm supposed to move an application from one redhat server to another, and without very good knowledge of the internal workings of the application, how would I move the OpenLDAP database from the one machine to the other, with schemas and all.

What files would I need to copy over? I believe the setup is pretty standard.

解决方案

The problem with SourceRebels answer is that slapcat(8) does not guarantee that the data is ordered for ldapadd(1)/ldapmodify(1). From the man page :

The  LDIF  generated  by this tool is suitable for use with slapadd(8).
As the entries are in database order, not superior  first  order,  they
cannot be loaded with ldapadd(1) without first being reordered.

Plus using a tool that uses the backend files to dump the database and then using a tool that loads the ldif through the ldap protocol is not very consistent.

I'd suggest to use a combination of slapcat(8)/slapadd(8) OR ldapsearch(1)/ldapmodify(1). My preference would go to the latter as it does not need shell access to the ldap server or moving files around.

For example, dump database from a master server under dc=master,dc=com and load it in a backup server

$ ldapsearch -Wx -D "cn=admin_master,dc=master,dc=com" -b "dc=master,dc=com" -H ldap://my.master.host -LLL > ldap_dump-20100525-1.ldif
$ ldapadd -Wx -D "cn=admin_backup,dc=backup,dc=com" -H ldap://my.backup.host -f ldap_dump-20100525-1.ldif

The -W flag above prompts for ldap admin_master password however since we are redirecting output to a file you wont see the prompt - just an empty line. Go ahead and type your ldap admin_master password and and it will work. First line of your output file will need to be removed (Enter LDAP Password:) before running ldapadd.

Last hint, ldapadd(1) is a hard link to ldapmodify(1) with the -a (add) flag turned on.

这篇关于如何克隆 OpenLDAP 数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆