FreeBSD (system optimization)

Source: Internet
Author: User
Tags comparison table

After the ports and src are upgraded, the infrastructure is complete. Now let's compile the kernel.
Enter the Kernel configuration file directory
# Cd/usr/src/sys/i386/conf
# Mkdir/root/kernels
# Cp GENERIC/root/kernels/IM. RD. BJ
# Ln-s/root/kernels/IM. RD. BJ
IM. RD. BJ: the name of your new Kernel configuration file.
 
Compile the kernel
# Cd/usr/src
# Make buildkernel KERNCONF = IM. RD. BJ
 
Install Kernel
# Make installkernel KERNCONF = IM. RD. BJ
 
You can configure your own Kernel File IM. RD. BJ before compiling the kernel so that she can meet her requirements.
 
For details about the Kernel configuration file, refer to the relevant official documents.
 
After compilation is complete, our current job is to optimize and adjust some system parameters.
 
# Ee/boot/loader. conf
Join:
Kern. ipc. maxsockets = 65535
Kern. maxusers = 256
Kern. ipc. nmbclusters = 32768
Kern. ipc. nsfbufs = 2496
 
# Ee/etc/sysctl. conf
Join:
Net. inet. ip. sourceroute = 0
Net. inet. ip. accept_sourceroute = 0
Net. inet. tcp. drop_synfin = 1
Kernel. maxvnodes = 8446
 
Kern. maxfiles = 65536
Kern. maxfilesperproc = 32768
Kern. ipc. somaxconn = 32768
Kern. ipc. shmmax = 67108864 #64 MB
Kern. ipc. shmall = 32768
Kern. ipc. shm_allow_removed = 0
Kern. coredump = 1
Net. inet. ip. portrange. last = 65535
 
Net. inet. tcp. msl = 2500
Net. inet. udp. blackhole = 1
Net. inet. udp. log_in_vain = 1
Net. inet. tcp. always_keepalive = 1
Net. inet. udp. blackhole = 1
Net. inet. raw. maxdgram = 65536
Net. inet. raw. recvspace = 65536
 
Net. inet. tcp. blackhole = 2
Net. inet. tcp. delayed_ack = 1
Net. inet. tcp. inflight. enable = 1
Net. inet. tcp. inflight. debug = 0
Net. inet. tcp. inflight. rttthresh = 10
Net. inet. tcp. inflight. min = 6144
Net. inet. tcp. inflight. max = 1073725440
Net. inet. tcp. inflight. stab = 20
 
Net. local. stream. sendspace = 65536
Net. local. stream. recvspace = 65536
Net. inet. tcp. sendspace = 32768
Net. inet. tcp. recvspace = 65536
Net. inet. udp. maxdgram = 24576
Net. inet. udp. recvspace = 49152
 
Net. inet. ip. rtexpire = 3600
Net. inet. ip. rtminexpire = 2
 
Net. inet. ip. random_id = 1
Net. inet. icmp. icmplim = 100
Net. inet. icmp. icmplim_output = 1
Net. inet. icmp. drop_redirect = 1
Net. inet. icmp. log_redirect = 1
 
Net. inet. tcp. keepidle = 600000
Net. inet. ip. redirect = 0
Net. isr. direct = 1
Net. inet. ip. intr_queue_maxlen = 4096
 
Kern. ipc. shm_use_phys = 1
Net. inet. ip. fastforwarding = 1
 
Vfs. hirunningspaces = 4194304
Vfs. ufs. dirhash_maxmem = 33554432 #32 MB
Vfs. write_behind = 0
Security. bsd. see_other_uids = 1
Security. bsd. see_other_gids = 1
 
After the configuration is complete, reboot the machine.
If you do not want to restart the machine to load the modified parameters, you can also use:
#/Etc/rc. d/sysctl reload
 
Well, after optimizing the parameters, we need to consider installing software using ports in the future. These software is installed in the form of source code, so we have to do two optimization work here, the first is to optimize the compiler, that is, the GCC compilation command, which can improve the efficiency of the software, and the second is to accelerate the download of the software for ports.
After the system is installed, the make. conf file does not exist by default. You can create one by yourself. (Self-reliance, good clothes and food, ha !)
 
