How to optimize the Linux server after it is installed

Source: Internet
Author: User
Tags openssh server


How to optimize the Linux server after it is installed is not directly hosted in the data center after it is installed, instead, we need to perform a series of optimization configurations and security configurations. 1. It should be easy to understand to close services that are not needed by our system, one advantage is to reduce memory and CPU usage, and the other advantage is to improve security. Which services must be retained? On linux machines, there are usually four services that must be retained. iptables is a powerful firewall in linux. As long as the machine needs to be connected to the Internet, the network of the linux machine must be enabled, if you do not want to access the Internet, you can disable it. If you want to access the Internet, you must enable it. sshd is an openssh server. If your machine is not operated locally, it is hosted in the IDC, therefore, syslog must be performed through the sshd service when accessing the machine. This is the log system of the linux system and must be available. Otherwise, the cause will not be found in the case of machine problems except for the four necessary services, what other services need to be retained? In this case, you can determine the purpose of the system. For example, to use a database server, you need to enable the mysqld (or oracle) web server, to enable apache 2 and disable unnecessary tty, edit your/etc/inittab and find the following section: 1: 2345: respawn:/sbin/mingetty tty12: 2345: respawn: /sbin/mingetty tty23: 2345: respawn:/sbin/mingetty tty34: 2345: respawn:/sbin/mingetty tty45: 2345: Weight:/sbin/mingetty tty56: 2345: Weight: the/sbin/mingetty tty6 command enables init to open six consoles for you. You can use alt + f1 to alt + f6 to access these six consoles by default, in fact, there is no need to use so many. You can see that the ps auxf command is six. Processes: root 3004 0.0 0.0 1892 tty1 Ss + Jun29/sbin/mingetty tty1root 412 3037 0.0 0.0 2492 tty2 Ss + Jun29/sbin/mingetty tty2root 412 3038 0.0 0.0 tty3 Ss + Jun29/sbin/mingetty tty3root 3051 0.0 0.0 1812 tty4 Ss + Jun29/sbin/mingetty tty4root 412 3056 0.0 0.0 2116 tty5 Ss + Jun29/sbin/mingetty tty5root 412 3117 0.0 2396 412 tty6 Ss + Jun29/sbin/mingetty tty6 How do I close these processes? Usually we can keep the first two consoles, and annotate the last four with #, and then we don't need to restart the machine, you only need to execute the init q command to define init q as a parameter: Re-execute the command in/etc/inittab and restart the machine to make the modification take effect. 3. How do I disable atime? A linux file has three default times: atime: Access time of this file ctime: Time When inode of this file changes mtime: the modification time of this file. If there are multiple small files, there is usually no need to record the file access time, which can reduce disk io, for example, how do I set multiple small images on a web server page? Modify the file system configuration file: vi/etc/fstab uses noatime in the partition containing a large number of small files. nodiratime includes:/dev/md5/data/pics1 ext3 noatime, nodiratime 0 0 will no longer generate disk write io when files are accessed. 4. Make sure your server runs on level 3. Practice: vi/etc/inittab id: 3: initdefault: it is unnecessary to run X on the server. 5. Optimization of sshd X11Forwarding no // forwarding of x images without UseDNS no // reverse resolution of IP addresses 6. Optimization of shell modification command history record # vi/etc/profile find HISTSIZE = 1000 to HISTSIZE = 100 and then source/etc/profile

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.