天天看點

centos系統新機部署

@TO加粗樣式C 新centos系統環境配置

|

  • 新的系統要想能夠提供測試和線上生産環境,一些标準化的流程是必須的,就像打地基蓋房子一樣。
  • 配置yum源 使用epel-release yum install -y epel-release openssh-devel lrzsz vim bind-utils
  • 執行初始環境腳本enent_.sh
  • #!/bin/bash

    read -p “請輸入系統最大打開的檔案數量” a

    read -p “請輸入系統最大的程序數量” b

    echo “* noproc $b” >> /etc/security/limits.conf

    echo “* nofile a " > > / e t c / s e c u r i t y / l i m i t s . c o n f s e d − i " 1 , a" >> /etc/security/limits.conf sed -i "1, a">>/etc/security/limits.confsed−i"1, s/SELINUX=enforcing/SELINUX=disabled/g” /etc/selinux/config

    setenforce 0

    cat /etc/issue | grep 6

    if [ $? -eq 0 ];then

    chkconfig iptables off

    /etc/init.d/iptables stop

    echo “您的系統是CENTOS 6 已經關閉防火牆”

    else

    systemctl stop firewalld && systemctl disable firewalld

    echo “您的系統是centos 7 防火牆已經關閉”

    fi

  • 在jenkins自動化部署環境中涉及到常常改變CI和UAT環境下發到不同IP的伺服器上,是以需要在下發配置目錄下更改項目的IP位址和port。是以有一個批量檢視此目錄下檔案名和檔案内容的腳本,友善于以後對于項目的統籌和管理,如下
  • [[email protected] src]# cat kk.sh

    #!/bin/bash

    if [ -f ./kk.txt ];then

    rm -rf ./kk.txt

    else

    touch ./kk.txt

    fi

    a=CI–*

    for name in $a

    do

    echo $name

    cat $name

    >> ./kk.txt

    done

以下為 輸出内容:

[[email protected] program_new]# cat kk.txt

CI–aps_approvalIP=10.194.63.111 PORT=8080

CI–crf_cdsIP=10.194.64.106 PORT=8080

CI–crf_channel_dataIP=10.194.63.100 PORT=8080

  • nginx的優化腳本

    [[email protected] src]# cat nginx_youhua.sh

    #!/bin/bash

    a=

    grep "define NGINX_VERSION" ./src/core/nginx.h

    b=

    grep "#define NGINX_VER" ./src/core/nginx.h

    sed -i “13s/KaTeX parse error: Expected 'EOF', got '#' at position 3: a/#̲define NGINX_VE…b/#define NGINX_VER “Apache/” NGINX_VERSION/” ./src/core/nginx.h

    sed -i “s/Server: nginx/Server: Apache/g” ./src/http/ngx_http_header_filter_module.c

    sed -i “s# nginx # Apache #” ./src/http/ngx_http_special_response.c

    #以上是安裝nginx之前編譯的更改源碼隐藏資訊及版本号

    useradd nginx -s /sbin/nologin -M #禁止登陸,無家目錄 配置檔案中修改為 worker_processes 1; user nginx;

  • 時間同步以保證安裝服務時候不會報錯
  • 1.安裝ntpdate工具

    yum -y install ntp ntpdate

    2.設定系統時間與網絡時間同步

    ntpdate cn.pool.ntp.org

    3.将系統時間寫入硬體時間

    hwclock --systohc

    4.強制系統時間寫入CMOS中防止重新開機失效

      hwclock -w

      或clock -w

    5.設定計劃任務 crontab -e 檢視計劃任務 crontab -l

/

繼續閱讀