环境
1.操作系统centos7 64位。
2.需要安装jdk1.8及以上版本。
3.使用solr内置的jetty容器部署solr服务。
现状
1.目前后台使用solr不支持权限。
2.目前只需部署单节点即可。
下载
- 安装包:solr-8.4.1.tgz
- 下载地址:https://archive.apache.org/dist/lucene/solr/8.4.1/solr-8.4.1.tgz
安装
在/usr/local/下创建solr目录,并赋权限。
1 | [root@admin /]# cd /usr/local/ |
进入solr文件夹,上传压缩包solr-8.4.1.tgz,并解压得到solr-8.4.1文件夹。
1 | [root@admin local]# cd solr/ |
启动solr
进入解压后的solr-8.4.1/bin/目录,solr这个脚本用于启动、停止、查看solr运行状态等。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19./solr start -p 端口 -force 启动
./solr stop -all 关闭
./solr status 查看状态
[root@admin solr]# cd solr-8.4.1/bin/
[root@admin bin]# ls
init.d install_solr_service.sh oom_solr.sh post solr solr.cmd solr.in.cmd solr.in.sh
[root@admin bin]# ./solr start -p 8983 -force
Started Solr server on port 8983 (pid=7834). Happy searching!
注意:
如果linux系统中缺少lsof组件,在启动solr时将报如下提示:
*** [WARN] *** Your open file limit is currently 1024.
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
*** [WARN] *** Your Max Processes Limit is currently 3795.
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
NOTE: Please install lsof as this script needs it to determine if Solr is listening on port 8983.
解决方案: 安装 lsof 组件即可
[root@admin bin]# yum -y install lsof设置防火墙开启8983端口开放远程访问
1
2
3
4[root@admin bin]# firewall-cmd --zone=public --add-port=8983/tcp --permanent
success
[root@admin bin]# firewall-cmd --reload
success浏览器访问管理页面 http://192.168.159.130:8983/solr
创建内核
目前后台需创建两个内核:bankstatement用于对账单的索引、enterprise用于对手方企业的索引。1
2
3
4
5
6
7
8[root@admin bin]# ./solr create -c bankstatement -force
WARNING: Using _default configset with data driven schema functionality. NOT RECOMMENDED for production use.
To turn off: bin/solr config -c bankstatement -p 8983 -action set-user-property -property update.autoCreateFields -value false
Created new core 'bankstatement'
[root@admin bin]# ./solr create -c enterprise -force
WARNING: Using _default configset with data driven schema functionality. NOT RECOMMENDED for production use.
To turn off: bin/solr config -c enterprise -p 8983 -action set-user-property -property update.autoCreateFields -value false
Created new core 'enterprise'
配置字段
在内核上创建字段、以及配置字段属性。
- 内核bankstatement:发送post请求:http://192.168.159.130:8983/solr/bankstatement/schema
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213Content-Type:application/json
请求体:
{
"add-field":[
{
"name":"leId",
"type":"pint",
"indexed":true,
"stored":true,
"multiValued":false,
"required":false
},
{
"name":"leAccountName",
"type":"string",
"indexed":true,
"stored":true,
"multiValued":false,
"required":false
},
{
"name":"leAccountNo",
"type":"string",
"indexed":true,
"stored":true,
"multiValued":false,
"required":false
},
{
"name":"trxFlag",
"type":"string",
"indexed":true,
"stored":true,
"multiValued":false,
"required":false
},
{
"name":"accountingDateId",
"type":"pint",
"indexed":true,
"stored":true,
"multiValued":false,
"required":false
},
{
"name":"trxDate",
"type":"string",
"indexed":true,
"stored":true,
"multiValued":false,
"required":false
},
{
"name":"amount",
"type":"pdouble",
"indexed":true,
"stored":true,
"multiValued":false,
"required":false
},
{
"name":"amountAbs",
"type":"pdouble",
"indexed":true,
"stored":true,
"multiValued":false,
"required":false
},
{
"name":"currency",
"type":"string",
"indexed":true,
"stored":true,
"multiValued":false,
"required":false
},
{
"name":"amountBalance",
"type":"pdouble",
"indexed":true,
"stored":true,
"multiValued":false,
"required":false
},
{
"name":"cashType",
"type":"string",
"indexed":true,
"stored":true,
"multiValued":false,
"required":false
},
{
"name":"customerAccountName",
"type":"string",
"indexed":true,
"stored":true,
"multiValued":false,
"required":false
},
{
"name":"customerAccountNo",
"type":"string",
"indexed":true,
"stored":true,
"multiValued":false,
"required":false
},
{
"name":"userMemo",
"type":"string",
"indexed":true,
"stored":true,
"multiValued":false,
"required":false
},
{
"name":"bank",
"type":"string",
"indexed":true,
"stored":true,
"multiValued":false,
"required":false
},
{
"name":"createDate",
"type":"string",
"indexed":true,
"stored":true,
"multiValued":false,
"required":false
},
{
"name":"createdBy",
"type":"pint",
"indexed":true,
"stored":true,
"multiValued":false,
"required":false
},
{
"name":"yearId",
"type":"pint",
"indexed":true,
"stored":true,
"multiValued":false,
"required":false
},
{
"name":"quarterId",
"type":"pint",
"indexed":true,
"stored":true,
"multiValued":false,
"required":false
},
{
"name":"monthId",
"type":"pint",
"indexed":true,
"stored":true,
"multiValued":false,
"required":false
},
{
"name":"weekId",
"type":"pint",
"indexed":true,
"stored":true,
"multiValued":false,
"required":false
},
{
"name":"dayId",
"type":"pint",
"indexed":true,
"stored":true,
"multiValued":false,
"required":false
},
{
"name":"catalog",
"type":"string",
"indexed":true,
"stored":true,
"multiValued":false,
"required":false
},
{
"name":"tags",
"type":"string",
"indexed":true,
"stored":true,
"multiValued":true,
"required":false
}
],
"add-dynamic-field":{
"name":"muti_catalog_*",
"type":"string",
"indexed":true,
"stored":true,
"multiValued":false,
"required":false
}
}
返回:表示成功
{
"responseHeader":{
"status":0,
"QTime":22606
}
}
- 内核enterprise:
发送post请求:http://192.168.159.130:8983/solr/enterprise/schema1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29Content-Type:application/json
请求体:
{
"add-field":[
{
"name":"name",
"type":"string",
"indexed":true,
"stored":true,
"multiValued":false,
"required":false
},
{
"name":"tags",
"type":"string",
"indexed":true,
"stored":true,
"multiValued":true,
"required":false
}
]
}
返回:表示成功
{
"responseHeader":{
"status":0,
"QTime":12265
}
}