When executing an eval script from a remote location.
How can we log so we can evaluate what is happening?
local name = KEYS[1]
local key = KEYS[2]
local desired = ARGV[1]
local expecting = ARGV[2]
local expires = ARGV[3]
local channel = ARGV[4]
local message = ARGV[5]
redis.log(...) ?
And where does such logs go? How can they be viewed?
If you configured logfile in redis.conf, the logs will go to that file. If logfile is empty string, i.e. the default value, and redis-server is not daemonized, the logs will be printed to standard output. If it's empty, and redis-server is daemonized, logs go to /dev/null.
Related
I have redis db in stage whose data I want to copy in dev server. I tried copying data using SLAVEOF command as well as SAVE command.
Both stage and dev are clustered redis servers.
Both commands are giving errors:
SLAVEOF:
# running in dev server
host-dev.redis.db:6379> SLAVEOF host-stage.redis.db 6379
(error) ERR unknown command `SLAVEOF`, with args beginning with: `host-dev.redis.db`, `6379`,
SAVE
# running in stage server
host-stage.redis.db:6379> SAVE
(error) ERR unknown command `SAVE`, with args beginning with:
Am I missing something with these commands in the case of clustered redis servers? Or these errors are due to some missing config?
I just updated to Icing 2.8 which needs "the new" way of checking remote hosts, so I'm trying to get that to work.
On the master I added a folder in zones.d with the hostname of the remote host. I added a few checks but they all seem to be executed from the master instead of the remote.
For example: I need to monitor Redis. My redis.conf in /etc/icinga2/zones.d/remotehostname/redis.conf:
apply Service "Redis" {
import "generic-service"
check_command = "Redis"
vars.notification["pushover"] = {
groups = [ "ADMINS" ]
}
assign where host.name == "remotehostname"
}
A new service pops up in IcingaWeb but it errors out with:
execvpe(/usr/lib/nagios/nagios-plugins/check_redis_publish_subscribe.pl) failed: No such file or directory
Which is correct because on the master that file does not exist. It does exist on the remote host however.
How do I get Icinga to execute this on the remote host and have that host return the output to the master?
You can write this to the service:
command_endpoint = host.name
Or you can try to create a zone and add the zone to the Host.
Maybe this could help you:
NetWays Blog
I would like to use EXPECT script for mount volume after reboot tens of our UBUNTU servers (12.04 & 14.04).
I am not able to figure out how set hostname like variable (for example to grab record from /etc/hostname ) -> I dont wanna create one script (set specific hostname) for each server. My idea is use this script global for my environment.
Following script works fine - but there is set fix hostname
#!/usr/bin/expect -f
set timeout 90
set sudo_pass "Password01
set mount_pass "Password02"
set hostname "test-staging" <<<==== here I set static hostname
# turns off the output to STDOUT
log_user 0
# run mount-script
spawn sudo mount-script
# type sudo pass
expect "password for"
send "$sudo_pass\r"
# type Pass for mount-script
expect "Enter passphrase"
send "$mount_pass\r"
# call & paste hostname
expect "Please provide a hostname for this instance,"
send "$hostname\r"
# type letter Y - for test environment
expect "Is this a test instance? Enter 'Y', otherwise press enter"
send "Y\r"
interact
I tried to google it I found commands for hostname like
send 'lsnrctl status listener_`hostname`\r'
or
send "cat /etc/rc.d/rc.local |grep hostname \r\n"
I tried set them like SET HOSTNAME and I tried call them via command send. Unfortunately, it doesn't work, too.
this is output
.......
dbg1.7>
1: expect "Please provide a hostname for this instance
dbg1.8>
Please provide a hostname for this instance
1: send 'lsnrctl status listener_`hostname`\r'
dbg1.9>
usage: send [args] string
while executing
"send 'lsnrctl status listener_`hostname`\r'"
(file "test01-expect.sh" line 38)
1: exit 1
I am open mind for different solution, too.
thank you
To get the host name of machine, can't you use the terminal command hostname ?
Tcl has a command exec which will execute the command and will return the result.
set host_name [exec hostname]
or, equivalently,
set host_name [ exec cat /etc/hostname]
Instead of saving it into a variable, this can be directly even used in the send command as,
expect "Please provide a hostname for this instance,"
send "[exec hostname]\r"
Reference : exec
I get the following error, whenever I execute any commands that modify data in redis
Redis is configured to save RDB snapshots, but is currently not able to persist on disk.
Commands that may modify the data set are disabled.
Please check Redis logs for details about the error.
I installed redis using brew on mac. How can I get the location of log files where redis-server logs information to. I tried looking for redis conf. file, but couldn't find it either.
What is the default location of [1] redis conf file [2] redis log file.
How do I get rid of the above error, and be able to execute commands that modify data in redis.
When installing with brew the logfile is set to stdout. You need to edit /usr/local/etc/redis.conf and change logfile to something else. I set mine to:
logfile /var/log/redis-server.log
You'll also make sure the user that runs redis has write permissions to the logfile, or redis will simply fail to launch completely. Then just restart redis:
brew services restart redis
After restarting it'll take a while for the error to show up in the logs, because it happens after redis fails its timed flushes. You should be seeing something like:
[7051] 29 Dec 02:37:47.164 # Background saving error
[7051] 29 Dec 02:37:53.009 * 10 changes in 300 seconds. Saving...
[7051] 29 Dec 02:37:53.010 * Background saving started by pid 7274
[7274] 29 Dec 02:37:53.010 # Failed opening .rdb for saving: Permission denied
After a brew install it attempts to save to /usr/local/var/db/redis/ and since redis is probably running as your current user and not root, it can't write to it. Once redis has permission to write to the directory, your logfile will say:
[7051] 29 Dec 03:08:59.098 * 1 changes in 900 seconds. Saving...
[7051] 29 Dec 03:08:59.098 * Background saving started by pid 8833
[8833] 29 Dec 03:08:59.099 * DB saved on disk
[7051] 29 Dec 03:08:59.200 * Background saving terminated with success
and the stop-writes-on-bgsave-error error will no longer get raised.
So I guess it is a bit late for adding an answer here but since I wondered on your question as I had the same error. I got it solved by changing my redis.conf 's dir variable like this:
# The filename where to dump the DB
dbfilename dump.rdb
# The working directory.
#
# The DB will be written inside this directory, with the filename specified
# above using the 'dbfilename' configuration directive.
#
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
dir /root/path/to/dir/with/write/access/
The default value is: ./, so depending on how you launch your redis server you might not be able to save snapshots.
Hope it helps someone !
In my case i resolved this issue with below steps
Cause : By default redis store data # ./ and if redis runs with redis user this means redis will not be able to write data in ./ file then you will face above error.
Resolution :
Step # 1 (Enter a valid location where redis can do write operations)
root#fpe:/var/lib/redis# vim /etc/redis/redis.conf
dir /var/lib/redis # ( This location must have right for redis user to write)
Step # 2 (Connect to redis cli and map directory to write and issue below variable)
127.0.0.1:6379> CONFIG SET dir "/var/lib/redis"
127.0.0.1:6379> BGSAVE -
This will enable redis to write data on dump file.
Was going through the github discussion and the proposed solution is
to run
config set stop-writes-on-bgsave-error no
in the redis-cli.
here's the link
https://github.com/redis/redis/issues/584#issuecomment-11416418
Steps to fix this error:
Go to redis cli by typing redis-cli
127.0.0.1:6379> config set stop-writes-on-bgsave-error no
after that try to set key value
127.0.0.1:6379> set test_key 'Test Value'
127.0.0.1:6379> get test_key
"Test Value"
Check the following places:
/usr/local/Cellar/redis...
/usr/local/var/log/redis.log
/usr/local/etc/redis.conf
This error often indicates an issue with write permissions, make sure you're RDB directory is writable.
It is usually because permission limits. In my case, it's redis disabled write options.
You can try to run redis-cli in the shell, and then run the following command:
set stop-writes-on-bgsave-error yes
I have a server ServerA ( user1 as userid) .I want to connect to same server ServerA with userid as user2 and then do scp to get files from other server and keep in ServerA server(userid as user2).
Could anyone please help me out asap.
Wouldn't it be easier to do the scp as user1, then chown the files to user2? If you need to store them in a place accessible only to user2 you could su to user2 and move them.
Say you're on hostC (client) and you want to copy files from userX#hostA to userY#hostB.
You can issue an scp command on hostC:
scp userX#hostA:file-to-copy userY#hostB:destination-folder/
However, you need to authenticate. If you have an ssh key set up for userX#hostA key authentication will work fine.
However scp will invoke ssh with options to either disable agent forwarding or clear forwarding keys, so that even if you have a key for userY#hostB it won't be available to hostB and you'll be prompted for a password.
One solution to this is to pass a -S <ssh-command> to the invocation of scp on hostC with a wrapper script to strip out the options that prevent agent forwarding, perhaps having to explicitly enable it.
e.g.
ssh-wrapper.py
#!/usr/bin/python
import sys, os
def is_exe(fpath):
return os.path.exists(fpath) and os.access(fpath, os.X_OK)
def which(program):
fpath, fname = os.path.split(program)
if fpath:
if is_exe(program):
return program
else:
for path in os.environ["PATH"].split(os.pathsep):
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file
return None
if __name__ == '__main__':
ssh = which('ssh')
assert ssh is not None
args = [ssh] + sys.argv[1:]
for x in ('-a','-oClearAllForwardings yes'):
if x in args:
args.remove(x)
if '-oForwardAgent yes' not in args:
args.insert(1,'-oForwardAgent yes')
os.execl(ssh,*args)
Invoking scp:
scp -S ssh-wrapper.py userX#hostA:file-to-copy userY#hostB:destination-folder/