redis的单实例配置+web链接redis
2023-09-14 09:00:10 时间
[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应用(redis应用到项目中)
- 实现最佳Redis性能:从配置优化开始(redis配置优化)
- 使用Redis实现分布式缓存的指南(redis使用实例)
- 如何优化Redis缓存配置(redis缓存配置)
- Ruby on Rails 与 Redis:构建高效的应用程序(rails redis)
- Redis命令管理之备份与恢复(redis 命令 备份)
- 配置Redis,实现功能性强大(编写redis配置类)
- 实现流式处理的Redis优势(流式写redis)
- 排查无法启动Redis实例(无法启动redis实例)
- Ubuntu下Redis的安装及环境配置(乌班图redis安装配置)
- 文件为何Redis需要创建配置文件(为啥redis要写配置)
- 通过SSH如何配置Redis服务器(ssh怎么配置redis)
- 掌握Redis之路进入数据库的步骤(如何进入redis数据库)
- Redis安装状态如何检查(如何看redis是否装好)
- 启航Redis之路脚本构建新生命(启动redis脚本)
- ClusterRedis Cluster让Redis项目性能更上新台阶(redis项目中配置)
- Redis集群配置谨慎检查(redis集群配置检查)
- Redis集群添置新节点,构建更健壮的分布式环境(redis集群新增实例)
- 为Redis加大连接数量,打造高效运行环境(redis配置大连接数)
- 使用SSM框架配置Redis服务(redis配置入ssm)
- Redis的完美配置让你的缓存更胜一筹(redis都有哪些配置)
- 警告Redis连接池用量超出预期(redis 连接池不够用)