redis部署-源码
1、环境准备
下载redis安装包
版本:redis-5.0.14
地址:https://download.redis.io/releases/redis-5.0.14.tar.gz
进行系统调优
echo "vm.overcommit_memory = 1" >> /etc/sysctl.conf
sysctl -p
echo never >> /sys/kernel/mm/transparent_hugepage/enabled
1)解压安装包
tar xf redis-5.0.14.tar.gz
2)建立redis目录
mkdir /opt/redis
3)编译安装
cd redis-5.0.14/
make
make PREFIX=/opt/redis install
1)复制配置文件到redis目录中
cp redis.conf /opt/redis/
2)复制启动脚本
cp utils/redis_init_script /etc/init.d/redis
3)修改启动脚本
vim /etc/init.d/redis
CONF="/opt/redis/redis.conf" redis.conf路径
EXEC=/opt/redis/bin/redis-server redis-server路径
CLIEXEC=/opt/redis/bin/redis-cli redis-cli路径
PIDFILE=/opt/redis/redis_${REDISPORT}.pid redis pid文件
CONF="/opt/redis/${REDISPORT}.conf" redis配置文件
4)修改配置文件
vim /opt/redis/redis.conf
port 16379 redis端口
requirepass 123Abc.. 设置redis登录密码
daemonize yes 设置后台运行
pidfile /opt/redis/redis_16379.pid pid文件路径
logfile "/opt/redis/log/redis.log" 日志文件路径
methon1
/etc/init.d/redis start
Starting Redis server...
17241:C 13 Feb 2022 01:37:37.760 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
17241:C 13 Feb 2022 01:37:37.760 # Redis version=5.0.14, bits=64, commit=00000000, modified=0, pid=17241, just started
17241:C 13 Feb 2022 01:37:37.760 # Configuration loaded
methon2
/redis/redis/bin/redis-server /redis/redis/16379.conf redis的配置文件,指启动时加载配置文件
ps -ef | grep redis
root 19702 19262 0 17:04 pts/1 00:00:00 su - redis
redis 19703 19702 0 17:04 pts/1 00:00:00 -bash
redis 19736 1 0 17:04 ? 00:00:00 /redis/redis/bin/redis-server 127.0.0.1:16379
redis 19749 19703 0 17:04 pts/1 00:00:00 ps -ef
redis 19750 19703 0 17:04 pts/1 00:00:00 grep --color=auto redis
注意,生产环境下最好建立专门的用户来启停redis
netstat -antp | grep "6379"
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 17242/redis-server
redis安装脚本
更多系统、中间件、应用、数据库相关脚本:https://opszzfwordpress.club/script/