Errors when try to run redis server - ruby-on-rails

I tried to run the command redis server and I get these error messages:
30260:C 06 Mar 19:19:52.861 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
30260:M 06 Mar 19:19:52.862 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
30260:M 06 Mar 19:19:52.862 # Server can't set maximum open files to 10032 because of OS error: Operation not permitted.
30260:M 06 Mar 19:19:52.862 # Current maximum open files is 4096. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
30260:M 06 Mar 19:19:52.862 # Creating Server TCP listening socket *:6379: bind: Address already in use
I already created a user for redis before because I used it in another Rails application and now I'm creating a new project that will also use this tool.
So, when I run ps aux | grep redis
fillype 5274 0.0 0.0 14244 1024 pts/2 S+ 19:36 0:00 grep --color redis
redis 29157 0.0 0.1 40292 11120 ? Ssl 19:16 0:01 /usr/bin/redis-server 127.0.0.1:6379
I know that this question is the same as redis-server in ubuntu14.04: Bind address already in use but their solutions doesn't work to me, that is, to kill the process.

Related

Redis store data in backup.db file

I have RedisDB that exists in a Docker container. Database restored from dump.rdb file and everything works well (I can get all data that stored in Redis before) until Redis tries to save data in the background. Log here:
1:M 28 Jan 2021 11:28:28.035 * 100 changes in 300 seconds. Saving...
1:M 28 Jan 2021 11:28:28.349 * Background saving started by pid 21
21:C 28 Jan 2021 11:30:23.589 * DB saved on disk
21:C 28 Jan 2021 11:30:23.930 * RDB: 0 MB of memory used by copy-on-write
And after that, I see in the folder a new file: backup.db, and all data I get from this file (instead of dump.rdb).
redis.conf:
appendonly yes
appendfilename "appendonly.aof"
dbfilename dump.rdb
dir ./
save 900 1
save 300 10
save 60 10000
Docker run command:
docker run --name redis -p 6379:6379 -v /redis/data:/data -v /redis/config/redis.conf:/usr/local/etc/redis/redis.conf -d redis
dump.rdb file stored into /redis/data folder and redis.conf stored into /redis/config folder
Redis version: 6.0.10
Question: How to avoid creation backup.db file?

How to connect to Docker containers using hostnames from Docker host? [duplicate]

This question already has answers here:
Access docker container from host using containers name
(7 answers)
Closed 3 years ago.
I want to connect to my Docker containers from my Docker host using hostnames.
I already know how to connect to containers by mapping their ports using docker run -p <host-port>:<container-port> ... and then access them through localhost.
Also, I can connect to containers using their IP-addresses given by docker inspect <container>. But these IP-adresses are not static.
How can I give containers hostnames, so that I can connect to them through exposed ports without having to think about non-static IPs?
Use docker-compose and make services in them. Each container will be a part of a Service and one container can talk to other container using the service name the container belongs to.
Ex:
$ cat docker-compose.yml
version: '3.1'
services:
server:
image: redis
command: [ "redis-server" ]
client:
image: redis
command: [ "redis-cli", "-h", "server", "ping" ]
links:
- server
$
$
$ docker-compose up
Starting server_1 ... done
Starting client_1 ... done
Attaching to server_1, client_1
client_1 | PONG
server_1 | 1:C 10 Dec 2019 12:59:20.161 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
server_1 | 1:C 10 Dec 2019 12:59:20.161 # Redis version=5.0.6, bits=64, commit=00000000, modified=0, pid=1, just started
server_1 | 1:C 10 Dec 2019 12:59:20.161 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
server_1 | 1:M 10 Dec 2019 12:59:20.162 * Running mode=standalone, port=6379.
server_1 | 1:M 10 Dec 2019 12:59:20.162 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
server_1 | 1:M 10 Dec 2019 12:59:20.162 # Server initialized
server_1 | 1:M 10 Dec 2019 12:59:20.162 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
server_1 | 1:M 10 Dec 2019 12:59:20.162 * Ready to accept connections
client_1 exited with code 0
Here, I created two services, server and client. server starts a redis-server and client tries to connect to the server. Also, note that I haven't exposed ports here, so the client container is talking to the server container using server (service-name)
client:
image: redis
command: [ "redis-cli", "-h", "server", "ping" ]

