美文网首页
搭建Redis服务器

搭建Redis服务器

作者: 北小秋 | 来源:发表于2020-04-14 13:06 被阅读0次

搭建redis服务器

1)安装源码redis软件

[root@redis1 redis]#yum -y install gcc

[root@redis1 redis]#tar -zxf redis-4.0.8.tar.gz

[root@redis1 redis]# cd redis-4.0.8/

[root@redis1 redis-4.0.8]# ls

00-RELEASENOTES  CONTRIBUTING  deps    Makefile  README.md  runtest          runtest-sentinel  src    utils

BUGS            COPYING      INSTALL  MANIFESTO  redis.conf  runtest-cluster  sentinel.conf    tests

[root@redis1 redis-4.0.8]#make

[root@redis1 redis-4.0.8]#make install

[root@redis1 redis-4.0.8]# cd utils/

[root@redis1 utils]#./install_server.sh

Welcome to the redis service installer

This script will help you easily set up a running redis server

Please select the redis port for this instance: [6379]

Selecting default: 6379

Please select the redis config file name [/etc/redis/6379.conf]

Selected default - /etc/redis/6379.conf

Please select the redis log file name [/var/log/redis_6379.log]

Selected default - /var/log/redis_6379.log

Please select the data directory for this instance [/var/lib/redis/6379]

Selected default - /var/lib/redis/6379

Please select the redis executable path [/usr/local/bin/redis-server]

Selected config:

Port          : 6379    //端口号

Config file    : /etc/redis/6379.conf    //配置文件目录

Log file      : /var/log/redis_6379.log  //日志目录

Data dir      : /var/lib/redis/6379      //数据库目录

Executable    : /usr/local/bin/redis-server //启动程序的目录

Cli Executable : /usr/local/bin/redis-cli  //命令行的连接工具

Is this ok? Then press ENTER to go on or Ctrl-C to abort. //回车完成配置

Copied /tmp/6379.conf => /etc/init.d/redis_6379 //服务启动脚本

Installing service...

Successfully added to chkconfig!

Successfully added to runlevels 345!

Starting Redis server...  //提示服务已经启动

Installation successful! //提示安装成功

2)查看服务状态

[root@redis1 utils]#/etc/init.d/redis_6379 status

Redis is running (15203)

3)查看监听的端口

[root@redis1 utils]#netstat -antupl |grep :6379//查看端口

tcp        0      0 127.0.0.1:6379          0.0.0.0:*              LISTEN      15203/redis-server

[root@redis1 utils]#ps  -C redis-server//查看进程

  PID TTY          TIME CMD

15203 ?        00:00:00 redis-server

4)停止服务

[root@redis1 utils]#/etc/init.d/redis_6379 stop

5)连接redis

[root@redis1 utils]#/etc/init.d/redis_6379 start

[root@redis1 utils]#redis-cli//默认连接127.0.0.1地址的 6379端口

127.0.0.1:6379> ping

PONG //PONG说明服务正常

6)存储变量school,值为123456,查看变量school的值

常用指令操作:

set keyname keyvalue //存储

get keyname //获取

127.0.0.1:6379>set school 123456

OK

127.0.0.1:6379> get school

"123456"

127.0.0.1:6379>

相关文章

网友评论

      本文标题:搭建Redis服务器

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