安装mariadb +主从复制https://www.cnblogs.com/pyyu/p/9467289.html

参考博客 redis https://www.cnblogs.com/pyyu/p/9843950.html

redis发布订阅

三个角色,提供的redis命令
.发布者
publish 频道 消息 给频道发消息
.订阅者
SUBSCRIBE 频道 订阅频道
PSUBSCRIBE 频道* 支持模糊匹配的订阅
.频道
channel 频道名 自定义

redis发布订阅

redis持久化之RDB
.在配置文件中添加参数,开启rdb功能
redis.conf 写入
port
daemonize yes
logfile /data//redis.log
dir /data/
dbfilename s15.rdb
save #rdb机制 每900秒 有1个修>改记录
save #每300秒 10个修改
记录
save #每60秒内 10000修>改记录
.开启redis服务端,测试rdb功能
redis-server redis.conf

redis持久化之RDB

.开启aof功能,在redis.conf中添加参数
port
daemonize yes
logfile /data//redis.log
dir /data/
appendonly yes
appendfsync everysec
.启动redis服务端,指定aof功能,测试持久化数据

redis持久化之aof

.准备rdb的redis服务端
redis-server s15-redis.conf (注明这是在rdb持久化模式下) .切换rdb到aof
redis-cli 登录redis,然后通过命令,激活aof持久化
127.0.0.1:> CONFIG set appendonly yes #用命令激活aof持久化(临时生效,注意写入到配置文件)
OK
127.0.0.1:>
127.0.0.1:>
127.0.0.1:> CONFIG SET save "" #关闭rdb持久化 2.5 将aof操作,写入到配置文件,永久生效,下次重启后生效
port
daemonize yes
logfile /data//redis.log
dir /data/ #dbfilename s15.rdb
#save
#save
#save
appendonly yes
appendfsync everysec .测试aof数据持久化 ,杀掉redis,重新启动
kill
redis-server s15-redis.conf .写入数据,检查aof文件

redis不重启之rdb数据切换到aof数据

.检查redis数据库信息,主从状态的命令
redis-cli -p info 检查数据库信息
redis-cli -p info replication 检查数据库主从信息 .准备三个redis配置文件,通过端口的区分,启动三个redis数据库实例,然后配置主从复制
redis-.conf
port
daemonize yes
pidfile /data//redis.pid
loglevel notice
logfile "/data/6379/redis.log"
dbfilename dump.rdb
dir /data/ redis-.conf
#通过命令快速生成配置文件
sed "s/6379/6380/g" redis-.conf > redis-.conf
slaveof 127.0.0.1 #指明主库的身份ip 和端口 redis-.conf
#通过命令快速生成配置文件
sed "s/6379/6381/g" redis-.conf > redis-.conf
slaveof 127.0.0.1 .启动三个数据库实例,检测redis主从同步方案 .redis主从赋值,故障手动切换,
.杀死6379的主库实例
kill 主库 .手动切换主从身份
.登录 redis- ,通过命令,去掉自己的从库身份,等待连接
info replication 查看自己的身份状态
slaoveof no one
.登录redis- ,通过命令,生成新的主任
slaveof 127.0.0.1 .测试新的主从数据同步

redis的主从同步

.什么是哨兵呢?保护redis主从集群,正常运转,当主库挂掉之后,自动的在从库中挑选新的主库,进行同步

.redis哨兵的安装配置
. 准备三个redis数据库实例(三个配置文件,通过端口区分)
redis-server redis-.conf
redis-server redis-.conf
redis-server redis-.conf
.准备三个哨兵,准备三个哨兵的配置文件(仅仅是端口的不同26379,,)
touch redis-sentinel-.conf
port
dir /var/redis/data/
logfile "26379.log" sentinel monitor s15master 127.0.0.1 sentinel down-after-milliseconds s15master sentinel parallel-syncs s15master sentinel failover-timeout s15master
daemonize yes touch redis-sentinel-.conf
快速生成配置文件
sed "s/26379/26380/g" redis-sentinel-.conf > redis-sentinel-.conf
touch redis-sentinel-.conf
sed "s/26379/26381/g" redis-sentinel-.conf > redis-sentinel-.conf 运行时先创建文件
mkdir -p /var/redis/data .启动三个哨兵
redis-sentinel redis-sentinel-.conf
redis-sentinel redis-sentinel-.conf
redis-sentinel redis-sentinel-.conf .检查哨兵的通信状态 redis-cli -p info sentinel
查看结果如下之后,表示哨兵正常
最后那里
# Sentinel
sentinel_masters:
sentinel_tilt:
sentinel_running_scripts:
sentinel_scripts_queue_length:
sentinel_simulate_failure_flags:
master0:name=s15master,status=ok,address=127.0.0.1:,slaves=,sentinels= 运行 redis-cli -p info replication 检查role:slave 状态 .杀死一个redis主库,6379节点,等待30s以内,检查6380和6381的节点状态
kill 6379主节点
redis-cli -p info replication
redis-cli -p info replication
如果切换的主从身份之后,(原理就是更改redis的配置文件,切换主从身份) .恢复6379节点的数据库,查看是否将6379添加为新的slave身份
redis-server redis-.conf
redis-cli -p info replication

