当前位置: 澳门新濠3559 > 操作系统 > 正文

(2).重启系统生效,1、生成密码

时间:2019-11-20 22:05来源:操作系统
  查询系统中全部的内核: GRUB密码保护,主要防止别个恶意修改你主机ROOT密码。 Linux入门教程:Linux开机启动过程浅析 Linux开机启动过程浅析 Introduction 开机启动过程分为以下6个步骤

 

查询系统中全部的内核:

GRUB密码保护,主要防止别个恶意修改你主机ROOT密码。

Linux入门教程:Linux开机启动过程浅析

Linux开机启动过程浅析

Introduction
开机启动过程分为以下6个步骤,分别是BIOS, MBR, GRUB, Kernel, Init, RunLevel, RunDefinition

BIOS
按下电源开关那一刻,开始加载BIOS,并且执行MBR(Master Boot Record)

BIOS表示基本输入输入系统(Basic Input/Output System),完成一些系统的完整性检查、搜索、
加载并且执行引导程序(boot loader), 它在软盘,CD-ROM或者硬盘上寻找引导程序。你可以在
系统启动时按下键盘(通常是F12或者F2,但是因系统而异)来修改启动顺序

一旦引导程序被检测到并且加载到内存,BIOS会将控制权移交给它

MBR
MBR表示主引导记录(Master Boot Record)

用于加载并执行GRUB

GRUB
GRUB是多重引导管理器(GRand Unified Bootloader)

执行 /etc/grub.conf, 加载内核镜像

vim /etc/grub.conf

default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS 6 (2.6.32-504.el6.x86_64)
        root (hd0,0)
        kernel /vmlinuz-2.6.32-504.el6.x86_64 ro root=/dev/mapper/vg_ddz-lv_root rd_NO_LUKS rd_NO_MD rd_LVM_LV=vg_ddz/lv_root crashkernel=128M LANG=zh_CN.UTF-8 rd_LVM_LV=vg_ddz/lv_swap  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
        initrd /initramfs-2.6.32-504.el6.x86_64.img

Kernel
执行内核首个进程 /sbin/init, 进程号为1, 是接下来所有其它进程的父进程

(2).重启系统生效,1、生成密码。initrd表示Initial RAM Disk

initrd被内核用作临时的根目录,直到内核启动完成并且真正的根目录挂载成功。
它也包括一些编译好的必要的驱动程序,这些程序有助于它访问硬盘和其他硬件

Init
执行 /etc/inittab, 来确定启动级别

vim /etc/intttab
# Default runlevel. The runlevels used are:
#  0 - halt (Do NOT set initdefault to this)
#  1 - Single user mode
#  2 - Multiuser, without NFS (The same as 3, if you do not have networking)
#  3 - Full multiuser mode (终端模式)
#  4 - unused
#  5 - X11(图形用户界面)
#  6 - reboot (Do NOT set initdefault to this)
#
id:5:initdefault:执行 /etc/rc.d/rc.sysinit, 来启动系统进程,比如说NetWork

RunLevel
执行启动级别相对应的一系列系统服务

对应启动级别的目录如下

ll /etc/rc.d/

drwxr-xr-x. 2 root root  4096 11月 29 09:49 rc0.d
drwxr-xr-x. 2 root root  4096 11月 29 09:49 rc1.d
drwxr-xr-x. 2 root root  4096 3月  10 17:18 rc2.d
drwxr-xr-x. 2 root root  4096 3月  10 17:18 rc3.d
drwxr-xr-x. 2 root root  4096 3月  10 17:18 rc4.d
drwxr-xr-x. 2 root root  4096 3月  10 17:18 rc5.d
drwxr-xr-x. 2 root root  4096 11月 29 09:49 rc6.d

RunDefinition
最后执行 /etc/rc.d/rc.local, 来运行自定义的服务

vim /etc/rc.d/rc.local

  1 #!/bin/sh
  2 #
  3 # This script will be executed *after* all the other init scripts.
  4 # You can put your own initialization stuff in here if you don't
  5 # want to do the full Sys V style init stuff.
  6
  7 touch /var/lock/subsys/local
  8 if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
  9    echo never > /sys/kernel/mm/transparent_hugepage/enabled
 10 fi
 11 if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
 12    echo never > /sys/kernel/mm/transparent_hugepage/defrag
 13 fi
 14
 15 /bin/bash /usr/local/apps/kylin/bin/kylin.sh start

其中第15行为自定义启动脚本

Final
进入登录界面

本文永久更新链接地址:

Linux开机启动过程浅析 Introduction 开机启动过程分为以下6个步骤,分别是BIOS, MBR, GRUB, Kernel, Init, RunLev...

  Oracle 安装时官方建议关闭Linux的透明大页,防止内存延迟分配导致的性能问题

