VIM command interpretation summary; mount usage and redundant backup disks of redundant disk arrays

IM pt

Configuring the application service in the Linux system is actually modifying its configuration file (there may be multiple configuration files, which contain different parameters), which must be passed through a text editor To be done. So a text editor is very necessary, vim text editor, yesviAn upgraded version of the editor.

Vim can be recognized by so many manufacturers and users because there are three modes in the Vim editor-Command mode, last line mode and Edit mode, there are a variety of different command shortcut key combinations, which greatly improves work efficiency, and you will feel very comfortable after using it. To be more efficient in text operations, we must first understand the operation differences and switching methods of the three modes of the Vim editor.

Command mode: Control cursor movement, delete, copy and paste text.

input mode: normal text entry.

Last line mode: save, exit and set the editing environment.

remember every time you run vim editor The default is “command mode“, you need to enter “input mode” After that, you can write the document, and each time the editing is completed, you need to return to the “command mode” and then enter the “last line mode” to save or exit the text.

Here are the most commonly used shortcut commands, There is no special technique for “input mode”.

Commonly used shortcut keys in the command mode of the vim editor

Command< /span>

Function

< /td>

dd

Delete (cut) the entire line where the cursor is located.

5dd< /span>

Delete (cut) the beginning of the cursor 5 rows.

yy< /span>

Copy the entire line where the cursor is located.

5yy< /span>

Copy 5 lines from the cursor.

p< /span>

delete (dd) or copy (yy ) Pasted data is pasted behind the cursor.

/character String

Search from top to bottom in the text The string.

? Character String

Search the text from bottom to top String.

n< /span>

Display the next character string located by the search command .

N< /span>

Display the last character string located by the search command .

u< /span>

Undo the previous step< /p>

Common commands in the last line mode of the vim editor< /strong>

span>

Command

Function

:w

Save p>

:q p>

Exit

:q!

Force Quit (Abandon the modification of the text)

:wq!

Force save and exit

:set nu

display line number

:set nonu< /span>

Do not display line numbers p>

:Command

Execute this command

:integer

Jump to this line

Note:

1. In command mode and last line mode, all shortcut key parameters are case sensitive.

2. There is a colon “:” in front of all shortcut key parameters in the last line mode .

write A document

Step 1 : Create a document.

share picture

Step 2: Tap the letter “a” to enter the input mode.

share picture

Step3: Enter a line of characters. ,

share picture

Step 4: Hit [esc] to return to the command mode.

Share pictures

< p>Step 5: Click “:wq”, save and exit.

Share pictures

span>6 steps: View the content of the document.

share picture

Step 7: Edit the file.

Share pictures

span>8 steps: tap the letter “o” to enter the input mode.

share picture

Step 9: Enter a line of characters.

share picture

th Step 10: After returning to the command mode, try “:q” to exit without saving.

share picture

Step 11: The prompt content has been modified and cannot be exited.

share picture

Step 12: Press “:q!” and then force to exit without saving.

Share pictures

< span style="font-size: 13px;">Step 13: Check the document and find that the second sentence is indeed not saved

< img alt="Share a picture" src="/wp-content/uploads/images/os/unix/1626797351495.png" width="1057" height="764" >

​< / p>

mount using redundant disk array (in Example RAID10) < p>

Step1: Add 5 more hard disks to the virtual machine:

share picture

Step2: Use the mdadm command to create RAID10 with the name ”/dev/md0″.

-C represents the creation operation, -v displays the creation process, -a yes checks the RAID name, -n is the number of hard drives used ,-L is to define the RAID level and write the name of the hard disk to be added to the array at the end.

[[email protected] ~]#mdadm -Cv /dev/md0 -a yes -n 5 -l 10 /dev/sdb /dev/sdc /dev/sdd /dev/sde /dev/sdf

share picture

Step3: Format and mount to use

Set RAID disk The array is formatted in ext4 format:

[[emailprotected] ~]# mkfs.ext4 /dev/md0

Create a mount directory:

[[ email protected] ~]# mkdir /RAID

To mount the file system:

[[emailprotected] ~]# mount /dev/md0 /RAID

< p>View the disk mounting information:

[[email protected] ~]# df -h

Set this disk array mounting information to still take effect after restarting:

p>

[[email Protected] ~]# echo “/dev/md0 /RAID ext4 defaults 0 0” >> /etc/fstab

share picture

< /p>

share picture

Step 4: View /dev/md0 device information

Parameters-D View the detailed information of the RAID array:

[[email protected] ~]# mdadm -D /dev/md0

share picture

Step 5: Simulate a case where a hard disk is damaged< /strong>

Usemdadm’s -f parameter to move /dev/sdb out of the array:

[[ email protected] ~]# mdadm /dev/md0 -f /dev/sdb

mdadm: set /dev/sdb faulty in /dev/md0

Look at the status of the array again (the /dev/sdb status at this time is removed and failed status):

[[emailprotected] ~]# mdadm -D /dev/md0

share picture

< p>Step 6: After the damage is still normal Use

BecauseRAID10 level can allow a group of RAID1 hard disks to have a faulty disk without affecting the use, so it still You can create or delete files normally~

Now add the new hard disk to it, of course, you can also restore the hard disksdb :Please After restartingExecute mdadm /dev/md0 -a /dev/sdb“.

share picture

< strong> Redundant backup disk settings (take RAID5 as an example)

Unmount the disk system first:

[[email Protected] ~]# umount /dev/md0

Stop the array device and completely disable it:

[[email protected] ~]# mdadm -S / dev/md0

mdadm: stopped /dev/md0

Now the array is no longer found:

[[email protected] ~]# mdadm -D /dev/md0

mdadm: cannot open /dev/md0: No such file or directory

Create RAID5 and set 1 block Backup failed disk:

[[email protected] ~]# mdadm -Cv /dev/md0 -n 3 -l 5 -x 1 /dev/sdb /dev/sdc /dev/sdd /dev/sde /dev/sdf

share picture

[[email Protected] ~]# mdadm -D /dev/md0

Share a picture

format the disk array toext4 system:

[[emailprotected] ~ ]# mkfs.ext4 /dev/md0

Share a picture

Because the fstab file has been set before, So now you can mount it directly:

[[email protected] ~]# mount -a

will/dev/sdb device is set to failure and removed from the array:

[[email protected] ~]# mdadm /dev/md0 -f /dev/sdb

mdadm: set / dev/sdb faulty in /dev/md0

Look at the detailed information of the array again (The hard disk sde is directly replaced at this time):

[[email protected] ~]# mdadm -D /dev/md0

Share Picture

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 5546 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.