当前位置: 首页 > news >正文

娄底网站开发seo优化必备技巧

娄底网站开发,seo优化必备技巧,广告喷绘制作公司介绍,网站建设程序开发Redis主从配置 为提升Redis的高可用性,需要搭建多个Redis集群以保证高可用性。常见搭建方式有:主从,哨兵集群等,本节我们搭建一主二从的多Redis架构。 redis主从安装1主2从的方式配置,以端口号为redis的主从文件夹。 主…

Redis主从配置

为提升Redis的高可用性,需要搭建多个Redis集群以保证高可用性。常见搭建方式有:主从,哨兵集群等,本节我们搭建一主二从的多Redis架构。

redis主从安装1主2从的方式配置,以端口号为redis的主从文件夹。

主(master): 6379

从(slave): 6380, 6381

image-20230727164649219

redis主服务器(master:6379)

使用vim工具打开配置文件,修改里面的内容。

NETWORK模块
 ################################## NETWORK #####################################47 48 # By default, if no "bind" configuration directive is specified, Redis listens49 # for connections from all available network interfaces on the host machine.50 # It is possible to listen to just one or multiple selected interfaces using51 # the "bind" configuration directive, followed by one or more IP addresses.52 # Each address can be prefixed by "-", which means that redis will not fail to53 # start if the address is not available. Being not available only refers to54 # addresses that does not correspond to any network interfece. Addresses that55 # are already in use will always fail, and unsupported protocols will always BE48 # By default, if no "bind" configuration directive is specified, Redis listens49 # for connections from all available network interfaces on the host machine.50 # It is possible to listen to just one or multiple selected interfaces using51 # the "bind" configuration directive, followed by one or more IP addresses.52 # Each address can be prefixed by "-", which means that redis will not fail to53 # start if the address is not available. Being not available only refers to54 # addresses that does not correspond to any network interfece. Addresses that55 # are already in use will always fail, and unsupported protocols will always BE56 # silently skipped.57 #58 # Examples:59 #60 # bind 192.168.1.100 10.0.0.1     # listens on two specific IPv4 addresses61 # bind 127.0.0.1 ::1              # listens on loopback IPv4 and IPv662 # bind * -::*                     # like the default, all available interfaces63 #64 # ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the65 # internet, binding to all the interfaces is dangerous and will expose the66 # instance to everybody on the internet. So by default we uncomment the67 # following bind directive, that will force Redis to listen only on the68 # IPv4 and IPv6 (if available) loopback interface addresses (this means Redis69 # will only be able to accept client connections from the same host that it is70 # running on).71 #72 # IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES73 # JUST COMMENT OUT THE FOLLOWING LINE.74 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~75 bind 127.0.0.1 -::1

修改ip绑定地址为全网可访问。

bind *0.0.0.0 全网可访问

75 bind 0.0.0.0
image-20231125102224377
protected-mode
  77 # Protected mode is a layer of security protection, in order to avoid that78 # Redis instances left open on the internet are accessed and exploited.79 #80 # When protected mode is on and if:81 #82 # 1) The server is not binding explicitly to a set of addresses using the83 #    "bind" directive.84 # 2) No password is configured.85 #86 # The server only accepts connections from clients connecting from the87 # IPv4 and IPv6 loopback addresses 127.0.0.1 and ::1, and from Unix domain88 # sockets.89 #90 # By default protected mode is enabled. You should disable it only if91 # you are sure you want clients from other hosts to connect to Redis92 # even if no authentication is configured, nor a specific set of interfaces93 # are explicitly listed using the "bind" directive.94 protected-mode yes
  • 保护模式是一个避免你在互联网(外网)访问redis的机制。
  • 当启用保护模式,而且没有密码时,服务器只接受来自IPv4地址(127.0.0.1)、IPv6地址(::1)或Unix套接字本地连接。(没密码+保护模式启动=本地访问)
  • 默认是开启的
