{"id":297,"date":"2011-02-18T17:57:00","date_gmt":"2011-02-18T17:57:00","guid":{"rendered":"https:\/\/questy.org\/?p=297"},"modified":"2024-09-26T19:10:55","modified_gmt":"2024-09-26T19:10:55","slug":"ldap-administration-v-replication","status":"publish","type":"post","link":"https:\/\/questy.org\/index.php\/2011\/02\/18\/ldap-administration-v-replication\/","title":{"rendered":"LDAP Administration V &#8211; Replication"},"content":{"rendered":"\n<p>Continuing our discussion of LDAP Administration, there\u2019s the matter of Replication.<\/p>\n\n\n\n<p>So far we\u2019ve created an LDAP store, turned up the server, configured a client, and even connected Apache authentication to it.&nbsp; However, if we\u2019re going to use our LDAP server for enterprise authentication, then there\u2019s the small matter of \u201cWhat happens when my authentication server wets the bed?\u201d.<\/p>\n\n\n\n<p>As with anything in the enterprise, you have backup systems.&nbsp; Sometimes they\u2019re failover systems, sometimes clusters.&nbsp; Sometimes they\u2019re tandem systems, and sometimes they\u2019re load-balanced.&nbsp; No matter the configuration, you have redundancy, resiliency, and scalability.&nbsp; I plan to talk about one of the many scenarios available to LDAP administrators today; the idea of a master server and many replicants.<\/p>\n\n\n\n<p><strong>Layout<\/strong><\/p>\n\n\n\n<p>In my configuration, I have a single administrative parent.&nbsp; This system is where we do all administrative level work.&nbsp; This includes adding users, adding groups, reporting, and the like.&nbsp; It is also the \u201cprovider\u201d store to all replicants in our environment.&nbsp; We learned earlier how to turn up a server that is queried directly.&nbsp; Now let\u2019s learn, instead, how to configure this system to replicate itself.<\/p>\n\n\n\n<p>Assume 3 systems total, ldap01.bob.com, ldap02.bob.com, and ldap03.bob.com.&nbsp; ldap01.bob.com is our master server and our replicants are ldap02 &amp; ldap03.&nbsp; To tell the system it will be replicating, you will need to configure it to do so.&nbsp; Shut down LDAP on the primary like so:<\/p>\n\n\n\n<p><em><strong>\/sbin\/service ldap stop<\/strong><\/em><\/p>\n\n\n\n<p>This shuts down all daemons and associated processes.&nbsp; Next, we need to edit our&nbsp;<strong>\/etc\/openldap\/slapd.conf<\/strong>&nbsp;to include information regarding where our replicants will be.&nbsp;&nbsp;&nbsp; You must add a few lines to the master to make this happen.&nbsp; Like so:<\/p>\n\n\n\n<p>replogfile&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/var\/log\/ldap\/slapd.replog<\/p>\n\n\n\n<p>replica uri=ldap:\/\/ldap02.bob.com:389 binddn=\u201ccn=admin,dc=bob,dc=com\u201d bindmethod=simple credentials=secret<\/p>\n\n\n\n<p>replica uri=ldap:\/\/ldap03.bob.com:389 binddn=\u201ccn=admin,dc=bob,dc=com\u201d bindmethod=simple credentials=secret<\/p>\n\n\n\n<p>This can be added at the end of the file.<\/p>\n\n\n\n<p>Next, we take our fresh two servers, and turn up a similar system to what ldap01 was before adding the above lines.&nbsp; In these systems, there are only two important lines to tell them they are replicants and not masters.&nbsp; They are as follows:<\/p>\n\n\n\n<p>updatedn \u201ccn=admin,dc=bob,dc=com\u201d updateref ldap:\/\/ldap01.bob.com<\/p>\n\n\n\n<p>That is literally the entire configuration.<\/p>\n\n\n\n<p><strong>Populating the Replicants<\/strong><\/p>\n\n\n\n<p>To have your schema transferred over, and to be working from the same general starting point, I find it important to copy your whole database over to start with.&nbsp; This is easily done utilizing standard LDAP tools.<\/p>\n\n\n\n<p>First, start back up your master server:<\/p>\n\n\n\n<p><em><strong>\/sbin\/service ldap start<\/strong><\/em><\/p>\n\n\n\n<p>Once you\u2019ve done this, the database is up and ready for queries.&nbsp; We will essentially dump our database for import on each of the replicants.&nbsp; To do this, we will use the&nbsp;<em>slapcat&nbsp;<\/em>utility, redirecting the output to a file we can use to move around to the replicants.&nbsp; Run&nbsp;<em>slapcat<\/em>&nbsp;as follows:<\/p>\n\n\n\n<p><strong><em>slapcat &gt;&gt; master.ldif<\/em><\/strong><\/p>\n\n\n\n<p>this will output the contents of your LDAP store to a single LDIF-formatted file, suitable for import into other servers.&nbsp; Simply copy this file to a generic location (such as your personal home directory) on each of the other servers, and we are set for import.<\/p>\n\n\n\n<p>Once your file is in the new location, you\u2019re ready to import.&nbsp; First, start LDAP as outlined above.&nbsp; Next, add the LDIF to your store:<\/p>\n\n\n\n<p><em><strong>slapadd -l master.ldif<\/strong><\/em><\/p>\n\n\n\n<p>Probably unnecessary, but I usually restart my ldap server after the import, and now I\u2019m ready to go.&nbsp; Repeat the process on your third LDAP store, and your full environment is running.<\/p>\n\n\n\n<p><strong>Next Steps<\/strong><\/p>\n\n\n\n<p>So let\u2019s see where we are.<\/p>\n\n\n\n<p>Master server up and serving.. check. Two slaves configured as replicants, up and running.. check.<\/p>\n\n\n\n<p>Now that you have your stores up, you have to do some testing. &nbsp;Primarily, that the master replicates to the slaves. &nbsp;The way I usually do this is use the&nbsp;<a href=\"http:\/\/directory.apache.org\">Apache Directory Studio<\/a>I covered in an earlier article. &nbsp;I simply add a user on the master. &nbsp;Then, I connect to each of the slaves in turn to see that the user has appeared there. &nbsp;If so, then we\u2019re ready for the next steps: &nbsp;High Availability.<\/p>\n\n\n\n<p>You have two query hosts that can equally provide query answers from remote clients. &nbsp;There are several ways you can make these available. &nbsp;Round-robin DNS, HA IP failover, and load-balancing via a hardware load balancer. &nbsp;I prefer the latter. &nbsp;However, to do so, you need a way to tell the load balancer that your LDAP store is up and responding.<\/p>\n\n\n\n<p>I prefer to use a small script on the system that can be served up via HTTP to the load balancer that does a simple operation.&nbsp; First, it does an LDAP search, looks for information, and then prints out to the web page it creates a simple \u201cUP\u201d or \u201cDOWN\u201d message for the load balancer to key on.&nbsp; The script looks like the following:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"691\" height=\"726\" src=\"https:\/\/i0.wp.com\/questy.org\/wp-content\/uploads\/2024\/08\/healthcheck.png?resize=691%2C726&#038;ssl=1\" alt=\"\" class=\"wp-image-186\"\/><\/figure>\n\n\n\n<p>As you can see, all we do is simply do an&nbsp;<em>ldapsearch&nbsp;<\/em>against our bob.com domain, look for the home directory for the admin user to look like \u201c\/home\/admin\u201d.&nbsp; If the answer returns, we say \u201cUP\u201d, if not, we say \u201cDOWN\u201d.<\/p>\n\n\n\n<p>Place this script into your \u201ccgi-bin\u201d directory, make it executable&nbsp;<em>(chmod 0755&nbsp;)<\/em>&nbsp;and simply call it in your browser via the URL:&nbsp;&nbsp;<a href=\"http:\/\/yoursite.com\/cgi-bin\/\">http:\/\/yoursite.com\/cgi-bin\/<\/a>.&nbsp; If you have Apache properly configured (outside the scope of this document) to serve CGI Executables, you should get the status of the individual system.&nbsp; Do this for both your replicants.<\/p>\n\n\n\n<p>Finally, ask your network team to configure these two systems in a load-balanced configuration behind a VIP (virtual IP).&nbsp; Have a sensible DNS name pointed at this IP (ldap.bob.com, for instance) and you\u2019re in business.&nbsp; Now, when you configure your clients to authenticate against LDAP (Article #1 in this series), you just point them at the ldap.bob.com name.&nbsp; If either of the systems go out, the load balancer will point you to the machine that is up to serve your requests.<\/p>\n\n\n\n<p><strong>Conclusion<\/strong><\/p>\n\n\n\n<p>I hope this gives you a basic direction to go in getting high-availability setup for your system through a combination of replication and load balancing.&nbsp; There are other methods for HA in the replicants.&nbsp; Perhaps we will cover that soon.<\/p>\n\n\n\n<p>Next up:&nbsp; Securing your LDAP installation.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Continuing our discussion of LDAP Administration, there\u2019s the matter of Replication. So far we\u2019ve created an LDAP store, turned up the server, configured a client, and even connected Apache authentication to it.&nbsp; However, if we\u2019re going to use our LDAP server for enterprise authentication, then there\u2019s the small matter of \u201cWhat happens when my authentication [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[8,1],"tags":[],"class_list":["post-297","post","type-post","status-publish","format-standard","hentry","category-open-source","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/questy.org\/index.php\/wp-json\/wp\/v2\/posts\/297","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/questy.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/questy.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/questy.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/questy.org\/index.php\/wp-json\/wp\/v2\/comments?post=297"}],"version-history":[{"count":1,"href":"https:\/\/questy.org\/index.php\/wp-json\/wp\/v2\/posts\/297\/revisions"}],"predecessor-version":[{"id":298,"href":"https:\/\/questy.org\/index.php\/wp-json\/wp\/v2\/posts\/297\/revisions\/298"}],"wp:attachment":[{"href":"https:\/\/questy.org\/index.php\/wp-json\/wp\/v2\/media?parent=297"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/questy.org\/index.php\/wp-json\/wp\/v2\/categories?post=297"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/questy.org\/index.php\/wp-json\/wp\/v2\/tags?post=297"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}