AWS EC2 CentOS release 6.5 部署redis
AWS EC2 CentOS release 6.5 部署redis
参考:http://blog.csdn.net/ludonqin/article/details/47211109
一.安装redis
1) 下载redis安装包
可去官网http://redis.io ,也可通过wget命令:
[root@ip-172-31-46-4 ~]# wget http://download.redis.io/redis-stable.tar.gz
2) 解压
执行命令:
[root@ip-172-31-46-4 ~]# tar –zxvf redis-stable.tar.gz
3) 编译、安装
执行命令:
[root@ip-172-31-46-4 ~]# cd redis-stable
执行命令:
[root@ip-172-31-46-4 redis-stable]# make
在make成功以后,需要执行命令:
[root@ip-172-31-46-4 redis-stable]# make test
成功后可手动拷贝src目录下redis-server、redis-cli、redis-check-aof、redis-check-dump等至/usr/local/bin目录下,也可执行命令:
[root@ip-172-31-46-4 redis-stable]# make install
验证系统目录下启动脚本:
[root@ip-172-31-46-4 ~]# cd /usr/local/bin
[root@ip-172-31-46-4 bin]# ls -ltrh
total 26M
-rwxr-xr-x 1 root root 7.5M Jan 7 08:03 redis-server
-rwxr-xr-x 1 root root 5.4M Jan 7 08:03 redis-benchmark
-rwxr-xr-x 1 root root 5.5M Jan 7 08:03 redis-cli
-rwxr-xr-x 1 root root 7.5M Jan 7 08:03 redis-check-rdb
lrwxrwxrwx 1 root root 12 Jan 7 08:03 redis-sentinel -> redis-server
-rwxr-xr-x 1 root root 22K Jan 7 08:03 redis-check-aof
二.修改配置文件.conf
1) 创建配置文件目录,dump file 目录,进程pid目录,log目录等
配置文件一般放在/etc/下,创建redis目录
[root@ip-172-31-46-4 bin]# cd /etc/
[root@ip-172-31-46-4 etc]# mkdir redis
ll 查看创建的redis目录
~
dump file、进程pid、log目录等,一般放在/var/目录下,
[root@ip-172-31-46-4 etc]# cd /var/
[root@ip-172-31-46-4 var]# mkdir redis
[root@ip-172-31-46-4 var]# cd redis
[root@ip-172-31-46-4 redis]# mkdir data log run
至此,目录创建完毕
2) 修改配置文件,配置参数
首先拷贝解压包下的redis.conf文件至/etc/redis
[root@ip-172-31-46-4 redis]# cp ~/redis-stable/redis.conf /etc/redis/
打开配置文件:
[root@ip-172-31-46-4 redis]# vi /etc/redis/redis.conf
修改端口(默认6379)
# Accept connections on the specified port, default is 6379 (IANA #815344).
# If port 0 is specified Redis will not listen on a TCP socket.
port 6379
修改pid目录为新建目录
# Creating a pid file is best effort: if Redis is not able to create it
# nothing bad happens, the server will start and run normally.
pidfile /var/redis/run/redis_6379.pid
修改dump目录为新建目录
# The working directory.
#
# The DB will be written inside this directory, with the filename specified
# above using the 'dbfilename' configuration directive.
#
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
dir /var/redis/data
修改log存储目录为新建目录
# Specify the log file name. Also the empty string can be used to force
# Redis to log on the standard output. Note that if you use standard
# output for logging but daemonize, logs will be sent to /dev/null
logfile /var/redis/log/redis.log
修改配置文件使得redis在background运行(默认redis服务是console模式运行的)
# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize yes
3)持久化
默认rdb,可选择是否开启aof,若开启,修改配置文件appendonly
4)启动redis,查看各目录下文件
[root@ip-172-31-46-4 redis]# cd /usr/bin/
[root@ip-172-31-46-4 bin]# redis-server /etc/redis/redis.conf
redis已启动,查看进程,dump, log, pid等
5)客户端连接redis
[root@ip-172-31-46-4 bin]# redis-cli
默认端口6379
6)至此,redis基础配置完毕,若有其他相关配置调整,可查找文档再修改
三.服务及开机自启动
1) 创建redis启动脚本
拷贝解压包下utils下redis启动脚本至/etc/init.d/
[root@ip-172-31-46-4 bin]# cp ~/redis-stable/utils/redis_init_script /etc/init.d/
修改脚本名称(也可不修改)为redis
[root@ip-172-31-46-4 bin]# mv /etc/init.d/redis_init_script /etc/init.d/redis
修改脚本pid及conf路径为实际路径
[root@ip-172-31-46-4 bin]# vi /etc/init.d/redis_init_script
REDISPORT=6379
EXEC=/usr/local/bin/redis-server
CLIEXEC=/usr/local/bin/redis-cli
PIDFILE=/var/redis/run/redis_${REDISPORT}.pid
CONF="/etc/redis/redis.conf"
至此,在/etc/init.d/目录下,已经可以通过:
service redis start/stop 命令启动和关闭redis
若在其他目录下,不能够使用这2个命令,请继续配置2),添加权限
2) 给启动脚本添加权限
chmod +x /etc/init.d/redis
实际命令,根据目录的不同,会不一样
相应的删除权限是
chmod –x /etc/init.d/redis
如果需要在开机的时候,redis服务自动启动,可继续3)
3) 设置自启动
chkconfig redis on
如果运行报错,提示
是因为没有在启动脚本里加入redis启动优先级信息,可添加如下
再次执行chkconfig redis on,成功
至此,自启动配置完毕
--------------------------------------------------------
安装可能出错的地方:
a.如果提示:
gcc command不识别,请自行安装gcc;
(执行:yum -y install gcc)
b.如果提示:
couldn’t execute tcl : no such file or dicrectory,请自行安装tcl;
(执行:yum install -y tcl)
c.如果提示:
zmalloc.h:51:31: error: jemalloc/jemalloc.h: No such file or directory
原因是编译依赖或原来编译遗留出现的问题
(执行:make distclean)
d.如果提示:
zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory
zmalloc.h:55:2: error: #error "Newer version of jemalloc required"
make[1]: *** [adlist.o] Error 1
make[1]: Leaving directory `/data0/src/redis-2.6.2/src'
make: *** [all] Error 2zmalloc.h:50:31: error: jemalloc/jemalloc.h:;
原因是jemalloc重载了Linux下的ANSI C的malloc和free函数
(执行:make MALLOC=libc)
进阶:
配置文件说明,请参考:http://www.cnblogs.com/kreo/p/4423362.html
redis集群搭建,请参考:http://www.cnblogs.com/wuxl360/p/5920330.html
AWS EC2 CentOS release 6.5 部署redis的更多相关文章
- AWS EC2 CentOS release 6.5 部署zookeeper、kafka、dubbo
AWS EC2 CentOS release 6.5 部署zookeeper.kafka.dubbo参考:http://blog.csdn.net/yizezhong/article/details/ ...
- AWS EC2中部署Apache服务器(LAMP)
关键词: 1.新建aws ec2实例 2.使用putty连接到aws ec2 实例(SSH协议) 3.使用filezilla连接到aws ec2实例(SFTP协议) 4.在aws ec2上部署apac ...
- AWS EC2笔记
朋友想搭一个境外网站,找我帮忙,希望服务器.域名都在境外.我没有在境外建站的经历,只能先尝试.于是上网搜索了一下境外服务器,大家比较常用的是Digital Ocean和AWS,我索性打开这两家的官网, ...
- Redis笔记 -- 在 Centos7.4单机中部署Redis集群(二)
0x00--背景和目的 在单台PC服务器上部署Redis集群,通过不同的TCP端口启动多实例,模拟多台独立PC组成集群. 0x01--环境描述: Centos版本:CentOS Linux relea ...
- 部署Redis Cluster 6.0 集群并开启密码认证 和 Redis-cluster-proxy负载
部署Redis Cluster集群并开启密码认证 如果只想简单的搭建Redis Cluster,不需要设置密码和公网访问,可以参考官方文档. 节点介绍 Cluster模式推荐最少有6个节点,本次实验搭 ...
- Amazon AWS EC2开启Web服务器配置
在Amazon AWS EC2申请了一年的免费使用权,安装了CentOS + Mono + Jexus环境做一个Web Server使用. 在上述系统安装好之后,把TCP 80端口开启(iptable ...
- 在Centos 5.6下安装 redis
先引用redis官方(http://redis.io/) 的介绍: Redis is an open source, advanced key-value store.<br>It is ...
- 如何用docker部署redis cluster
前言 由于本人是个docker控,不喜欢安装各种环境,而且安装redis-trib也有点繁琐,索性用docker来做redis cluster. 本文用的是伪集群,真正的集群放到不同的机器即可.端口是 ...
- AWS EC2服务器的HTTPS负载均衡器配置过程
AWS EC2服务器配置负载均衡器步骤: 1.普通负载均衡器 至少两台EC2实例,这里以Centos6.7系统为例 启动之后先安装个apache的httpd服务器默认80端口,或者使用其他服务 ...
随机推荐
- 史上最全TensorFlow学习资源汇总
来源 | 悦动智能(公众号ID:aibbtcom) 本篇文章将为大家总结TensorFlow纯干货学习资源,非常适合新手学习,建议大家收藏. ▌一 .TensorFlow教程资源 1)适合初学者的Te ...
- linux查看日志文件内容命令tail、cat、tac、head、echo
linux查看日志文件内容命令tail.cat.tac.head.echo tail -f test.log你会看到屏幕不断有内容被打印出来. 这时候中断第一个进程Ctrl-C, ---------- ...
- HTTP响应状态解析
100 客户端应当继续发送请求.这个临时响应是用来通知客户端它的部分请求已经被服务器接收,且仍未被拒绝.客户端应当继续发送请求的剩余部分,或者如果请求已经完成,忽略这个响应.服务器必须在请求完成后向客 ...
- [BZOJ]4805: 欧拉函数求和
解题思路类似莫比乌斯函数之和 题目大意:求[1,n]内的欧拉函数$\varphi$之和.($n<=2*10^{9}$) 思路:令$ M(n)=\sum_{i=1}^{n}\varphi (i) ...
- ●BZOJ 1006 [HNOI2008]神奇的国度(弦图最小染色数)○ZOJ 1015 Fishing Net
●赘述题目 给出一张弦图,求其最小染色数. ●题解 网上的唯一“文献”:<弦图与区间图>(cdq),可以学习学习.(有的看不懂) 摘录几个解决改题所需的知识点: ●子图和诱导子图(一定要弄 ...
- ●BZOJ 4822 [Cqoi2017]老C的任务
题链: https://www.luogu.org/problemnew/show/P3755 (洛谷上数据范围给全了的) 题解: 树状数组,离线询问 (本来想弄一个二维树状数组/二维RMQ,然后直接 ...
- bzoj4558[JLoi2016]方 容斥+count
4558: [JLoi2016]方 Time Limit: 20 Sec Memory Limit: 256 MBSubmit: 452 Solved: 205[Submit][Status][D ...
- springboot由于mysql表类型导致的 setRollbackOnly() 事务不回滚
在SpringBoot 中,使用事务非常简单,只需在方法上面加入 @Transactional 注解就可以实现.也可加在类上,此时则类中所有方法都支持事务. 而当我使用下面代码时,发现事务却没有回滚 ...
- C++内存机制中内存溢出、内存泄露、内存越界和栈溢出的区别和联系
当我们在用C++做底层驱动的时候,经常会遇到内存不足的警告,究其原因,往往是因为内存出现溢出,泄露或者越界等原因.那么他们之间有什么联系吗? 内存溢出(out of memory) 是指程序在申请内存 ...
- Python之作业购物车
作业之购物车优化 购物车优化要求如下: 用户入口: 启动程序后,输入用户名密码后,如果是第一次登录,让用户输入工资,然后打印商品列表 允许用户根据商品编号购买商品 用户选择商品后,检测余额是否够,够就 ...