Solr 8.3.1启动异常:无法加载org.apache.solr.util.SolrCLI及进程检测问题
The Problem You Faced
As a new Solr user on Windows 10 with Java 1.8.0_181 and Solr 8.3.1 (with solr/bin added to your PATH), you ran into multiple frustrating errors when using Git Bash to execute Solr commands:
- Running
solr startthrewulimit: -m: invalid option, plus warnings about open file/max processes limits, a syntax error[: !=: unary operator expected, and a note about missinglsof. Even though the script claimed the server started,solr statusshowed the process wasn't found. - Executing
solr start -e cloudorsolr start -e techproductsresulted inError: Could not find or load main class org.apache.solr.util.SolrCLI.
The Solution
The root issue is compatibility conflicts between Git Bash (built on Cygwin) and Solr's Windows-specific scripts. The fix is straightforward: switch to using Windows Command Prompt (CMD) or PowerShell instead of Git Bash. All your Solr commands will work as expected once you make this change.
Working Output Examples After Switching
solr start output:
Java HotSpot(TM) 64-Bit Server VM warning: JVM cannot use large page memory because it does not have enough privilege to lock pages in memory.
Waiting up to 30 to see Solr running on port 8983
Started Solr server on port 8983. Happy searching!
solr status output:
Found Solr process 50764 running on port 8983
{ "solr_home":"D:\Program Files and Documents\solr-8.3.1\server\solr", "version":"8.3.1 a3d456fba2cd1b9892defbcf46a0eb4d4bb4d01f - ishan - 2019-11-29 11:51:37", "startTime":"2019-12-19T22:20:25.127Z", "uptime":"0 days, 0 hours, 0 minutes, 14 seconds", "memory":"176.3 MB (%34.4) of 512 MB"}
solr start -e cloud output:
Welcome to the SolrCloud example! This interactive session will help you launch a SolrCloud cluster on your local workstation. To begin, how many Solr nodes would you like to run in your local cluster? (specify 1-4 nodes) [2]:
Why This Happens
Solr's Windows scripts are built to work with native Windows terminals. Git Bash emulates a Unix environment, so Unix-specific commands like ulimit don't function correctly in this setup, leading to the cascade of errors you encountered. Sticking to CMD or PowerShell ensures the scripts run as intended without compatibility hiccups.
内容的提问来源于stack exchange,提问作者user3684314

