{"id":92,"date":"2024-04-29T17:55:20","date_gmt":"2024-04-29T17:55:20","guid":{"rendered":"https:\/\/www.rajeshkumar.xyz\/blog\/?p=92"},"modified":"2024-05-01T19:26:03","modified_gmt":"2024-05-01T19:26:03","slug":"apache-solr-installation-and-configurations","status":"publish","type":"post","link":"https:\/\/www.rajeshkumar.xyz\/blog\/apache-solr-installation-and-configurations\/","title":{"rendered":"Apache Solr Installation and Configurations"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">System Requirements<\/h2>\n\n\n\n<p>The system requirements for Apache Solr vary depending on the scale of your deployment and the specific workload. However, here are some general guidelines for hardware and software requirements that will help ensure a robust and efficient Solr setup:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Hardware Requirements<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>CPU<\/strong>: Solr is a CPU-intensive application, particularly during indexing. A modern multi-core processor (quad-core or higher) is recommended for better performance, especially for high-query environments or large indexing tasks.<\/li>\n\n\n\n<li><strong>Memory<\/strong>: Solr heavily relies on RAM for its caching and to hold the inverted index. The amount of RAM needed will depend on the size of your data and your query load. It&#8217;s common to start with at least 8 GB of RAM, but for larger datasets or higher query volumes, 16 GB or more may be necessary.<\/li>\n\n\n\n<li><strong>Disk Space<\/strong>: Solr stores indexes on disk, and these indexes can be quite large depending on the dataset. Fast I\/O is crucial, so SSDs (Solid State Drives) are recommended over HDDs (Hard Disk Drives) for production environments. The amount of disk space required will depend on the size of your data and your index configurations.<\/li>\n\n\n\n<li><strong>Network<\/strong>: Good network throughput is essential, especially in a distributed SolrCloud setup, where nodes need to communicate frequently.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Software Requirements<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Java<\/strong>: Solr is a Java application and requires a Java Runtime Environment (JRE). As of Solr 8.x and later, Java 11 or newer is required. Make sure to use a supported Java version for your specific Solr version.<\/li>\n\n\n\n<li><strong>Operating System<\/strong>: Solr is platform-independent and can run on any operating system that supports Java, including Linux, Windows, and MacOS. However, a Unix-like environment (e.g., Linux) is typically preferred for production deployments due to its stability and performance handling.<\/li>\n\n\n\n<li><strong>Servlet Container<\/strong>: For older versions of Solr (before Solr 5.x), a servlet container such as Apache Tomcat or Jetty was required. From Solr 5.x onwards, Solr comes with a built-in Jetty servlet container, so no external container is needed.<\/li>\n\n\n\n<li><strong>Browser<\/strong>: For accessing the Solr Admin interface, a modern web browser is required. This is not a server requirement per se but necessary for administrative access.<\/li>\n<\/ol>\n\n\n\n<p>Here is a table summarizing major versions of Apache Solr and the Java versions they support:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Solr Version<\/th><th>Supported Java Version<\/th><\/tr><\/thead><tbody><tr><td>Solr 4.x<\/td><td>Java 7+<\/td><\/tr><tr><td>Solr 5.x<\/td><td>Java 8+<\/td><\/tr><tr><td>Solr 6.x<\/td><td>Java 8+<\/td><\/tr><tr><td>Solr 7.x<\/td><td>Java 8+<\/td><\/tr><tr><td>Solr 8.x<\/td><td>Java 8 to 15<\/td><\/tr><tr><td>Solr 9.x<\/td><td>Java 11+<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Network Configuration<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Ensure that appropriate firewall and security settings are configured to allow traffic on the ports used by Solr (default is 8983 for the HTTP interface).<\/li>\n\n\n\n<li>For SolrCloud configurations, additional setup for ZooKeeper nodes and inter-node communication is necessary, often requiring configuration on multiple ports.<\/li>\n<\/ul>\n\n\n\n<p><strong>It is strongly recommended to run Apache Solr as a normal user, not as the root user. Running Solr as root can pose security risks, especially if Solr is exposed to the internet.<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Install Solr using Docker?<\/h2>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\">## ------------------------------------------------------------------------------------ ##<\/span>\n<span class=\"hljs-comment\"># Running Solr with host-mounted directories<\/span>\n$ mkdir solrdata\n$ docker run -d -v <span class=\"hljs-string\">\"$PWD\/solrdata:\/var\/solr\"<\/span> -p <span class=\"hljs-number\">8983<\/span>:<span class=\"hljs-number\">8983<\/span> --name my_solr solr solr-precreate gettingstarted\n\n<span class=\"hljs-comment\">## ------------------------------------------------------------------------------------ ##<\/span>\nThen with a web browser go to http:<span class=\"hljs-comment\">\/\/localhost:8983\/ to see Solr\u2019s Admin UI (adjust the hostname for your docker host). In the UI, click on \"Core Admin\" and should now see the \"gettingstarted\" core.<\/span>\n\nNext load some of the example data that is included in the container:\n$ docker exec -it my_solr post -c gettingstarted example\/exampledocs\/manufacturers.xml\n\n<span class=\"hljs-comment\">## ------------------------------------------------------------------------------------ ##<\/span>\n<span class=\"hljs-comment\"># For quick demos of Solr docker, there is a single command that starts Solr, creates a collection called \"demo\", and loads sample data into it:<\/span>\n\n$ docker run --name solr_demo -d -p <span class=\"hljs-number\">8983<\/span>:<span class=\"hljs-number\">8983<\/span> solr solr-demo\n\n<span class=\"hljs-comment\">## ------------------------------------------------------------------------------------ ##<\/span>\n<span class=\"hljs-comment\"># Loading Your Own Data<\/span>\n\n<span class=\"hljs-comment\"># start Solr. Listens on localhost:8983<\/span>\n$ docker run --name my_solr -p <span class=\"hljs-number\">8983<\/span>:<span class=\"hljs-number\">8983<\/span> solr solr-precreate books\n\n<span class=\"hljs-comment\"># get data<\/span>\n$ mkdir mydata\n$ wget -O mydata\/books.csv https:<span class=\"hljs-comment\">\/\/raw.githubusercontent.com\/apache\/solr\/main\/solr\/example\/exampledocs\/books.csv<\/span>\n$ docker run --rm -v <span class=\"hljs-string\">\"$PWD\/mydata:\/mydata\"<\/span> --network=host solr post -c books \/mydata\/books.csv\n\n<span class=\"hljs-comment\">## ------------------------------------------------------------------------------------ ##<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">How to Install Solr using Docker Compose?<\/h2>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">version: <span class=\"hljs-string\">'3'<\/span>\n<span class=\"hljs-attr\">services<\/span>:\n  solr:\n    image: solr\n    <span class=\"hljs-attr\">ports<\/span>:\n     - <span class=\"hljs-string\">\"8983:8983\"<\/span>\n    <span class=\"hljs-attr\">volumes<\/span>:\n      - data:<span class=\"hljs-regexp\">\/var\/<\/span>solr\n    <span class=\"hljs-attr\">command<\/span>:\n      - solr-precreate\n      - gettingstarted\n<span class=\"hljs-attr\">volumes<\/span>:\n  data:<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>you can simply run:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">$ docker compose up -d<\/code><\/span><\/pre>\n\n\n<h2 class=\"wp-block-heading\">How to run Apache solr 9.x in ubuntu?<\/h2>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">sudo apt update\nsudo apt install openjdk<span class=\"hljs-number\">-11<\/span>-jdk\nwget https:<span class=\"hljs-comment\">\/\/dlcdn.apache.org\/solr\/solr\/9.6.0\/solr-9.6.0.tgz<\/span>\ntar xzf solr<span class=\"hljs-number\">-9.6<\/span><span class=\"hljs-number\">.0<\/span>.tgz\ncd solr<span class=\"hljs-number\">-9.6<\/span><span class=\"hljs-number\">.0<\/span>\nbin\/solr start\n\nThis will run Solr on the <span class=\"hljs-keyword\">default<\/span> port <span class=\"hljs-number\">8983.<\/span> Access the Solr admin panel via http:<span class=\"hljs-comment\">\/\/localhost:8983\/solr.<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Solr Configuration Files<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"882\" height=\"782\" src=\"https:\/\/www.rajeshkumar.xyz\/blog\/wp-content\/uploads\/2024\/04\/image-16.png\" alt=\"\" class=\"wp-image-113\" srcset=\"https:\/\/www.rajeshkumar.xyz\/blog\/wp-content\/uploads\/2024\/04\/image-16.png 882w, https:\/\/www.rajeshkumar.xyz\/blog\/wp-content\/uploads\/2024\/04\/image-16-300x266.png 300w, https:\/\/www.rajeshkumar.xyz\/blog\/wp-content\/uploads\/2024\/04\/image-16-768x681.png 768w\" sizes=\"auto, (max-width: 882px) 100vw, 882px\" \/><\/figure>\n\n\n\n<p>Here&#8217;s a table summarizing some key Solr configuration files and their purposes:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>File Name<\/th><th>Purpose<\/th><\/tr><\/thead><tbody><tr><td><code>solr.xml<\/code><\/td><td>The main configuration file for a Solr instance, defining core properties and settings for the Solr environment.<\/td><\/tr><tr><td><code>schema.xml<\/code><\/td><td>Defines the schema for data indexing, including field types, fields, and how fields are processed during indexing and querying.<\/td><\/tr><tr><td><code>solrconfig.xml<\/code><\/td><td>Configures the Solr core, specifying settings for query processing, request handlers, and other core behaviors.<\/td><\/tr><tr><td><code>stopwords.txt<\/code><\/td><td>Contains a list of stopwords that are not indexed to improve search efficiency and relevance.<\/td><\/tr><tr><td><code>elevate.xml<\/code><\/td><td>Configures query elevation to prioritize certain documents in search results.<\/td><\/tr><tr><td><code>synonyms.txt<\/code><\/td><td>Manages synonyms to expand or conflate query terms for more comprehensive search results.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><code>core.properties<\/code><\/td><td>Stores properties specific to each core, including core name and data directory path, used for core discovery and configuration.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Apache Solr Directory Layout<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"672\" height=\"311\" src=\"https:\/\/www.rajeshkumar.xyz\/blog\/wp-content\/uploads\/2024\/05\/image-2.png\" alt=\"\" class=\"wp-image-131\" srcset=\"https:\/\/www.rajeshkumar.xyz\/blog\/wp-content\/uploads\/2024\/05\/image-2.png 672w, https:\/\/www.rajeshkumar.xyz\/blog\/wp-content\/uploads\/2024\/05\/image-2-300x139.png 300w\" sizes=\"auto, (max-width: 672px) 100vw, 672px\" \/><\/figure>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">After installing Solr, you\u2019ll see the following directories and files within them:\n\nbin\/\nThis directory includes several important scripts that will make using Solr easier.\n\nsolr and solr.cmd\nThis is Solr\u2019s Control Script, also known <span class=\"hljs-keyword\">as<\/span> bin\/solr (*nix) \/ bin\/solr.cmd (Windows). This script is the preferred tool to start and stop Solr. You can also create collections or cores, configure authentication, and work <span class=\"hljs-keyword\">with<\/span> configuration files when running <span class=\"hljs-keyword\">in<\/span> SolrCloud mode.\n\npost\nThe Post Tool, which provides a simple command line interface <span class=\"hljs-keyword\">for<\/span> POSTing content to Solr.\n\nsolr.in.sh and solr.in.cmd\nThese are property files <span class=\"hljs-keyword\">for<\/span> *nix and Windows systems, respectively. System-level properties <span class=\"hljs-keyword\">for<\/span> Java, Jetty, and Solr are configured here. Many <span class=\"hljs-keyword\">of<\/span> these settings can be overridden when using bin\/solr \/ bin\/solr.cmd, but <span class=\"hljs-keyword\">this<\/span> allows you to <span class=\"hljs-keyword\">set<\/span> all the properties in one place.\n\ninstall_solr_services.sh\nThis script is used on *nix systems to install Solr as a service. It is described in more detail in the section Taking Solr to Production.\n\nmodules\/\nSolr\u2019s modules directory includes 1st-party add-ons for specialized features that enhance Solr. See the section Solr Modules for more information. This is not included in the slim distribution.\n\nprometheus-exporter\/\nA standalone application, included under bin\/, that montiors Solr instances and produces Prometheus metrics. See the section Monitoring with Prometheus and Grafana for more information. This is not included in the slim distribution.\n\ndocker\/\nThis contains a Dockerfile to build a Docker image from the binary distribution, that is compatible with the official image. This directory also contains the scripts needed when using Solr inside the Docker image, under the scripts\/ directory. The README.md in this directory describes how custom Solr Docker images can be built using this binary distribution. Refer to the section Solr in Docker page for information on using a Solr Docker image.\n\nlib\/\nFolder where Solr will look for additional plugin jar files.\n\ndist\/\nThe dist directory contains the main Solr .jar files.\n\ndocs\/\nThe docs directory includes a link to online Javadocs for Solr.\n\nexample\/\nThe example directory includes several types of examples that demonstrate various Solr capabilities. See the section Solr Examples below for more details on what is in this directory.\n\nlicenses\/\nThe licenses directory includes all of the licenses for 3rd party libraries used by that distribution of Solr.\n\nserver\/\nThis directory is where the heart of the Solr application resides. A README in this directory provides a detailed overview, but here are some highlights:\n\nSolr\u2019s Admin UI &amp; JAR files (server\/solr-webapp)\n\nJetty libraries (server\/lib)\n\nLog files (server\/logs) and log configurations (server\/resources). See the section Configuring Logging for more details on how to customize Solr\u2019s default logging.\n\nSample configsets (server\/solr\/configsets)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"678\" height=\"176\" src=\"https:\/\/www.rajeshkumar.xyz\/blog\/wp-content\/uploads\/2024\/05\/image-3.png\" alt=\"\" class=\"wp-image-134\" srcset=\"https:\/\/www.rajeshkumar.xyz\/blog\/wp-content\/uploads\/2024\/05\/image-3.png 678w, https:\/\/www.rajeshkumar.xyz\/blog\/wp-content\/uploads\/2024\/05\/image-3-300x78.png 300w\" sizes=\"auto, (max-width: 678px) 100vw, 678px\" \/><\/figure>\n\n\n\n<p><strong>Here are the examples included with Solr:<\/strong><\/p>\n\n\n\n<p><strong>exampledocs<\/strong><\/p>\n\n\n\n<p>This is a small set of simple CSV, XML, and JSON files that can be used with\u00a0<code>bin\/solr post<\/code>\u00a0when first getting started with Solr. For more information about using\u00a0<code>bin\/solr post<\/code>\u00a0with these files, see\u00a0<a href=\"https:\/\/solr.apache.org\/guide\/solr\/latest\/indexing-guide\/post-tool.html\">Post Tool<\/a>.<\/p>\n\n\n\n<p><strong>files<\/strong><\/p>\n\n\n\n<p>The\u00a0<code>files<\/code>\u00a0directory provides a basic search UI for documents such as Word or PDF that you may have stored locally. See the README there for details on how to use this example.<\/p>\n\n\n\n<p><strong>films<\/strong><\/p>\n\n\n\n<p>The&nbsp;<code>films<\/code>&nbsp;directory includes a robust set of data about movies in three formats: CSV, XML, and JSON. See the README there for details on how to use this dataset.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Reference<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/solr.apache.org\/guide\/solr\/latest\/deployment-guide\/system-requirements.html\">https:\/\/solr.apache.org\/guide\/solr\/latest\/deployment-guide\/system-requirements.html<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/solr.apache.org\/guide\/solr\/latest\/deployment-guide\/solr-in-docker.html\">https:\/\/solr.apache.org\/guide\/solr\/latest\/deployment-guide\/solr-in-docker.html<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/solr.apache.org\/guide\/solr\/latest\/index.html\">https:\/\/solr.apache.org\/guide\/solr\/latest\/index.html<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/github.com\/apache\/solr\">https:\/\/github.com\/apache\/solr<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>System Requirements The system requirements for Apache Solr vary depending on the scale of your deployment and the specific workload. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-92","post","type-post","status-publish","format-standard","hentry","category-apache-solr"],"_links":{"self":[{"href":"https:\/\/www.rajeshkumar.xyz\/blog\/wp-json\/wp\/v2\/posts\/92","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rajeshkumar.xyz\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rajeshkumar.xyz\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rajeshkumar.xyz\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rajeshkumar.xyz\/blog\/wp-json\/wp\/v2\/comments?post=92"}],"version-history":[{"count":12,"href":"https:\/\/www.rajeshkumar.xyz\/blog\/wp-json\/wp\/v2\/posts\/92\/revisions"}],"predecessor-version":[{"id":136,"href":"https:\/\/www.rajeshkumar.xyz\/blog\/wp-json\/wp\/v2\/posts\/92\/revisions\/136"}],"wp:attachment":[{"href":"https:\/\/www.rajeshkumar.xyz\/blog\/wp-json\/wp\/v2\/media?parent=92"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rajeshkumar.xyz\/blog\/wp-json\/wp\/v2\/categories?post=92"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rajeshkumar.xyz\/blog\/wp-json\/wp\/v2\/tags?post=92"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}