一 配置(可能用到)
- 将 Linux 内核超量使用内存设置设置为1,修改/etc/sysctl.conf,添加
vm.overcommit_memory = 1
。然后重启或使用命令sysctl vm.overcommit_memory=1
使之生效。 - 关闭Linux特性Transparent Huge Pages:
echo never > /sys/kernel/mm/transparent_hugepage/enabled
二 Redis简单安装
1.下载
wget https://download.redis.io/redis-stable.tar.gz
2.编译
tar -xzvf redis-stable.tar.gz
cd redis-stable
make
以下为拓展命令
编译支持TLS
make BUILD_TLS=yes
编译支持systemd,需要安装systemd开发环境库,Debian/Ubuntu :libsystemd-dev,CentOS :systemd-devel
make USE_SYSTEMD=yes
追加后缀
make PROG_SUFFIX="-alt"
编译32位
make 32bit
32位编译报错,安装libc6-dev-i386 或 g+±multilib,清理编译文件后
make CFLAGS="-m32 -march=native" LDFLAGS="-m32"
对编译文件清理
make distclean
空间配置器(Allocator)
Linux默认使用jemalloc,比libc malloc内存碎片化问题小。
To force compiling against libc malloc, use:
make MALLOC=libc
To compile against jemalloc on Mac OS X systems:
make MALLOC=jemalloc
3.安装
默认安装至 /usr/local/bin
make install
指定安装路径:
make PREFIX=/some/other/directory install
使用install_server.sh
安装,交互式问答,通过/etc/init.d/redis_<portnumber>
启动关闭
cd utils
./install_server.sh
如果报错:
This systems seems to use systemd.
Please take a look at the provided example service unit files in this directory, and adapt and install them. Sorry!
注释相关代码即可
#bail if this system is managed by systemd
#_pid_1_exe="$(readlink -f /proc/1/exe)"
#if [ "${_pid_1_exe##*/}" = systemd ]
#then
# echo "This systems seems to use systemd."
# echo "Please take a look at the provided example service unit files in this directory, and adapt and install them. Sorry!"
# exit 1
#fi
#unset _pid_1_exe
通过上述操作,会生成一个/etc/init.d/redis_6379
,可能需要对相关的配置文件和该命令进行修改。
4.布隆过滤器安装
https://blog.youkuaiyun.com/u013271384/article/details/129480958
5.Cluster集群模式
https://blog.youkuaiyun.com/u013271384/article/details/130465559