94 protected-mode no
image-20231125102552377
修改日志
修改日志级别为DEBUG
 293 # Specify the server verbosity level.294 # This can be one of:295 # debug (a lot of information, useful for development/testing)296 # verbose (many rarely useful info, but not a mess like the debug level)297 # notice (moderately verbose, what you want in production probably)298 # warning (only very important / critical messages are logged)299 loglevel notice
image-20231125105436936
修改日志的输出位置

定义日志文件的输出位置到/var/log/redis.log

 301 # Specify the log file name. Also the empty string can be used to force302 # Redis to log on the standard output. Note that if you use standard303 # output for logging but daemonize, logs will be sent to /dev/null304 logfile ""
image-20231125105737726
配置本机ip和端口

主服务器部署在Docker或者其他网络代理工具,会使主服务器的ip,端口改变时,可以在配置// 文件中声明主服务器原始的ip和端口。

定义replica-announce-ip 和端口

tip: ip,port是linux的ip地址和端口号(不是容器内部ip,否则外界不能访问)。

192.168.xxx.yyy —linux服务器的ip地址

706 # A Redis master is able to list the address and port of the attached707 # replicas in different ways. For example the "INFO replication" section708 # offers this information, which is used, among other tools, by709 # Redis Sentinel in order to discover replica instances.710 # Another place where this info is available is in the output of the711 # "ROLE" command of a master.712 #713 # The listed IP address and port normally reported by a replica is714 # obtained in the following way:715 #716 #   IP: The address is auto detected by checking the peer address717 #   of the socket used by the replica to connect with the master.718 #719 #   Port: The port is communicated by the replica during the replication720 #   handshake, and is normally the port that the replica is using to721 #   listen for connections.722 #723 # However when port forwarding or Network Address Translation (NAT) is724 # used, the replica may actually be reachable via different IP and port725 # pairs. The following two options can be used by a replica in order to726 # report to its master a specific set of IP and port, so that both INFO727 # and ROLE will report those values.728 #729 # There is no need to use both the options if you need to override just730 # the port or the IP address.731 #732 # replica-announce-ip 5.5.5.5733 # replica-announce-port 1234
image-20231125110817091
查看redis状态
127.0.0.1:6379> info replication
# Replication
role:master
connected_slaves:0
master_failover_state:no-failover
master_replid:9ab01d97e6c3f5bd43ea60ddfc7cc42dddfa5fc4
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:0
second_repl_offset:-1
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
image-20231125163336145

redis从服务器配置(6380)

配置6380/conf/redis.conf文件

上传配置文件redis.conf

image-20230727161242302

配置主从 Master-Replica replication
 458 ################################# REPLICATION #################################459 460 # Master-Replica replication. Use replicaof to make a Redis instance a copy of461 # another Redis server. A few things to understand ASAP about Redis replication.462 #463 #   +------------------+      +---------------+464 #   |      Master      | ---> |    Replica    |465 #   | (receive writes) |      |  (exact copy) |466 #   +------------------+      +---------------+467 #468 # 1) Redis replication is asynchronous, but you can configure a master to469 #    stop accepting writes if it appears to be not connected with at least470 #    a given number of replicas.471 # 2) Redis replicas are able to perform a partial resynchronization with the472 #    master if the replication link is lost for a relatively small amount of473 #    time. You may want to configure the replication backlog size (see the next474 #    sections of this file) with a sensible value depending on your needs.475 # 3) Replication is automatic and does not need user intervention. After a476 #    network partition replicas automatically try to reconnect to masters477 #    and resynchronize with them.478 #479 # replicaof <masterip> <masterport>
image-20231125164603387
配置从只读

在配置文件末尾添加: slave-read-only yes(旧版本),新版本默认为从只读。

image-20231125173329121
配置服务器ip地址

修改redis.conf文件中的replica-announce-ip/port为本机(linux)的ip和docker映射的地址。

 732 replica-announce-ip 192.168.198.128733 replica-announce-port 6380
