solr集群容器化部署

43 阅读3分钟

强烈建议不要在生产环节部署,会占用较高的内存,导致经常触发oom

安装solr-operator

添加我们的solr -operator helm仓库

$ helm repo add apache-solr https://solr.apache.org/charts
$ helm repo update
接下来安装solr operator图标
# Install the Solr & Zookeeper CRDs
$ kubectl create -f https://solr.apache.org/operator/downloads/crds/v0.8.0/all-with-dependencies.yaml
# Install the Solr operator and Zookeeper Operator
$ helm install solr-operator apache-solr/solr-operator --version 0.8.0

请注意,Helm 图表版本不包含 v 前缀,而下载版本则包含 v 前缀。Helm 图表版本是 Solr Operator 版本中唯一不使用 v 前缀的部分。

安装后,您可以检查集群中的内容,以确保 Solr 和 ZooKeeper 运算符已正确启动。

kubectl get pod -n dev|grep solr-oper

solr-operator-9d75b5865-pbm8j                                     2/2     Running                  0                 3h50m

solr-operator-zookeeper-operator-76595c9658-2csd4                 2/2     Running                  0                 3h50m

启动示例solr cloud集群

helm install solr-9-5-solr apache-solr/solr --version 0.8.0 \
--set image.tag=9.5.0 \ # 选择对于版本
--set solrOptions.javaMemory="-Xms300m -Xmx300m" \
--set addressability.external.method=Ingress \
--set addressability.external.domainName="solr.local.domain" \
--set addressability.external.useExternalAddress="true" \
--set ingressOptions.ingressClassName="nginx"

kubectl get solrclouds -w

NAME       VERSION                         TARGETVERSION   DESIREDNODES   NODES   READYNODES   UPTODATENODES   AGE

solr-9-5   v1.15.3.43-gc66d25a6cd-aliyun   9.5.0           2              2       2            2               28m

控制我们的版本

kubectl scale --replicas=5 solrcloud/example
发出缩放命令后,开始点击管理 UI 中的“刷新”按钮。 您将看到如何添加新的 Solr 节点。 您还可以通过以下命令查看状态:kubectl get solrclouds

更新版本信息

# Take note of the current version, which is 8.11.2
curl -s http://default-example-solrcloud.ing.local.domain/solr/admin/info/system | grep solr-i

# Update the solrCloud configuration with the new version, keeping all previous settings and the number of nodes set by the autoscaler.
helm upgrade example-solr apache-solr/solr --version 0.8.0 \
  --reuse-values \
  --set image.tag=8.7

# Click the 'Show all details" button in Admin UI and start hitting the "Refresh" button
# See how the operator upgrades one pod at a time. Solr version is in the 'node' column
# You can also watch the status with the 'kubectl get solrclouds' command
kubectl get solrclouds -w

# Hit Control-C when done

通过部署后我们查看pod的信息

kubectl get pods,svc -n dev|grep solr-9-5

pod/solr-9-5-solrcloud-0                                              2/2     Running                  0                 26m

pod/solr-9-5-solrcloud-1                                              2/2     Running                  0                 10m

pod/solr-9-5-solrcloud-zookeeper-0                                    2/2     Running                  0                 31m

pod/solr-9-5-solrcloud-zookeeper-1                                    2/2     Running                  0                 30m

pod/solr-9-5-solrcloud-zookeeper-2                                    2/2     Running                  0                 29m

service/solr-9-5-solrcloud-0                                       ClusterIP      10.10.5.115              80/TCP                                            31m

service/solr-9-5-solrcloud-1                                       ClusterIP      10.10.7.198              80/TCP                                            31m

service/solr-9-5-solrcloud-2                                       ClusterIP      10.10.5.42               80/TCP                                            31m

service/solr-9-5-solrcloud-common                                  ClusterIP      10.10.12.181             80/TCP                                            31m

service/solr-9-5-solrcloud-zookeeper-admin-server                  ClusterIP      10.10.13.195             8080/TCP                                          31m

service/solr-9-5-solrcloud-zookeeper-client                        ClusterIP      10.10.1.219              2181/TCP                                          31m

service/solr-9-5-solrcloud-zookeeper-headless                      ClusterIP      None                     2181/TCP,2888/TCP,3888/TCP,7000/TCP,8080/TCP      31m

这里完成后我们在VS中配置域名

apiVersion: networking.istio.io/v1beta1``kind: VirtualService``metadata:``  ``name: solr-``9``-``5``-solrcloud``  ``namespace: dev``spec:``  ``gateways:``    ``- http-gateway``  ``hosts:``    ``- solrcloud.dev1.com``  ``http:``    ``- route:``        ``- destination:``            ``host: solr-``9``-``5``-solrcloud-common

访问创建我们的信息

上传我们的config文件

./zkcli.sh -zkhost solr-``9``-``5``-solrcloud-zookeeper-headless:``2181 -cmd upconfig -confdir  /opt/solr-``9.5``.``0``/server/solr/configsets/_default/conf -confname solr-``9``-``5``更新单个文件`` ``./zkcli.sh -zkhost solr-``9``-``5``-solrcloud-zookeeper-headless:``2181 -cmd putfile /configs/solr-``9``-``5``/solrconfig.xml /tmp/solrconfig.xml

创建collection就算结束完成了

删除solrcloud集群

kubectl delete solrcloud example