redis的单实例配置+web链接redis

时间:2022-02-17 07:48:35
[root@cache01 src]# wget http://download.redis.io/redis-stable.tar.gz
[root@cache01 src]# tar -xzvf redis-stable.tar.gz
[root@cache01 redis-stable]# pwd
/usr/local/src/redis-stable
[root@cache01 redis-stable]# ls
00-RELEASENOTES COPYING Makefile redis.conf runtest-sentinel tests
BUGS deps MANIFESTO runtest sentinel.conf utils
CONTRIBUTING INSTALL README.md runtest-cluster src

安装redis依赖包

[root@cache01 redis-stable]# yum install -y gcc tcl

编译并安装redis

[root@cache01 redis-stable]# make
[root@cache01 redis-stable]# make test
[root@cache01 redis-stable]# make install PREFIX=/app/server/redis-3.2.1
[root@cache01 redis-stable]# make test
[root@cache01 redis-stable]# ln -s /app/server/redis-3.2.1/ /app/server/redis

配置环境变量并生效:

[root@cache01 bin]# echo "PATH=/app/server/redis/bin:$PATH" >>/etc/profile
[root@cache01 bin]# . /etc/profile
[root@cache01 bin]#mkdir /app/server/redis/conf

创建redis配置文件目录,拷贝相关配置文件

[root@cache01 bin]# cp /usr/local/src/redis-stable/redis.conf /app/server/redis/conf/6379.conf

修改配置文件中相关参数,如下所示:

[root@cache01 bin]# mkdir /app/server/redis/logs
[root@cache01 bin]# egrep "(daemonize|pidfile|logfile)" /app/server/redis/conf/6379.conf
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize yes
# When the server runs non daemonized, no pid file is created if none is
# specified in the configuration. When the server is daemonized, the pid file
pidfile /var/run/redis_6379.pid
# output for logging but daemonize, logs will be sent to /dev/null
logfile "/app/server/redis/logs/6379.log"

拷贝redis启动脚本到/etc/init.d/目录下,并重命名为redis

[root@cache01 bin]# cp /usr/local/src/redis-stable/utils/redis_init_script /etc/init.d/redis

修改redis启动脚本,相关参数如下所示:

[root@cache01 bin]# egrep "^(REDISHOME|EXEC|CLIEXEC|PIDFILE|CONF)" /etc/init.d/redis
REDISHOME=/app/server/redis
EXEC=$REDISHOME/bin/redis-server
CLIEXEC=$REDISHOME/bin/redis-cli
PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF="$REDISHOME/conf/${REDISPORT}.conf"

配置完成,启动redis并查看进程及端口号:

[root@cache01 bin]# /etc/init.d/redis start

[root@cache01 bin]# ss -lnupt|grep 6379
tcp LISTEN 0 128 127.0.0.1:6379 *:* users:(("redis-server",10590,4)) [root@cache01 bin]# ps -ef|grep redis|grep -v grep
root 10590 1 0 14:52 ? 00:00:00 /app/server/redis/bin/redis-server 127.0.0.1:6379

执行客户端命令并测试:

[root@cache01 bin]# redis-cli
127.0.0.1:6379> set num 100
OK
127.0.0.1:6379> get num
"100"
127.0.0.1:6379> incr num
(integer) 101
127.0.0.1:6379> decr num
(integer) 100
127.0.0.1:6379> del num
(integer) 1
127.0.0.1:6379> get num
(nil)
127.0.0.1:6379>

关闭redis服务

[root@cache01 bin]# /etc/init.d/redis stop
Stopping ...
Redis stopped [root@cache01 bin]# ps -ef |grep redis|grep -v "grep"
[root@cache01 bin]# ss -lnutp|grep 6379

到此redis的单实例配置完成。

web链接redis测试:192.168.1.112是redis服务器

<?php
$redis = new redis();
$redis->connect('192.168.1.112',6379);
$result = $redis->set('test',"1234567");
var_dump($result);
?>