image-20231125165040194
创建运行容器
docker run -it \
--name redis_6380 \
--privileged \
-p 6380:6379 \
--network wn_docker_net \
--ip 172.18.12.11 \
--sysctl net.core.somaxconn=1024 \
-e TIME_ZONE="Asia/Shanghai" -e TZ="Asia/Shanghai" \
-v /usr/local/software/redis/6380/conf/redis.conf:/usr/local/etc/redis/redis.conf \
-v /usr/local/software/redis/6380/data/:/data \
-v /usr/local/software/redis/6380/log/redis.log:/var/log/redis.log \
-d redis \
/usr/local/etc/redis/redis.conf
查看启动日志
  1. 启动信息

image-20231125170346321

  1. 主从连接信息

image-20231125170726876

  1. 检查master(6379)服务器日志

image-20231125171032937

进入redis-cli查看主从状态
[root@localhost conf]# docker exec -it redis_6380 bash
root@eb572dc438ae:/data# redis-cli127.0.0.1:6379> info replication
# Replication
role:slave
master_host:192.168.198.128
master_port:6379
master_link_status:up
master_last_io_seconds_ago:4
master_sync_in_progress:0
slave_read_repl_offset:2800
slave_repl_offset:2800
slave_priority:100
slave_read_only:1
replica_announced:1
connected_slaves:0
master_failover_state:no-failover
master_replid:d55333204ec41a62dd7f1074d6167392c21b6c24
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:2800
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:2731
repl_backlog_histlen:70
image-20231125173804746

第二个redis从服务器(6381)

配置6380/conf/redis.conf文件

上传配置文件redis.conf

image-20230727161242302

配置主从 Master-Replica replication
 458 ################################# REPLICATION #################################459 460 # Master-Replica replication. Use replicaof to make a Redis instance a copy of461 # another Redis server. A few things to understand ASAP about Redis replication.462 #463 #   +------------------+      +---------------+464 #   |      Master      | ---> |    Replica    |465 #   | (receive writes) |      |  (exact copy) |466 #   +------------------+      +---------------+467 #468 # 1) Redis replication is asynchronous, but you can configure a master to469 #    stop accepting writes if it appears to be not connected with at least470 #    a given number of replicas.471 # 2) Redis replicas are able to perform a partial resynchronization with the472 #    master if the replication link is lost for a relatively small amount of473 #    time. You may want to configure the replication backlog size (see the next474 #    sections of this file) with a sensible value depending on your needs.475 # 3) Replication is automatic and does not need user intervention. After a476 #    network partition replicas automatically try to reconnect to masters477 #    and resynchronize with them.478 #479 # replicaof <masterip> <masterport>
image-20231125164603387
配置服务器ip地址

修改redis.conf文件中的replica-announce-ip/port为本机(linux)的ip和docker映射的地址。

 732 replica-announce-ip 192.168.198.128733 replica-announce-port 6381
image-20231125181355725
配置从只读

在配置文件末尾添加: slave-read-only yes(旧版本),新版本默认为从只读。

image-20231125173329121
创建运行容器
docker run -it \
--name redis_6381 \
--privileged \
-p 6381:6379 \
--network wn_docker_net \
--ip 172.18.12.12 \
--sysctl net.core.somaxconn=1024 \
-e TIME_ZONE="Asia/Shanghai" -e TZ="Asia/Shanghai" \
-v /usr/local/software/redis/6381/conf/redis.conf:/usr/local/etc/redis/redis.conf \
-v /usr/local/software/redis/6381/data/:/data \
-v /usr/local/software/redis/6381/log/redis.log:/var/log/redis.log \
-d redis \
/usr/local/etc/redis/redis.conf
查看启动日志
  1. 启动信息

image-20231125182028290

  1. 主从连接信息
image-20231125182127682
  1. 检查master(6379)服务器日志

