CentOS7.5安装Redis3.0.0

redis,咱们经常使用来作缓存,也是著名的nosql存储中间件。html

信息统计

  • 下载地址:暂无。
  • 软件版本: redis-3.0.0
  • 安装地址: /usr/setup/redis-3.0.0
  • 配置文档地址: /usr/setup/redis-3.0.0/redis.conf
  • 占用端口:6379
  • 用户名和密码:无

安装

  • 安装gcc编译工具包
[root@redis01 ~]# yum update -y
[root@redis01 ~]# yum install -y gcc
复制代码
  • 解压
[root@redis01 ~]# tar zxf /opt/packages/redis-3.0.0.tar.gz -C /opt/unziped/
复制代码
  • 建立文件夹
[root@redis01 ~]# mkdir -p /usr/setup/redis-3.0.0
[root@redis01 ~]# mkdir /usr/setup/redis-3.0.0/log
[root@redis01 ~]# mkdir /usr/setup/redis-3.0.0/data
复制代码
  • 进入解压后的redis目录并执行make命令
[root@redis01 ~]# cd /opt/unziped/redis-3.0.0/
[root@redis01 redis-3.0.0]# make
复制代码
  • 执行安装命令
[root@redis01 redis-3.0.0]# make install PREFIX=/usr/setup/redis-3.0.0
cd src && make install
make[1]: 进入目录“/opt/unziped/redis-3.0.0/src”

Hint: It's a good idea to run 'make test' ;) INSTALL install INSTALL install INSTALL install INSTALL install INSTALL install make[1]: 离开目录“/opt/unziped/redis-3.0.0/src” 复制代码
  • 拷贝配置文件
[root@redis01 redis-3.0.0]# cp /opt/unziped/redis-3.0.0/redis.conf /usr/setup/redis-3.0.0
复制代码
  • 打开守护进程运行模式
// 修改配置文件,将daemonize的值改成yes
[root@redis01 redis-3.0.0]# vi /usr/setup/redis-3.0.0/redis.conf
daemonize yes
复制代码
  • 加入开机自启
[root@redis01 redis-3.0.0]# cd /opt/unziped/redis-3.0.0/utils/
[root@redis01 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] /usr/setup/redis-3.0.0/redis.conf
Please select the redis log file name [/var/log/redis_6379.log] /usr/setup/redis-3.0.0/log/redis.log
Please select the data directory for this instance [/var/lib/redis/6379] /usr/setup/redis-3.0.0/data/6379
Please select the redis executable path [] /usr/setup/redis-3.0.0/bin/redis-server
Selected config:
Port           : 6379
Config file    : /usr/setup/redis-3.0.0/redis.conf
Log file       : /usr/setup/redis-3.0.0/log/redis.log
Data dir       : /usr/setup/redis-3.0.0/data/6379
Executable     : /usr/setup/redis-3.0.0/bin/redis-server
Cli Executable : /usr/setup/redis-3.0.0/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!
复制代码
  • 开启端口,并重启防火墙
$ firewall-cmd --zone=public --permanent --add-port=6379/tcp
$ firewall-cmd --reload
复制代码
  • 重启后测试
1. 本机链接测试
$ cd /usr/setup/redis-3.0.0/bin/
$ ./redis-cli
127.0.0.1:6379> info

2. 开发机链接测试
cmd: redis-cli.exe -h 10.168.0.120 -p 6379
复制代码

简单使用

./redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> set a 10
OK
127.0.0.1:6379> get a
"10"
127.0.0.1:6379> incr a
(integer) 11
127.0.0.1:6379> get a
"11"
127.0.0.1:6379> decr a
(integer) 10
127.0.0.1:6379> keys *
1) "a"
127.0.0.1:6379> del a
(integer) 1
127.0.0.1:6379> keys *
(empty list or set)
127.0.0.1:6379> exit // 关闭客户端
复制代码

参考连接

  1. www.cnblogs.com/zhang-ke/p/…
  2. blog.csdn.net/sjhuangx/ar…
  3. redis.io/
  4. www.ruanyifeng.com/blog/2016/0…
  5. blog.csdn.net/amandalm/ar…

推荐阅读

送你一本Java程序员运维技能手册。在这程序员

相关文章
相关标签/搜索