- 依赖环境检查
- 系统内核参数调整
- 安装包下载
- 编译redis
- 运行
- 注册为系统服务
rpm -qa | grep tcl yum install tcl rpm -qa | grep ruby rpm -qa | grep gem yum install ruby gem sources gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/ gem list系统内核参数调整
/etc/sysctl.conf sysctl vm.overcommit_memory=1 echo never > /sys/kernel/mm/transparent_hugepage/enabled sysctl -p sysctl -w fs.file-max=386979 sysctl -p #------------------------ vim /etc/security/limits.conf * soft nofile 102400 * hard nofile 102400 * - memlock unlimited ulimit -Hn ulimit -Sn #------------------------ sysctl -n kernel.threads-max sysctl -n netcore.somaxconn sysctl -n kernel.shmmni sysctl -n kernel.sem sysctl -w kernel.threads-max=32767 sysctl -w net.core.somaxconn="1024" sysctl -w kernel.sem="2048 32000 100 1024" sysctl -p安装包下载
链接地址: http://download.redis.io/releases/.
编译redistar -zxvf XXX.tar.gz cd XXX make cd src make install #如果要安装到指定位置,添加参数PREFIX make install PREFIX=/指定路径 #安装完成后src目录会多出几个高亮显示的文件 cd ../bin #生成的文件介绍 redis-benchmark Redis性能压测工具 redis-check-aof 修复有问题的AOF文件 redis-check-rdb 修复有问题的dump.rdb文件 redis-cli Redis客户端 redis-sentinel Redis哨兵模式 redis-server Redis服务端运行
#使用cp命令,从redis源码目录中复制redis.conf配置文件,到redis的安装目录 vim redis.conf #找到daemonize no,将no修改为yes #修改 bind 192.168.5.221(此IP为自己服务注册IP) #关闭安全模式 protected-mode no #pidfile路径 pidfile /home/logs/redis/redis.pid #文件存储路径 dir /home/data/redis #启动 ./redis-server /path/to/redis.conf注册为系统服务
vim /usr/lib/systemd/system/redis.service #写入 [Unit] Description=Redis After=network.target [Service] Type=forking PIDfile=/home/logs/redis/redis.pid ExecStart=/home/app/redis/bin/redis-server /home/data/redis/conf/redis.conf ExecReload=/bin/kill -s HUP $MAINPID ExecStop=/bin/kill -s QUIT $MAINPID PrivateTmp=true [Install] WantedBy=multi-user.target
systemctl enable redis.service systemctl start|stop| restart redis.service