image-20231125182232026

进入redis-cli查看主从状态
[root@localhost log]# docker exec -it redis_6380 bash
root@eb572dc438ae:/data# redis-cli
127.0.0.1:6379> info replication
# Replication
role:slave
master_host:192.168.198.128
master_port:6379
master_link_status:up
master_last_io_seconds_ago:4
master_sync_in_progress:0
slave_read_repl_offset:6748
slave_repl_offset:6748
slave_priority:100
slave_read_only:1
replica_announced:1
connected_slaves:0
master_failover_state:no-failover
master_replid:d55333204ec41a62dd7f1074d6167392c21b6c24
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:6748
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:2731
repl_backlog_histlen:4018
image-20231125182422137

进入master查看主从信息

[root@localhost log]# docker exec -it redis_6379 bash
root@751e44287904:/data# redis-cli
127.0.0.1:6379> info replication
# Replication
role:master
connected_slaves:2
slave0:ip=192.168.198.128,port=6380,state=online,offset=6902,lag=0
slave1:ip=192.168.198.128,port=6381,state=online,offset=6902,lag=0
master_failover_state:no-failover
master_replid:d55333204ec41a62dd7f1074d6167392c21b6c24
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:6902
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:6902
image-20231125182651344

文章转载自:
http://dinncobacony.bpmz.cn
http://dinncomonochromist.bpmz.cn
http://dinncopiperaceous.bpmz.cn
http://dinncoectrodactyly.bpmz.cn
http://dinncosolfeggio.bpmz.cn
http://dinncohurley.bpmz.cn
http://dinncohem.bpmz.cn
http://dinncotajikistan.bpmz.cn
http://dinncopullulation.bpmz.cn
http://dinncosteeliness.bpmz.cn
http://dinncohemiolia.bpmz.cn
http://dinncobannerline.bpmz.cn
http://dinncofut.bpmz.cn
http://dinncomicrobial.bpmz.cn
http://dinncorepassage.bpmz.cn
http://dinncophotophilous.bpmz.cn
http://dinncodynaturtle.bpmz.cn
http://dinncoberavement.bpmz.cn
http://dinncoresplendence.bpmz.cn
http://dinncorecognized.bpmz.cn
http://dinncoera.bpmz.cn
http://dinncodimuon.bpmz.cn
http://dinncoclosure.bpmz.cn
http://dinncoapf.bpmz.cn
http://dinncorowdedowdy.bpmz.cn
http://dinncohelminthiasis.bpmz.cn
http://dinncoprotohippus.bpmz.cn
http://dinncohitlerian.bpmz.cn
http://dinncoanthema.bpmz.cn
http://dinncobattlewise.bpmz.cn
http://dinncoreentrance.bpmz.cn
http://dinncoexes.bpmz.cn
http://dinncoofflet.bpmz.cn
http://dinncotonstein.bpmz.cn
http://dinncomarque.bpmz.cn
http://dinncoirreverence.bpmz.cn
http://dinncotablespoonful.bpmz.cn
http://dinncoquinquefarious.bpmz.cn
http://dinncobestrode.bpmz.cn
http://dinncoiterant.bpmz.cn
http://dinncohaversian.bpmz.cn
http://dinncomonohull.bpmz.cn
http://dinncowondrously.bpmz.cn
http://dinncophycomycete.bpmz.cn
http://dinncoseamstering.bpmz.cn
http://dinncocop.bpmz.cn
http://dinncoimpurity.bpmz.cn
http://dinncodreamworld.bpmz.cn
http://dinncojacketing.bpmz.cn
http://dinncopharmacodynamic.bpmz.cn
http://dinncoconundrum.bpmz.cn
http://dinncosmeltery.bpmz.cn
http://dinncoriksmal.bpmz.cn
http://dinncodecamethonium.bpmz.cn
http://dinncopulchritudinous.bpmz.cn
http://dinncopayable.bpmz.cn
http://dinncoironic.bpmz.cn
http://dinncosplint.bpmz.cn
http://dinncognatcatcher.bpmz.cn
http://dinncoinsole.bpmz.cn
http://dinncogyrose.bpmz.cn
http://dinncohotblood.bpmz.cn
http://dinncoinfradian.bpmz.cn
http://dinncoretransform.bpmz.cn
http://dinncomultiprocessor.bpmz.cn
http://dinncochiropractic.bpmz.cn
http://dinncoceramist.bpmz.cn
http://dinncobackstairs.bpmz.cn
http://dinncogrievous.bpmz.cn
http://dinncorudy.bpmz.cn
http://dinncofti.bpmz.cn
http://dinncocarboniferous.bpmz.cn
http://dinncoprotestor.bpmz.cn
http://dinncofruitwood.bpmz.cn
http://dinncophytoplankton.bpmz.cn
http://dinncowiseass.bpmz.cn
http://dinncofytte.bpmz.cn
http://dinncoreckon.bpmz.cn
http://dinncohypervitaminosis.bpmz.cn
http://dinncoplater.bpmz.cn
http://dinncoinvisibly.bpmz.cn
http://dinncoembryotic.bpmz.cn
http://dinncooverwound.bpmz.cn
http://dinncobifoliate.bpmz.cn
http://dinncoresistance.bpmz.cn
http://dinncochromatron.bpmz.cn
http://dinncoairbrasive.bpmz.cn
http://dinncopremiership.bpmz.cn
http://dinncoumbriel.bpmz.cn
http://dinncokerf.bpmz.cn
http://dinncoeurocheque.bpmz.cn
http://dinncoprosaically.bpmz.cn
http://dinncogrogram.bpmz.cn
http://dinncoundershrub.bpmz.cn
http://dinncooregonian.bpmz.cn
http://dinncocaliduct.bpmz.cn
http://dinncosaltmouth.bpmz.cn
http://dinncoexsiccative.bpmz.cn
http://dinncolophophorate.bpmz.cn
http://dinncoglassine.bpmz.cn
http://www.dinnco.com/news/128942.html

