使用 ISPConfig 3.1 在 Debian 8.4 Jessie 上安装 Web、电子邮件和 MySQL 数据库集群
本教程描述了使用 ISPConfig 3 控制面板在 Debian 8 上安装集群 Web、电子邮件、数据库和 DNS 服务器以实现冗余、高可用性和负载平衡。 MySQL 主/主复制将用于在服务器之间复制 MySQL 客户端数据库,Unison 将用于同步 /var/www(网站),邮件将与 Dovecot 同步。
1 一般说明
在此设置中,将有一台主服务器(运行 ISPConfig 控制面板界面)和一台镜像网络(apache)、电子邮件(postfix 和 dovecot)、dns(绑定)和数据库(MySQL 或 MariaDB)服务的从服务器的主服务器。
要安装集群设置,我们需要两台具有 Debian 8.4 最小安装和相同 ISPConfig 版本的服务器。
在我的示例中,我为两台服务器使用了以下主机名和 IP 地址:
主服务器
主机名:server1.example.tld
IP 地址:192.168.0.105
IPv6 地址:2001:db8::1
从属服务器
主机名:server2.example.tld
IP 地址:192.168.0.106
IPv6 地址:2001:db8::2
无论这些主机名或 IP 地址在接下来的安装步骤中出现在哪里,您都必须更改它们以匹配服务器的 IP 和主机名。
所有命令都必须以 root 用户身份运行。如果您需要更改 MySQL,请使用 MySQL 的根密码登录 MySQL:
mysql -u root -p
2 安装主服务器
首先我们需要在主服务器上安装 ISPConfig。如果您已经在此服务器上安装了 ISPConfig,则可以跳过安装(确保现有安装是最新的)。
根据 The Perfect Server - Debian 8.4 Jessie (Apache2, BIND, Dovecot, ISPConfig 3.1) 在主服务器上安装 ISPConfig。
将 Slave Server 添加到 /etc/hosts 文件
vi /etc/hosts
所以它看起来像:
127.0.0.1 localhost
192.168.0.105 server1.example.tld server1
2001:db8::1 server1.example.tld server1
192.168.0.106 server2.example.tld
2001:db8::2 server2.example.tld
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
3 准备从服务器
从 The Perfect Server - Debian 8.4 Jessie(Apache2、BIND、Dovecot、ISPConfig 3.1)运行步骤 1 - 19。
不要在 server2 上安装 ISPConfig。
将主服务器添加到 /etc/hosts 文件
vi /etc/hosts
所以它看起来像:
127.0.0.1 localhost
192.168.0.105 server1.example.tld
2001:db8::1 server1.example.tld
192.168.0.106 server2.example.tld server2
2001:db8::2 server2.example.tld server2
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
4 Server1到Server2的无密钥登录
在服务器 2 上:
我们暂时允许 root 使用密码登录到 server2。打开 /etc/sshd_config:
vi /etc/ssh/sshd_config
并改变
PermitRootLogin without-password
到
PermitRootLogin yes
之后,重新启动 ssh-daemon:
service ssh restart
在服务器 1 上:
创建私钥/公钥对:
ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): <-- ENTER
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): <-- ENTER
Enter same passphrase again: <-- ENTER
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:
f3:d0:62:a7:24:6f:f0:1e:d1:64:a9:9f:12:6c:98:5a
The key's randomart image is:
+---[RSA 2048]----+
| |
| . |
| + |
| + * |
| E S + |
| o O @ . |
| . B + |
| o o |
| . |
+-----------------+
重要的是不要输入密码,否则镜像在没有人工交互的情况下将无法工作,所以只需点击 ENTER!
接下来,我们将公钥复制到 server2.example.tld:
ssh-copy-id -i /root/.ssh/id_rsa.pub
The authenticity of host '192.168.0.106 (192.168.0.106)' can't be established.
ECDSA key fingerprint is 25:d8:7a:ee:c2:4b:1d:92:a7:3d:16:26:95:56:62:4e.
Are you sure you want to continue connecting (yes/no)? <-- yes (you will see this only if this is the first time you connect to server2)
/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
's password: <- enter root password from server2
现在尝试登录机器:
ssh
并检查 /root/.ssh/authorized_keys 以确保我们没有添加您不期望的额外密钥。
cat /root/.ssh/authorized_keys
ssh-dss AAAAB3NzaC1kc3MAAACBAPhiAexgEBexnw0rFG8lXwAuIsca/V+lhmv5lhF3BqUfAbL7e2sWlQlGhxZ8I2UnzZK8Ypffq6Ks+lp46yOs7MMXLqb7JBP9gkgqxyEWqOoUSt5hTE9ghupcCvE7rRMhefY5shLUnRkVH6hnCWe6yXSnH+Z8lHbcfp864GHkLDK1AAAAFQDddQckbfRG4C6LOQXTzRBpIiXzoQAAAIEAleevPHwi+a3fTDM2+Vm6EVqR5DkSLwDM7KVVNtFSkAY4GVCfhLFREsfuMkcBD9Bv2DrKF2Ay3OOh39269Z1rgYVk+/MFC6sYgB6apirMlHj3l4RR1g09LaM1OpRz7pc/GqIGsDt74D1ES2j0zrq5kslnX8wEWSHapPR0tziin6UAAACBAJHxgr+GKxAdWpxV5MkF+FTaKcxA2tWHJegjGFrYGU8BpzZ4VDFMiObuzBjZ+LrUs57BiwTGB/MQl9FKQEyEV4J+AgZCBxvg6n57YlVn6OEA0ukeJa29aFOcc0inEFfNhw2jAXt5LRyvuHD/C2gG78lwb6CxV02Z3sbTBdc43J6y
禁止使用密码进行 root 登录。打开 /etc/sshd_config:
vi /etc/ssh/sshd_config
并改变
PermitRootLogin yes
到
PermitRootLogin without-password
之后,重新启动 ssh-daemon:
service ssh restart
从 server2 注销:
exit
logout
Connection to 192.168.0.106 closed.
我们现在回到服务器 1。