CentOS6.7生產環境基礎優化實戰

CentOS6.7生產環境基礎優化實戰


1、添加aliyun在線yum源。

添加源前,首先請做好備份/etc/yum.repos.d/CentOS-Base.repo

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

下面提供多個在線源供選擇:

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.sohu.com/help/CentOS-Base-sohu.repo

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS6-Base-163.repo

接下來就要安裝幾個必要的軟件了:

[root@sample ~]# yum install -y lrzsz tree telnet

[root@sample ~]# rpm -qa tree telnet lrzsz
telnet-0.17-48.el6.x86_64
tree-1.5.3-3.el6.x86_64
lrzsz-0.12.20-27.1.el6.x86_64


2、關閉SELINUX和iptables

[root@sample ~]# sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
                                            #修改配置文件則永久生效,但是必須要重啓系統。
[root@sample ~]# setenforce 0    #臨時生效命令
[root@sample ~]# getenforce    #查看selinux當前狀態
Permissive


[root@sample ~]# /etc/init.d/iptables status                #查看iptables的狀態
Table: filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination         
1    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED 
2    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0           
3    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           
4    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22 
5    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination         
1    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination   

#iptables off

[root@sample ~]# chkconfig iptables off                     #取消開機自啓動iptables
[root@sample ~]# chkconfig --list|grep iptables
iptables        0:off   1:off   2:off   3:off   4:off   5:off   6:off
[root@sample ~]# /etc/init.d/iptables stop                  #臨時停止iptables服務
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]
[root@sample ~]# /etc/init.d/iptables status
iptables: Firewall is not running.                         #再次查看服務已沒有運行。


3、添加普通用戶並進行sudo授權管理

[root@sample ~]# useradd guest

wKiom1hme0iit9Y-AABF4-5LfqE434.png-wh_50


4、定時自動更新服務器時間

[root@sample ~]# crontab -e

[root@sample ~]# crontab -l
#####sync time#####
*/5 * * * * /usr/sbin/ntpdate time.windows.com >/dev/null 2>&1



待續……………………






















發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章