redis单机模式部署

1 Redis setup tips

Linux
Deploy Redis using the Linux operating system. Redis is also tested on OS X, and from time to time on FreeBSD and OpenBSD systuser. However, Linux is where most of the stress testing is performed, and where most production deployments are run.

Set the Linux kernel overcommit memory setting to 1. Add vm.overcommit_memory = 1 to /etc/sysctl.conf. Then, reboot or run the command sysctl vm.overcommit_memory=1 to activate the setting.

To ensure the Linux kernel feature Transparent Huge Pages does not impact Redis memory usage and latency, use this command:

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

2 安装依赖

--root用户执行
yum -y install gcc gcc-c++ tcl python3

3 稳定版本

redis-7.2.3.tar.gz

4 编译安装redis

--root用户执行
cd /home/user/redis/redis-7.2.3
make test 执行成功参考注释
/*  6 seconds - unit/cluster/human-announced-nodename
  17 seconds - unit/cluster/cli
  28 seconds - unit/obuf-limits
  62 seconds - unit/aofrw
  16 seconds - unit/cluster/links
  29 seconds - unit/wait
  34 seconds - unit/geo
  49 seconds - integration/psync2
  56 seconds - unit/maxmemory
  57 seconds - unit/hyperloglog
  164 seconds - integration/replication-psync
  177 seconds - integration/replication
  0 seconds - list-large-memory
  0 seconds - set-large-memory
  0 seconds - bitops-large-memory
  167 seconds - defrag
  1 seconds - violations

\o/ All tests passed without errors!

Cleanup: may take some time... OK

make[1]: 离开目录“/home/user/redis/redis-7.2.3/src”
*/
--通过root执行make install
cd /home/user/redis/redis-7.2.3
make install
/*
[root@user redis-7.2.3]# pwd
/home/user/redis/redis-7.2.3
[root@user redis-7.2.3]# make install
cd src && make install
make[1]: 进入目录“/home/user/redis/redis-7.2.3/src”

Hint: It's a good idea to run 'make test' ;)

    INSTALL redis-server
    INSTALL redis-benchmark
    INSTALL redis-cli
make[1]: 离开目录“/home/user/redis/redis-7.2.3/src”
*/

5 环境变量

--root用户配置
vim ~/.bash_profile
export REDIS_HOME=/home/user/redis/redis-7.2.3
export PATH=$PATH:$REDIS_HOME/src
--当前终端生效
source ~/.bash_profile

6 redis配置

--root用户配置
port 16379
daemonize yes
logfile "/home/user/redis/logs/redis-server.log"
dir "/home/user/redis/data/"
bind 0.0.0.0 -::1
protected-mode no
requirepass 123456
--user用户创建文件夹
cd /home/user/redis
mkdir data
mkdir logs

7 启动redis

--root用户配置
cd /home/user/redis/redis-7.2.3
redis-server redis.conf
/*
[root@user redis-7.2.3]# cd /home/user/redis/redis-7.2.3
[root@user redis-7.2.3]# redis-server redis.conf
[root@user redis-7.2.3]# ps -ef|grep redis
root      685025       1  0 11:07 ?        00:00:00 redis-server 0.0.0.0:16379
root      685031  659576  0 11:07 pts/0    00:00:00 grep redis
*/

8 reids登录

redis-cli -a "123456" -p 16379
[root@node1 redis-7.2.3]# redis-cli -a "123456" -p 16379
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:16379> ping
PONG

9 开机启动

vim /etc/rc.local
/home/user/redis/redis-7.2.3/src/redis-server /home/user/redis/redis-7.2.3/redis.conf
chmod +x /etc/rc.d/rc.local

10 查看配置

cat redis.conf |grep -v "#"|grep -v "^$"
  • 7
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值