分类 CentOS配置 下的文章

1. 设置NTP同步,实现服务器为标准时间。

vi /etc/ntp.conf
## 1. 国外服务器 添加以下3个时间服务器。
## 国内服务器可用 中国国家授时 ntp.ntsc.ac.cn
server time-a.nist.gov
server time-b.nist.gov
server time.windows.com

2. 强制更新时间为nist时间

## 个人使用或非生产服务器。生产服务器无须进行此操作,让ntp慢慢同步时间即可。
ntpdate time.nist.gov

3. 启动ntp时间同步服务

systemctl start ntpd

4. 设置ntp为开机自启动的服务

systemctl enable ntpd

5. 查看时间同步情况

## 更新前
ntpq -p
        remote           refid      st t when poll reach   delay   offset  jitter
   ==============================================================================
   +20.189.79.72    25.66.230.5      3 u  356 1024  377   50.116   19.730   3.571
   +time-a-g.nist.g .NIST.           1 u  66m 1024  210  273.868   -4.648   4.312
   *time-b-g.nist.g .NIST.           1 u  418 1024  211  276.645  -10.136   4.238
## 更新后
ntpq -p
         remote           refid      st t when poll reach   delay   offset  jitter
    ==============================================================================
     time-a-g.nist.g .INIT.          16 u    -   64    0    0.000    0.000   0.000
     time-b-g.nist.g .INIT.          16 u    -   64    0    0.000    0.000   0.000
     40.81.188.85    25.66.230.0      3 u   19   64    1    8.632   -4.547   0.000

1. 查看启动菜单

egrep ^menuentry /etc/grub2.cfg | cut -f 2 -d \’

menuentry 'CentOS Linux (4.11.8-1.el7.elrepo.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-957.el7.x86_64-advanced-c376c392-8e32-46c8-9496-cd004fb61679' {
menuentry 'CentOS Linux (0-rescue-c2a4bfa7e0c74436b3a978656ab959e8) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-c2a4bfa7e0c74436b3a978656ab959e8-advanced-c376c392-8e32-46c8-9496-cd004fb61679' {

2. 设置默认菜单为第1项

grub2-set-default 0

3. 修改超时时间为 1秒

sed -i -r "s/set timeout=[0-9]+/set timeout=1/g" /boot/grub2/grub.cfg

4. 确认 /boot/grub2/grub.cfg 修改成功

grep timeout /boot/grub2/grub.cfg

if [ x$feature_timeout_style = xy ] ; then
  set timeout_style=menu
  set timeout=1
# Fallback normal timeout code in case the timeout_style feature is
  set timeout=1

  1. 下载最新rpm
    最新文件名参照 https://dev.mysql.com/downloads/repo/yum/
    sudo rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

  2. 安装 mysql 服务器
    sudo yum install mysql-community-server

  3. 查看 root 密码
    grep "temporary password" /var/log/mysqld.log

  4. 更新 root 密码
    4.1 登录mysql
    mysql -u root -p
    4.2 更新root 密码
    alter user 'root'@'localhost' identified by '1.jishuquan.com';
    密码规则:同时包含大写字母、数字、特殊字符。

一、简单更新升级

##更新当前系统为最新版本
yum -y update

二、安装常用工具 wget/locate

## 安装  wget / locate
yum -y install wget mlocate
## 更新文件名数据库
updatedb
## 按文件名搜索路径
locate php.ini