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端口,或者使用其他服务 ...
随机推荐
- POJ-1068 Parencodings---模拟括号的配对
题目链接: https://vjudge.net/problem/POJ-1068 题目大意: 给出一种括号序列的表示形式名叫P序列,规则是统计出每个右括号之前的左括号个数作为序列每项的值.然后要求你 ...
- Windows下使用console线连接思科交换机
在XP下可以直接使用内置工具"超级终端",在win7或者更高版本需要下载安装SecureCRT. 本文假设已经下载安装好了SecureCRT. 首先,将电脑连接console线.因 ...
- JavaScript数据结构与算法(六) 链表的实现
// 链表存储有序的元素集合,但不同于数组,链表中的元素在内存中并不是连续放置的.每个 // 元素由一个存储元素本身的节点和一个指向下一个元素的引用(也称指针或链接)组成.下图展 // 示了一个链表的 ...
- 页面中引入mui 地址选择,点击页面中其他input时页面回到顶部
问题:在页面中引入mui地址选择时,点击页面中的input页面会滚到顶部(谷歌浏览器中出现的bug),在手机上点击input会出现跳动.开始的时候是想修改mui.min.js里的滚动事件,但是后来找到 ...
- SQL注入 手注与联合注入
SQL注入,吧sql命令插入到WEB表单,或输入域名或页面亲求的查询字符串,最终达到欺骗服务器执行恶意的SQL命令: 得到数据库用户名和密码 1:在以,{ .asp?id=32( ...
- 推送本地项目至Github遇到的问题以及解决办法记录
在把本地新项目推送至GitHub仓库时的大致流程和步骤,首先现在GitHub上面新建一个项目,复制该项目的 带.git 后缀的地址,比如 git@github.com:XXX/XXX.git 然后在本 ...
- [NOIp 2014]解方程
Description 已知多项式方程: a0+a1x+a2x^2+..+anx^n=0 求这个方程在[1, m ] 内的整数解(n 和m 均为正整数) Input 输入文件名为equation .i ...
- NOIP 2011 观光公交
题目描述 风景迷人的小城Y 市,拥有n 个美丽的景点.由于慕名而来的游客越来越多,Y 市特意安排了一辆观光公交车,为游客提供更便捷的交通服务.观光公交车在第 0 分钟出现在 1号景点,随后依次前往 2 ...
- codeforces 523D tatistics of Recompressing Videos
一个称为DH(DogHouse)的狗的社交网络有k台专用服务器来重新上传可爱的猫的上传视频.每个视频上传后,应该在一个(任何)服务器上重新压缩,之后才可以保存在社交网络中. 我们知道每个服务器需要一秒 ...
- ●BZOJ 1499 [NOI2005]瑰丽华尔兹
题链: http://www.lydsy.com/JudgeOnline/problem.php?id=1499 题解: 单调队列优化DP 定义 dp[t][x][y] 表示第t个时间段之后,处在(x ...