embedded-redis
embedded-redis copied to clipboard
"Can't start redis server. Check logs for details" - which logs????
Caused by: java.lang.RuntimeException: Can't start redis server. Check logs for details.
at redis.embedded.AbstractRedisInstance.awaitRedisServerReady(AbstractRedisInstance.java:61)
at redis.embedded.AbstractRedisInstance.start(AbstractRedisInstance.java:39)
at redis.embedded.RedisServer.start(RedisServer.java:9)
at com.nemesis.platform.config.PlatformCoreSessionConfig$RedisServerBean.afterPropertiesSet(PlatformCoreSessionConfig.java:82)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1633)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:116)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:606)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:462)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
In the upcoming release I plan to expose redis logs to file, which you can inspect for issues.
I got the exact same error with both 0.5 and 0.6. Windows 7 64 bits.
If it's happening to you (dear reader) and you have no idea how to debug this until logs are indeed added to the application (thanks for your work btw) you can just do the following.
Use your favorite IDE and create a very simple reproducer :
public static void main(String... args) throws Exception {
RedisServer server = new RedisServer(6379);
server.start();
}
Then in your favorite IDE, put a breakpoint here and debug the main method in your IDE.
You should be able to read the error message from here. In my case, it was the following :
[9520] 03 Jun 18:12:27.054 # The Windows version of Redis allocates a memory mapped heap for sharing with the forked process used for persistence operations. In order to share this memory, Windows allocates from the system paging file a portion equal to the size of the Redis heap.
At this time there is insufficient contiguous free space available in the system paging file for this operation (Windows error 0x5AF).
To work around this you may either increase the size of the system paging file, or decrease the size of the Redis heap with the --maxheap flag.
Sometimes a reboot will defragment the system paging file sufficiently for this operation to complete successfully. Please see the documentation included with the binary distributions for more details on the --maxheap flag.
Which helped me a lot to diagnose the issue.
Hope this helps someone one day.
(this is actually issue #9 )
I'm also having the same issue. It's running fine on mac os x but when I run this under centos6.6 and redis-2.4 it throws this error
Usage: ./redis-server [/path/to/redis.conf]
./redis-server - (read config from stdin)
./redis-server --test-memory <megabytes>
java.lang.RuntimeException: Can't start redis server. Check logs for details.
[info] at redis.embedded.AbstractRedisInstance.awaitRedisServerReady(AbstractRedisInstance.java:61)
[info] at redis.embedded.AbstractRedisInstance.start(AbstractRedisInstance.java:39)
[info] at redis.embedded.RedisServer.start(RedisServer.java:9)
I have been spending a lot of time debugging this so a better logging mechanism would be really appreciated
Hey sorry, it was because of the version of redis is too old. After I upgrade redis, everything works fine
As my build is failing on Jenkins (still need to check if it is not https://github.com/kstyrc/embedded-redis/issues/49) I have to ask when do you plan next release with logs? Keep up the good work!
Same here for me, I get java.lang.RuntimeException: Can't start redis server. Check logs for details.
when running on Jenkins (Centos 6.6), but tests pass if running locally on Ubuntu 15.
Using a redis-server build which was created on a CentOS System solved it for me.
get the same running on snap-ci
Same problem running in Circle CI.
Turns out that Circle had it's own Redis instance using the same port. Just changing the port fixed it.
on snap-ci I also started use the provided redis service, so no need to start an embedded one
I am having the same error on my jenkins build running on Debian 4.8.4-1. Has there been any update here? I cannot install redis on the jenkins machine.
This project is great! thank you!
In my case, the problem was an already running instance of the Redis server (port already in use). Seems like one application shutdown went wrong and therefore failed to kill it.
Yeah... this sometimes happens. What I do, which seems to work fine, is to start the redis server with a random port. That way, if the CI build fails to stop the redis server there's no problem since the new runs will have a different port. Also allows for safer concurrent builds since there are no conflicts.
Any progress here?
Hi I got the same issue . Simple what I did is just clear the C: disc and remove unnecessary program installed, clear desktop and clear recycle bin and increase the virtual memory . worked fined for me.
Hey there! I was pulling my hairs to resolve :
Caused by: java.lang.RuntimeException: Can't start redis server. Check logs for details.
at edis.embedded.AbstractRedisInstance.awaitRedisServerReady(AbstractRedisInstance.java:61)
at redis.embedded.AbstractRedisInstance.start(AbstractRedisInstance.java:39)
at redis.embedded.RedisServer.start(RedisServer.java:9)
error, finally I saw an instance of redis server is already running in background, So I killed that proccess and Re-rn the App and Yeah the App worked without that error.
^ that. What I usually do, and it might not work for all use cases, is to always start the server with a random port. I can do this because I start/discard servers for every unit tests that needs them.
C:\Users\ADMINI~1\AppData\Local\Temp\1469700558020-0\redis-server-2.8.19.exe
path error:File executable = RedisExecProvider.defaultProvider().get(); System.out.println("======executable:" + executable.getAbsolutePath()); ======executable:C:\Users\ADMINI~1\AppData\Local\Temp\1469700558020-0\redis-server-2.8.19.exe
public RedisServer(int port) throws IOException { super(port);
C:\Users\Administrator>F:\it\redis\redis-server-2.8.19.exe [8468] 28 Jul 18:19:18.622 # The Windows version of Redis allocates a memory mapped heap for sharing with the forked process used for persistence operations. In order to share this memory, Windows allocates from the system paging file a portion equal to the size of the Redis heap. At this time there is insufficient contiguous free space available in the system paging file for this operation (Windows error 0x5AF). To work around this you may either increase the size of the system paging file, or decrease the size of the Redis heap with the --maxheap flag. Sometimes a reboot will defragment the system paging file sufficiently for this operation to complete successfully.
Please see the documentation included with the binary distributions for more details on the --maxheap flag.
Redis can not continue. Exiting.
Redis-x64-3.2.100.zip https://github.com/MSOpenTech/redis/releases
Build failing on Ubuntu 12.02, i686 (32 Bit) through Jenkins due to Same issue. Any updates on it?
The problem lies in the following function awaitRedisServerReady() for me. There the startup input stream of redis is just ignored and parsed for the "ready" line only. But sometimes there is other important information logged into there, like the reason why the startup fails. So I need to debug this function to find out the actual reason. Would be nice if this stream would be logged somewhere and not just ignored.
For me it worked after shifting it on 64 Bit Machine.. !!
Thank @aesteve and @dalilagauge . On Windows 64-bit it works after setting maxheap.
@Configuration
@Profile("test")
public class EmbeddedRedisServer {
@Value("${spring.redis.port:6380}")
private int redisPort;
private RedisServer redisServer;
@PostConstruct
public void startRedis() throws IOException, URISyntaxException {
//redisPort = org.springframework.util.SocketUtils.findAvailableTcpPort(6380);
//RedisExecProvider customRedisExec = RedisExecProvider.defaultProvider().override
// (OsArchitecture.detect().os(), OsArchitecture.detect().arch(), "redis-server-2.8.19.exe");
redisServer = RedisServer.builder()
.port(redisPort)
//.redisExecProvider(customRedisExec) //com.github.kstyrc (not com.orange.redis-embedded)
.setting("maxmemory 128M") //maxheap 128M
.build();
redisServer.start();
}
@PreDestroy
public void stopRedis() throws InterruptedException {
if (redisServer != null) {
redisServer.stop();
}
}
}
hope this helps somebody someday,
I am seeing this problem (on Arch Linux) in the outputLine of redisProcess:
[21412] 02 Nov 12:02:10.430 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
If I start embeded redis with maxclients=1024, it works. Maybe it helps someone
The same issue surfaces when creating a Cluster using sample code in README (with RedisCluster.builder()). However, the work-around of using custom settings, like @ducquoc suggested, doesn't work, since RedisClusterBuilder#buildMaster and RedisClusterBuilder#buildSlaves invoke builder.reset, hence passing configured RedisServerBuilders to RedisClusterBuilder effectively does nothing.
What worked for me was to subclass RedisServerBuilder like so:
class CustomClusterRedisServerBuilder extends RedisServerBuilder {
@Override
void reset() {
def confBuilderField = this.class.superclass.declaredFields.find {it.name == 'redisConfigBuilder'}
confBuilderField.setAccessible(true)
def oldConfBuilder = confBuilderField.get(this)
super.reset()
confBuilderField.set(this, oldConfBuilder)
}
}
This is effectively a hack, which only works when you use custom settings, like I did. If you omit resetting entirely, though, you will end up with masters being slaves to other masters (since the configuration object is reused).
and then use it when building a cluster:
RedisCluster.builder()
.sentinelPorts(redisSentinels) //btw, order counts here, if you set ports after setting replication groups
.serverPorts(redisHosts) //you will get different ports. Go figure
.withServerBuilder(new CustomClusterRedisServerBuilder().setting("maxmemory 128").setting("maxheap 128M")) //same goes for settings
.withSentinelBuilder(RedisSentinel.builder().setting("maxmemory 128").setting("maxheap 128M"))
.sentinelCount(3)
.quorumSize(2)
.replicationGroup("master1", 1)
.replicationGroup("master2", 1)
.replicationGroup("master3", 1)
.build()
Hope that helps somebody. Please note - I use this setup for tests, so this code could theoretically have ramifications if used for other purposes.
redisServer.stop()
doesn't stop on OSX