#!/bin/bash
####redis版本为4.2.0,需要php5.6以上才支持,可先将安装包上传到/tools目录。

yum -y install wget
yum -y install unzip

mkdir /tools
mkdir -p /app/redis-5.0.3/
cd /tools
wget http://download.redis.io/releases/redis-5.0.3.tar.gz
tar xzf redis-5.0.3.tar.gz
cd /tools/redis-5.0.3
make
make PREFIX=/app/redis-5.0.3/ install
ln -s /app/redis-5.0.3/ /app/redis
echo 'PATH=/app/redis/bin/:$PATH' >>/etc/profile ##有$符号,最好手工操作写入
sleep 3
. /etc/profile
mkdir /app/redis/conf
cp /tools/redis-5.0.3/redis.conf /app/redis/conf/
#在/app/redis-5.0.3/目录下,运行./utils/install_server.sh配置向导来配置redis,并且可以将redis服务加到开机自启动中。【重要】
##最大限度使用内存
sysctl vm.overcommit_memory=1

echo "vm.overcommit_memory = 1" >> /etc/sysctl.conf

sed -i "s/# requirepass foobared/requirepass w3e123/g" /app/redis/conf/redis.conf
sed -i "s@bind 127.0.0.1@bind 0.0.0.0@g" /app/redis/conf/redis.conf
redis-cli shutdown save
redis-server /app/redis/conf/redis.conf &

##为php安装redis客户端扩展(php部分视php安装路径而定,安装后php才能调用redis)
##安装后查看php输出信息,检查是否安装成功(以下需要php5.6以上才支持,确定php路径后可启用##部分)。
cd /tools
wget https://github.com/nicolasff/phpredis/archive/master.zip
##wget https://github.com/nicolasff/phpredis/archive/master.zip --no-check-certificate
unzip master.zip
##cd /tools/phpredis-master/
##/usr/local/php/bin/phpize
##./configure -with-php-config=/usr/local/php56/bin/php-config
##make
##make install
##echo "extension=redis.so" >>/usr/local/php56/etc/php.ini
##/etc/init.d/php-fpm stop
##/etc/init.d/php-fpm start

#######python扩展安装(python要先升级到2.7以上)##########
cd /tools
wget https://files.pythonhosted.org/packages/38/75/06ce149efb17817c9ad2428c571372cf2c31b28cee8a4199994ba8fab954/redis-3.2.0.tar.gz
tar zxvf redis-3.2.0.tar.gz
cd /tools/redis-3.2.0
python setup.py install
##python ##测试部分
##import redis
##r = redis.Redis(host='172.16.210.122',port=6379,password='w3e123',db=0)
##r.set('id008','00008')
##r.get('id008')
##r.dbsize()
##r.keys()

##############其它操作####################
##关闭:redis-cli shutdown save
## help @list
##进入redis: redis-cli -a w3e123
##set id01 001
##getset id01 001
##mset id008 ricky age 33 sex male work it
## mget id008 age sex work
##append id01 kkkk
##get id01
##del id01
##get id01
##exists id01
##redis默认有16个库
##keys *
##select 1
##echo "set id004 0004"|nc 127.0.0.1 6379
##redis-cli -a w3e123
###auth w3e123
##echo "get id004"|nc 127.0.0.1 6379
##bgsave 保存。

#####配置文档redis.conf##################
## 218 save 900 1 #这些会阻塞客户端的请求
## 219 save 300 10
## 220 save 60 10000
##

########多实例##################
##cp redis.conf 到一个自己定义好的目录,如/app/redis/conf/6381/redis.conf,
###并修改配置文档里的port、pidfile(pidfile /app/redis/data/6381/redis_6381.pid)和保存数据的dir(dir /app/redis/data/6380/),
##以命令redis-server /app/redis/conf/6381/redis.conf & 启动即可。

#######主从同步###############
##以下配置后即是变为从库:
##cat >> /app/redis/conf/redis.conf << EOF
##slaveof 172.16.210.122 6379
##masterauth w3e123
##EOF

##从库进入客户端(redis-cli -a w3e123)后用monitor命令可以知道与主库的同步情况
##egrep "^slave|^master" /app/redis/conf/redis.conf ,查看配置。
##repl-backlog-size 1mb 不能设置过小,不然当从库断开又重新连上时,可能会丢失数据
##slave-priority 100 设置从库的优先级,当主库宕机时,优先级高的从库将成为主库
##客户端下查看配置设备:info (全部) ; info cpu (查cpu)

##Redis没有用户的概念,但可以设密码。
##rename-command set "" ##禁用命令set

