Setting up Search with Social database in Smart IT
Elasticsearch is a flexible and powerful open-source, distributed, real-time search and analytics engine. If you do not install Elasticsearch, BMC Remedy with Smart IT (Smart IT) and BMC MyIT use the built-in search of MongoDB.
Best practice
Use the following process to configure MongoDB to use Elasticsearch:
Before you begin
Before starting this procedure, complete the following tasks:
- Verify that the JAVA_HOME environment variable is set.
- Install MongoDB.
- For high availability, configure MongoDB replica sets.
- Take note of the installation path of Elasticsearch 1.4.2 bundled with the installer; for example:
C:\program files\BMC Software\smart_it_myit\smart_it_myit\elasticsearch
To configure MongoDB to use Elasticsearch
To configure the social database MongoDB to use Elasticsearch, perform the following steps:
Open the config.js file in InstallationDirectory\Smart_IT_MyIT\Smart_IT_MyIT\social\.
Add the following three lines:
search_type:1
search_hosts:["elasticSearchServerIPaddress"]
search_host_port:"elasticsearchPort"For high availability environments, the
search_hosts
parameter must include all the Elasticsearch servers:
search_hosts:["elasticSearchServerOneIPaddress", "elasticSearchServerTwoIPaddress"]The Elasticsearch port is typically 9200.
- Save the config.js file.
- If MongoDB is configured for authentication, perform the following steps:
- Log on to the mongo shell with the pathToMongoDB/bin/mongo command.
- To be authorized as a user with userAdminAnyDatabase permission, enter the following commands:
- use admin
- db.auth("username", "password")
Create two users with only the read role for admin and social database:
db.adduser( { user: "elasticsearchuser", pwd: "password", roles: [ "read" ] } )To configure the River plug-in, use the
curl
command to add the indexes for activities, subactivities, users, and resources. Replace the IP addresses and passwords in the following command:curl -XPUT "http://<elasticsearch-server-ip>:9200/_river/activitysearch/_meta" -d '
{
"type": "mongodb",
"mongodb": {
"servers": [
{ "host": "mongodb_primary_ip", "port": 27017 },
{ "host": "mongodb_secondary_ip", "port": 27017 },
{ "host": "mongodb_secondary_ip", "port": 27017 }
],
"db": "social",
"collection": "activities",
"credentials": [
{
"db": "admin",
"user": "elasticsearchuser",
"password": "<password>"
},
{
"db": "social",
"user": " elasticsearchuser ",
"password": "<password>"
}
]
},
"index": {
"name": "activitysearch",
"type": "activities"
}
}'
curl -XPUT "http:// <elasticsearch-server-ip>:9200/_river/subactivitysearch/_meta" -d '
{
"type": "mongodb",
"mongodb": {
"servers": [
{ "host": "mongodb_primary_ip", "port": 27017 },
{ "host": "mongodb_secondary_ip", "port": 27017 },
{ "host": "mongodb_secondary_ip", "port": 27017 }
],
"db": "social",
"collection": "subactivities",
"credentials": [
{
"db": "admin",
"user": "elasticsearchuser",
"password": "<password>"
},
{
"db": "social",
"user": " elasticsearchuser ",
"password": "<password>"
}
]
},
"index": {
"name": "subactivitysearch",
"type": "subactivities"
}
}'
curl -XPUT "http:// <elasticsearch-server-ip>:9200/_river/usersearch/_meta" -d '
{
"type": "mongodb",
"mongodb": {
"servers": [
{ "host": "mongodb_primary_ip", "port": 27017 },
{ "host": "mongodb_secondary_ip", "port": 27017 },
{ "host": "mongodb_secondary_ip", "port": 27017 }
],
"db": "social",
"collection": "users",
"credentials": [
{
"db": "admin",
"user": "elasticsearchuser",
"password": "<password>"
},
{
"db": "social",
"user": " elasticsearchuser ",
"password": "<password>"
}
]
},
"index": {
"name": "usersearch",
"type": "users"
}
}'
curl -XPUT "http:// <elasticsearch-server-ip>:9200/_river/resourcesearch/_meta" -d '
{
"type": "mongodb",
"mongodb": {
"servers": [
{ "host": "mongodb_primary_ip", "port": 27017 },
{ "host": "mongodb_secondary_ip", "port": 27017 },
{ "host": "mongodb_secondary_ip", "port": 27017 }
],
"db": "social",
"collection": "resources",
"credentials": [
{
"db": "admin",
"user": "elasticsearchuser",
"password": "<password>"
},
{
"db": "social",
"user": " elasticsearchuser ",
"password": "<password>"
}
]
},
"index": {
"name": "resourcesearch",
"type": "resources"
}
}'
- Restart the social service:
(Windows) MyITSocialService
(Linux) socialserviced
To verify the Elasticsearch indexes
On the Elasticsearch server, open a web browser and confirm that the following queries provide the expected results:
Query | Expected result |
---|---|
http://localhost:9200/_stats | json with the indexes created. |
http://localhost:9200/usersearch/_search?pretty | Number of tickets indexed matches the database count. |
http://localhost:9200/activitysearch/_search?pretty | Number of tickets indexed matches the database count. |
http://localhost:9200/subactivitysearch/_search?pretty | Number of work logs and comments indexed matches the database count. |
http://localhost:9200/resourcesearch/_search?pretty | Number of assets and points of interest (POI) indexed matches the database count. |
Search for users in your database. For example, http://localhost:9200/usersearch/_search?q=Allen&pretty | Users match the users in the database. |
Comments
Log in or register to comment.