时间:2020-02-16来源:电脑系统城作者:电脑系统城
搭建一个高可用web集群网站
2.3.1 数据库采用mysql主主复制和mmm高可用
2.3.2 web集群为lvs+dr模式,keeplived实现高可用
2.3.3 nfs使两个web服务器间信息数据同步
2.3.4 nagios监控各服务器状态
或者此处也可使用自建内网yum源
mount -t iso9660 /dev/sr0 /media
echo ‘/dev/sr0 /media iso9660 defaults 0 0’>>/etc/fstab
[root@web02 ~]# cat /etc/yum.repos.d/centos.repo
[centos6-iso]
name=centos
baseurl=file:///media
enabled=1
gpgcheck=0
service iptables stop;chkconfig iptables off
sed -i “s/SELINUX=enforcing/SELINUX=disabled/” /etc/selinux/config;setenforce 0
[root@nagios ~]# rpm -qa|grep ntp
如未安装使用yum install -y ntp安装
chkconfig ntpd on
vim /etc/ntp.conf
#restrict default kod nomodify notrap nopeer noquery #注释此行
restrict 192.168.2.0 mask 255.255.0.0 nomodify notrap #新增此行
server s1d.time.edu.cn #网络同步地址
server s2g.time.edu.cn #网络同步地址
[root@nagios ~]#service ntpd restart 重启ntp服务
然后其他主机做定时任务同步此时间服务器
echo ‘*/5 * * * * /usr/sbin/ntpdate 192.168.2.11 >/dev/null 2>&1’>>/var/spool/cron/root
[root@nagios ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.2.62 mysql-m44
192.168.2.64 mysql-m45
192.168.2.40 mysql-mon40
192.168.2.65 web-lnmp01
192.168.2.66 web-lnmp02
192.168.2.60 nfs
192.168.2.50 lb-01
192.168.2.51 lb-02
192.168.2.11 nagios
所需软件包
nagios-3.5.1.tar.gz
nagios-plugins-2.1.1.tar
nrpe-2.15.tar
[root@nagios ~]# yum install -y httpd
[root@nagios ~]# chkconfig httpd on
[root@nagios nagios]# groupadd nagios;useradd nagios -g nagios
[root@nagios ~]# tar xzvf nagios-3.5.1.tar.gz ;cd nagios
[root@nagios nagios]# yum install -y gcc gcc-c++ glibc glibc-common gd gd-devel mysql-server httpd php php-gd
[root@nagios nagios]# ./configure –prefix=/usr/local/nagios –with-command-group=nagios
[root@nagios nagios]#make all && make install
[root@nagios nagios]# make install-init;make install-commandmode;make install-config
[root@nagios nagios]# make install-webconf ##nagios web配置文件
[root@nagios nagios]# htpasswd -cb /usr/local/nagios/etc/htpasswd.users nagiosadmin 123456
service httpd restart && service nagios restart
[root@nagios ~]# tar xf nagios-plugins-2.1.1.tar.gz
[root@nagios ~]# cd nagios-plugins-2.1.1
[root@nagios nagios-plugins-2.1.1]# ./configure –prefix=/usr/local/nagios/ –with-nagios-user=nagios –with-nagios-group=nagios && make && make install
[root@nagios ~]# /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
[root@nagios nagios-plugins-2.1.1]# chkconfig nagios on
[root@nagios nagios-plugins-2.1.1]# service nagios restart
如想看到详细报错又不想用/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg命令
可以修改vim /etc/init.d/nagios,将下图中定向到空的内容删除
即修正后为$NagiosBin -v $NagiosCfgFile;
[root@nagios ~]# vim /usr/local/nagios/etc/nagios.cfg
cfg_file=/usr/local/nagios/etc/objects/hosts.cfg
cfg_file=/usr/local/nagios/etc/objects/services.cfg
#cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
[root@nagios ~]# vim /usr/local/nagios/etc/objects/hosts.cfg
[root@nagios etc]# head -51 objects/localhost.cfg |grep -v ‘#|^
>objects/hosts.cfg
[root@nagios etc]# vim objects/hosts.cfg
define host{
use linux-server
host_name 2.11-nagios
alias 2.11-nagios
address 127.0.0.1
}
define hostgroup{
hostgroup_name linux-servers
alias Linux Servers
members 2.11-nagios
}
[root@nagios etc]# grep -v ‘#|^$’ objects/services.cfg
define service{
use local-service ; Name of service template to use
host_name 2.11-nagios
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
define service{
use local-service ; Name of service template to use
host_name 2.11-nagios
service_description Root Partition
check_command check_local_disk!20%!10%!/
}
define service{
use local-service ; Name of service template to use
host_name 2.11-nagios
service_description Current Users
check_command check_local_users!20!50
}
define service{
use local-service ; Name of service template to use
host_name 2.11-nagios
service_description Total Processes
check_command check_local_procs!250!400!RSZDT
}
define service{
use local-service ; Name of service template to use
host_name 2.11-nagios
service_description Current Load
check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0
}
define service{
use local-service ; Name of service template to use
host_name 2.11-nagios
service_description Swap Usage
check_command check_local_swap!20!10
}
define service{
use local-service ; Name of service template to use
host_name 2.11-nagios
service_description SSH
check_command check_ssh
notifications_enabled 0
}
define service{
use local-service ; Name of service template to use
host_name 2.11-nagios
service_description HTTP
check_command check_http
notifications_enabled 0
}
[root@nagios etc]#chown nagios.nagios /usr/local/nagios/etc/objects/hosts.cfg
[root@nagios etc]#chown nagios.nagios /usr/local/nagios/etc/objects/services.cfg
[root@nagios etc]# /etc/init.d/nagios checkconfig
Total Warnings: 0
Total Errors: 0
Things look okay – No serious problems were detected during the pre-flight check
OK.
[root@nagios etc]# /etc/init.d/nagios restart
客户端访问http://192.168.2.11/nagios
mysql-5.5.52.tar.gz #源码安装
[root@xuegod62 mysql-5.5.52]# yum install -y ncurses-devel libaio-devel cmake
[root@xuegod62 ~]# tar xf mysql-5.5.52.tar.gz;cd mysql-5.5.52
[root@xuegod64 mysql-5.5.52]# cmake -DCMAKE_INSTALL_PREFIX=/application/mysql -DMYSQL_DATADIR=/application/mysql/data -DMYSQL_UNIX_ADDR=/application/mysql/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1
[root@xuegod62 mysql-5.5.52]# make -j 4 && make install
[root@xuegod62 mysql-5.5.52]# mysql -V
mysql Ver 14.14 Distrib 5.5.52, for Linux (x86_64) using readline 5.1
#授权mysql用户管理mysql的安装目录,
[root@mysql-m62 mysql-5.5.52]# chown -R mysql.mysql /application/mysql/
[root@mysql-m62 mysql-5.5.52]# /application/mysql/scripts/mysql_install_db –basedir=/application/mysql/ –datadir=/application/mysql/data/ –user=mysql
[root@mysql-m62 mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@mysql-m62 mysql]# chmod +x /etc/init.d/mysqld
原因及解决方法:前面存在残留进程,杀掉即可
设置mysql开机自启动
[root@mysql-m62 mysql]# chkconfig mysqld on
[root@mysql-m62 mysql]# chkconfig –add mysqld
重启mysql service mysqld restart
[root@mysql-m62 mysql]# mysqladmin -uroot password ‘123456’
删除多余不用库
2024-07-18
Centos 7 二进制安装配置 MariaDB数据库2024-07-18
Centos7默认firewalld防火墙使用命令大全2024-07-07
四种执行python系统命令的方法常用权限linux系统内有档案有三种身份 u:拥有者 g:群组 o:其他人这些身份对于文档常用的有下面权限:r:读权限,用户可以读取文档的内容,如用cat,more查看w:写权限,用户可以编辑文档x...
2024-07-07
然而,如果我们遵循通常的 WordPress 最佳实践,这些安全问题可以避免。在本篇中,我们会向你展示如何使用 WPSeku,一个 Linux 中的 WordPress 漏洞扫描器,它可以被用来找出你安装...
2024-07-03