我需要在GCP memorystore redis实例上安装RedSearch模块。
docker run-p 6379:6379 redislabs/redisearch:latest
我将这个docker映像推送到Kubernetes集群,并暴露了外部IP。我使用该外部IP和6379端口作为应用程序的配置,但无法连接到RedSearch。
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.apache.beam.sdk.Pipeline;
import org.apache.beam.sdk.PipelineResult;
import org.apache.beam.sdk.options.Default;
import org.apache.beam.sdk.options.Description;
import org.apache.beam.sdk.options.PipelineOptions;
import org.apache.beam.sdk.options.PipelineOptionsFactory;
import org.apache.beam.sdk.transforms.Create;
import org.apache.beam.sdk.transforms.DoFn;
import org.apache.beam.sdk.transforms.ParDo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.redisearch.client.Client;
import io.redisearch.*;
public class RediSearch {
static Client client = new Client("testdoc1", "clusteripaddress", 8097);
private static final Logger LOG = LoggerFactory.getLogger(RediSearch.class);
public interface Options extends PipelineOptions {
@Description("gcp project id.")
@Default.String("XXXX")
String getProjectId();
void setProjectId(String projectId);
}
public static PipelineResult run(Options options) throws IOException {
Pipeline pipeline = Pipeline.create(options);
pipeline.apply(Create.of("test"))
.apply(ParDo.of(new DoFn<String, String>() {
private static final long serialVersionUID = 1L;
@ProcessElement
public void processElement(ProcessContext c) throws Exception {
String pubsubmsg = c.element();
Schema sc = new Schema()
.addTextField("title", 5.0)
.addTextField("body", 1.0)
.addNumericField("price");
client.createIndex(sc, Client.IndexOptions.Default());
Map<String, Object> fields = new HashMap<String, Object>();
fields.put("title", "hello world");
fields.put("body", "lorem ipsum");
fields.put("price", 800);
fields.put("price", 1337);
fields.put("price", 2000);
client.addDocument("searchdoc3", fields);
SearchResult[] res = client.searchBatch(new Query("hello world").limit(0, 5).setWithScores());
for (Document d : res[0].docs) {
LOG.info("redisearchlog{}",d.getId().startsWith("search"));
LOG.info("redisearchlog1{}",d.getProperties());
LOG.info("redisearchlog2{}",d.toString());
}
}
}));
return pipeline.run();
}
public static void main(String[] args) throws IOException {
Options options = PipelineOptionsFactory.fromArgs(args).as(Options.class);
run(options);
}
}
redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
at redis.clients.jedis.util.Pool.getResource(Pool.java:59)
at redis.clients.jedis.JedisPool.getResource(JedisPool.java:234)
at redis.clients.jedis.JedisPool.getResource(JedisPool.java:15)
at io.redisearch.client.Client._conn(Client.java:137)
at io.redisearch.client.Client.getAllConfig(Client.java:275)
at com.testing.redisearch.RediSearch$1.processElement(RediSearch.java:59)
Caused by: redis.clients.jedis.exceptions.JedisConnectionException: Failed connecting to host xxxxxxxxxxx:6379
at redis.clients.jedis.Connection.connect(Connection.java:204)
at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:100)
at redis.clients.jedis.BinaryJedis.connect(BinaryJedis.java:1894)
at redis.clients.jedis.JedisFactory.makeObject(JedisFactory.java:117)
at org.apache.commons.pool2.impl.GenericObjectPool.create(GenericObjectPool.java:889)
at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:424)
at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:349)
at redis.clients.jedis.util.Pool.getResource(Pool.java:50)
at redis.clients.jedis.JedisPool.getResource(JedisPool.java:234)
at redis.clients.jedis.JedisPool.getResource(JedisPool.java:15)
at io.redisearch.client.Client._conn(Client.java:137)
at io.redisearch.client.Client.getAllConfig(Client.java:275)
at com.testing.redisearch.RediSearch$1.processElement(RediSearch.java:59)
at com.testing.redisearch.RediSearch$1$DoFnInvoker.invokeProcessElement(Unknown Source)
at org.apache.beam.runners.dataflow.worker.repackaged.org.apache.beam.runners.core.SimpleDoFnRunner.invokeProcessElement(SimpleDoFnRunner.java:218)
at org.apache.beam.runners.dataflow.worker.repackaged.org.apache.beam.runners.core.SimpleDoFnRunner.processElement(SimpleDoFnRunner.java:183)
at org.apache.beam.runners.dataflow.worker.SimpleParDoFn.processElement(SimpleParDoFn.java:335)
at org.apache.beam.runners.dataflow.worker.util.common.worker.ParDoOperation.process(ParDoOperation.java:44)
at org.apache.beam.runners.dataflow.worker.util.common.worker.OutputReceiver.process(OutputReceiver.java:49)
at org.apache.beam.runners.dataflow.worker.util.common.worker.ReadOperation.runReadLoop(ReadOperation.java:201)
at org.apache.beam.runners.dataflow.worker.util.common.worker.ReadOperation.start(ReadOperation.java:159)
at org.apache.beam.runners.dataflow.worker.util.common.worker.MapTaskExecutor.execute(MapTaskExecutor.java:77)
at org.apache.beam.runners.dataflow.worker.BatchDataflowWorker.executeWork(BatchDataflowWorker.java:411)
at org.apache.beam.runners.dataflow.worker.BatchDataflowWorker.doWork(BatchDataflowWorker.java:380)
at org.apache.beam.runners.dataflow.worker.BatchDataflowWorker.getAndPerformWork(BatchDataflowWorker.java:305)
at org.apache.beam.runners.dataflow.worker.DataflowBatchWorkerHarness$WorkerThread.doWork(DataflowBatchWorkerHarness.java:140)
at org.apache.beam.runners.dataflow.worker.DataflowBatchWorkerHarness$WorkerThread.call(DataflowBatchWorkerHarness.java:120)
at org.apache.beam.runners.dataflow.worker.DataflowBatchWorkerHarness$WorkerThread.call(DataflowBatchWorkerHarness.java:107)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.SocketTimeoutException: connect timed out
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at redis.clients.jedis.Connection.connect(Connection.java:181)
... 31 more
任何解决方案都将不胜感激。
如果您希望在memorystore实例中使用RedSearch模块,那么它似乎还不受支持。你可以在这里的谷歌云文档中看到,在撰写本文时,即使是5.0版,也不支持redis模块。
根据错误JedisConnectionException:无法从池中获取资源
,有多个原因。根据这个问题的答案,问题是无法建立到RediSearch的连接,可能是因为Redis未运行、连接超时或无法分配。
无论如何,我注意到,即使您在端口6379上部署Redis,在您的代码中,您仍试图在端口8097上访问它。请将您的客户端声明更改为以下内容,然后重试连接。
static Client client = new Client("testdoc1", "<cluster_ip_address>", 6379);
我已经创建了Self-Signed Certifice(SSL),并在Intranet Ubuntu Server-Tomcat7上托管了Spring MVC web应用程序,它运行良好。 但是当我用Tomcat7将这个应用程序部署到Amazon EC2-Ubuntu时,端口8443没有响应。 谢谢 @edit:catalina.log(安装ssl后我的服务器状态)
问题内容: 我正在尝试安装pywin32。我从sourceforge.net下载了它。当我跑步 它显示“无法找到vcvarsall.bat”。我在Google上搜索了一下,发现我必须安装MinGW并设置路径然后运行 但它显示 有人可以帮忙吗?(我已经安装了Visual Studio 2010 Ultimate的试用版,并且安装了MinGW C和C ++编译器。操作系统:Windows7。) 有人可
在Windows10中,如何在WSL中安装多个Ubuntu的独立实例?我想为不同的工作空间提供不同的实例。例如,一个用于Python开发,一个用于Ruby开发,一个用于.NET核心开发等等。我知道我可以将所有这些都塞进同一个Ubuntu on WSL实例中,但我更希望为这些场景中的每一个都有一个单独的实例。这可能吗?
你能告诉我如何用在我的Synology上运行的模块获得Python3(DS214play,与DSM 6.0.1-7393更新1)吗?我想要的:在我的Synology上运行Python3中的Tweepy和其他模块。 我被困的地方: > 如何让PIP3安装Tweepy,如果我尝试,我会得到: 因为当与SSH(使用PuTTY)连接到我的Synology时,我可以在DSM包管理器和相关文件夹中看到Pyth
问题内容: Google App Engine启动器告诉我: 警告appengine_rpc.py:399找不到ssl模块。如果没有ssl模块,则无法验证远程主机的身份,并且连接可能不安全。要解决此问题,请从http://pypi.python.org/pypi/ssl安装ssl模块 。 我下载了软件包,其中包含一个文件。我跑了: 接着: 然后我安装了MinGW32,现在编译不起作用。编译错误的末
我需要在EC2的Amazon ami linux实例上安装JDK15。使用命令我似乎找不到它,任何答案都将不胜感激!