部署一台子服务器所需要的步骤

部署一台子服务器的整体思路

      当你拿到一台服务器之后第一件该做的就是看一下服务器的内存和磁盘的空间,然后再进行清理环境,下载你所需要的东西,然后就是打开防火墙iptables看一下规则,有规则的话就全部清理掉;然后就是配置epel源和zabbix源,下载密钥,安装zabbix客户端还有同步数据所需要对的东西,以防万一还是要看一下环境有没有清理干净。之后配置zabbix文件还有实时同步的文件,然后重启服务器之后,配置你所需要的贵规则,同步你所需要的数据资料,最后重启服务器防火墙等,这台服务器就配置完成啦。

第一步:看空间内存并下载你会用到的工具

# df -h 

# free -m

# yum install wget net-tools vnstat lsof lrzsz

第二步:配置源

# vim /etc/yum.repos.d/zabbix.repo添加下面文件

  [zabbix]
  name=Zabbix Official Repository – $basearch
  baseurl=http://repo.zabbix.com/zabbix/3.2/rhel/7/$basearch/
  enabled=1
  gpgcheck=1
  gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

  [zabbix-non-supported]
  name=Zabbix Official Repository non-supported – $basearch
  baseurl=http://repo.zabbix.com/non-supported/rhel/7/$basearch/
  enabled=1
  gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
  gpgcheck=1
# vim /etc/yum.repos.d/epel.repo

  [epel]
  name=Extra Packages for Enterprise Linux 7 – $basearch
  #baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
  mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
  failovermethod=priority
  enabled=1
  gpgcheck=1
  gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

  [epel-debuginfo]
  name=Extra Packages for Enterprise Linux 7 – $basearch – Debug
  #baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch/debug
  mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch
  failovermethod=priority
  enabled=0
  gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
  gpgcheck=1

  [epel-source]
  name=Extra Packages for Enterprise Linux 7 – $basearch – Source
  #baseurl=http://download.fedoraproject.org/pub/epel/7/SRPMS
  mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch
  failovermethod=priority
  enabled=0
  gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
  gpgcheck=1

弄好环境之后,就可以安装zabbix

# yum install -y zabbix-agent iptables* rsync nginx

第三步:清理环境

# getenforce                    ——查看selinux的状态

#vim /etc/selinux/config  

把SELINUX=enforcing改成SELINUX=disabled

重启后生效。

# systemctl status firewalld       ——查看firewalld的状态

# systemctl stop firewalld         ——临时关闭firewalld

# systemctl disable firewalld     ——永久关闭firewalld

# systemctl status iptables        ——查看防火墙iptables的状态

# systemctl stop iptables          ——临时关闭防火墙

# systemctlt disable iptables     ——永久关闭防火墙

# systemctl status NetworkManager    ——查看刷新环境的状态

# systemctl stop NetworkManager      ——临时关闭刷新环境

# systemctl disable NetworkManager   ——永久关闭刷新环境

第四步:配置服务器文件

# vim /etc/rsyncd.conf添加下面内容
[ziliao]
path = /software
read only = false
uid=xiaoke
gid=xiaoke

# vim /etc/nginx/nginx.conf把include下的内容注释掉,下面我已经注释好了

        include /etc/nginx/kis/*.conf;

#        location / {
#    }

#    error_page 404 /404.html;
#        location = /40x.html {
#   }

# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
#  }

 # vim /etc/zabbix/zabbix-agentd.conf修改一下几项

Hostname=101.1.10               ——本机的IP

ServerActive=45.45.20.231   ——监控机的IP  

 ListenPort=10050                 ——打开端口

Server=45.45.20.231            ——监控机的IP

# mkdir /software 存放网站的目录

# mkdir /etc/nginx/kis 存放绑定域名配置文件的目录

# mkdir /etc/nginx/conf  存放证书的目录

# systemctl enable rsyncd  ——开机自启(下同)

# systemctl enable nginx

# systemctl enable zabbix-agend

第五步:添加规则

# systemctl start iptables

# iptables -F

# iptables -F -t nat

# iptables -F -t mangle

# iptables -A INPUT -p udp -m multiport –dport 53 -j ACCEPT       ——yum install—-通道
# iptables -A OUTPUT -p udp -m state –state established -j ACCEPT
# iptables -A OUTPUT -p udp -m state –state new,established -j ACCEPT
# iptables -A INPUT -p udp -m multiport –sport 53 -j ACCEPT

# iptables -A INPUT -p tcp -m multiport –dport 22 -j ACCEPT                          ——SSH服务
# iptables -A OUTPUT -p tcp -m state –state established -j ACCEPT
# iptables -A OUTPUT -p tcp -m state –state new,established -j ACCEPT
# iptables -A INPUT -p tcp -m multiport –sport 22 -j ACCEPT

# iptables -A INPUT -p tcp -m multiport –dport 80,443,873,10050,10051 -j ACCEPT           ——nginx所需要端口
# iptables -A OUTPUT -p tcp -m state –state established -j ACCEPT
# iptables -A OUTPUT -p tcp -m state –state new,established -j ACCEPT
# iptables -A INPUT -p tcp -m multiport –sport 80,443,873,10050,10051 -j ACCEPT

# iptables -A INPUT -p icmp -j ACCEPT
# iptables -A OUTPUT -p icmp -j ACCEPT

# iptables -P INPUT DROP
# iptables -P OUTPUT DROP
# service iptables save

第六步:同步数据

# cd /software/

# systemctl start rsyncd

# systemctl restart iptables

# rsync -av 要同步的主机的IP(45.0.0.10)::ziliao .

# bash 2软连接到nginx配置.sh

# bash 6拷贝证书到linux下.sh

 

# nginx -t 

第七步:所有服务器重启

# systemctl restart nginx

# systemctl restart zabbix-agent

# systemctl restat rsyncd 

# systemctl restart iptables

# systemctl enable nginx

# systemctl enable zabbix-agent

# systemctl enable iptables

# systemcyl enable rsyncd

检查一下端口有没有起来

# lsof -i:443

# lsof -i:80

# lsof -i:10050

# vim  /etc/sudoers

 xiaoke  ALL=(ALL)   NOPASSWORD:ALL

# vim /etc/resolv.conf添加DNS

 servername  114.114.114.114

 servername  8.8.8.8

如果不放心的话可以检查一下环境是否安全然后重启服务器就可以了。

 

原文链接:https://www.cnblogs.com/ping-7/p/7955953.html

© 版权声明
THE END
喜欢就支持一下吧
点赞10 分享