First, adjust the GCC compilation parameters.
# Touch/etc/make. conf
# Ee/etc/make. conf
Join:
CFLAGS =-march = pentium-m-O2-pipe-msse2-mmmx-mfpmath = sse
CXXFLAGS =$ {CFLAGS}
Among them,-march refers to the CPU of your machine. If you do not know the CPU model, you can use the following method to check it. My name is IBMT43. The result is as follows:
# Sysctl hw. model
Hw. model: Intel (R) Pentium (R) M processor 1.86 GHz
The following is a comparison table. It will be OK if you change the CPU model. (here only the comparison of CPU is provided. No parameter is added. There are many parameters added on the Internet, which may not be suitable, so let's take a look at this article and add it by yourself. You can feel at ease and find out the cause if you are wrong .).
I386 (Intel)
CFLAGS =-march = i386
CXXFLAGS + =-march = i386
Isung (Intel)
CFLAGS =-march = isung
CXXFLAGS + =-march = isung
Pentium 1 (Intel)
CFLAGS =-march = pentium
CXXFLAGS + =-march = pentium
Pentium MMX (Intel)
CFLAGS =-march = pentium-mmx
CXXFLAGS + =-march = pentium-mmx
Pentium PRO (Intel)
CFLAGS =-march = pentiumpro
CXXFLAGS + =-march = pentiumpro
Pentium II (Intel)
CFLAGS =-march = pentium2
CXXFLAGS + =-march = pentium2
Celon (Mendocino), aka Celeron1 (Intel)
CFLAGS =-march = pentium2
CXXFLAGS + =-march = pentium2
Pentium III (Intel)
CFLAGS =-march = pentium3
CXXFLAGS + =-march = pentium3
Celon (Coppermine) aka Celeron2 (Intel)
CFLAGS =-march = pentium3
CXXFLAGS + =-march = pentium3
Celon (Willamette ?) (Intel)
CFLAGS =-march = pentium4
CXXFLAGS + =-march = pentium4
Pentium 4 (Intel)
CFLAGS =-march = pentium4
CXXFLAGS + =-march = pentium4
Eden C3/Ezra ()
CFLAGS =-march = i586-m3dnow
CXXFLAGS + =-march = i586-m3dnow
K6 (AMD)
CFLAGS =-march = k6
CXXFLAGS + =-march = k6
AMD (K6-2)
CFLAGS =-march = k6-2
CXXFLAGS + =-march = k6-2
AMD (K6-3)
CFLAGS =-march = k6-3
CXXFLAGS + =-march = k6-3
Athlon (AMD)
CFLAGS =-march = athlon
CXXFLAGS + =-march = athlon
Athlon-tbird, aka K7 (AMD)
CFLAGS =-march = athlon-tbird
CXXFLAGS + =-march = athlon-tbird
Athlon-tbird XP (AMD)
CFLAGS =-march = athlon-xp
CXXFLAGS + =-march = athlon-xp
Athlon 4 (AMD)
CFLAGS =-march = athlon-4
CXXFLAGS + =-march = athlon-4
Athlon XP (AMD)
CFLAGS =-march = athlon-xp
CXXFLAGS + =-march = athlon-xp
Athlon MP (AMD)
CFLAGS =-march = athlon-mp
CXXFLAGS + =-march = athlon-mp
 
Next, we will adjust the download of ports. These websites are fast and recommended by most users:
MASTER_SITE_OVERRIDE? =
The http://ports.hshh.org/$ {DIST_SUBDIR }/
The http://ports.cn.freebsd.org/$ {DIST_SUBDIR }/
Ftp://ftp.freeBSDchina.org/pub/FreeBSD/ports/distfiles/$ {DIST_SUBDIR }/
MASTER_SITE_OVERRIDE? =$ {MASTER_SITE_BACKUP}
Finally, we also came to play with the multi-thread download of ports. axel was invited to play! Doon and Doon...
If you do not know the position of axel in ports, run the following command to find it:
# Cd/usr/ports
# Make search key = axel
Port: axel-1.0b
Path:/usr/ports/ftp/axel
Info: A download accelerator
Maint: ports@FreeBSD.org
B-deps: gettext-0.14.5_2 gmake-3.81_1 libiconv-1.9.2_2
R-deps: gettext-0.14.5_2 libiconv-1.9.2_2
WWW: http://wilmer.gaast.net/main.php/axel.html
In fact, another more convenient method is whereis.
# Whereis axel
Axel:/usr/ports/ftp/axel
Now that we know the location is there, let's go to her. In a small case, if you are hiding it deep, you can also find it. I search for it and check it...
# Cd/usr/ports/ftp/axel
# Make install clean
Wait for her to complete the installation, because she still needs to install some dependent packages, which may take a little longer. Please wait patiently or go out to the migen cigarettes (Smoking is not good, we still don't recommend it here, so we can stand up and take a look at the green color to make it environmentally friendly and healthy. Grandpa Mao told us: "The body is the capital of the revolution." This is especially true for IT practitioners !!!)
After the installation is complete, we need to set it so that she can work for us or set it in make. conf.
# Ee/etc/make. conf
Join:
FETCH_CMD = axel
FETCH_BEFORE_ARGS =-n 10-
FETCH_AFTER_ARGS =
DISABLE_SIZE = yes
 
Now, our system environment has been installed and configured. Because we need to configure four servers, We need to copy three VMS for simple and convenient installation of related application software. Leave this as a backup so that the system is damaged and can be replaced, saving you from re-installation. This is convenient, and virtual machines are good!

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.