redis哨兵

redis-cluster安装配置
.准备6个redis数据库实例,准备6个配置文件redis-{....}配置文件
redis-.conf
redis-.conf
redis-.conf
redis-.conf
redis-.conf
redis-.conf 配置文件 port
daemonize yes
dir "/opt/redis/data"
logfile "7005.log"
dbfilename "dump-7005.rdb"
cluster-enabled yes
cluster-config-file nodes-.conf  sed "s/7000/7001/g" redis-.conf > redis-.conf
sed "s/7000/7002/g" redis-.conf > redis-.conf
sed "s/7000/7003/g" redis-.conf > redis-.conf
sed "s/7000/7004/g" redis-.conf > redis-.conf
sed "s/7000/7005/g" redis-.conf > redis-.conf .启动6个redis数据库实例
redis-server redis-.conf
redis-server redis-.conf
redis-server redis-.conf
redis-server redis-.conf
redis-server redis-.conf
redis-server redis-.conf .配置ruby语言环境,脚本一键启动redis-cluster
.下载ruby语言的源码包,编译安装
wget https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.1.tar.gz
.解压缩
./configure --prefix=/opt/ruby/ 释放makefile
make && make install 编译且安装
.下载安装ruby操作redis的模块包
wget http://rubygems.org/downloads/redis-3.3.0.gem .配置ruby的环境变量
echo $PATH vim /etc/profile
写入最底行
PATH=$PATH:/opt/ruby/bin/
读取文件
source /etc/profile .通过ruby的包管理工具去安装redis包,安装后会生成一个redis-trib.rb这个命令
/opt/ruby/bin/gem install -l redis-3.3..gem 一键创建redis-cluster 其实就是分配主从关系 以及 槽位分配 slot槽位分配
/opt/redis-4.0./src/redis-trib.rb create --replicas 127.0.0.1: 127.0.0.1: 127.0.0.1: 127.0.0.1: 127.0.0.1: 127.0.0.1: .检查节点主从状态
redis-cli -p info replication .向redis集群写入数据,查看数据流向
redis-cli -p #这里会将key自动的重定向,放到某一个节点的slot槽位中
set name s15
set addr shahe

一键创建集群

.yum解决编译nginx所需的依赖包,之后你的nginx就不会报错了

    yum install gcc patch libffi-devel python-devel  zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel openssl openssl-devel -y

.安装配置nginx软件,下载源代码
wget -c https://nginx.org/download/nginx-1.12.0.tar.gz
.解压缩源码,编译且安装
tar -zxvf nginx-1.12..tar.gz
切换源码目录
./configure --prefix=/opt/nginx112/
make && make install
.进入nginx的工作目录
cd /opt/ngin112/ .查看gninx的工作目录
[root@localhost nginx112]# ls
conf 配置文件目录
html 网页根目录,你的index.html就放在这里,然后通过域名访问 pythonav.cn/index.html html/index.html
logs 日志
sbin 存放nginx可执行命令的 .定制自己的nginx网站
修改/opt/nginx112/html/index.html 这是nginx网页根文件,清空内容写入自己的html标签 .启动nginx服务器
/opt/nginx112/sbin/nginx 直接回车执行 .检查nginx服务端口
ps -ef|grep nginx .通过windows访问nginx web服务
浏览器 访问http://192.168.13.79

nginx 入门学习

最新文章

  1. Netbeans+CodeIgniter搭建PHP开发环境
  2. C# ~ 泛型委托
  3. JavaScript学习笔记-实例详解-类(二)
  4. Android源码剖析之Framework层实战版(Ams管理Activity启动)
  5. datatables中columns.render的使用
  6. Hbase之使用回调函数进行批处理操作
  7. ConnectionReset
  8. AJAX技术的核心
  9. oracle sql语句
  10. SAE 上传根目录不存在!请尝试手动创建:./Uploads/Picture/
  11. .NET和JAVA 反射对比
  12. linux pxe网络装机无人值守
  13. Android BLE与终端通信(一)——Android Bluetooth基础API以及简单使用获取本地蓝牙名称地址
  14. 用Redis管理Session
  15. 开发宏功能:excel中从sheet批量插入
  16. PHPcms 缓存的读取和设置
  17. 内层DIV超出后,出现滚动条问题
  18. Winform开发框架之通用附件管理模块 --SNF快速开发平台3.3-Spring.Net.Framework
  19. python的ConfigParser模块
  20. Cache: a place for concealment and safekeeping.Cache: 一个隐藏并保存数据的场所

热门文章

  1. 【总结整理】overflow: auto/hidden;清除自己
  2. wpf label下划线不显示的问题
  3. jmeter响应结果乱码问题
  4. JavaScript学习系列5 ---ES6中的var, let 和const
  5. 【OpenGL】Shader概述
  6. webconfig配置详解--转
  7. PS2018学习笔记(25-29节)
  8. CEPH安装教程(下)
  9. PHP现阶段发现的不足点
  10. PAT L2-006【二叉树中序后序构造树】