Friday, May 27, 2016

add insecure-registry flag in docker for Mac client


  1. get current setting by command pinata get daemon > daemon.json.
  2. add key value pair insecure-registry:<ip/domain:port> or inecure-registries:[<ip/domain:prot>,<ip/domain:prot>]
  3. write new setting back pinata set daemon @daemon.json
  4. restart the client pinata restart

Tuesday, April 26, 2016

Save large amount of data in Redis

  1. make sure the Redis work directory is in a partition own free space larger than memory

  2. to avoid BGSAVE fail with a fork() error even with a lot of availbe memory

    • run echo 1 > /proc/sys/vm/overcommit_memory as temporary solution.
    • add vm.overcommit_memory=1 to /etc/sysctl.conf and reboot as a long term solution
  3. keep writing when BGSAVE error
    in /etc/redis.conf, add or modify stop-writes-on-bgsave-error no

  4. disable Transparent Huge Pages(THP)
    This will create latency and memory usage issue with redis.
    Run the following command, and add it to /etc/rc.local to retain the setting after reboot

    sudo echo never > /sys/kernel/mm/transparent_hugepage/enabled
  5. enlarge TCP backlog setting
    Run the following command, and add it to /etc/rc.local to retain the setting after reboot

    sysctl -w net.core.somaxconn=65535

Monday, April 25, 2016

Run multiple Redis instances on CentOS7

Install 1st Redis instance

By installing the first Redis instance, you can use the configuration as template for your 2nd one.

yum install redis
service redis start

This redis instance listens on localhost:6379 by default.

Install 2nd Redis instance

create a new working directory

The default redis instance uses /var/lib/redis as its working directory, dumped memory content is saved under this directory with name dump.rdb if you did not change it manually.

to avoid runtime conflict, we need to create a new working directory

mkdir -p /var/lib/redis2/
chown redis /var/lib/redis2/
chgrp redis /var/lib/redis2/

generate configurations

Create a new configuration file by copying /etc/redis.conf

cp /etc/redis.conf /etc/redis2.conf

Edit following settings to avoid conflicts

logfile "/var/log/redis/redis2.log"
dir "/var/lib/redis2"
pidfile "/var/run/redis/"
port 6380

add startup script

Create service file

cp /usr/lib/systemd/system/redis.service /usr/lib/systemd/system/redis2.service

Modify the settings under Service section

ExecStart=/usr/bin/redis-server /etc/redis2.conf --daemonize no
ExecStop=/usr/bin/redis-shutdown redis2

set to start with boot

systemctl enable redis2

start 2nd redis

service redis2 start

check status

lsof -i:6379
lsof -i:6380