Redis is shutting down for no reason in docker container

I am trying to launch a redis docker container using docker-compose, but I always get this error. This is my docker-compose run commands docker-compose -f docker-compose.yml build and docker-compose -f docker-compose.yml up -d --force-recreate. I am running the docker containers on aws ecs and using a t2.micro ec2 instance. I am not sure if that is the reason why. Any insight would be helpful.
I have also included my docker-compose.yml
version: '2.1'
services:
redis:
image: redis:latest
container_name: redis
volumes:
- redis_data:/data
ports:
- 6379:6379
app:
image: custom_image
build: .
depends_on:
redis:
condition: service_started
ports:
- 8003:8003
links:
- redis
volumes:
redis_data:
Error
1:C 11 Sep 00:18:34.345 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1:C 11 Sep 00:18:34.348 # Redis version=4.0.11, bits=64, commit=00000000, modified=0, pid=1, just started
1:C 11 Sep 00:18:34.348 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
1:M 11 Sep 00:18:34.349 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
1:M 11 Sep 00:18:34.349 # Server can't set maximum open files to 10032 because of OS error: Operation not permitted.
1:M 11 Sep 00:18:34.349 # Current maximum open files is 4096. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
1:M 11 Sep 00:18:34.350 * Running mode=standalone, port=6379.
1:M 11 Sep 00:18:34.350 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
1:M 11 Sep 00:18:34.350 # Server initialized
1:M 11 Sep 00:18:34.350 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
1:M 11 Sep 00:18:34.350 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
1:M 11 Sep 00:18:34.350 * Ready to accept connections
1:signal-handler (1536625117) Received SIGTERM scheduling shutdown...
1:M 11 Sep 00:18:37.375 # User requested shutdown...
1:M 11 Sep 00:18:37.375 * Saving the final RDB snapshot before exiting.
1:M 11 Sep 00:18:37.378 * DB saved on disk
1:M 11 Sep 00:18:37.378 # Redis is now ready to exit, bye bye...
Ran into the same issues. After a bit of digging we found that it was killed by systemd due to inactive.
Run systemctl show docker.service command show that the inactive and active enter timestamp match up with when the redis service stop and start again.
InactiveEnterTimestamp=Tue 2021-08-03 22:07:19 AEST
ActiveEnterTimestamp=Wed 2021-08-04 09:30:36 AEST
Our solution is just to perform some activity on redis so that it doesn't enter inactive state.

Issue with Sidekiq rails

I am trying to to run this below command for Sidekiq.
bundle exec sidekiq
I am getting below error and Can't able to run jobs with sidekiq.
$ bundle exec sidekiq
Note: Google::Cloud::Logging is disabled because it failed to authorize with the service. (Unable to read the credential file specified by GOOGLE_APPLICATION_CREDENTIALS: file /home/app/config/secrets/pubsub-credentials.json does not exist) Falling back to the default Rails logger.
INFO: Booting Sidekiq 5.1.1 with redis options {:url=>"redis://redis:6379/0", :role=>:master, :password=>"REDACTED", :id=>"Sidekiq-server-PID-10968"}
m,
`$b
.ss, $$: .,d$
`$$P,d$P' .,md$P"'
,$$$$$bmmd$$$P^'
.d$$$$$$$$$$P'
$$^' `"^$$$' ____ _ _ _ _
$: ,$$: / ___|(_) __| | ___| | _(_) __ _
`b :$$ \___ \| |/ _` |/ _ \ |/ / |/ _` |
$$: ___) | | (_| | __/ <| | (_| |
$$ |____/|_|\__,_|\___|_|\_\_|\__, |
.d$$ |_|
INFO: Running in ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux]
INFO: See LICENSE and the LGPL-3.0 for licensing details.
INFO: Upgrade to Sidekiq Pro for more features and support: http://sidekiq.org
getaddrinfo: Name or service not known
/vendor/cache/ruby/2.4.0/gems/redis-4.0.1/lib/redis/connection/ruby.rb:210:in `getaddrinfo'
I also checked redis
$redis-cli ping
PONG
$ redis-server
1991:C 07 Sep 17:11:54.900 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1991:C 07 Sep 17:11:54.901 # Redis version=4.0.9, bits=64, commit=00000000, modified=0, pid=1991, just started
1991:C 07 Sep 17:11:54.901 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
1991:M 07 Sep 17:11:54.901 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
1991:M 07 Sep 17:11:54.901 # Server can't set maximum open files to 10032 because of OS error: Operation not permitted.
1991:M 07 Sep 17:11:54.901 # Current maximum open files is 4096. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
1991:M 07 Sep 17:11:54.901 # Creating Server TCP listening socket *:6379: bind: Address already in use
Help me to solve it. Thanks in advance.
To run sidekiq you need a redis server:
Redis provides data storage for Sidekiq. It holds all the job data along with runtime and historical data to power Sidekiq's Web UI.
From the documentation:
https://github.com/mperham/sidekiq/wiki/The-Basics#redis
https://github.com/mperham/sidekiq/wiki/Using-Redis
If your redis server runs anywhere else than localhost:6379, you can configure the URL.
To setup a local redis server, you can install it with homebrew:
brew install redis
redis-server # will run the server on `localhost:6379`
Then in a second shell window, try to launch sidekiq:
bundle exec sidekiq
You set sidekiq to use redis at redis://redis:6379/0, but that's not a valid url on your system. In particular, host redis can't be resolved to an IP address.

