In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to set up the exchange file in CentOS7, which is very detailed and has a certain reference value. Friends who are interested must read it!
Source of problem
Want to buy VPS to set up some blog services, prefer dynamic blogs and so on, choose nodejs, the scope is reduced, fancy N-blog at the beginning. You need to install bower. If you keep asking about the npm version during installation:
Npm WARN deprecated This version of npm lacks support for important features,npm WARN deprecated such as scoped packages, offered by the primary npmnpm WARN deprecated registry. Consider upgrading to at least npm@2, if not thenpm WARN deprecated latest stable version. To upgrade to npm@2, run:npm WARN deprecated npm WARN deprecated npm-g install npm@latest-2npm WARN deprecated npm WARN deprecated To upgrade to the latest stable version, run:npm WARN deprecated npm WARN deprecated npm-g install npm@latestnpm WARN deprecated npm WARN deprecated (Depending on how Node.js was installed on your system, younpm WARN deprecated may need to prefix the preceding commands with `sudo`, or ifnpm WARN deprecated on Windows, run them from an Administrator prompt.) npm WARN deprecated npm WARN deprecated If you're running the version of npm bundled withnpm WARN deprecated Node.js 0.10 LTS Be aware that the next version of 0.10 LTSnpm WARN deprecated will be bundled with a version of npm@2, which has some smallnpm WARN deprecated backwards-incompatible changes made to `npm run- script` andnpm WARN deprecated semver behavior.
The hint is actually very clear, which means that the npm version is too low and some features are not supported. Refer to the prompt, execute
Npm-g install npm@latest
Similarly, there is a screen prompt. After all, npm has not been upgraded at this moment. After waiting for dozens of seconds, the following appears
. Npm WARN deprecated backwards-incompatible changes made to `npm run- script` andnpm WARN deprecated semver behavior.Killed is omitted above
If you are not careful, you will find that it is inexplicably over, and npm has not been updated. If you look closely, you will see a Killed prompt on the last line. A search on the Internet, you can find that this is because there is not enough memory, the server does not have enough memory, so the program ends directly. In fact, if the VPS memory is small, there will be problems not only when installing the nodejs library, but also when using yum to install the package directly, it will also prompt Cannot allocate memory's Error.
Solution
Upgrade VPS configuration
The easiest way, of course, is to upgrade the VPS configuration, which can be done by clicking a button on the web page, as long as you pay. For individual players, just use VPS to set up some personal websites and twists and turns some gadgets, there is not much traffic, and often does not need a good configuration. Therefore, the following method is adopted to add the exchange file.
SWAP FILE
We usually hear more about swapping partitions, that is, dividing a separate area directly on the hard disk to use as swap space. If it is not convenient to create a new partition after the system has been installed, you can use files instead. Swap space is essentially a hard disk, a large cache used as memory in the system, when the operating system memory is not enough, some less commonly used pages will be replaced into the swap space. Therefore, swap space will improve the performance of some systems. However, the larger the swap space, the better, because if the application happens to use the data of the swap space, there will be a large delay at this time, and too large swap partitions will lead to a large number of applications with high latency. Therefore, if the program has large memory requirements, the best way is to increase physical memory. Buying memory is the king, and swapping space is just a way to slightly improve performance.
CentOS7 settings exchange file
Check system condition
First of all, check whether the system has set up the swap space, in principle, try to set only one swap space. In addition, it is also necessary to check whether the system has enough spare hard disk space.
Swapon-s
You can view the swap space of the system through the swapon command, or you can view it through the free command.
Free-h
Use the df command to check the remaining hard disk space on the system.
Df-h
Create a swap file
Use the fallocate command to create a new swap file, because my system memory is 512m, and the swap partition is generally set to 2x4 times memory, so I set it to 1G and mount it directly to the root directory.
Sudo fallocate-l 1G / swapfile
You can view it through the ls command
Ls-lh / swapfile
The results are as follows
-rw-r--r-- 1 root root 1.0G Oct 30 11:00 / swapfile
Enable swap files
First, modify the / swapfile permission to allow access only to root users.
Sudo chmod 600 / swapfile
The results of ls are as follows
-rw- 1 root root 1.0G Oct 30 11:00 / swapfile
Next, inform the system to create the swap space
Sudo mkswap / swapfile
Finally, enable swap space
Sudo swapon / swapfile
You can view the results through the swapon-s or df-h commands, and the swap space should be displayed.
Persistent configuration
After reboot, the system will no longer set / swapfile as swap space. You can add the following to / etc/fstab
/ swapfile swap swap sw 0 0
In this way, the system will automatically map / swapfile to swap space after reboot.
Last
It is conceivable that if the actual memory requirements far exceed the physical memory size, the data exchange between memory and swap space will occur frequently, which will cause great damage to the hard disk. Moreover, the application experience will be relatively poor.
Therefore, swapping space is only a temporary solution, and buying a memory stick is the king.
The above is all the contents of the article "how to set up Exchange Files in CentOS7". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to 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.