{"id":7244,"date":"2020-11-16T18:26:11","date_gmt":"2020-11-16T15:26:11","guid":{"rendered":"https:\/\/kifarunix.com\/?p=7244"},"modified":"2024-03-14T23:47:39","modified_gmt":"2024-03-14T20:47:39","slug":"install-latest-apache-solr-on-ubuntu-20-04","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-latest-apache-solr-on-ubuntu-20-04\/","title":{"rendered":"Install latest Apache Solr on Ubuntu 20.04"},"content":{"rendered":"\n<p>In this tutorial, you will how to install latest Apache Solr on Ubuntu 20.04. <a aria-label=\"Apache Solr (opens in a new tab)\" href=\"https:\/\/lucene.apache.org\/solr\/\" target=\"_blank\" rel=\"noreferrer noopener\" class=\"rank-math-link\">Apache Solr<\/a><em> is the popular, blazing-fast, open source enterprise search platform built on Apache Lucene. It is highly reliable, scalable and fault tolerant, providing distributed indexing, replication and load-balanced querying, automated failover and recovery, centralized configuration and more. Solr powers the search and navigation features of many of the world&#8217;s largest internet sites<\/em>. <em>With Solr, you put documents in it (called &#8220;indexing&#8221;) via JSON, XML, CSV or binary over HTTP. You query it via HTTP GET and receive JSON, XML, CSV or binary results<\/em>.<\/p>\n\n\n\n<p>Solr Features as outlined on <a aria-label=\"Apache Solr Features page (opens in a new tab)\" href=\"https:\/\/lucene.apache.org\/solr\/features.html\" target=\"_blank\" rel=\"noreferrer noopener\" class=\"rank-math-link\">Apache Solr Features page<\/a>.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Advanced Full-Text Search Capabilities<\/li>\n\n\n\n<li>Optimized for High Volume Traffic<\/li>\n\n\n\n<li>Standards Based Open Interfaces &#8211; XML, JSON and HTTP<\/li>\n\n\n\n<li>Comprehensive Administration Interfaces<\/li>\n\n\n\n<li>Easy Monitoring<\/li>\n\n\n\n<li>Highly Scalable and Fault Tolerant<\/li>\n\n\n\n<li>Flexible and Adaptable with easy configuration<\/li>\n\n\n\n<li>Near Real-Time Indexing<\/li>\n\n\n\n<li>Extensible Plugin Architecture<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Installing Apache Solr on Ubuntu 20.04<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Run System Update<\/h3>\n\n\n\n<p>Update your system package cache;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt update<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"install-java-jre-ubuntu-20.04\"><a href=\"#install-java-jre-ubuntu-20.04\" class=\"rank-math-link\">Install Java Runtime Environment (JRE) on Ubuntu 20.04<\/a><\/h3>\n\n\n\n<p>JRE is one of the requirements for installing latest Apache Solr on Ubuntu 20.04. JRE version 1.8 or higher. Hence, run the command below to install the default JRE on Ubuntu 20.04;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt install default-jre<\/code><\/pre>\n\n\n\n<p>You can verify the version of installed JRE by executing the command below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>java --version<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>openjdk 11.0.9.1 2020-11-04\nOpenJDK Runtime Environment (build 11.0.9.1+1-Ubuntu-0ubuntu1.20.04)\nOpenJDK 64-Bit Server VM (build 11.0.9.1+1-Ubuntu-0ubuntu1.20.04, mixed mode, sharing)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Install Apache Solr on Ubuntu<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">Download latest Apache Solr release version<\/h4>\n\n\n\n<p>Solr 8.7.0 is the most recent Apache Solr release. Hence, navigate their <a aria-label=\"downloads page (opens in a new tab)\" href=\"https:\/\/lucene.apache.org\/solr\/downloads.html\" target=\"_blank\" rel=\"noreferrer noopener\" class=\"rank-math-link\">downloads page<\/a> and grab the latest release archive. You can simply obtain the download url and use wget to pull it down.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>wget https:\/\/downloads.apache.org\/lucene\/solr\/8.7.0\/solr-8.7.0.tgz<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Verify Integrity of Apache Solr Archive<\/h4>\n\n\n\n<p>Before you can proceed, you need to verify the integrity of the downloaded Apache Solr archive. The downloaded archive can be verified using the PGP or SHA checksum. We use the later in this guide. Therefore, download the SHA512 checksum of the same version of the Apache Solr release you downloaded from the download page.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>wget https:\/\/downloads.apache.org\/lucene\/solr\/8.7.0\/solr-8.7.0.tgz.sha512<\/code><\/pre>\n\n\n\n<p>Once the download is done, calculate the SHA512 checksum of the Apache Solr archive downloaded;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>gpg --print-md SHA512 solr-8.7.0.tgz<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>gpg: directory '\/root\/.gnupg' created\ngpg: keybox '\/root\/.gnupg\/pubring.kbx' created\nsolr-8.7.0.tgz: 15A3AF83 997E2CBC 4BFED304 F7D43EFD 260674D9 80592416 05FF3CDE\n                0AE02D8B D1CCD569 73C6CBA1 CC118956 55BB76FC F1991BBB 94B004E5\n                17CE15F7 28FA163F<\/code><\/pre>\n\n\n\n<p>Compare the hash value with the contents of the SHA512 file downloaded.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>cat solr-8.7.0.tgz.sha512<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>15a3af83997e2cbc4bfed304f7d43efd260674d98059241605ff3cde0ae02d8bd1ccd56973c6cba1cc11895655bb76fcf1991bbb94b004e517ce15f728fa163f *solr-8.7.0.tgz<\/code><\/pre>\n\n\n\n<p>Ensure that the hashes match.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Extract Apache Solr Archive<\/h4>\n\n\n\n<p>Once you verify the integrity of the downloaded archive, extract it as follows;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>tar xzf solr-8.7.0.tgz<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Install Apache Solr on Ubuntu 20.04<\/h4>\n\n\n\n<p>Run the command below to install Apache Solr on Ubuntu 20.04;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>solr-8.7.0\/bin\/install_solr_service.sh solr-8.7.0.tgz<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>id: \u2018solr\u2019: no such user\nCreating new user: solr\nAdding system user `solr' (UID 114) ...\nAdding new group `solr' (GID 120) ...\nAdding new user `solr' (UID 114) with group `solr' ...\nCreating home directory `\/var\/solr' ...\n\nExtracting solr-8.7.0.tgz to \/opt\n\n\nInstalling symlink \/opt\/solr -&gt; \/opt\/solr-8.7.0 ...\n\n\nInstalling \/etc\/init.d\/solr script ...\n\n\nInstalling \/etc\/default\/solr.in.sh ...\n\nService solr installed.\nCustomize Solr startup configuration in \/etc\/default\/solr.in.sh\n\u25cf solr.service - LSB: Controls Apache Solr as a Service\n     Loaded: loaded (\/etc\/init.d\/solr; generated)\n     Active: active (exited) since Mon 2020-11-16 14:26:20 UTC; 5s ago\n       Docs: man:systemd-sysv-generator(8)\n    Process: 30824 ExecStart=\/etc\/init.d\/solr start (code=exited, status=0\/SUCCESS)\n\nNov 16 14:26:07 ubuntu20.kifarunix-demo.com systemd&#91;1]: Starting LSB: Controls Apache Solr as a Service...\nNov 16 14:26:07 ubuntu20.kifarunix-demo.com su&#91;30828]: (to solr) root on none\nNov 16 14:26:07 ubuntu20.kifarunix-demo.com su&#91;30828]: pam_unix(su-l:session): session opened for user solr by (uid=0)\nNov 16 14:26:20 ubuntu20.kifarunix-demo.com systemd&#91;1]: Started LSB: Controls Apache Solr as a Service.<\/code><\/pre>\n\n\n\n<p>The command extracts and installs and create Apache Solr systemd service unit, solr.service.<\/p>\n\n\n\n<p>As you can also see from the installation output, Apache Solr is started and hence running.<\/p>\n\n\n\n<p>Note that it is also installed under <code>\/opt\/solr<\/code> (symlinked to \/opt\/solr-$VER, where $VER is the version release number)<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ls \/opt\/solr\/<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>bin\/                contrib\/            docs\/               licenses\/           LUCENE_CHANGES.txt  README.txt          \nCHANGES.txt         dist\/               example\/            LICENSE.txt         NOTICE.txt          server\/<\/code><\/pre>\n\n\n\n<p>You can find the various control scripts under the <code><strong>\/opt\/solr\/bin\/<\/strong><\/code> directory. For example, you can as well check the status by running the command below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>\/opt\/solr\/bin\/solr status<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Found 1 Solr nodes: \n\nSolr process 30901 running on port 8983\n{\n  \"solr_home\":\"\/var\/solr\/data\",\n  \"version\":\"8.7.0 2dc63e901c60cda27ef3b744bc554f1481b3b067 - atrisharma - 2020-10-29 19:39:16\",\n  \"startTime\":\"2020-11-16T14:26:10.033Z\",\n  \"uptime\":\"0 days, 0 hours, 5 minutes, 31 seconds\",\n  \"memory\":\"36.9 MB (%7.2) of 512 MB\"}<\/code><\/pre>\n\n\n\n<p>As you can see, Solr is now listening on port 8983;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ss -altnp | grep 8983<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>LISTEN   0        50                           *:8983                  *:*       users:((\"java\",pid=30901,fd=154))<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Accessing Apache Solr Admin Interface<\/h3>\n\n\n\n<p>To access Apache Solr web admin interface, you can access it via the http:\/\/server-ip-or-resolvable-hostname:8983\/solr<\/p>\n\n\n\n<p>If you are not accessing Apache Solr on localhost, you need to allow external access to port 8983\/tcp, if UFW is running.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ufw allow 8983\/tcp<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1854\" height=\"868\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/11\/apache-solr-interface.png\" alt=\"Install latest Apache Solr on Ubuntu 20.04\" class=\"wp-image-7250\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/11\/apache-solr-interface.png?v=1605539829 1854w, https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/11\/apache-solr-interface-768x360.png?v=1605539829 768w, https:\/\/kifarunix.com\/wp-content\/uploads\/2020\/11\/apache-solr-interface-1536x719.png?v=1605539829 1536w\" sizes=\"(max-width: 1854px) 100vw, 1854px\" \/><\/figure>\n\n\n\n<p>You can now create Solr Core to start indexing and analyzing your data.<\/p>\n\n\n\n<p>You can create Solr core from the Core Admin interface or from command line using the <code><strong>\/opt\/solr\/bin\/solr<\/strong><\/code> command whose syntax is;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/opt\/solr\/bin\/solr create &#91;-c name] &#91;-d confdir] &#91;-n configName] &#91;-shards #] &#91;-replicationFactor #] &#91;-p port] &#91;-V]<\/code><\/pre>\n\n\n\n<p>The command in short <em>Create a core or collection depending on whether Solr is running in standalone (core) or SolrCloud mode (collection). In other words, this action detects which mode Solr is running in, and then takes the appropriate action (either create_core or create_collection<\/em>).<\/p>\n\n\n\n<p>You can obtain help by executing the commands;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>\/opt\/solr\/bin\/solr create_core -help<\/code><\/pre>\n\n\n\n<p>Or<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>\/opt\/solr\/bin\/solr create_collection -help<\/code><\/pre>\n\n\n\n<p>For example, to create a sample Solr Core using \/tmp\/mytestcore as the configuration directory;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mkdir \/tmp\/mytestcore<\/code><\/pre>\n\n\n\n<p>You need to create a core as Solr user;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>su - solr -c \"\/opt\/solr\/bin\/solr create_core -c mytestcore -d \/tmp\/mytestcore\/\"<\/code><\/pre>\n\n\n\n<p>You core should now be available on the Core Admin panel on Solr web interface.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Further Reading<\/h3>\n\n\n\n<p><a href=\"https:\/\/lucene.apache.org\/solr\/\" class=\"rank-math-link\" target=\"_blank\" rel=\"noopener\">Apache Solr Documentation<\/a><\/p>\n\n\n\n<p><a class=\"rank-math-link\" href=\"https:\/\/lucene.apache.org\/solr\/guide\/8_7\/solr-tutorial.html\" target=\"_blank\" rel=\"noopener\">Apache Solr Reference Guide 8.7<\/a><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you will how to install latest Apache Solr on Ubuntu 20.04. Apache Solr is the popular, blazing-fast, open source enterprise search platform<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[121],"tags":[2872,2875,2876,2877,2873,1200],"class_list":["post-7244","post","type-post","status-publish","format-standard","hentry","category-howtos","tag-apache-solr","tag-install-apache-solr-ubuntu-20-04","tag-install-solr-20-04","tag-latest-apache-solr","tag-solr","tag-ubuntu-20-04","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/7244"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=7244"}],"version-history":[{"count":6,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/7244\/revisions"}],"predecessor-version":[{"id":21561,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/7244\/revisions\/21561"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=7244"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=7244"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=7244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}