redis搭建实录的更多相关文章

  1. ELK+redis搭建nginx日志分析平台

    ELK+redis搭建nginx日志分析平台发表于 2015-08-19   |   分类于 Linux/Unix   |  ELK简介ELKStack即Elasticsearch + Logstas ...

  2. 使用elk+redis搭建nginx日志分析平台

    elk+redis 搭建nginx日志分析平台 logstash,elasticsearch,kibana 怎么进行nginx的日志分析呢?首先,架构方面,nginx是有日志文件的,它的每个请求的状态 ...

  3. ELK_elk+redis 搭建日志分析平台

    这个是最新的elk+redis搭建日志分析平台,今年时间是2015年9月11日. Elk分别为 elasticsearch,logstash, kibana 官网为:https://www.elast ...

  4. linux下利用elk+redis 搭建日志分析平台教程

    linux下利用elk+redis 搭建日志分析平台教程 http://www.alliedjeep.com/18084.htm   elk 日志分析+redis数据库可以创建一个不错的日志分析平台了 ...

  5. 基于springboot+bootstrap+mysql+redis搭建一套完整的权限架构【六】【引入bootstrap前端框架】

    https://blog.csdn.net/linzhefeng89/article/details/78752658 基于springboot+bootstrap+mysql+redis搭建一套完整 ...

  6. 安装logstash+kibana+elasticsearch+redis搭建集中式日志分析平台

    安装logstash+kibana+elasticsearch+redis搭建集中式日志分析平台 2014-01-16 19:40:57|  分类: logstash |  标签:logstash   ...

  7. Spring Boot 项目学习 (三) Spring Boot + Redis 搭建

    0 引言 本文主要介绍 Spring Boot 中 Redis 的配置和基本使用. 1 配置 Redis 1. 修改pom.xml,添加Redis依赖 <!-- Spring Boot Redi ...

  8. Redis搭建Windows平台

    安装程序下载 从官网下载安装程序. https://redis.io/download https://github.com/MicrosoftArchive/redis/releases 新地址:h ...

  9. 基于 Node.js 的服务器自动化部署搭建实录

    基于 Node.js 的服务器自动化部署搭建实录 在服务器上安装 Node.js 编写拉取仓库.重启服务器脚本 配置 Github 仓库的 Webhook 设置 配置 Node.js 脚本 其他问题 ...

随机推荐

  1. /sbin/mount.vboxsf: mounting failed with the error: Protocol error

    公司换了新电脑,需要把之前的虚拟机的配置全部备份下来,在移动的过程中挂载共享文件夹时候出现了 /sbin/mount.vboxsf: mounting failed with the error: P ...

  2. PSD转HTML

    随着时间的推移,技术的进步,越来越多的人也越来越熟悉HTML和CSS以及不同的技术来将 Photoshop 设计转换成 HTML 或 CSS 格式.对于一个设计师或网页开发人员,知道如何将PSD文件转 ...

  3. markdownPad常用功能示例

    1.列表 无序列表 姓名 张三 李四 王五 有序列表 张三 李四 王五 2.超链接 百度 3.引用 锄禾日当午,汗滴禾下土.谁知盘中餐,粒粒皆辛苦. -- 李绅<古风二首> 4.简要修饰文 ...

  4. js 函数对象的继承 inherit 带 插件完整解析版[helpers.js]

    前言:         本人纯小白一个,有很多地方理解的没有各位大牛那么透彻,如有错误,请各位大牛指出斧正!小弟感激不尽.         本篇文章为您分析一下原生JS的对象继承方法 需求分析: 1. ...

  5. 计算2的n次幂htm代码

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. Eclipse新建类的时候如何自动添加注释(作者,时间,版本等信息)

    为什么80%的码农都做不了架构师?>>>   方法一:Eclipse中设置在创建新类时自动生成注释 windows–>preference  Java–>Code Sty ...

  7. 使用CXF开发Web Service服务

    1.使用CXF开发Web Service服务端 1.1 开发一个Web Service业务接口,该接口要用@WebService修饰 (1)创建一个Java项目MyServer (2)在MyServe ...

  8. 07 模型层 orm相关查询 F查询Q查询 django开启事务

    一.Django终端打印SQL语句 如果你想知道你对数据库进行操作时,Django内部到底是怎么执行它的sql语句时可以加下面的配置来查看 在Django项目的settings.py文件中,在最后复制 ...

  9. oracle常用字符函数

    字符函数: concat:(字符连接函数) --字符连接 select concat('con','cat') from dual; select 'co'||'nc'||'at' from dual ...

  10. 【T-SQL】基础 —— 语法(1)

    USE master--检查是否已经存在一个表,如果有就删除IF(EXISTS(SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = ' ...