linux_base

硬盘测速

1
2
3
4
5
6
ssd测速
yum install hdparm -y
hdparm -t /dev/xvda
注意,“/dev/xvda”指的是对应磁盘的驱动号,请执行“fdisk -l”查看。
普通硬盘测速
dd if=/dev/zero of=test bs=64k count=16k oflag=dsync

Close SELINUX

1
2
setenforce 0  
sed -i 's/^SELINUX=.*$/SELINUX=disabled/' /etc/selinux/config

手动关闭

1
2
3
vim /etc/selinux/config
SELINUX=disabled    #把enforcing改为disabled
setenforce 0     #即时生效

关闭firewalld防火墙

1
2
systemctl stop firewalld    #关闭firewalld防火墙
systemctl disable firewalld    #禁止开机自启

安装iptables防火墙并开启

1
2
3
yum install iptables-services    #安装iptables防火墙
systemctl start iptables    #启动
systemctl enable iptables    #开机自启

Set timezone

1
2
rm -rf /etc/localtime  
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

Update time

1
2
0 0 * * * /usr/sbin/ntpdate cn.ntp.org.cn >/dev/null 2>&1
5 6,18 * * * /usr/sbin/ntpdate cn.ntp.org.cn >/dev/null 2>&1;/sbin/hwclock --systohc >/dev/null 2>&1

安装工具包

常用软件包

1
2
3
4
$ yum -y install wget bash-completion zsh git mlocate man unzip procps-ng\
    net-tools bind-utils tcpdump nmap mtr psmisc tree screen dmidecode\
    at openssl openssl-devel readline-devel telnet ntpdate coreutils\
    deltarpm nss

编译所需工具包

1
2
3
4
5
6
7
8
$ yum -y install vim gcc gcc-c++ make cmake autoconf automake \
   texinfo pcre pcre-devel zlib-devel zlib ncurses ncurses-devel\
   bison bison-devel curl curl-devel glibc glibc-devel glib2 glib2-devel\
   bzip2 bzip2-devel libxslt libxslt-devel libxml2 libxml2-devel \
   libxml2-static gd gd-devel freetype freetype-devel libjpeg libjpeg-devel\
   libpng libpng-devel openldap openldap-devel openssl openssl-devel \
   readline-devel expat-devel gettext-devel libicu-devel perl-Digest-SHA \
   deltarpm perl-devel nss

更换源

1
2
3
4
5
6
7
8
9
10
备份源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup


下载CentOS 7阿里源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
epel:
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

运行yum makecache生成缓存