1. "Project name"
daily management of Linux system
"Project description"
1. Install the deployment Rhel system and build a RAID disk array.
2. install Nginx script to write Nginx Service service startup script
"Project assessment Skills Point"
1, install the deployment of RHEL system, network settings.
2. Basic usage of shell scripts
3, installation of Nginx
4, the whole program should include: System installation, disk partition format, Shell script application and other related content.
The project environment can be referenced as follows:
1. Install two Rhel hosts
corresponding host name and IP:xuegod63.cn 192.168.1.63
xuegod64.cn 192.168.1.64
2. Build raid0,raid1,raid5,raid10. Disk array.
3. Install Nginx.
4. Edit shell script to implement Nginx auto-start
Daily management of Linux system
#############################################################
1. Install two Rhel hosts
corresponding host name and IP:xuegod63.cn 192.168.1.63
xuegod64.cn 192.168.1.64
The first step:
Open the VMware software and create a new two virtual machine, rhel7_xuegod63, RHEL7_XUEGOD64, respectively. 1G Memory, 4 cores, remove printer, others use default settings
finally specify the optical drive Mount rhel7.2 image , start installing the operating system (you can also install one later, copy and rename).
Select the first item to install the RHEL7.2 operating system directly, set the following:
1. Keyboard and language selection: English (US), Time zone: Shanghai
2. Close Security POLICY
3. Set up the software source
4, set up a server with GUI, and select the installation development tools,
5. Set the disk partition to:/boot 500M, swap 2G,/10G
6. Close Kdump
7, in the network settings, modify the host name xuegod63.cn, and turn on the network card
To start the installation, you need to set the root password and create a user!
After the installation is complete, such as: (then reboot, and enter the system)
Step Two:
After logging into the system with the root user, start deploying the RHEL7 System lab environment as follows:
1. Turn off the firewall and set the power off automatically
2. Turn off SELinux and set it to turn off automatically
3. Mount the optical drive to the/MNT and set the automatic boot mount
Set up an optical drive auto-connect in VMware
4. Set Yum source
5. Set up a virtual machine network using a specific virtual network mode
IP is 192.168.1.63, 192.168.1.64, respectively
Setting the virtual machine network mode to a specific virtual network mode
See if the native IP address network segment conflicts with the network segment that will be set
In VMware, set up a native Vmnet1 Nic such as:
And see if the settings take effect in Cmd.exe
In the RHEL7 system, the settings are as follows:
Restart, after logging in again, check for such as:
Ok, save the snapshot!
The other virtual machine is also set up as above.
############################################################################################################### ############################################################
2. Build raid0,raid1,raid5,raid10. Disk array.
(implemented in the xuegod63.cn host)
For convenience, only a piece of disk is added to the virtual machine and the disk is organized by partition
Boot up and save the snapshot (RAID)
Remote connection via Xshell
Step one: Build a RAID0 disk array
1. Partition the disk (two 2G)
[Email protected] ~]# ls/dev/sdb*
/dev/sdb
[Email protected] ~]# Fdisk/dev/sdb
Welcome to Fdisk (Util-linux 2.23.2).
Changes'll remain in memory only, until the decide to write them.
Be careful before using the Write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x743bcf7f.
Command (M for help): N
Partition Type:
P Primary (0 primary, 0 extended, 4 free)
E Extended
Select (default P):
Using Default Response P
Partition number (1-4, default 1):
First sector (2048-41943039, default 2048):
Using Default Value 2048
Last sector, +sectors or +size{k,m,g} (2048-41943039, default 41943039): +2g
Partition 1 of type Linux and of size 2 GiB is set
Command (M for help): t
Selected partition 1
Hex code (type L to list all codes): FD
Changed type of partition ' Linux ' to ' Linux raid AutoDetect '
Command (M for help): N
Partition Type:
P Primary (1 primary, 0 extended, 3 free)
E Extended
Select (default P):
Using Default Response P
Partition number (2-4, default 2):
First sector (4196352-41943039, default 4196352):
Using Default Value 4196352
Last sector, +sectors or +size{k,m,g} (4196352-41943039, default 41943039): +2g
Partition 2 of type Linux and of size 2 GiB is set
Command (M for help): t
Partition Number (2, default): 2
Hex code (type L to list all codes): FD
Changed type of partition ' Linux ' to ' Linux raid AutoDetect '
Command (M for help): P
disk/dev/sdb:21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * MB = bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk label Type:dos
Disk identifier:0x743bcf7f
Device Boot Start End Blocks Id System
/DEV/SDB1 2048 4196351 2097152 fd Linux raid AutoDetect
/DEV/SDB2 4196352 8390655 2097152 fd Linux raid AutoDetect
Command (M for help): W
The partition table has been altered!
Calling IOCTL () to re-read partition table.
Syncing disks.
[Email protected] ~]# ls/dev/sdb*
[Email protected] ~]# MDADM-E/dev/sdb[1-2]
[Email protected] ~]# mdadm-c/dev/md0-n 2-l 0/dev/sdb[1-2]
[Email protected] ~]# MDADM-E/dev/sdb[1-2]
2. Build RAID0 disk array:
3. Format/DEV/MD1 Disk
[Email protected] ~]# mkfs.xfs/dev/md0
4. Mount and set the boot automatically mount
[Email protected] ~]# Mkdir/raid
[Email protected] ~]# Mount/dev/md0/raid
[Email protected] ~]# Df-ht | Grep/raid
[Email protected] ~]#
[Email protected] ~]# echo "/dev/md0/raid xfs defaults 0 0" >>/etc/fstab
[Email protected] ~]# tail-1/etc/fstab
/dev/md0/raid XFS Defaults 0 0
[Email protected] ~]# Umount/raid
[Email protected] ~]# Mount-av
6. Save disk Array configuration information
[Email protected] ~]# Mdadm-dvs >/etc/mdadm.conf
[email protected] ~]# cat!$
5. Testing
Step two: Build a RAID1 disk array
1, restore the snapshot, partition format (two 5G partitions)
2. Create a RAID1 disk array
[Email protected] ~]# mdadm-c/dev/md1-n 2-l 1/dev/sdb[1-2]
Mdadm:Note:this array have metadata at the start and
May is suitable as a boot device. If you plan to
Store '/boot ' on this device, ensure that
Your Boot-loader understands md/v1.x metadata, or use
--metadata=0.90
Continue creating array? Yes
Mdadm:defaulting to version 1.2 metadata
MDADM:ARRAY/DEV/MD1 started.
[Email protected] ~]#
3. Save configuration information
[Email protected] ~]# Mdadm-dvs >>/etc/mdadm.conf
4. Format the disk partition and set the automatic boot mount
[Email protected] ~]# MKFS.XFS/DEV/MD1
[Email protected] ~]# Ls/raid
[Email protected] ~]# echo "/dev/md1/raid xfs defaults 0 0" >>/etc/fstab
[Email protected] ~]# tail-1!$
[Email protected] ~]# Mount-av
5. Delete the disk array RAID1
[Email protected] ~]# Umount/raid/
[Email protected] ~]# Mdadm--stop/dev/md1
[Email protected] ~]# Mdadm--remove/dev/md1
[Email protected] ~]# mdadm--misc--zero-superblock/dev/sdb1
[Email protected] ~]# mdadm--misc--zero-superblock/dev/sdb2
[Email protected] ~]# MDADM-E/dev/sdb[1-2]
Step three: Build a RAID5 disk array
1. Restore snapshot, partition format (three 5G partitions) (No hot spare-X is used)
2. Create a disk array RAID5
3. Save configuration information
[Email protected] ~]# Mdadm-dvs >/etc/mdadm.conf
4. Format the disk partition and set the automatic boot mount
[Email protected] ~]# MKFS.XFS/DEV/MD5
[Email protected] ~]# Ls/raid/
[Email protected] ~]# echo "/dev/md5/raid xfs defaults 0 0" >>/etc/fstab
[Email protected] ~]# tail-1!$
[Email protected] ~]# Mount-av
Fourth step: Build a RAID10 disk array
1. Recover snapshot, partition format (six 3G partitions) (use two hot spare x)
2. Creation of two RAID1 disk arrays
[Email protected] ~]# MDADM-E/dev/sdb[1-7]
[Email protected] ~]# mdadm-c/dev/md11-n 2-l 1-x 1/dev/sdb[1-3]
[Email protected] ~]# mdadm-d/dev/md11
[Email protected] ~]# mdadm-c/dev/md12-n 2-l 1-x 1/dev/sdb[5-7]
[Email protected] ~]# mdadm-d/dev/md12
3. Create a RAID0 disk array using RAID1
[Email protected] ~]# mdadm-e/dev/md1*
[Email protected] ~]# mdadm-c/dev/md10-n 2-l 0/dev/md1[1-2]
[Email protected] ~]# mdadm-d/DEV/MD10
4. Save configuration information
[Email protected] ~]# Mdadm-dvs >/etc/mdadm.conf
5, format, and set the boot automatically mount
[Email protected] ~]# MKFS.XFS/DEV/MD10
[Email protected] ~]# Mkdir/raid
[Email protected] ~]# tail-1!$
[Email protected] ~]# Mount-av
############################################################################################################### ############################################################
3. Install Nginx.
(implemented in the xuegod64.cn host)
Turn on the virtual machine and connect remotely via Xshell
1. See if Nginx service is installed
2, from the Nginx official website Download Nginx source package, and through Xftp upload Nginx source package to the virtual machine
3, unzip the source package to the specified directory
[Email protected] ~]# TAR-ZXF nginx-1.11.3.tar.gz-c/usr/src/
4. Create Nginx User
5. Configure Nginx
[Email protected] nginx-1.11.3]#/configure--prefix=/usr/local/nginx--user=nginx--group=nginx
This is to find an error, because less install the dependency package Pcre-devel, Zlib-devel
[Email protected] nginx-1.11.3]# rpm-q pcre-devel
[Email protected] nginx-1.11.3]# rpm-q zlib-devel
[Email protected] nginx-1.11.3]# rpm-ivh/mnt/packages/pcre-devel-8.32-15.el7.x86_64.rpm
[Email protected] nginx-1.11.3]# rpm-ivh/mnt/packages/zlib-devel-1.2.7-15.el7.x86_64.rpm
After the installation dependency is complete, continue with the configuration, and then use the echo $? See if the configuration is successful!
6. Compile and install
[Email protected] nginx-1.11.3]# Make-j 4
[[email protected] nginx-1.11.3]# make install
7, optimize, and start the Nginx service, check the service time installation success
[Email protected] ~]# Cp/usr/local/nginx/sbin/nginx/usr/sbin/nginx
[Email protected] ~]# Ls/usr/sbin/nginx
[Email protected] ~]# Nginx
[Email protected] ~]# Netstat-anlpt | grep nginx
Ok, in your own host to see if the situation indicates that the configuration nginx successfully!!!
################################################################
4. Edit shell script to implement Nginx auto-start
The operation is as follows:
[[email protected] ~]# Touch Nginx
[Email protected] ~]# chmod +x nginx
[Email protected] ~]# ls-l Nginx
[Email protected] ~]# vim Nginx
[email protected] ~]# CP Nginx/etc/init.d/nginx
[Email protected] ~]# chkconfig--add nginx
[Email protected] ~]# chkconfig--list nginx
The script code is as follows:
#!/bin/bash
#chkconfig: 2345 80 80
#description: Nginx Server Scripts
nginx= "/usr/local/nginx/sbin/nginx"
Case $ in
Start
Netstat-anlpt | grep nginx
If [$?-eq 0]
Then
echo "Nginx Server is already started!"
Else
echo "Nginx Server ready to start!"
$nginx
If [$?-eq 0]
Then echo "Nginx Server start success!"
else echo "Nginx Server start fail!"
Fi
Fi
;;
Stop
Netstat-anlpt | grep nginx
If [$?-eq 0]
Then
echo "Nginx Server ready to stop!"
$nginx-S Stop
If [$?-eq 0]
Then echo "Nginx Server stop success!"
else echo "Nginx Server stop fail!"
Fi
Else
echo "Nginx Server is already stop!"
Fi
;;
Restart
$nginx-S Reload
If [$?-eq 0]
Then
echo "Nginx Server restart success!"
Else
echo "Nginx Server restart failed!"
Fi
;;
Status
Netstat-anlpt | grep nginx
If [$?-eq 0]
Then
echo "Nginx Server is running!"
Else
echo "Nginx Server is not running!"
Fi
;;
*)
echo "Error, please enter \" Services {start | Stop | Restart | Status} nginx\ ' "
;;
Esac
First stage test: daily management of Linux system