ERR unknown command '--cluster' when rebalancing slots - redis-cluster

I have created a RedisClient using go-redis
rdClient := rd.NewClusterClient(rdClusterOpts)
I can do other database operation using the client
out,err := rdClient.Ping(context.TODO()).Result()
PONG
I can also do get set operation using the client.
When I try to rebalance the slots, it shows an error.
out, err := rdClient.Do(context.TODO(), "--cluster", "rebalance", "10.244.0.98", "--cluster-use-empty-masters").Result()
It shows the Error
ERR unknown command '--cluster', with args beginning with: 'rebalance' '10.244.0.96:6379' '--cluster-use-empty-masters
Is there any way to perform the Redis Cluster Manager commands using go-redis or any other go redis client ?

Related

Send transaction on local avalanche node using geth

I've spun up a local avalanche network using the avalanche network runner and I've successfully connected to it using geth:
❮❮❮ geth attach ws://127.0.0.1:35260/ext/bc/C/ws
Welcome to the Geth JavaScript console!
instance: v0.8.4-rc.3
coinbase: 0x0100000000000000000000000000000000000000
at block: 0 (Wed Dec 31 1969 18:00:00 GMT-0600 (CST))
modules: eth:1.0 net:1.0 rpc:1.0 web3:1.0
To exit, press ctrl-d or type exit
I'm trying to send a transaction from one account to another. I've found that this avalanche network pre-seeds account 0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC with some ETH based on this comment and confirmed it using geth:
> eth.getBalance("0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52Fc")
5e+25
However, when I try to send a transaction from this account, it fails:
> eth.getBalance("0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52Fc")
5e+25
> eth.sendTransaction({from:"0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC", to:"0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FD", value: web3.toWei(0.05, "ether")})
Error: unknown account
at web3.js:6365:37(47)
at send (web3.js:5099:62(35))
at <eval>:1:20(15)
I suspect it's because I don't have the account in the list of accounts:
> eth.accounts
[]
I've tried to import the account using geth account import <path to keyfile> but that did not result in eth.accounts having an entry.
I've also tried to use the personal.importRawKey function, but that doesn't work either:
> personal.importRawKey("56289e99c94b6912bfc12adc093c9b51124f0dc54ac7a766b2bc5ccf558d8027", "lol")
Error: the method personal_importRawKey does not exist/is not available
at web3.js:6365:37(47)
at send (web3.js:5099:62(35))
at <eval>:1:22(5)
> personal
{
listAccounts: undefined,
ecRecover: function(),
getListAccounts: function(callback),
importRawKey: function(),
lockAccount: function(),
newAccount: function github.com/ethereum/go-ethereum/internal/jsre.MakeCallback.func1(),
openWallet: function github.com/ethereum/go-ethereum/internal/jsre.MakeCallback.func1(),
sendTransaction: function(),
sign: function github.com/ethereum/go-ethereum/internal/jsre.MakeCallback.func1(),
unlockAccount: function github.com/ethereum/go-ethereum/internal/jsre.MakeCallback.func1()
}
Do I need to import this account? If so, how?
How do I send a transaction using geth on a local avalanche network using the default funded address by the avalanche network runner?
Turns out I was on the right track with importing the private key but I had to enable the personal namespace in the avalanche node.
The personal namespace can be enabled by adding internal-private-personal to the C Chain config being used by the node.
Once this namespace is enabled, you can connect to your node with geth and issue
> personal.importRawKey("56289e99c94b6912bfc12adc093c9b51124f0dc54ac7a766b2bc5ccf558d8027", "lol")
"0x8db97c7cece249c2b98bdc0226cc4c2a57bf52fc"
> personal.unlockAccount("0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC", "lol", 300)
which then enables the account for spending.

lua setting an expiration time using the redis command with 'setex' appears as a permanent key in openresty

