How To Configure a Redis Cluster on CentOS 7

yum install gcc make
cd ~
mkdir init
wget http://download.redis.io/releases/redis-3.2.3.tar.gz
tar -zxvf redis-3.2.3.tar.gz 
cd redis-3.2.3
make 
make install

#cd utils
#./install_server.sh

cd src/
cp redis-server redis-cli /usr/local/bin
cp redis-sentinel redis-benchmark redis-check-aof redis-check-dump /usr/local/bin

mkdir /etc/redis
mkdir -p /var/lib/redis/6379

Set the vm.overcommit_memory to 1, which means always, this will avoid data to be truncated, take a look here for more.

sysctl -w vm.overcommit_memory=1

Change the maximum of backlog connections some value higher than the value on tcp-backlog option of redis.conf, which defaults to 511. You can find more on sysctl based ip networking “tunning” on kernel.org website.

sysctl -w net.core.somaxconn=512

Disable transparent huge pages support, that is known to cause latency and memory access issues with Redis.

echo never > /sys/kernel/mm/transparent_hugepage/enabled

Redis.conf is the Redis configuration file, however you will see the file named as 6379.conf here, where the number is the same as the network port is listening to. This name is recommended if you are going to run more than one Redis instance.

cp redis.conf /etc/redis/6379.conf
vim /etc/redis/6379.conf

daemonize yes #note
pidfile /var/run/redis_6379.pid
port 6379
loglevel notice
logfile /var/log/redis_6379.log
dir /var/lib/redis/6379

Starting at boot

cp utils/redis_init_script /etc/init.d/redis_6379
vim /etc/systemd/system/redis_6379.service

[Unit]
Description=Redis on port 6379

[Service]
Type=forking
ExecStart=/etc/init.d/redis_6379 start
ExecStop=/etc/init.d/redis_6379 stop

[Install]
WantedBy=multi-user.target

vim /etc/sysctl.conf

vm.overcommit_memory = 1
net.core.somaxconn=512

For the transparent huge pages support there is no sysctl directive, so you can put the command at the end of /etc/rc.local

echo never > /sys/kernel/mm/transparent_hugepage/enabled

以上内容

Configure Redis Master

vi /etc/redis.conf

daemonize yes #note
tcp-keepalive 60
#bind 127.0.0.1
requirepass your_redis_master_password
maxmemory-policy noeviction
appendonly yes
appendfilename "appendonly.aof"

restart if makeinstall
redis-server /etc/redis/6379.conf

Configure Redis Slave

daemonize yes #note
#bind 127.0.0.1
requirepass your_redis_slave_password
slaveof your_redis_master_ip 6379
masterauth your_redis_master_password

redis-cli -h 127.0.0.1 -p 6379
AUTH your_redis_slave_password
INFO
以上内容

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值