Une erreur s'est produite.

L'erreur a été envoyée par e-mail à l'administrateur pour analyse.

How do I try out a search engine in my project?

Install Solr from the source code.

Hello, my name is Christopher Tate. I am a Red Hat consultant and I love open source software. Databases and search engines are both valuable resources for serving up data in different ways. Databases are perfect for persistent, normalized user data. Search engines are perfect for transformed, denormalized, searchable versions of the data. Lightning fast indexes, query highlighting, pagination, filters and faceting are just a few of the crucial features you can add to your site with a search engine. I will help you install the most recent version of Solr to make your website searchable the open source way.

Customize the whole site for your domain.

  1. Just click the [ Login ] button above.
  2. Click: New user? Register
  3. It's free, and your information is private.

How do I install the dependencies for Solr?

Build the dependencies with yum.

sudo yum install -y ivy lsof maven ant git
  1. sudo
    : The command to install yum repositories begins with the command sudo. The "sudo" command allows your current user to have root privileges for a few minutes after entering your password. Installing yum repositories always requires root privileges.
  2. yum
    Stands for "Yellowdog Updater Modified", but nobody knows it as yellowdog, just yum. CentOS manages software packages and RPM application files with yum.
  3. install
    : For installing new yum packages.
  4. -y
    : Suppress messages asking to confirm if you want to install the software.
  5. ivy lsof maven ant git
    : The package names of the dependencies for building Solr from the source code.

Where do I put the Solr source code?

Create a solr directory in /usr/local/src.

sudo install -d -o $USER -g $USER /usr/local/src/solr
  1. sudo
  2. install: Creates directories and sets attributes on the new directory.
  3. -d: Create directories.
  4. -o: Set ownership on the directory (super-user only).
  5. $USER: The current user to make the owner of the directory.
  6. -g: Set group ownership on the directory (super-user only).
  7. $USER: The current user to make the group owner of the directory.
  8. /usr/local is a place for extra software that you install without the package manager. /usr/local/src is a good place to clone your open source software repositories.

How do I download the Solr source code?

Clone the source code with the git command.

git clone https://github.com/apache/lucene-solr.git /usr/local/src/solr --single-branch --depth 1 --branch releases/lucene-solr/7.1.0
  1. git: The distributed revision control system for most open source software.
  2. clone: Clone a repository into a directory.
  3. https://github.com/apache/lucene-solr.git: The git URL to the Solr source code repository.
  4. /usr/local/src/solr: The directory where the Solr source code will be cloned.
  5. --single-branch: Clone and checkout only the history leading to the tip of a single branch.
  6. --depth 1: Do not retrieve any history for the branch.
  7. ):--branch releases/lucene-solr/7.1.0 ): A recent tag to base the branch from.

Solr has a huge git repository with a lot of history and can be slow to clone. To greatly speed up time, we can clone a single branch at the tip. The version 7.1.0 is a recent branch that doesn't require a new version of ant. Installing a version greater than 7.1.0 is more challenging, and I would recommend waiting for an operating system upgrade with ant version 1.10.*.

How do I build the Solr source code?

Build Solr with the ant command.

(cd /usr/local/src/solr/solr && ant ivy-bootstrap)
  1. (cd
  2. /usr/local/src/solr/solr
  3. &&
  4. ant: A platform-independent build tool for Java projects.
  5. ivy-bootstrap): Install a copy of Ivy into your Ant User Library.
(cd /usr/local/src/solr/solr && ant package)
  1. (cd
  2. /usr/local/src/solr/solr
  3. &&
  4. ant
  5. package): Build Solr from the source code.

After compiling Solr, where do I install it as a server?

Create a solr directory in /srv.

sudo install -d -o $USER -g $USER /srv/solr
  1. sudo
  2. install
  3. -d
  4. -o
  5. $USER
  6. -g
  7. $USER
  8. /srv is a good place to install open source software serveurs like Solr that run as a service.
