Apache Replication主从复制同步机制实践
来源:互联网 发布:淘宝店主寄语文艺 编辑:程序博客网 时间:2024/06/05 18:24
Apache Replication 主从复制同步机制实践
1.两台server都安装Apache
apt-get install apache2
2.两台server都安装Rsync
apt-get install rsync
3.在ServerA使用cron做计划
crontab -e
进入编辑模式,然后输入下面内容,代表每5分钟会执行一次同步
5 * * * * rsync -avzhe ssh root@machinenameServerB.domainname.com:/var/www/ /var/www/
下面这个是配置的格式:
# ┌───────────── min (0 - 59)
# │ ┌────────────── hour (0 - 23)
# │ │ ┌─────────────── day of month (1 - 31)
# │ │ │ ┌──────────────── month (1 - 12)
# │ │ │ │ ┌───────────────── day of week (0 - 6) (0 to 6 are Sunday to Saturday, or use names; 7 is Sunday, the same as 0)
# │ │ │ │ │
# │ │ │ │ │
# * * * * * command to execute
4.修改ServerB的/var/www/index.html的内容
5.检查ServerA的/var/www/index.html的内容被更新成ServerB一样的内容
(注意:为了让cron可以不输入密码直接执行rsync,需要设置下ssh-keygen如下:
root@machineAName # ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
a2:ff:3e:7b:2d:b4:98:27:0a:3d:1b:0b:98:51:98:3c root@machineAName
The key's randomart image is:
+--[ RSA 2048]----+
| |
| . o |
| E . |
| o |
| . . S |
| + o . . |
| o + + + o |
| + == = . |
| =++* . |
+-----------------+
/tmp
root@machineAName # ssh-copy-id -i /root/.ssh/id_rsa.pub machineBName
The authenticity of host 'machineBName (10.185.98.24)' can't be established.
RSA key fingerprint is cd:9d:d5:81:7b:38:3e:4c:41:0b:cb:72:de:51:03:da.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@machineBName's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'machineBName"
and check to make sure that only the key(s) you wanted were added.
关于ssh-keygen可以参考:http://www.thegeekstuff.com/2011/07/rsync-over-ssh-without-password/)
- Apache Replication主从复制同步机制实践
- Mysql Replication机制主从同步实践
- MSSQL Server Replication机制主从同步实践
- Linux MySQL主从复制(Replication)实践配置
- mysql主从复制,半同步复制(Semisynchronous Replication)
- MySQL主从Replication同步&&半同步&&主主复制架构
- Linux MySQL主从复制(Replication)(MySQL数据同步)配置
- MYSQL 主从复制(Replication)
- mysql主从复制(replication)
- 备份策略四、使用主从复制机制(replication)
- Redis的Replication(主从复制)和sentinel机制
- 配置MySQL主从复制(Replication)
- MySQL 主从复制 replication 实验!
- 配置MySQL主从复制(Replication)
- mysql主从复制(replication)
- MySQL Replication主从复制搭建
- MySQL 的主从 Replication同步
- MySQL 备份和恢复策略四:使用主从复制机制(replication)实现数据库实时备份
- skill tree
- 修复Android虚拟导航栏(Navigation Bar)遮挡app部分界面的错误
- 客户端缓存
- Flotherm 网格划分经验
- android RadioGroup中的RadioButton手动设置相关问题
- Apache Replication主从复制同步机制实践
- RecyclerView Bug:IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter的解决方案
- 要期末考试啦!记住这些
- 胡杨林
- 《python》学习笔记(Day1++),try\except\finally机制
- Android 讲解:存储(2)
- wordnet
- json数据BOM头去除
- LightOJ1214 - Large Division(大数取余)