1.课程
小型电商:页面静态化 页面太多的时候,上亿,重新渲染,需要几天,不太靠谱
大型电商:异步+多级缓存+nginx本地化动态渲染
高并发、高可用,qps
总之一句话redis很重要、龙国学院很屌
2.实践安装笔记 CenterOS的集群 redis的安装
scp命令:scp -r /Users/panda/Desktop/jdk-8u171-linux-x64.rpm [email protected]:/usr/local
固定ip地址:
host eshop-fastdfs {
hardware ethernet 00:50:56:28:C1:EA;
fixed-address 172.16.55.137;
}
host eshop-cache01 {
hardware ethernet 00:0C:29:A1:98:09;
fixed-address 172.16.55.131;
}
host eshop-cache02 {
hardware ethernet 00:0C:29:4C:21:6C;
fixed-address 172.16.55.132;
}
host eshop-cache03 {
hardware ethernet 00:0C:29:20:60:1D;
fixed-address 172.16.55.133;
}
host eshop-cache04 {
hardware ethernet 00:0C:29:C3:31:ED;
fixed-address 172.16.55.134;
}
host eshop-cache05 {
hardware ethernet 00:0C:29:89:7C:39;
fixed-address 172.16.55.135;
}
关闭防火墙:
service iptables stop
service ip6tables stop
chkconfig iptables off
chkconfig ip6tables off
vi /etc/selinux/config
SELINUX=disabled
配置yum:
yum clean all
yum makecache
yum install wget
java的安装:
1、将jdk-7u60-linux-i586.rpm通过WinSCP上传到虚拟机中
2、安装JDK:rpm -ivh jdk-7u65-linux-i586.rpm
3、配置jdk相关的环境变量
vi .bashrc
export JAVA_HOME=/usr/java/latest
export PATH=$PATH:$JAVA_HOME/bin
source .bashrc
4、测试jdk安装是否成功:java -version
linux perl的安装:
yum install -y gcc
wget http://www.cpan.org/src/5.0/perl-5.16.1.tar.gz
tar -xzf perl-5.16.1.tar.gz
cd perl-5.16.1
./Configure -des -Dprefix=/usr/local/perl
make && make test && make install
perl -v
为什么要装perl?我们整个大型电商网站的详情页系统,复杂。java+nginx+lua,需要perl。
perl,是一个基础的编程语言的安装,tomcat,跑java web应用
安装CenterOS集群:免密钥通信
vi /etc/hosts 设置host
172.16.55.131 eshop-cache01
172.16.55.132 eshop-cache02
172.16.55.133 eshop-cache03
172.16.55.134 eshop-cache04
172.16.55.135 eshop-cache05
生成公钥:ssh-keygen -t rsa
cd /root/.ssh
cp id_rsa.pub authorized_keys
ssh-copy-id -i hostname:将本机的公钥拷贝到指定机器的authorized_keys文件中
定时任务出错啦:
mkdir: /usr/local/redis/snapshotting: No such file or directory
cp: /usr/local/redis/snapshotting/2018051110: No such file or directory
单机版redis的安装:
wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz
tar -xzvf tcl8.6.1-src.tar.gz
cd /usr/local/tcl8.6.1/unix/
./configure
make && make install
$ wget http://download.redis.io/releases/redis-4.0.9.tar.gz
$ tar xzf redis-4.0.9.tar.gz
$ cd redis-4.0.9
$ make
redis的作用:
redis各种数据结构和命令的使用,包括java api的使用
redis一些特殊的解决方案的使用,pub/sub消息系统,分布式锁,输入的自动完成,等等
redis日常的管理相关的命令
redis企业级的集群部署和架构
redis主从复制、读写分离实践:主节点负责写数据、从节点负责读取数据 10部走
(1)redis utils目录下,有个redis_init_script脚本
(2)将redis_init_script脚本拷贝到linux的/etc/init.d目录中,将redis_init_script重命名为redis_6379,6379是我们希望这个redis实例监听的端口号
(3)修改redis_6379脚本的第6行的REDISPORT,设置为相同的端口号(默认就是6379)
(4)创建两个目录:/etc/redis(存放redis的配置文件),/var/redis/6379(存放redis的持久化文件)
(5)修改redis配置文件(默认在根目录下,redis.conf),拷贝到/etc/redis目录中,修改名称为6379.conf
(6)修改redis.conf中的部分配置为生产环境
redis.conf配置为生产环境:
daemonize yes 让redis以daemon进程运行
pidfile /var/run/redis_6379.pid 设置redis的pid文件位置
port 6379 设置redis的监听端口号
dir /var/redis/6379 设置持久化文件的存储位置
(7) success
redis开机自启动:https://blog.csdn.net/lovejj1994/article/details/53096268
在redis_6379脚本中,最上面,加入两行注释
/ # chkconfig: 2345 90 10
/# description: Redis is a persistent key-value database
chkconfig redis_6379 on
(8)错误:Error condition on socket for SYNC: No route to host 需要关闭防火墙
Error condition on socket for SYNC: Connection refused
博客:https://blog.csdn.net/chwshuang/article/details/54929277 bind的问题,需要绑定指定ip
bind 127.0.0.1 172.16.55.132 172.16.55.133 172.16.55.134 172.16.55.135 没起作用啊?
bind 0.0.0.0
开放6379端口:iptables -A INPUT -ptcp --dport 6379 -j ACCEPT
远程连接:redis-cli -h ipaddr -p port
info replication命令:
/# Replication
role:slave
master_host:172.16.55.131
master_port:6379
master_link_status:up
master_last_io_seconds_ago:4
master_sync_in_progress:0
slave_repl_offset:464
slave_priority:100
slave_read_only:1
connected_slaves:0
master_replid:f74abda85fe4192aefc439877ad08e7d13a26dfb
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:464
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:464
role:master
connected_slaves:1
slave0:ip=172.16.55.132,port=6379,state=online,offset=464,lag=1
master_replid:f74abda85fe4192aefc439877ad08e7d13a26dfb
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:478
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:478
(9)强制读写分离
从节点:slave-read-only 拒绝所有写请求
(10)集群安全认证
requirepass:启用安全认证
masterauth:连接口令