rsync -r /usr/local/src/solr/solr/build/solr-7.1.0-SNAPSHOT/ /srv/solr/
  1. rsync: a fast, versatile, remote (and local) file-copying tool.
  2. -r: Recurse into directories.
  3. /usr/local/src/solr/build/solr- 7.1.0 -SNAPSHOT/: The directory where the maven application was built. Don't forget the ending slash or rsync assumes it's a file inside the destination.
  4. /srv/solr/: The directory where the server will be installed. It's best to always write directories with a trailing slash in rsync for fewer surprises.
chmod a+x /srv/solr/bin/*
  1. chmod: Change the file mode bits.
  2. a+x: Give all users executable privileges on the following files.
  3. /srv/solr/bin/*: The Solr binaries to make executable.
rm -rf /srv/solr/example/
  1. rm: Remove files and directories.
  2. -rf: Remove all files and directories recursively without prompting.
  3. /srv/solr/example/: The Solr example files that will result in error messages when starting the server if they remain.

How do I configure the Solr server?

Create a solr.xml file.

echo '<?xml version="1.0" encoding="UTF-8" ?>
<solr>
<solrcloud>
<str name="host">${host:}</str>
<int name="hostPort">${jetty.port:8983}</int>
<str name="hostContext">${hostContext:solr}</str>
<bool name="genericCoreNodeNames">${genericCoreNodeNames:true}</bool>
<int name="zkClientTimeout">${zkClientTimeout:30000}</int>
<int name="distribUpdateSoTimeout">${distribUpdateSoTimeout:600000}</int>
<int name="distribUpdateConnTimeout">${distribUpdateConnTimeout:60000}</int>
<str name="zkCredentialsProvider">${zkCredentialsProvider:org.apache.solr.common.cloud.DefaultZkCredentialsProvider}</str>
<str name="zkACLProvider">${zkACLProvider:org.apache.solr.common.cloud.DefaultZkACLProvider}</str>
</solrcloud>
<shardHandlerFactory name="shardHandlerFactory" class="HttpShardHandlerFactory">
<int name="socketTimeout">${socketTimeout:600000}</int>
<int name="connTimeout">${connTimeout:60000}</int>
</shardHandlerFactory>
</solr>

' | tee /srv/solr/solr.xml
  1. echo '...': Write a string to the console.
  2. |: Read the string into the following command.
  3. tee: Write a string to a file.
  4. /srv/solr/solr.xml: A new config file for Solr.

How do I create a Solr configset for my site.

Try out my own favorite configset from my opensource project computate.

git clone https://github.com/computate/computate.git /srv/solr/server/solr/configsets/computate
  1. git
  2. clone
  3. https://github.com/computate/computate.git: The open source git repository that is the base of all my work.
  4. /srv/solr/server/solr/configsets/ computate : The directory for the computate Solr configset.
(cd /srv/solr/server/solr/configsets/computate/ && git filter-branch --subdirectory-filter config/solr/server/solr/configsets/computate HEAD)
  1. (cd
  2. /srv/solr/server/solr/configsets/ computate
  3. &&
  4. git
  5. filter-branch: Rewrite the branch, applying custom filters on each revision.
  6. --subdirectory-filter: Only look at the history which touches the given subdirectory.
  7. config/solr/server/solr/configsets/computate: My favorite configset to use in Solr.
  8. HEAD): The current HEAD revision to filter.

How do I upload my Solr configset to Zookeeper?

Use the solr zk upconfig command.

/srv/solr/bin/solr zk upconfig -n computate -d /srv/solr/server/solr/configsets/computate -z localhost:10281
  1. /srv/solr/bin/solr: The solr executable binary.
  2. zk: Perform a zookeeper operation with Solr configsets.
  3. upconfig: Upload a Solr configset to zookeeper.
  4. -n computate : The name of the Solr configset.
  5. -d /srv/solr/server/solr/configsets/ computate : The path to the Solr configset.
  6. -z localhost: 10281 : The host and port to the Zookeeper server.

How do I run Solr all the time, when my computer starts up?

How to run Solr as a systemd service.

echo '
[Unit]

Description=A powerful open source search engine.

After=network.target

[Service]
Type=forking
User='"$USER"'
Group='"$USER"'

ExecStart=/srv/solr/bin/solr -c -s /srv/solr -p 10380 -z localhost:10281

Restart=on-failure

[Install]
WantedBy=multi-user.target
' | sudo tee /usr/lib/systemd/system/solr.service
  1. echo '...': Write a string to the console.
  2. [Unit]: A unit configuration file whose name ends in ".service" encodes information about a process controlled and supervised by systemd.
  3. Description=...: The description of the service.
  4. After=...: The Solr service will be started after the following dependencies.
  5. [Service]: Information about a service controlled and supervised by systemd.
  6. Type=forking: Because it is expected that the process configured with ExecStart= will call fork() as part of its start-up.
  7. User=...: The user as the current user that will run the service.
  8. Group=...: The group user as the current user that will run the service.
  9. ExecStart=...: The Solr command that will start the service.
  10. Restart=on-failure: Restart the service if it fails.
  11. [Install]: This section is optional and is used to define the behavior or a unit if it is enabled or disabled.
  12. WantedBy=multi-user.target: When the service is enabled, a directory called multi-user.target.wants will be created within /etc/systemd/system (if not already available) and a symbolic link to the current unit will be placed within.
  13. |: Read the string into the following command.
  14. sudo
  15. tee: Write a string to a file.
  16. /usr/lib/systemd/system/solr.service: A new systemd service file to write to for Solr.

How does the system know about the new service?

Reload the systemd daemon.

sudo systemctl daemon-reload
  1. sudo
  2. systemctl: Controls the systemd system and service manager.
  3. daemon-reload: Reload the configuration file of a systemd unit.

How do I enable the Solr service?

Use the systemctl enable command.

sudo systemctl enable solr
  1. sudo
  2. systemctl
  3. enable: Enable one or more unit files or unit file instances.
  4. solr: Enable the Solr service to start when the computer starts.

How do I start the Solr service?

Use the systemctl start command.

sudo systemctl start solr
  1. sudo
  2. systemctl
  3. start: Start one or more services.
  4. solr: Start the Solr service.

How do I make sure the Solr service started successfully?

Use the systemctl status command.

sudo systemctl status solr
  1. sudo
  2. systemctl
  3. status: Check the status of one or more services.
  4. solr: Check the status of the Solr service.

And just like that, your Solr server is ready for client to connect and begin clustering. In future lessons we will connect a search engine, as well as your web applications to Solr to allow them to scale.

How do I create Solr collections to begin indexing and searching my content?

Create collections with the solr command.

/srv/solr/bin/solr create_collection -c site -n computate
  1. /srv/solr/bin/solr
  2. create_collection: A Solr collection
  3. -c site : The name of the solr collection to create.
  4. -n computate : The name of the solr collection to create.

Where can I go once I have installed a Solr server?

Here are some useful URLs related to your Solr server.

To review:

Monday
June 3 2019 How do I try out clustered configuration, requests, events and shared data sources in development? Install Solr from the source code. By Christopher Tate
Questions Answers
How do I install the dependencies for Solr? Build the dependencies with yum.
Where do I put the Solr source code? Create a solr directory in /usr/local/src.
How do I download the Solr source code? Clone the source code with the git command.
How do I build the Solr source code? Build Solr with the ant command.
After compiling Solr, where do I install it as a server? Create a solr directory in /srv.
How do I configure the Solr server? Create a solr.xml file.
How do I create a Solr configset for my site. Try out my own favorite configset from my opensource project computate.
How do I upload my Solr configset to Zookeeper? Use the solr zk upconfig command.
How do I run Solr all the time, when my computer starts up? How to run Solr as a systemd service.
How does the system know about the new service? Reload the systemd daemon.
How do I enable the Solr service? Use the systemctl enable command.
How do I start the Solr service? Use the systemctl start command.
How do I make sure the Solr service started successfully? Use the systemctl status command.
How do I create Solr collections to begin indexing and searching my content? Create collections with the solr command.
Where can I go once I have installed a Solr server? Here are some useful URLs related to your Solr server.

Previous article.

Don't give up on your dreams. You can do hard things!

Share this story.

Let's get connected.
Up to the top.