Install the Java language Software Development Kit
Alternatively, select the Mac version jdk-8u111-macosx-x64.dmg download and install on the Oracle website.
Install SOLR
The SOLR version of the current (2016-11-10) Brew source is 6.1.0, you can modify the version you want to install through brew edit SOLR, or download the source package from the official website to compile the installation.
Start SOLR
SOLR start
Returning the following text hint indicates that the SOLR server was successfully installed and the default listener port number is 8983:
Waiting up to seconds to the running on the port 8983 [\]
started SOLR server on port 8983 (pid=890). Happy searching!
accessing in the browser
SOLR provides a visual management interface, SOLR Admin, and the default access URL is: http://localhost:8983/solr/
Create a core that is named Test
Returns the following information, which indicates a successful creation:
Copying configuration to new core instance directory:
/usr/local/cellar/solr/6.1.0/server/solr/test
creating New core ' test ' using command:
http://localhost:8983/solr/admin/cores?action=create&name=test& Instancedir=test
{"
Responseheader": {"
status": 0,
"qtime": 8845},
"core": "Test"}
This command creates a directory of command test/in the/usr/local/cellar/solr/6.1.0/server/solr/directory that contains the test core-related data files and configuration files in the test/directory.
You can see test core information in the SOLR Admin admin interface:
Installing the MySQL Database
Change the password of root to 123456. or any other password you like:
mysqladmin-u root password ' 123456 '
This MySQL account will be used when configuring the SOLR index MySQL information.
To add the data that tests are used for testing:
Create database Solrdata;
Use Solrdata;
CREATE TABLE goods (ID int not NULL auto_increment, name varchar () NOT NULL default ", number varchar NOT NULL DEFAU Lt ', updatetime timestamp NOT NULL default current_timestamp on update Current_timestamp, primary key (ID));
INSERT into goods (name, number) values (' Shoes ', m);
INSERT into goods (name, number) values (' clothes ');
INSERT into goods (name, number) values (' trousers ', 300);
Download MySQL Driver
Download the Mysql-connector-java driver package from the official MySQL address. Or just run the command to get the 5.1.40 version of the drive:
wget http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.40.tar.gz
Copy this driver package to the/usr/local/cellar/solr/6.1.0/libexec/dist/directory:
TAR-ZXVF mysql-connector-java-5.1.40.tar.gz
CD mysql-connector-java-5.1.40
CP mysql-connector-java-5.1.40-bin.jar/usr/local/cellar/solr/6.1.0/libexec/dist/
Modify Solrconfig.xml Configuration
Vi/usr/local/cellar/solr/6.1.0/server/solr/test/conf/solrconfig.xml
Introduction of related driver packages
Enter the 3 related jar packages in the/usr/local/cellar/solr/6.1.0/libexec/dist/:
<lib dir= "${solr.install.dir}/libexec/dist/" regex= "Mysql-connector-java-5.1.40-bin.jar"/> <lib dir=
"${solr.install.dir}/libexec/dist/" regex= "Solr-dataimporthandler-.*\.jar"/>
Add MySQL configuration information
In <requesthandler name= "/select" class= "SOLR." Add the following information to the front of the Searchhandler >:
<requesthandler name= "/dataimport" class= "Org.apache.solr.handler.dataimport.DataImportHandler" >
< LST name= "Defaults" >
<str name= "config" >data-config.xml</str>
</lst>
</ Requesthandler>
Create a new Data-config.xml file in the same directory
Vi/usr/local/cellar/solr/6.1.0/server/solr/test/conf/data-config.xml
Add the following information:
<?xml version= "1.0" encoding= "UTF-8"?>
<dataConfig>
<datasource name= "Source1" type= "
Jdbcdatasource "
driver=" Com.mysql.jdbc.Driver "
url=" Jdbc:mysql://localhost:3306/solrdata "
user=" Root "
password=" 123456 "
batchsize="-1 "/>
<document>
<entity name="
goods "pk=" ID "
datasource=" Source1 "
query=" SELECT * from goods "
deltaimportquery=" select * from goods where id= ' ${ Dih.delta.id} ' "
deltaquery=" SELECT ID from goods where updatetime> ' ${dataimporter.last_index_time} ' ">
<field column= "id"
name= "id"/>
<field column= "name"
name= "name"/>
< Field column= "number"
name= "number"/>
<field column= "updatetime"
name= "UpdateTime"/>
</entity>
</document>
</dataConfig>
Managed-schema Configuration Field Information
Vi/usr/local/cellar/solr/6.1.0/server/solr/test/conf/managed-schema
Add the following information:
<field name= "Name" type= "string" indexed= "true" stored= "false"/> <field name= "number
" type= "int" indexed = "true" stored= "false"/> <field name= "updatetime" type= "date" indexed=
"true" stored= "false"/>
Restart the SOLR service
SOLR restart
Returns the following information stating that the SOLR server restarted successfully:
Sending stop command to SOLR running on port 8983 ... waiting 5 seconds to allow Jetty process 1446 to stop gracefully.
waiting up to seconds to the running on the port 8983 [/]
started SOLR server on port 8983 (pid=1784). Happy searching!
DataImport operation
Open the browser into SOLR Admin, and in the following interface, click the Execute button:
After successful, the following interface is displayed:
Query queries
Enter the Query page and click the Execute button:
The above is a small set to introduce the MacOS installation SOLR and index MySQL, I hope to help you, if you have any questions please give me a message, small set will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!