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
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