solr安装,
为什么80%的码农都做不了架构师?>>>
(如有侵权,请联系我删掉)
腾讯云安装solr:( 我使用的是solr7.5) 下载solr包: wget http://mirror.bit.edu.cn/apache/lucene/solr/7.5.0/solr-7.5.0.tgz
解压:tar -zxvf solr-7.5.0.taz
1.启动solr(cloud启动) 启动命令 solr start -e cloud //此命令配置集群启动,初次启动需要配置一些信息
1、设置节点数 solr显示提示语:
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]: `
回车默认即可,生成两个节点
2、设置端口号
提示语:
Ok, let's start up 2 Solr nodes for your example SolrCloud cluster. Please enter the port for node1 [8983]:
没有特殊要求的话,回车即可,此时默认启动8983和7574两个节点,并且会启动内置的zookeeper服务器,服务器端口为默认端口+1000,如启动默认节点8983,则zookeeper端口为9983。
3、solr提示创建collection
Now let's create a new collection for indexing documents in your 2-node cluster.
Please provide a name for your new collection: [gettingstarted]
testCollection
然后设置分片数和副本数,直接默认就可以。
然后设置配置文件,配置文件有两个_default和sample_techproducts_configs 两个,随便选一个就可以了。
在配置文件文件夹中managed-schema or schema.xml 这两个文件比较重要。
_default和sample_techproducts_configs文件夹位置:solr-7.5.0/server/solr/configsets/文件夹下。
二、solr安装过程中碰到的问题
问题1、solr关闭与重启
./solr stop -all //关闭所有端口
启动cloud时,需要按照端口启动
./solr start -c -p 8983 -s ../example/cloud/node1/solr
./solr start -c -p 7574 -s ../example/cloud/node2/solr -z localhost:9983
问题2:Max Processes Limit
笔者用的服务器是阿里云的超低配版本,默认的最大限制用户进程数是 7857,因此在启动 Solr 时就马上看到警告:
*** [WARN] *** Your Max Processes Limit is currently 7857.
It should be set to 65000 to avoid operational disruption.
If you no longer wish to see this warning, set SOLR_ULIMIT_CHECKS to false in your profile or solr.in.sh
原本想只是一个警告罢了,忽略就好,结果还是 GG 了。
ERROR: Failed to start Solr using command: "/usr/local/java/solr-7.4.0/bin/solr" start -cloud -p 8983 -s "/usr/local/java/solr-7.4.0/example/cloud/node1/solr" Exception : org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
1
既然这样,那就只能正视问题了。
首先,查看一下系统限制的最大用户进程数:
root@panda:/# ulimit -u
7857
确认是 7857 没错了。
那么现在,我们需要解决的就是更改这个默认值。在笔者的环境中,max user processes 可以在 /etc/security/limits.conf 文件中进行设置,格式为<domain> <type> <item> <value>,详情如下:
root soft nproc 65535
root hard nproc 65535
* soft nproc 65535
* hard nproc 65535
保存后重启会话,发现该值已经变成 65535 了。
root@panda:~# ulimit -u
65535
注:CentOS 的配置文件似乎在 /etc/security/limits.d 文件夹下。
问题3:不能使用 root 用户
解决了上一个问题后,笔者欢快地重新尝试启动 Solr:
WARNING: Starting Solr as the root user is a security risk and not considered best practice. Exiting.
Please consult the Reference Guide. To override this check, start with argument '-force'
ERROR: Failed to start Solr using command: "/usr/local/java/solr-7.4.0/bin/solr" start -cloud -p 8983 -s "/usr/local/java/solr-7.4.0/example/cloud/node1/solr" Exception : org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
orz,结果告诉笔者不能用 root 用户启动 Solr。当然,可以使用 -force 参数强行跳过这个检测,但既然官方说这样做不好,那就乖乖听话吧。(换用户就换用户,您开心就好。)
su panda
问题4:文件读写权限
笔者又满心欢喜地重新尝试启动 Solr:
ERROR: Logs directory /usr/local/java/solr-7.4.0/example/cloud/node1/solr/../logs could not be created. Exiting
ERROR: Failed to start Solr using command: "/usr/local/java/solr-7.4.0/bin/solr" start -cloud -p 8983 -s "/usr/local/java/solr-7.4.0/example/cloud/node1/solr" Exception : org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
结果被告知没有权限创建日志文件。
好吧,才想起来自己现在不是 root 用户,要先为 Solr 文件夹设置文件读写权限。
root@panda:/usr/local/java# chmod -R 777 solr-7.4.0/
问题五:无法创建log文件夹
手动创建文件夹即可。
问题5:关于collection reload配置文件的理解
每次reload的时候,都是从zookeeper节点上下载对应的配置文件,并不是从我们服务器上存放配置文件的位置来下载配置文件配置collection,所以,每次修改配置文件managed-schema或者schema.xml时,需要更新对应的collection的配置文件,更新命令如下:
bin/solr zk upconfig -z 111.222.333.444:2181 -n mynewconfig -d /path/to/configset
-z zookeeper地址 -n collection name -d local config path
具体操作可以查看文档:
solr说明文档 链接:https://pan.baidu.com/s/1vjLc3RElzAeaokV5tEwnNQ 密码:92ba
转载于:https://my.oschina.net/mrfu/blog/2242217