PostgreSQL wrong ownership

I'll preface this with the fact that I haven't used PostgreSQL much. I tried using it with RoR but the fact that it uses an ORM, I never got why PostgreSQL was the flavor of choice.
After fighting with getting the damn thing installed on Ubuntu 14.04, I need to clone a repo that depends on it.
After about 30 minutes of dealing trying a few things, I discovered:
$ /usr/lib/postgresql/9.4/bin/postgres -d 3 -D /var/lib/postgresql/9.4/main -c config_file=/etc/postgresql/9.4/main/postgresql.conf
LOG: skipping missing configuration file "/var/lib/postgresql/9.4/main/postgresql.auto.conf"
2015-02-14 21:05:01 PST [7665-2] FATAL: data directory "/var/lib/postgresql/9.4/main" has wrong ownership
2015-02-14 21:05:01 PST [7665-3] HINT: The server must be started by the user that owns the data directory.
2015-02-14 21:05:01 PST [7665-4] DEBUG: shmem_exit(1): 0 before_shmem_exit callbacks to make
2015-02-14 21:05:01 PST [7665-5] DEBUG: shmem_exit(1): 0 on_shmem_exit callbacks to make
2015-02-14 21:05:01 PST [7665-6] DEBUG: proc_exit(1): 0 callbacks to make
2015-02-14 21:05:01 PST [7665-7] DEBUG: exit(1)
One, I don't know what this auto.conf file it's looking for as I'm specifying the conf file.
However... (edited to what I think are the appropriate line[s])
$ sudo gedit /etc/postgresql/9.4/main/pg_hba.conf
local all postgres 127.0.0.1 peer
(I added in the local IP after nothing working. Still doesn't work.)
And (/etc/postgresql/9.4/main/)
-rw-r--r-- 1 postgres postgres 315 Feb 14 20:20 environment
-rw-r--r-- 1 postgres postgres 143 Feb 14 20:20 pg_ctl.conf
-rw-r----- 1 postgres postgres 4641 Feb 14 20:55 pg_hba.conf
-rw-r----- 1 postgres postgres 4641 Feb 14 20:20 pg_hba.conf~
-rw-r----- 1 postgres postgres 1636 Feb 14 20:20 pg_ident.conf
-rw-r--r-- 1 postgres postgres 21461 Feb 14 20:20 postgresql.conf
-rw-r--r-- 1 postgres postgres 378 Feb 14 20:20 start.conf
Seems to me the configuration files are owned by postgres. What gives?
Update (9:30p)
Running the following command (as postgres) gives the same result.
$ su - postgres; /usr/lib/postgresql/9.4/bin/postgres -d 3 -D /var/lib/postgresql/9.4/main -c config_file=/etc/postgresql/9.4/main/postgresql.conf
Judging from the error message, ownership for the data directory seems to be misconfigured. If so, fix with (as privileged system user):
chown postgres:postgres /var/lib/postgresql/9.4
chown postgres:postgres /var/lib/postgresql/9.4/main
Use the "recursive" option -R if anything inside those directories is owned by different users.

Resources