HTTP-backend
From ISPWiki
Contents |
Prerequisite
If the second interface is not present on the network interface, jump this step.
Open /etc/network/interfaces
# nano /etc/network/interfaces
to add the following lines
auto ethX
iface ethX inet static
address 10.0.0.7
netmask 255.0.0.0
where X is the network interface number.
Run the following command to apply the changes:
# /etc/init.d/networking restart
Installing and customizing libnss-extrausers
Install additional modules for the NSS service that will provide the system with user and group information from the files:/var/lib/extrausers/passwd, /var/lib/extrausers/shadow и /var/lib/extrausers/groups.
# apt-get install libnss-extrausers
Open /etc/nsswitch.conf
# nano /etc/nsswitch.conf
and change the passwd, group and shadow options
... passwd: compat extrausers group: compat extrausers shadow: compat extrausers ...
Installing and customizing sshfs
Install the utility for working with the network file system via SSH:
# apt-get install sshfs
Open /etc/rc.local
# nano /etc/rc.local
and add the line
/usr/bin/sshfs 10.0.0.1:/storage/etc /var/lib/extrausers
where 10.0.0.1 is the storage serevr floating IP-address.
Create the /root/.ssh directory:
# mkdir /root/.ssh
Get a SSH serve public key:
# ssh root@10.0.0.1 "cat /root/.ssh/id_rsa.pub"
Open /root/.ssh/known_hosts
# nano /root/.ssh/known_hosts
to add the line
10.0.0.1 X
where X is the SSH server public key.
Create a SSH public key:
# ssh-keygen -t rsa -f /root/.ssh/id_rsa -N ""
Get the SSH public key
# cat /root/.ssh/id_rsa.pub
and add it on the list of authorized keys
# ssh root@10.0.0.1 "echo \"X\" >> /root/.ssh/authorized_keys"
where X is a local SSH public key.
Thus, you have exchanged public keys with the storage server.
Installing and customizing the NFS-server
Install the utility for the NFS-server:
# apt-get install nfs-common
Open /etc/default/nfs-common
# nano /etc/default/nfs-common
to change the NEED_IDMAPD option
... NEED_IDMAPD="yes" ...
Open /etc/idmapd.conf
# nano /etc/idmapd.conf
to change the Domain option in the General section and Method in the Translation section
[General] Domain = cluster.lan ... [Translation] Method = nsswitch ...
Restart the NFS-server with the command:
# /etc/init.d/nfs-common restart
Customizing the SSH-server
Open /etc/ssh/sshd_config
# nano /etc/ssh/sshd_config
to change the Port option
... Port 222 ...
for the SSH-server that runs from the server not to conflict with the Master node SSH-server.
Restart the SSH-server with the command:
# /etc/init.d/ssh restart
Connecting the storages
Create the following directories for connecting the storage:
# mkdir -p /storage \
/var/run-cluster/mysqld \
/var/run-cluster/apache2 \
/var/cluster/spool/exim4 \
/var/cluster/log/account \
/var/cluster/lib/exim4 \
/var/httpd-logs
Open /etc/fstab
# nano /etc/fstab
to add the line
10.0.0.1:/ /storage nfs4 rw,rsize=65000,wsize=65000,proto=tcp,soft,intr,noatime,noauto,actimeo=240,acregmin=10,acdirmin=30,timeo=50,sync 0 0
Open /etc/rc.local
# nano /etc/rc.local
to add the following lines
/bin/mount /storage /bin/mount --bind /dev /storage/dev /bin/mount --bind /dev/pts /storage/dev/pts /bin/mount --bind /proc /storage/proc /bin/mount --bind /tmp /storage/tmp /bin/mount --bind /lib/modules /storage/lib/modules /bin/mount --bind /var/run-cluster /storage/var/run /bin/mount --bind /var/cache/debconf /storage/var/cache/debconf /bin/mount --bind /var/cluster/spool/exim4 /storage/var/spool/exim4 /bin/mount --bind /var/cluster/log/account /storage/var/log/account /bin/mount --bind /var/cluster/lib/exim4 /storage/var/lib/exim4 /bin/mount --bind /var/httpd-logs /storage/home/httpd-logs
Connect the storages:
# chmod +x /etc/rc.local && /etc/rc.local
Customizing the HTTP-backup
Add the Добавьте публичный ключ ISPmanager Cluster public key on the list of authorized keys:
# mkdir /root/.ssh && cat /storage/usr/local/ispmgr/etc/ssh-key.pub >> /root/.ssh/authorized_keys
Register the HTTP-backend in ISPmanager Cluster:
# chroot /storage /usr/local/ispmgr/sbin/mgrctl -m ispmgr clusternodes.new ip=10.0.0.7 sok=ok
Add the anynode role to the HTTP-backend:
# chroot /storage /usr/local/ispmgr/sbin/mgrctl -m ispmgr clusternodes.roles.edit plid=10.0.0.7 name=anynode sok=ok
Generate an internal password for exchanging information among the proxy-server services. Add the ClusterCtl role to the HTTP-backend:
# chroot /storage /usr/local/ispmgr/sbin/mgrctl -m ispmgr clusternodes.roles.edit plid=10.0.0.7 name=ClusterCtl port=654 password=X sok=ok
where X is the internal password for exchanging information among the proxy-server services.
Create the HTTP role in ISPmanager Cluster:
# chroot /storage /usr/local/ispmgr/sbin/mgrctl -m ispmgr clusterroles.edit name=HTTP sok=ok
Add scripts for running the HTTP role:
# chroot /storage /usr/local/ispmgr/sbin/mgrctl -m ispmgr clusterroles.startscripts.edit \ plid=HTTP priority=0 command=\"/usr/local/ispmgr/etc/cluster_roles/init.d/oproxy-mysql start\" sok=ok # chroot /storage /usr/local/ispmgr/sbin/mgrctl -m ispmgr clusterroles.startscripts.edit \ plid=HTTP priority=0 command=\"/usr/local/ispmgr/etc/cluster_roles/init.d/HTTP start\" sok=ok
Add scripts for stopping the HTTP role:
# chroot /storage /usr/local/ispmgr/sbin/mgrctl -m ispmgr clusterroles.startscripts.edit \ plid=HTTP priority=1 command=\"/usr/local/ispmgr/etc/cluster_roles/init.d/oproxy-mysql stop\" sok=ok # chroot /storage /usr/local/ispmgr/sbin/mgrctl -m ispmgr clusterroles.startscripts.edit \ plid=HTTP priority=1 command=\"/usr/local/ispmgr/etc/cluster_roles/init.d/HTTP stop\" sok=ok
Add the HTTP role to the HTTP-backend:
# chroot /storage /usr/local/ispmgr/sbin/mgrctl -m ispmgr clusternodes.roles.edit plid=10.0.0.7 \ name=HTTP port=81 maxconnections=10000 percent=100 sok=ok
Create the HTTP-backend web-servers. You can create a web server with the IP-address 10.0.7.1 and use it as an example for creating new web-servers.
Add the web server to the HTTP-backend:
# ssh root@10.0.0.6 "/usr/local/ispmgr/sbin/mgrctl -m ispmgr clusternodes.webservers.edit plid=10.0.0.7 ip=10.0.7.1 \ folder=/usr/local/ispmgr/etc/cluster_apache/webservers-conf.d/10.0.7.1 config=/usr/local/ispmgr/etc/cluster_apache/configs/10.0.7.1.conf \ default=on sok=ok"
Create /storage/usr/local/ispmgr/etc/cluster_apache/webservers-conf.d/10.0.7.1:
# mkdir /storage/usr/local/ispmgr/etc/cluster_apache/webservers-conf.d/10.0.7.1
Create and open /storage/usr/local/ispmgr/etc/cluster_apache/configs/10.0.7.1.conf:
# nano /storage/usr/local/ispmgr/etc/cluster_apache/configs/10.0.7.1.conf
to add the following lines:
Include /usr/local/ispmgr/etc/cluster_apache/global.conf Use Setup "10.0.7.1"
Install Apache:
# chroot /storage /usr/sbin/apache2ctl stop
Run the current node:
# chroot /storage usr/local/ispmgr/sbin/clusterctl --node LOCAL start
Open /etc/rc.local
# nano /etc/rc.local
to add the line
# chroot /storage usr/local/ispmgr/sbin/clusterctl --node LOCAL start
Distribute sites among web servers:
# chroot /storage usr/local/ispmgr/sbin/sitectl --distribute