$ rpm -q kernel

1、生成密码
[root@localhost ~]# grub-md5-crypt
Password:
Retype password:
$9U6aAg751$6l/ob1$8KK/bMZFhK6NQw1
[root@localhost ~]#

        

kernel-2.6.32-431.el6.x86_64
kernel-2.6.32-504.16.2.el6.x86_64
kernel-2.6.32-504.23.4.el6.x86_64
kernel-2.6.32-504.30.3.el6.x86_64

2、修改Grub.conf文件

 

删掉:

[root@localhost ~]# vi /etc/grub.conf

  MOS:ID 1557478.1

sudo yum remove kernel-2.6.32-504.30.3.el6.x86_64
删除后:

default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu

   Because Transparent HugePages are known to cause unexpected node reboots and performance problems with RAC, Oracle strongly advises to disable the use of Transparent HugePages. In addition, Transparent Hugepages may cause problems even in a single-instance database environment with unexpected performance problems or delays. As such, Oracle recommends disabling Transparent HugePages on all Database servers running Oracle.

$ sudo cat /etc/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,1)
#          kernel /vmlinuz-version ro root=/dev/mapper/vg_l-lv_root
#          initrd /initrd-[generic-]version.img
#boot=/dev/sdb1
device (hd0) HD(1,800,64000,8e3964af-b55a-4977-826c-49c250cf7fac)
default=0
timeout=5
splashimage=(hd0,1)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32-504.23.4.el6.x86_64)
    root (hd0,1)
    kernel /vmlinuz-2.6.32-504.23.4.el6.x86_64 ro root=/dev/mapper/vg_l-lv_root nomodeset rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_l/lv_root rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=128M rd_LVM_LV=vg_l/lv_swap  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
    initrd /initramfs-2.6.32-504.23.4.el6.x86_64.img
title CentOS (2.6.32-504.16.2.el6.x86_64)
    root (hd0,1)
    kernel /vmlinuz-2.6.32-504.16.2.el6.x86_64 ro root=/dev/mapper/vg_l-lv_root nomodeset rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_l/lv_root rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=128M rd_LVM_LV=vg_l/lv_swap  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
    initrd /initramfs-2.6.32-504.16.2.el6.x86_64.img
title CentOS (2.6.32-431.el6.x86_64)
    root (hd0,1)
    kernel /vmlinuz-2.6.32-431.el6.x86_64 ro root=/dev/mapper/vg_l-lv_root nomodeset rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_l/lv_root rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=128M rd_LVM_LV=vg_l/lv_swap  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
    initrd /initramfs-2.6.32-431.el6.x86_64.img

password --md5 $9U6aAg751$6l/ob1$8KK/bMZFhK6NQw1
title CentOS (2.6.32-431.el6.x86_64)--在此行前加入密码信息
      root (hd0,0)
      kernel /vmlinuz-2.6.32-431.el6.x86_64 ro root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=VolGroup/lv_swap SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=VolGroup/lv_root  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
...
....

 

 

3、保存退出

1.查看透明大页是否启用

4、Reboot查看效果

   RHEL  6:

澳门新濠3559 1

# cat /sys/kernel/mm/redhat_transparent_hugepage/enabled

[oracle@rhel 6 ~]$ cat /sys/kernel/mm/redhat_transparent_hugepage/enabled
[always] madvise never

 

  RHEL  7:

# cat /sys/kernel/mm/transparent_hugepage/enabled

[root@rhel 7 ~]# cat /sys/kernel/mm/transparent_hugepage/enabled

[always] madvise never

 

2.禁用透明大页

RHEL 6:

(1).编辑 /etc/grub.conf 文件,在kernel 那一行后面追加 transparent_hugepage=never

例如:

default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux 6 (2.6.32-642.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-642.el6.x86_64 ro root=/dev/mapper/rootvg-lvroot rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=us LANG=en_US.UTF-8 rd_LVM_LV=rootvg/lvswap rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=rootvg/lvroot rd_NO_DM rhgb quiet transparent_hugepage=never
initrd /initramfs-2.6.32-642.el6.x86_64.img

(2).重启系统生效。

RHEL 7:

(1).编辑/etc/sysconfig/grub 文件,在 GRUB_CMDLINE_LINUX 那一行后面追加 transparent_hugepage=never

例如:

澳门新濠3559,GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=rootvg/root rd.lvm.lv=rootvg/swap rhgb quiet transparent_hugepage=never"
GRUB_DISABLE_RECOVERY="true"

(2).再使用 grub2-mkconfig 生成grub.cfg配置文件。

# grub2-mkconfig -o /boot/grub2/grub.cfg

(3).重启系统使配置生效。

编辑:操作系统 本文来源:(2).重启系统生效,1、生成密码

关键词: