美文网首页
Redis 安装及配置

Redis 安装及配置

作者: SnorlaxSE | 来源:发表于2017-10-03 14:46 被阅读0次
  • 安装 gcc
# yum -y install gcc
  • 解压 tcl8.6.1-src.tar.gz
[root@grape0 download]# tar -zxvf tcl8.6.1-src.tar.gz -C /usr/local/

进入目录

[root@grape0 download]# cd /usr/local/tcl8.6.1/unix/

./configure 生成 Makefile 文件,为下一步编译做准备

[root@grape0 unix]# ./configure

编译及安装,make 以及 make install

[root@grape0 unix]# make
[root@grape0 unix]# make install

报错:

make[1]: Leaving directory `/usr/local/tcl8.6.1/unix/pkgs/thread2.7.0'
  • 解压redis-2.8.13.tar.gz
[root@grape0 download]# tar -zxvf redis-2.8.13.tar.gz  -C /usr/local/
[root@grape0 download]#cd /usr/local/redis-2.8.13/
[root@grape0 redis-2.8.13]# make
Hint: To run 'make test' is a good idea ;)
make[1]: Leaving directory `/usr/export/software/redis-2.8.13/src'
  • 执行安装命令
make PREFIX=/usr/local/redis install
#PREFIX=/usr/local/redis可以省略,省略情况下redis会默认安装到/usr/local/bin目录下
cd src && make install
make[1]: Entering directory `/usr/export/software/redis-2.8.13/src'

Hint: To run 'make test' is a good idea ;)

    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
make[1]: Leaving directory `/usr/export/software/redis-2.8.13/src'
  • 根据提示,执行:cd src && make install
[root@grape0 redis-2.8.13]# cd src && make install

Hint: To run 'make test' is a good idea ;)

    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install

[root@grape0 src]#
  • 安装tcl8.5(如不进行redis test测试可以不安装)
[root@grape0 src]# yum install tcl
Loaded plugins: fastestmirror, refresh-packagekit, security
Determining fastest mirrors
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os error was
12: Timeout on http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os: (28, 'Operation too slow. Less than 1 bytes/sec transfered the last 30 seconds')
 * base: mirrors.btte.net
 * extras: mirrors.tuna.tsinghua.edu.cn
 * updates: mirrors.tuna.tsinghua.edu.cn
base                                                   | 3.7 kB     00:00
extras                                                 | 3.4 kB     00:00
updates                                                | 3.4 kB     00:00
updates/primary_db                                     | 4.7 MB     00:05
Setting up Install Process
Package 1:tcl-8.5.7-6.el6.x86_64 already installed and latest version
Nothing to do
[root@grape0 src]#
  • 测试Redis
[root@grape0 src]# make test
Cleanup: may take some time... OK
Starting test server at port 11111
Executing test client: couldn't open socket: connection refused.
couldn't open socket: connection refused
    while executing
"socket localhost $server_port"
    (procedure "test_client_main" line 2)
    invoked from within
"test_client_main $::test_server_port "
Executing test client: couldn't open socket: connection refused.
couldn't open socket: connection refused
    while executing
    ......
[root@grape0 redis-2.8.13]# make test
cd src && make test
make[1]: Entering directory `/usr/export/software/redis-2.8.13/src'
You need tcl 8.5 or newer in order to run the Redis test
make[1]: *** [test] Error 1
make[1]: Leaving directory `/usr/export/software/redis-2.8.13/src'
make: *** [test] Error 2

没有出错继续

[root@grape0 redis-2.8.13]# make install
  • 复制并修改配置文档
    --- 创建redis日志目录,和数据文件目录
[root@grape1 src]#cd /usr/local/redis-2.8.13
[root@grape1 redis-2.8.13]# cp redis.conf  /usr/local/redis/
[root@grape1 redis-2.8.13]# mkdir -p /usr/local/redis/log
[root@grape1 redis-2.8.13]# mkdir -p /usr/local/redis/db
  • 修改redis.conf下面的配置项
[root@grape1 redis-2.8.13]# cd /usr/local/redis/
[root@grape1 redis]# vi redis.conf
daemonize yes  #确保守护进程开启 
pidfile /usr/local/redis/redis.pid
logfile /usr/local/redis/log
dir /usr/local/redis/db
  • 启动redis
[root@grape1 redis]#cd /usr/local/redis/bin/
[root@grape1 bin]# ./redis-server
//以daem方式启动redis服务
# redis-server
  • 启动客户端(另起一个命令框)
[root@grape0 src]#  /usr/local/redis/bin/redis-cli
或
[root@grape0 src]#  /usr/local/bin/redis-cli
127.0.0.1:6379>
  • 测试
127.0.0.1:6379> set welcome 'hello redis'
OK
127.0.0.1:6379> get welcome
"hello redis"
127.0.0.1:6379>
  • 关闭服务
127.0.0.1:6379> shutdown
  或者
[root@grape0 src]# redis-cli shutdown
[25723] 07 Oct 19:32:39.046 # User requested shutdown...
[25723] 07 Oct 19:32:39.046 * Saving the final RDB snapshot before exiting.
[25723] 07 Oct 19:32:39.079 * DB saved on disk
[25723] 07 Oct 19:32:39.079 # Redis is now ready to exit, bye bye...
[root@grape0 redis-2.8.13]#
  • 设置开机启动 redis
vi /etc/init.d/redis  
#!/bin/sh
# chkconfig: 2345 10 90
# description: Start and Stop redis
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.

PATH=/usr/local/bin:/sbin:/usr/bin:/bin
REDISPORT=6379
EXEC=/usr/local/bin/redis-server
CLIEXEC=/usr/local/bin/redis-cli
PIDFILE=/var/run/redis_6379.pid
CONF="/home/cloud/Desktop/redis-4.0.1/redis.conf"
AUTH="1234"

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
        ;;
     restart | force-reloaded)
                ${0} stop
                ${0} start
                ;;
    *)
        echo "Usage: /etc/init.d/redis {start|stop|restart|force-reloaded}" >&2
        exit 1
esac

添加权限

chmod 755 /etc/init.d/redis

启动或关闭服务 进行测试

service redis start  
service redis stop

设置开机启动

chkconfig redis on

参考:
CentOS 6.5下Redis安装记录Redis之——CentOS 6.5安装配置rediscentos7下redis的安装

相关文章

  • linux redis 安装及基本配置

    每次 linux redis安装,都要百度,索性将 linux redis 源码安装及配置记下,含 redis ...

  • Redis安装+Python操作Redis

    一、Redis安装及服务启动 1、redis安装 Windows平台安装Linux平台安装 2、启动配置 conf...

  • Ubuntu Redis 集群

    安装环境及版本: 系统:ubuntu 18.04 LTS Redis: redis-5.0.5 配置说明:六个节点...

  • Swoole单例模式及依赖注入进行Redis底层类库封装

    redis安装及php-redis扩展安装 初步使用 封装基类 – 单例模式 优化封装 – 依赖注入 从配置加载 ...

  • Ubuntu安装配置Redis

    安装Redis 安装并启动 检查Redis是否运行 ubuntu安装Redis桌面管理器 Redis配置 查看配置...

  • SpringBoot Redis缓存

    关于redis的安装、配置及启动,参考Redis简单配置使用 1.添加依赖 2.添加配置文件 3.添加配置类 Re...

  • Redis 安装及配置

    安装 gcc 解压 tcl8.6.1-src.tar.gz 进入目录 ./configure 生成 Makefil...

  • linux 安装java环境

    Redis安装 获取redis资源 解压 安装 移动配置文件 配置redis后台启动 将redis加入到开机启动 ...

  • redis

    redisredis理论Redis:安装和配置redis安装配置和使用redisRedis Cluster程序环境...

  • Redis的安装和配置 for CentOS

    Redis 安装和配置 Redis 安装 Redis 安装官网:http://redis.io/官网下载:http...

网友评论

      本文标题:Redis 安装及配置

      本文链接:https://www.haomeiwen.com/subject/ljffyxtx.html