setting an expiration time using the redis command appears as a permanent key when i do this in openresty with lua script.
the lua script is follow this:
local function ip_frequency(ip,red)
local limit_num=50
local key = "limit:frequency:"..ip
local resp, err = red:get(key)
if resp==nil then
local ok,err=red:setex(key,2,1)
if not ok then
return false;
end
end
if type(resp) == "string" then
if tonumber(resp) > limit_num then
return false
end
end
ok, err = red:incr(key)
if not ok then
return false
end
return true
end
When the openresty program has run for some time,some permanent keys appear in redis.From this function it can be seen that I did not set a key for the permanent time,but it just happens. Why is that,please help me answer this question. Thank you!
The software version is as follows:
openresty: 1.17.8.2
redis: 6.0+
centos: 8.0+
Openresty connects to redis database and uses it's functionality. Such usage of redis functions in lua or other language is not atomic. For redis server it means: [redis:get, pause, redis:setex] or [redis:get, pause, redis:incr]. During pause period can happen a lot of things, event if there is only 1ms, such as cleanup of 'dead' keys.
And this what could happen with your code:
local resp, err = red:get(key)
You get valid key value which is smaller than limit_num
ok, err = red:incr(key)
Redis checks if key is valid, and removes it if reaches ttl
Redis checks that there is no such key, so creates key with value=0 and increments key value
So at this point you have permanent key. If you want to avoid permanent keys, use something like: red:setex(key,2,tonumber(res)+1) istead of red:incr(key)

Aerospike - command execution timed out on client

Using the following code to load data in Aerospike. data is a list of maps of type BinMap
for _, binMap := range data {
id, ok := binMap["id"].(string)
key, _ := as.NewKey("test", "myset", id)
err := shared.Client.Put(nil, key, binMap)
if err !=nil {
fmt.Println(err)
}
After loading few records, the following error message is received.
command execution timed out on client: Exceeded number of retries.
See `Policy.MaxRetries`. (last error: Node not found for partition
test:711 in partition table.)
For each iteration, the partition test number changes.
The error continues even after waiting for 5 seconds after each Put command. I am not sure what timeout is reported in the error message.What client configuration is required for go client?
Using MacOs 10.15.3; go client; Aerospike running on docker 2.2.0.3
There's a good chance your cluster hasn't formed correctly, or that its networking isn't properly set up to give clients access to all the nodes. Since you're using Docker, take a look at Lucien's Medium post How do I get a 2 nodes Aerospike cluster running quickly in Docker without editing a single file?.

go/golang + redis too many open files error

I'm using redis in Golang with the Redigo connector (https://github.com/garyburd/redigo) suggested by the Redis website.
I have:
After every Dial() I defer a Close()
Set fs.file-max = 100000
Set vm.overcommit_memory = 1
Disabled saving
Set maxclients = 100000
I run a high traffic website, and everything runs great for about 10 minutes, from which I get
error: dial tcp 127.0.0.1:6379: too many open files
Then I can't access redis at all from my application.
I see nothing in the redis logs to suggest any errors or problems. What do I do to fix this?
I don't know which driver you use but with redigo you can define a number of open connections in a pool, all you have to do then is in every query to redis, first get a client from the pool, then close it, so it goes back to the pool and gets re-used, just like this:
redisPool = &redis.Pool{
MaxIdle: 3,
MaxActive: 10, // max number of connections
Dial: func() (redis.Conn, error) {
c, err := redis.Dial("tcp", ":6379")
if err != nil {
panic(err.Error())
}
return c, err
},
}
r := redisPool.Get() // get a client from the pool
_, err = r.Do("GET one") // use the client
if err != nil {
panic(err.Error())
}
r.Close() // close the client so the connection gets reused
Your problem is that Redis cant open new connections and then becomes unresponsive, you need to increase the file descriptors limit of your operating system (ubuntu defaults to 1024 which can be a problem) which right now is dominating the redis maxclients setting.
The way you tweak this limit depends on the os redis is running, on linux you need something like this:
ulimit -n 99999

Redis SET command can't fail, but can?

I'm trying to debug some Redis issues I am experiencing and came by some inconclusive documentation about the SET command.
In my Redis config; I have the following lines (snippet):
# Note: with all the kind of policies, Redis will return an error on write
# operations, when there are not suitable keys for eviction.
#
# At the date of writing this commands are: set setnx setex append
On the documentation page for the SET command I found:
Status code reply: always OK since SET can't fail.
Any insights on the definitive behaviour?
tl;dr: SET will return an error response if the redis instance runs out of memory.
As far as I can tell from the source code in redis.c, esentially when a command is to be processed the flow goes like this (pseudo code):
IF memory is needed
IF we can free keys
Free keys
Process the command
SET -> process and return OK response
ELSE return error response
ELSE
Process command
SET -> process and return OK response
It's not exactly written this way, but the basic idea comes down to that: memory is being checked before the command is processed, so even if the command cannot fail, an error response will be returned if there's no memory regardless the actual response of the command.