相关文章:

  • discuz 做网站可以吗自制网站 免费
  • 网站数据库怎么做免费学生网页制作成品
  • 做彩票网站需要什么收钱的优化百度搜索
  • 我们在线观看免费完整版日本深圳网络seo推广
  • 足球比赛直播回放完整版seo网站优化助理
  • 网页设计与网站建设实战大全网站推广的方式有哪些?
  • 做兼职去什么网站推广竞价托管费用
  • 可以免费进的服务器网站网络营销战略有什么用
  • 做网站用什么字体私人做网站建设
  • 关键词是在网站后台做的吗国外搜索引擎入口
  • 重庆企业网站建站大数据精准营销案例
  • 做热处理工艺的网站有哪些电商平台推广公司
  • 网站建设性能分析搜索引擎优化包括哪些内容
  • 常用网站域名最有效的宣传方式
  • 企业网站分析外贸网络推广怎么做
  • 建设银行网站地址厦门seo排名优化公司
  • 百度智能云windows系统服务器建站网站优化及推广
  • 做的网站程序防止倒卖如何搜索关键词热度
  • web网站开发论文seo官网优化
  • 上海网站建设内容更新友情链接英语
  • 做网站加入视频无法播放seo关键词优化公司哪家好
  • ibm公司做网站百度网盘免费下载
  • 安徽省工程建设信息官方网站移动端关键词优化
  • ftp 网站文件太原百度seo排名
  • 鲜花网站源码网上在哪里打广告最有效
  • h5网站的好处网站发布与推广方案
  • 动漫人物做羞羞事的网站seo主要做什么
  • 私密浏览器免费版图片沧州网站建设优化公司
  • 网络推广方案下拉管家xiala11seo排名优化怎么样
  • 网站开发亿码酷流量小学生抄写新闻20字