Centos6.5安装Redis3.0备忘记录
2019-04-17 23:30
204 查看
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_36645607/article/details/89367539
文章目录
- Centos6.5安装Redis3.0
- 1. 安装C编译环境
- 2. 将redis3.0上传到Linux上
- 3. 解压redis,我这里解压到/usr/local下
- 4.编译
- 5. 安装
- 6. 修改配置文件
- 7. 后台启动测试
- 8. 客户端登录及测试
- 9. 远程访问配置
- 10. Java连接测试
Centos6.5安装Redis3.0
1. 安装C编译环境
首先需要安装编译Redis的C环境,在命令行执行以下命令:
[root@itzhouq32 tools] yum install gcc-c++
2. 将redis3.0上传到Linux上
3. 解压redis,我这里解压到/usr/local下
[root@itzhouq32 tools]# tar -xvf redis-3.0.0.tar.gz -C /usr/local
4.编译
进入解压的目录,使用make编译
[root@itzhouq32 tools]# cd /usr/local/ [root@itzhouq32 local]# ls bin games jdk1.8.0_201 lib64 redis-3.0.0 share src etc include lib libexec sbin soft tomcat [root@itzhouq32 local]# cd redis-3.0.0/ [root@itzhouq32 redis-3.0.0]# ls 00-RELEASENOTES COPYING Makefile redis.conf runtest-sentinel tests BUGS deps MANIFESTO runtest sentinel.conf utils CONTRIBUTING INSTALL README runtest-cluster src [root@itzhouq32 redis-3.0.0]# make
5. 安装
在原来的目录下安装,当前目录为/usr/local/redis
[root@itzhouq32 redis-3.0.0]# make PREFIX=/usr/local/redis install
6. 修改配置文件
进入redis-3.0.0的目录,找到redis.conf配置文件,将其拷贝到redis/bin目录下
[root@itzhouq32 local]# ls bin games jdk1.8.0_201 lib64 redis sbin soft tomcat etc include lib libexec redis-3.0.0 share src [root@itzhouq32 local]# cd redis-3.0.0/ [root@itzhouq32 redis-3.0.0]# ls 00-RELEASENOTES COPYING Makefile redis.conf runtest-sentinel tests BUGS deps MANIFESTO runtest sentinel.conf utils CONTRIBUTING INSTALL README runtest-cluster src [root@itzhouq32 redis-3.0.0]# cp redis.conf ../redis/bin/
返回redis/bin目录,修改redis.conf配置文件
[root@itzhouq32 redis-3.0.0]# cd ../redis/bin/ [root@itzhouq32 bin]# ls dump.rdb redis-check-aof redis-cli redis-sentinel redis-benchmark redis-check-dump redis.conf redis-server [root@itzhouq32 bin]# vi redis.conf
将redis.conf文件中的daemonize从false修改成true表示后台启动
7. 后台启动测试
[root@itzhouq32 bin]# ./redis-server redis.conf [root@itzhouq32 bin]# ps -ef | grep redis root 4653 4628 0 16:56 pts/1 00:00:00 ./redis-cli root 4702 1 0 17:11 ? 00:00:02 ./redis-server *:6379 root 4782 1631 0 17:37 pts/0 00:00:00 grep redis [root@itzhouq32 bin]#
进程中有redis,说明后台启动成功。
8. 客户端登录及测试
[root@itzhouq32 bin]# ./redis-cli 127.0.0.1:6379> set username zhangsan OK 127.0.0.1:6379> get username "zhangsan" 127.0.0.1:6379> exit [root@itzhouq32 bin]#
9. 远程访问配置
如果需要远程访问redis,需要在Linux防火墙中开放6379端口,并将规则保存到防火墙中。
[root@itzhouq32 bin]# /sbin/iptables -I INPUT -p tcp --dport 6379 -j ACCEPT [root@itzhouq32 bin]# /etc/rc.d/init.d/iptables save iptables:将防火墙规则保存到 /etc/sysconfig/iptables: [确定] [root@itzhouq32 bin]#
10. Java连接测试
在Eclipse中导入jar包,编写一个测试类。
package com.itzhouq.jedis; import org.junit.Test; import redis.clients.jedis.Jedis; public class JedisTest { @Test public void test01() { //1. 获得连接对象 Jedis jedis = new Jedis("192.168.146.132", 6379); //2. 获得数据 String username = jedis.get("username"); System.out.println(username);//zhangsan //3. 存储 jedis.set("addr", "上海"); System.out.println(jedis.get("addr"));//上海 } }
相关文章推荐
- CentOS 6.5 Redis3.0安装部署
- CentOS 6.5 安装 Redis 记录
- centos6.5安装配置redis3.0
- centos6.5安装配置redis3.0
- centos6.5安装配置redis
- CentOS 6.5下Redis安装记录
- Centos6.5 linux下安装Redis3.2.9
- CentOS 6.5下Redis安装配置记录
- Centos 6.5+Tengine(Nginx)+Django+uwsgi 安装记录
- centos6.5安装redis
- centos6.5 安装redis-2.8.13.tar.gz
- 大数据之Hadoop平台(二)Centos6.5(64bit)Hadoop2.5.1伪分布式安装记录,wordcount运行测试
- redis安装在centos6.5
- 点滴记录——Centos 6.5 yum安装Ganglia
- CentOS 6.5 下安装 Redis 2.8.7
- Centos6.5安装IPython3.0
- 解决redis在centos自带ruby版本太低问题centos 6.5 ruby环境安装2.2+
- centos安装redis3.0及phpredis扩展使用
- Centos6.5安装Metasploit记录