Linux When you are doing Tsung stress test, you may need to create multiple tcp requests, but the system file open number is fixed, can not meet the demand, this is the need to modify the file open number, the following small series Let me introduce how to modify the number of files opened in the Linux system.
Operating System Version: Redhat 5.4
background to the issue: Tsung stress test, we want to make as many tcp requests and found that you can only build 1013 request.
Reason analysis: The default number of file openers in Linux is 1024, minus 11 used in other places, and the rest is 1013.
Solution:
1) First use the ulimit -n or ulimit -a command to find that the number of open files is 1024
The code is as follows:
[root@SamuluIndex ~]# ulimit -n
1024
2) Use ulimit -n 65535 to change the file open number to the maximum value of 65535, and then use ulimit -n to verify that the modification was successful.
The code is as follows:
[root@SamuluIndex ~]# ulimit -n 65535
[root@SamuluIndex ~]# ulimit -n
65535< Br>
At this point, run tsung start and find that only 1013 requests can still be created. In addition, after logging in again, it is found that the number of file openes is reset back to the default of 1024. Explain that this solution does not work.
3) Add the following two lines to the end of /etc/security/limits.conf
The code is as follows:
* soft nofile 65535
* hard Nofile 65535
Re-verification, success.
Supplementary information:
Modify the maximum number of open files in the Linux system
The maximum number of open files currently set can be viewed by the following command.
ulimit -n
This number shows the maximum number of files a normal user can open in a single session.
Note. If it is root, the following operations cannot increase the output of ulimit -n. Because the user root user is not subject to this ulimit limit. Only ordinary users will be subject to this restriction.
In order to increase the maximum number of open files to the default value of 1024 or more, you need to modify 2 places on the system.
In this case, we increased the maximum number of open files to 2048. All steps require root user operations. Ordinary users need to log in again for the settings to take effect.
1. Set the system according to the maximum number of open files, and check the /proc/sys/fs/file-max file to confirm that the maximum number of open files has been set correctly.
# cat /proc/sys/fs/file-max
If the setting is too small, modify the /etc/sysctl.conf variable to the appropriate value. This will take effect after each reboot. If the setting is large enough, skip the next step.
# echo 2048 》 /proc/sys/fs/file-maxEdit the file /etc/sysctl.conf and insert it into the downlink.
fs.file-max = 2048
2. Set the maximum number of open files in the /etc/security/limits.conf file. Here is a line:
# "domain" "type" "item" "value" add the following line.
* - nofile 2048
This line sets the default number of open files per user to 2048.
Note that there are two possible restrictions on the &noquo;nofile” item. It is hard and soft under "type".
In order for the maximum number of open files to be modified to take effect, these two restrictions must be set.
If you set "type" with the “-” character, the hard and soft settings will be set at the same time.
The hard limit indicates the maximum value that can be set in the soft limit.
The soft limit refers to the setting value that is currently in effect for the system.
The hard limit value can be lowered by ordinary users. But can't increase.
The soft limit cannot be set higher than the hard limit.
Only the root user can increase the hard limit.
When adding a file limit description, you can simply double the current value.
The example is as follows. If you want to increase the default value of 1024, it is better to increase it to 2048. If you want to continue to increase, you need to set it to 4096.
3.Add the following line to the /etc/pam.d/login and /etc/pam.d/xdm file, if it does not already exist:
session required /lib /security/pam_limits.so
4. logout and logon
or dynamically loaded in the shell configuration file.
如.bashrc Riga:
ulimit -HSn 2048
Second, install
tar zxvf mysql-5.1.50-linux-i686-glibc23. Tar.gz
cp -rf mysql-5.1.50-linux-i686-glibc23 /usr/local/
cd /usr/local/
mv mysql-5.1 .50-linux-i686-glibc23/mysql
Install as the default path, so you don't have to make soft links for the program directory
groupadd mysql
useradd -g mysql Mysql
cd mysql/
cp support-files/my-medium.cnf /etc/my.cnf
sed -i ‘s/log-bin=mysql -bin/#log-bin=mysql-bin/g’ /etc/my.cnf
sed -i ‘s/binlog_format=mixed/#binlog_format=mixed/g’ /etc/my.cnf
sed -i ‘s/skip-locking/skip-locking/nmax_connections = 1000/nwait_timeout = 5/g’ /etc/my.cnf
Next to initialize the database
scripts/mysql_install_db --user=mysql
Install mysql service control
cp support-files/mysql.server /etc/Rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on< Br>
service mysqld start
bin/mysqladmin -u root password 123654
The above is the method of modifying the number of open files under Linux. Usually, the number of open files is absolutely sufficient. If you really need to modify the file open number, you can try the method described in this article. What are you waiting for?
Cacti is a network traffic monitoring graphical analysis tool, which needs to be im
awk is a text processing tool in Linux, similar to the shell programming language, has its own langu
As long as people who understand the program know the assert, write it in VC under Windows. After us
There is a command to terminate the process directly under the Linux system. The co
Analysis of Linux memory exhaustion
Linux iis can not run asp file how to solve
Tips for setting up IPv4 in Ubuntu system
Linux method for creating custom Docker images
Fedora system ifconfig and netstat command can not find a solution
Linux uses the source command method
Ubuntu install vim plugin steps
Steps to install Tmux software on CentOS
What should I do if the partition reads and writes error after Debian mounts the mobile hard disk?
Linux uses commands to clear the terminal screen
How to solve the problems encountered when Unix migration to Linux system training
Microsoft officially demonstrates the Win10 system user experience video
The linux shell implements multiple methods of random numbers (date, random, uuid)
How to quickly use search applications with Win7
Is the speed of the network related to the computer?
Don't care! Protect your "command prompt"
Win10 mobile phone preview version of Microsoft edge browser using tutorial
WinXP gets the method of not using IP address
How to right-click Win8 to send files to Skydrive to back up files anytime and anywhere