centOS 中安装 Redis
之前安装过了 jdk,mysql,tomcat,这次安装 Redis,最开始是将 redis 安装在 windows 下 run 的,这时安装在 Linux 里面试试。
1 . 首先得安装 c环境,用来编译 Redis源码,
- [root@msym lib64]# clear
- [root@msym lib64]# yum install gcc-c++
接下来大约要下载 22MB 这个样子,很快就能下载完,
2 . 准备 redis 源码文件
利用 SSH 将 redis 拷贝到 centOS 中的 /soft 中,然后我在 /usr/local/ 下新建了一个 redis_home 的目录,将 redis 解压到这个里面,解压好之后查看一下,
- [root@msym soft]# cd /usr/local/redis_home/
- [root@msym redis_home]# ll
- 总用量 4
- drwxrwxr-x. 6 root root 4096 4月 1 2015 redis-3.0.0
- [root@msym redis_home]#
3 . 编译 redis 源码
解压好,在进入 redis 目录中,使用 make 指令进行编译,大约需要一分钟:
- [root@msym redis_home]# cd redis-3.0.0/
- [root@msym redis-3.0.0]# make
编译完成后就可以安装了,执行下面命令:(命令中的 redis 是真正的安装目录,之前创建的目录 redis_home 只是我的习惯)
- [root@msym redis-3.0.0]# make PREFIX=/usr/local/redis install
4 . 启动服务(前端启动)
然后进行 redis 目录,进入 bin 目录,运行 redis-server:
- [root@msym redis-3.0.0]# cd ../
- [root@msym redis_home]# cd ../
- [root@msym local]# cd redis
- [root@msym redis]# ll
- 总用量 4
- drwxr-xr-x. 2 root root 4096 7月 2 08:38 bin
- [root@msym redis]# cd bin
- [root@msym bin]# ll
- 总用量 15440
- -rwxr-xr-x. 1 root root 4588886 7月 2 08:38 redis-benchmark
- -rwxr-xr-x. 1 root root 22193 7月 2 08:38 redis-check-aof
- -rwxr-xr-x. 1 root root 45411 7月 2 08:38 redis-check-dump
- -rwxr-xr-x. 1 root root 4691801 7月 2 08:38 redis-cli
- lrwxrwxrwx. 1 root root 12 7月 2 08:38 redis-sentinel -> redis-server
- -rwxr-xr-x. 1 root root 6450321 7月 2 08:38 redis-server
- [root@msym bin]#
运行 redis :(./和redis之间没有空格,是紧挨着的)
- [root@msym bin]# ./redis-server
- 10010:C 02 Jul 08:44:03.199 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
- 10010:M 02 Jul 08:44:03.200 * Increased maximum number of open files to 10032 (it was originally set to 1024).
- _._
- _.-``__ ''-._
- _.-`` `. `_. ''-._ Redis 3.0.0 (00000000/0) 64 bit
- .-`` .-```. ```\/ _.,_ ''-._
- ( ' , .-` | `, ) Running in standalone mode
- |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
- | `-._ `._ / _.-' | PID: 10010
- `-._ `-._ `-./ _.-' _.-'
- |`-._`-._ `-.__.-' _.-'_.-'|
- | `-._`-._ _.-'_.-' | http://redis.io
- `-._ `-._`-.__.-'_.-' _.-'
- |`-._`-._ `-.__.-' _.-'_.-'|
- | `-._`-._ _.-'_.-' |
- `-._ `-._`-.__.-'_.-' _.-'
- `-._ `-.__.-' _.-'
- `-._ _.-'
- `-.__.-'
- 10010:M 02 Jul 08:44:03.216 # Server started, Redis version 3.0.0
- 10010:M 02 Jul 08:44:03.217 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
- 10010:M 02 Jul 08:44:03.218 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
- 10010:M 02 Jul 08:44:03.219 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
- 10010:M 02 Jul 08:44:03.219 * The server is now ready to accept connections on port 6379
这样 redis 服务器就启动了。
在 SSH 客户端下再开启一个命令行窗口,进入redis的bin目录,运行redis-cli,用作客户端,
如果将服务器的命令关闭或者按下Ctrl + c,就是关闭服务器了,接下来在后台启动 redis 服务器,
5 . 启动服务器(后端启动)
进入到之前的 redis_home 目录中redis源码所在目录:
找到 redis.conf ,把它拷贝到 redis/bin目录下,(其实拷到哪里都可以,只要知道他的路径就可以,这里是为了方便)
- [root@msym redis]# cd /usr/local/redis_home/
- [root@msym redis_home]# ll
- 总用量 4
- drwxrwxr-x. 6 root root 4096 4月 1 2015 redis-3.0.0
- [root@msym redis_home]# cd redis-3.0.0/
- [root@msym redis-3.0.0]# ll
- 总用量 144
- -rw-rw-r--. 1 root root 25890 4月 1 2015 00-RELEASENOTES
- -rw-rw-r--. 1 root root 53 4月 1 2015 BUGS
- -rw-rw-r--. 1 root root 1439 4月 1 2015 CONTRIBUTING
- -rw-rw-r--. 1 root root 1487 4月 1 2015 COPYING
- drwxrwxr-x. 6 root root 4096 7月 2 08:36 deps
- -rw-rw-r--. 1 root root 11 4月 1 2015 INSTALL
- -rw-rw-r--. 1 root root 151 4月 1 2015 Makefile
- -rw-rw-r--. 1 root root 4223 4月 1 2015 MANIFESTO
- -rw-rw-r--. 1 root root 5201 4月 1 2015 README
- -rw-rw-r--. 1 root root 41403 4月 1 2015 redis.conf 【我在这里】
- -rwxrwxr-x. 1 root root 271 4月 1 2015 runtest
- -rwxrwxr-x. 1 root root 280 4月 1 2015 runtest-cluster
- -rwxrwxr-x. 1 root root 281 4月 1 2015 runtest-sentinel
- -rw-rw-r--. 1 root root 7109 4月 1 2015 sentinel.conf
- drwxrwxr-x. 2 root root 4096 7月 2 08:37 src
- drwxrwxr-x. 10 root root 4096 4月 1 2015 tests
- drwxrwxr-x. 5 root root 4096 4月 1 2015 utils
- [root@msym redis-3.0.0]#
拷贝一份到 redis/bin下:
- [root@msym redis-3.0.0]# cp redis.conf /usr/local/redis/bin/
- [root@msym redis-3.0.0]# cd ../../redis/bin
- [root@msym bin]# ll
- 总用量 15488
- -rw-r--r--. 1 root root 35 7月 2 09:03 dump.rdb
- -rwxr-xr-x. 1 root root 4588886 7月 2 08:38 redis-benchmark
- -rwxr-xr-x. 1 root root 22193 7月 2 08:38 redis-check-aof
- -rwxr-xr-x. 1 root root 45411 7月 2 08:38 redis-check-dump
- -rwxr-xr-x. 1 root root 4691801 7月 2 08:38 redis-cli
- -rw-r--r--. 1 root root 41403 7月 2 09:10 redis.conf
- lrwxrwxrwx. 1 root root 12 7月 2 08:38 redis-sentinel -> redis-server
- -rwxr-xr-x. 1 root root 6450321 7月 2 08:38 redis-server
- [root@msym bin]#
然后 vim 编辑 redis.conf 文件:
将其中的一个 daemonize no 改为 daemonize yes,即后台运行;
在下次启动的时候,需要指定 redis.conf 文件,就能后端启动了,【这里指定的 redis.conf 文件就是之前修改的】
- [root@msym bin]# ./redis-server redis.conf
- [root@msym bin]#
这样就后端启动了 redis 服务器了。
获取之前存储的字符串:
- [root@msym bin]# ./redis-server redis.conf
- [root@msym bin]# ./redis-cli
- 127.0.0.1:6379> get username
- "msym"
- 127.0.0.1:6379>
6 . 关闭 redis 服务器:(先Ctrl + c 或者 exit 退出客户端,再关闭服务器)
- [root@msym bin]# ./redis-cli shutdown
7 . 开启外部访问 redis 端口(6379)
开启端口,然后保存
- [root@msym bin]# /sbin/iptables -I INPUT -p tcp --dport 6379 -j ACCEPT
- [root@msym bin]# /etc/rc.d/init.d/iptables save
- iptables:将防火墙规则保存到 /etc/sysconfig/iptables: [确定]
- [root@msym bin]#
在加几点,redis 的事务相关,设置事务的属性需要前往 redis.conf 配置文件进行修改,rdb 和 aof的设置,编辑使用命令 vim。
再补充一点:
需要外部访问 Linux 中的 redis 时和访问 Tomcat 服务器一样,需要在防火墙中开启端口,
- /sbin/iptables -I INPUT -p tcp --dport 6379 -j ACCEPT
- /etc/rc.d/init.d/iptables save
然后启动服务器即可。
补充:(2017/7/5)
回想一下,在 windows下,安装 jdk之后,如果不配置 bin的路径的话,就只能在安装 jdk的 bin目录下才能运行 java和 javac命令,在系统环境变量中的 path配置了 bin路径之后,就可以任意目录下运行 java和javac了。
那么 centOS中的 redis也应该是可以的,包括 tomcat的启动,mysql,jdk,类比 windows。
下面就开始设置了:
启动 centOS ,使用 putty连接,
centOS 中安装 Redis的更多相关文章
- 虚拟机centOS中安装Redis,主机Redis Destop Manager不能访问虚拟机Redis server的解决方案
今天在学些redis的时候碰到个问题,发现主机Redis Destop Manager不能访问虚拟机Redis server的解决方案,找了一些网上的资料,原因可能有两个,整理记录下来: 1. Red ...
- CentOS中搭建Redis伪分布式集群【转】
解压redis 先到官网https://redis.io/下载redis安装包,然后在CentOS操作系统中解压该安装包: tar -zxvf redis-3.2.9.tar.gz 编译redis c ...
- 如何在win7系统中安装redis
转载于:http://www.itxuexiwang.com/a/shujukujishu/redis/2016/0216/92.html?1455871954 如何在win7系统中安装redis ...
- 在centos中安装jenkins master测试环境
在centos中安装jenkins 1)安装目录 pwd (/home/AAA) 2)检查java是否安装 [AAA@Centos_AAA jenkins]$ java -version j ...
- centos中安装chromium和flash
安装环境:centos 6.5 64位 在centos中安装chromium 安装Google源 cd /etc/yum.repos.d/ sudo wget http://people.CentOS ...
- 在Ubuntu中安装Redis
原文地址:http://blog.fens.me/linux-redis-install/ 在Ubuntu中安装Redis R利剑NoSQL系列文章,主要介绍通过R语言连接使用nosql数据库.涉及的 ...
- Centos中安装Sublime编辑器
Centos中安装Sublime编辑器 1.从官网下载相应操作系统的下的安装包(http://www.sublimetext.com/2),这里下的是linux下的安装包 2.解压安装包,并将其放在/ ...
- centos中安装tomcat6
在centos中安装tomcat6 1)通过yum自动安装tomcat和dependences root@Centos_AAA ~]# yum install tomcat6 [root@Cent ...
- 在Centos中安装HustOJ实验记录
hustoj是目前使用最广泛的刷题平台,自建平台是编程教学中重要一环,教,学,测,反思形成闭合回路.目前利用现有的服务器资源,建成了开高开源code中心,一个刷题系统,六月再建一个私有云,私有云不仅是 ...
随机推荐
- 20155203 2016-2017-2 《Java程序设计》第2周学习总结
20155203 2016-2017-2 <Java程序设计>第2周学习总结 教材学习内容总结 第三章的主要内容是使用Java语言设计程序的基础语法的学习 java语言中的计算:如果两个数 ...
- day 10 文件
1.文本文件 ,二进制文件 二进制文件:用vi 打开一个图片,MP3,视频 2.文件打开方式 # 重定向 文件不存在 文件存在 r error 文件开头 w 相当于 > 创建 覆盖,删除以前的内 ...
- luogu 2051 [AHOI2009]中国象棋
luogu 2051 [AHOI2009]中国象棋 真是一道令人愉♂悦丧心并框的好题... 首先"没有一个炮可以攻击到另一个炮"有个充分条件就是没有三个炮在同一行或同一列.证明:显 ...
- 了解ASP.NET Core 依赖注入,看这篇就够了
DI在.NET Core里面被提到了一个非常重要的位置, 这篇文章主要再给大家普及一下关于依赖注入的概念,身边有工作六七年的同事还个东西搞不清楚.另外再介绍一下.NET Core的DI实现以及对实例 ...
- Spring学习(五)-----注入bean属性的三种方式( 1: 正常的方式 2: 快捷方式 3: “p” 模式)
在Spring中,有三种方式注入值到 bean 属性. 正常的方式 快捷方式 “p” 模式 看到一个简单的Java类,它包含两个属性 - name 和 type.稍后将使用Spring注入值到这个 b ...
- linux-ubuntu常用命令(深圳文鹏)
系统信息 arch 显示机器的处理器架构(1) uname -m 显示机器的处理器架构(2) uname -r 显示正在使用的内核版本 dmidecode -q 显示硬件系统部件 - (SMBIOS ...
- Linux 安装FastDFS<单机版>(使用Mac远程访问)
阅读本文需要先阅读安装FastDFS<准备> 一 编译环境 yum install gcc-c++ yum -y install libevent yum install -y pcre ...
- Phaser3 屏幕适配iPhoneX、iPhoneXs的坑 -- JavaScript Html5 游戏开发
PhaserJS 坑:在config内不要把 width 设为 window.innnerWidth在config内不要把 width 设为 window.innnerWidth在config内不 ...
- Ryu学习总结(持续更新)
Ryu学习总结 该篇学习笔记,与其他分析Ryu控制器代码的笔记不同,主要按照程序的构成来进行分块总结,由于本人为新手入门,不能保证没有错误,如果发现错误,欢迎指教. 以下的内容主要来源: 源码 官方文 ...
- Memcached&PHP-Memcache安装配置
参考文档: memcache官网:https://memcached.org/ 参考:http://www.runoob.com/memcached/memcached-install.html 参考 ...