redis的单实例配置+web链接redis的更多相关文章

  1. Redis基础知识之——自定义封装单实例和普通类Redis

    一.普通Redis实例化类: class MyRedis { private $redis; public function __construct($host = '121.41.88.209', ...

  2. 【Redis】windows环境下安装redis服务器,并配置php的redis扩展

    win7示例: 1.下载Redis服务器 : https://github.com/dmajkic/redis/downloads:(随便下,建议不要太老的) 2.在D:\phpStudy\ 新建Re ...

  3. windows上redis的安装和配置

    windows上redis的安装和配置 进入到Redis的根目录D:\Programming\Redis\Redis6379\Redis-x64-3.2.100底下操作: 配置文件启动 redis-s ...

  4. CentOS7 配置 Redis单实例

    Redis单实例安装 环境.准备 安装 作为服务启动 启动 1.环境.准备 系统 CentOS7 最小化安装. gcc安装,Make时需要. yum -y install gcc 下载安装包 下载当前 ...

  5. Redis:安装、配置、操作和简单代码实例&lpar;C语言Client端&rpar;

    Redis:安装.配置.操作和简单代码实例(C语言Client端) - hj19870806的专栏 - 博客频道 - CSDN.NET Redis:安装.配置.操作和简单代码实例(C语言Client端 ...

  6. 安装Redis 4&period;0单实例

    一.Redis简单介绍 转载于网络 Redis是一个开源(BSD许可)的内存中的数据结构存储系统,它可以用作数据库.缓存和消息中间件.由于Redis采用运行在内存中的数据集工作方式,其性能卓越,能支持 ...

  7. redis 单实例安装

    单实例安装 近些年,由于内存技术的提升.造价的下降,越来越多企业的服务器内存已增加到几百G.这样的内存容量给了内存数据库一个良好的发展环境. 而使用Redis是内存数据库的一股清流,渐有洪大之势.下面 ...

  8. Spring boot配置多个Redis数据源操作实例

    原文:https://www.jianshu.com/p/c79b65b253fa Spring boot配置多个Redis数据源操作实例 在SpringBoot是项目中整合了两个Redis的操作实例 ...

  9. Redis多实例配置以及主从同步

    一.多实例配置 1.准备俩配置文件,开两个就准备两个 redis-6380.conf redis-6381.conf 2.分别写入配置信息(这里简化了配置) # 运行在6380端口 bind 172. ...

随机推荐

  1. mongodb权限管理

    说到mongodb就得先谈谈mongodb的用户组,和传统的关系型数据库不一样,mongodb并没有在创建应用时就要求创建权限管理组,所以类似于Robomongo这样的数据库可视化工具在创建conne ...

  2. 如何配置使用 Log4j

    最近在用Java 写一个FTP上传下载文件工具,正好需要产生操作日志. 利用Log4j.jar可以轻松解决.下面介绍一下Log4j的使用,具体概念到官网查阅: -------------------- ...

  3. CSMA&sol;CD协议——学习笔记

    CSMA/CD协议要点: 1)适配器从网络层获得一个分组,加上以太网的首部和尾部,组成以太网帧,放入适配器的缓存中,准备发送. 2)若适配器检测到信道空闲(即在96比特时间内没有检测到信道上有信号), ...

  4. (转载)delphi 中如何调用sql 存储过程

    delphi 中如何调用sql 存储过程 使用TADOStoredProc组件,可以,给你举个例子好了 with ADOStoredProc1 do begin Close; Parameters.C ...

  5. Linux下Memcached的安装步骤

    一.安装gcc# yum -y install gcc 二.安装libevent# wget http://www.monkey.org/~provos/libevent-2.0.12-stable. ...

  6. Linux - atexit&lpar;&rpar;(注册终止)函数

    进程终⽌的⽅式有8种,前5种为正常终⽌,后三种为异常终⽌: 1. 从main函数返回: 2 .调⽤exit函数:3 .调⽤_exit或_Exit:4 .最后⼀个线程从启动例程返回:5 .最后⼀个线程调 ...

  7. 【春华秋实】&period;NET Core之只是多看了你一眼

    感官初体验 技术学习是一件系统性的事情,如果拒绝学习,那么自己就会落后以至于被替代..NET也是一样,当开源.跨平台成为主流的时候,如果再故步自封,等待.NET的就是死路一条,幸好.NET Core问 ...

  8. appium三种等待时间

    1.强制等待(固定等待) 2.隐式等待 是appium中webdriver中自带的休眠方法,设置的是全局等待时间(在全局等待时间内之间的响应操作都会立即结束等待,然后进行操作) 3.显式等待

  9. Confluence 6 找到你的支持识别代码(SEN)

    你可以在下面 3 个地方找到你的 SEN 代码: 在 Confluence 中,进入  > 基本配置(General Configuration) > 许可证详细(License Deta ...

  10. javaSE——字节流

    IO流:InputStream/OutputStream 字节流:         文件输出流 :内存 ——>文件 文件输入流 :内存<——文件 应用             文件输入/出 ...