In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to increase the swap exchange space on the Linux system. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article. Let's take a look at it with the editor.
The purpose of increasing the size of server swap swap space in Linux systems is to prevent a shortage of applications. There are two options for increasing swap swap partitions.
1. Use zoning:
Special swap zones are divided when OS is installed, the space size should be planned in advance, and mount should be carried out automatically when the system is started. This method can only be set when installing OS, once the setting is not easy to change, unless the system is reinstalled.
2. Use swapfile: (or the entire free partition)
Create a new temporary swapfile or free partition, set it to swap space when needed, and add up to 8 swapfile. The size of swap space is closely related to CPU. In i386 system, the space of 2GB can be used at most. Increase or decrease the total capacity of 2G as needed after the system is started. This method is more flexible and convenient, but the disadvantage is that it needs to be set up manually after starting the system.
Here are the steps to increase swap space using swapfile:
The commands involved:
Free-View memory status command, can display the size and usage of memory,swap,buffer cache, etc.; dd-read, convert and output data commands; mkswap-set swap swapon-enable swap, equivalent to mount swapoff-turn off swap, equivalent to umount
*
Steps:
1. Create a swapfile file:
Under root permission, create a swapfile, assuming that the current directory is "/", and execute the following command:
[root@testyuyuedb ~] # dd if=/dev/zero of=/swapfile bs=1G count=5 dd: error writing "/ swapfile": there is no space on the device to record 5'0 read in and 4'0 write out 5137985536 bytes (5. 1 GB) copied, 13.9181 seconds, 369 MB/ seconds created a swapfile in the root directory, the name is "swapfile", the size is 5G, you can also output files to any directory you want.
Personally, I think it is better to put it directly under the root directory, which is clear at a glance and is not easy to be destroyed by mistake, but not in other directories (of course, there should be enough disk space in the root directory! )
2. Set swapfile to swap space
# mkswap / swapfile is setting swap space version 1, size = 5017560 KiB no label, UUID=944dc5b9-7526-4fca-90d5-394aecd396bd3, enable swap space, this operation is somewhat similar to mount operation (personal understanding):
# swapon / swapfile swapon: / swapfile: unsafe permission 0644. It is recommended to use 0600. (although there is a hint, it has been enabled successfully. In the future, you should try to modify the file permission to 0600.) now that the operation of increasing the swap space is over, you can use the free command to check whether the swap space size has changed.
There are two ways to increase swap space:
Strictly speaking, there is only one way to add swap after the system is installed, and that is the second method in this article, while the first method should be to set up the swap area when the system is installed.
1. Use zoning:
Special swap zones are divided when OS is installed, the space size should be planned in advance, and mount should be carried out automatically when the system is started. This method can only be set when installing OS, once the setting is not easy to change, unless the system is reinstalled.
2. Use swapfile: (or the entire free partition)
Create a new temporary swapfile or free partition, set it to swap space when needed, and add up to 8 swapfile. The size of swap space is closely related to CPU. In i386 system, the space of 2GB can be used at most. Increase or decrease the total capacity of 2G as needed after the system is started. This method is more flexible and convenient, but the disadvantage is that it needs to be set up manually after starting the system.
Here are the steps to increase swap space using swapfile:
The commands involved:
Free-View memory status command, can display the size and usage of memory,swap,buffer cache, etc.; dd-read, convert and output data commands; mkswap-set swap swapon-enable swap, equivalent to mount swapoff-turn off swap, equivalent to umount
*
Steps:
1. Create a swapfile file:
Under root permission, create a swapfile, assuming that the current directory is "/", and execute the following command:
[root@testyuyuedb ~] # dd if=/dev/zero of=/swapfile bs=1G count=5 dd: error writing "/ swapfile": there is no space on the device to record 5'0 read in and 4'0 write out 5137985536 bytes (5. 1 GB) copied, 13.9181 seconds, 369 MB/ seconds created a swapfile in the root directory, the name is "swapfile", the size is 5G, you can also output files to any directory you want.
Personally, I think it is better to put it directly under the root directory, which is clear at a glance and is not easy to be destroyed by mistake, but not in other directories (of course, there should be enough disk space in the root directory! )
2. Set swapfile to swap space
# mkswap / swapfile is setting swap space version 1, size = 5017560 KiB no label, UUID=944dc5b9-7526-4fca-90d5-394aecd396bd3, enable swap space, this operation is somewhat similar to mount operation (personal understanding):
# swapon / swapfile swapon: / swapfile: unsafe permission 0644. It is recommended to use 0600. (although there is a hint, it has been enabled successfully. In the future, you should try to modify the file permission to 0600.) now that the operation of increasing the swap space is over, you can use the free command to check whether the swap space size has changed.
The above is how to increase the swap exchange space on the Linux system. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.