linux 配置redis自启动

1.redis的简介

redis :是基于key-value 形式的进行存储的内存行数据库
一.1.1 数据存储为key-value
1.2 数据存储在内存中
1.21 优点:效率高,理论值10k数据读取
1.3 定位:数据库软件
1.31 作用:存储数据
二 2.1Redis 是一个NOSQL数据库,字面理解:不适用sql命令操作数据软件
2.2 NoSql:英文全称not only sql ,表示在应用程序开发时,不是必须使用关系型数据库,可以用nosql来代替关系型数据库的部分功能.
三 目前NoSql不能完全代替关系型数据库,使用关系型数据库结合NoSql数据库进行完成项目.
3.1 当数据比较复杂时不适用与NoSql数据库
3.2 关系型数据库仍然时主流的数据存储软件
3.3 NoSql数据库适用于缓存工具来使用.
3.3.1 把某些使用频率较高的内容不仅存储到关系型数据库,还存储到NoSql数据库中
3.3.2 需要考虑到NoSql和关系型数据库同步的问题

2.安装 Redis(略…)

3.配置redis自启动

1.进入redis 的解压目录 进入utils 目录中

[root@VM_0_12_centos init.d]# cd /usr/local/redis-3.0.0/utils/
[root@VM_0_12_centos utils]# ls
build-static-symbols.tcl  hyperloglog        lru           redis-copy.rb      redis_init_script.tpl  speed-regression.tcl
generate-command-help.rb  install_server.sh  mkrelease.sh  redis_init_script  redis-sha1.rb          whatisdoing.sh

2.复制redis_init_script 文件到 /etc/init.d/ 目录下

[root@VM_0_12_centos etc]# cp redis_init_script /etc/init.d/redisd
//查看复制成功没有
root@VM_0_12_centos etc]# cd /etc/init.d/
[root@VM_0_12_centos init.d]# ls
chkconfig_11.0-79.1-2_all.deb  chkconfig_11.0-79.1-2_all.deb.1  functions  netconsole  network  README  redisd  sshservice  tomcat

3.修改redisd 文件

#!/bin/sh
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.
# chkconfig: 2345 90 10 
# description: Redis is a persistent key-value database  
REDISPORT=6379
EXEC=/usr/local/redis/bin/redis-server
CLIEXEC=/usr/local/redis/bin/redis-cli

PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF="/usr/local/redis/etc/redis.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

**

注意:

#!/bin/sh

Simple Redis init.d script conceived to work on Linux systems

as it does use of the /proc filesystem.

chkconfig: 2345 90 10 //设置权限

description: Redis is a persistent key-value database

REDISPORT=6379 EXEC=/usr/local/redis/bin/redis-server CLIEXEC=/usr/local/redis/bin/redis-cli PIDFILE=/var/run/redis_${REDISPORT}.pid CONF="/usr/local/redis/etc/redis.conf"

**

输入开启启动命令 #chkconfig redis on

查看是否配置成功

[root@VM_0_12_centos init.d]# chkconfig --list

Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.

      If you want to list systemd services use 'systemctl list-unit-files'.
      To see services enabled on particular target use
      'systemctl list-dependencies [target]'.

netconsole     	0:off	1:off	2:off	3:off	4:off	5:off	6:off
network        	0:off	1:off	2:on	3:on	4:on	5:on	6:off
redisd         	0:off	1:off	2:on	3:on	4:on	5:on	6:off
tomcat         	0:off	1:off	2:on	3:on	4:on	5:on	6:off

配置成功 启动redis服务

root@VM_0_12_centos init.d]# service redisd strat
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值