源码安装redis3.2.3并注册为系统服务
2016-09-25 11:31
543 查看
源码安装redis3.2.3并注册为系统服务
1、下载安装包redis-3.2.3.tar.gzwget http://download.redis.io/releases/redis-3.2.3.tar.gz[/code]
2、解压并安装tar -zxvf redis-3.2.3.tar.gz cd redis-3.2.3/src make prefix=/usr/local/redis install #指定安装路径
3、创建配置文档,修改配置
创建配置文档路径mkdir /etc/redis cp ../redis.conf /etc/redis/6379.conf vim /etc/redis/6379.conf
以下几个参数常用到daemonize no #后台运行 bind 127.0.0.1 #绑定ip,需要外网访问时将其注释掉 protected-mode yes #保护模式,默认是开启的,需要其他客户端链接时,改为no关闭 requirepass foobared #其他客户端链接时的密码 appendonly yes #每次更新后记录日志
4、注册系统服务,开机自启
创建启动脚本cp ../utils/redis_init_script /etc/rc.d/init.d/redis vim /etc/rc.d/init.d/redis
修改redis启动脚本,要修改的地方有
添加 chkconfig 注释
redis-server 、redis-cli 、pidfile、redis.conf路径
如果需要配置密码,还要在停止命令增加参数 -a 指定密码#!/bin/sh # chkconfig: 2345 90 10 #添加 chkconfig 注释 # Simple Redis init.d script conceived to work on Linux systems # as it does use of the /proc filesystem. REDISPORT=6379 EXEC=/usr/local/redis/bin/redis-server CLIEXEC=/usr/local/redis/bin/redis-cli PIDFILE=/var/run/redis_${REDISPORT}.pid CONF="/etc/redis/6379.conf" case "$1" in start) if [ -f $PIDFILE ] then echo "$PIDFILE exists, process is already running or crashed" else echo "Starting Redis server..." $EXEC $CONF fi ;; stop) if [ ! -f $PIDFILE ] then echo "$PIDFILE does not exist, process is not running" else PID=$(cat $PIDFILE) echo "Stopping ..." $CLIEXEC -p $REDISPORT shutdown while [ -x /proc/${PID} ] do echo "Waiting for Redis to shutdown ..." sleep 1 done echo "Redis stopped" fi ;; *) echo "Please use start or stop as first argument" ;; esac
保存后执行注册成系统服务:chkconfig --add redis chkconfig redis on
完成后,可以使用service redis start|stop启动关闭redis服务
5、添加环境变量:vim /etc/profile
在最后添加:PATH=$PATH:/usr/local/redis/bin export PATH source /etc/profile
6、启动服务并测试service redis start ps -ef | grep redis
用redis-cli 链接,set,get正常redis-cli -h 127.0.0.1 -p 6379 -a foobared 127.0.0.1:6379> set name xiaoming OK 127.0.0.1:6379> get name "xiaoming" 127.0.0.1:6379>
相关文章推荐
- Ubuntu 14 环境下编译安装 Redis 并将其注册为系统服务
- Redhat5.8 环境下编译安装 Redis 并将其注册为系统服务
- Redhat5.8 环境下编译安装 Redis 并将其注册为系统服务
- Redis单点安装,注册为系统服务,开机启动
- Ubuntu 14 环境下编译安装 Redis 并将其注册为系统服务
- Redhat5.8 环境下编译安装 Redis 并将其注册为系统服务
- Redhat5.8 环境下编译安装 Redis 并将其注册为系统服务
- CentOS7下源码安装Redis系统服务配置
- CentOS7源码安装Redis及配置系统服务
- Redhat5.8 环境下编译安装 Redis 并将其注册为系统服务
- Redis集群安装,注册为系统服务,开机启动
- centos下安装redis并且注册为服务
- Windows 系统安装 redis 服务
- centos安装redis3为系统服务
- VMware虚拟机CentOS7系统上安装Redis3.2.3
- 安装apached源码包以及编写shell脚本使其启动更加方便,并且和启动系统服务相同
- (二)Redis的安装及配置(3)---注册服务与自动启动
- centos安装redis3为系统服务
- Mac 系统安装redis服务
- cengos 安装redis 并将redis启动添加为系统服务