Senin, 28 Desember 2020

, , , , , ,

How to Use Traceroute

Reading Time: 4 minutes

Traceroute is an application that traces the path data takes from one computer to another. Basically a traceroute is a map that shows what stops or locations that data must pass through in order to go from one computer to another. To be an effective troubleshooting tool, the traceroute needs to be run from a computer experiencing the problem while the problem is occurring.

How Do I Run A Traceroute?

To Run a Traceroute in Windows

The command application (cmd.exe) is used to run a traceroute on Windows. Launching it is slightly different depending on your version of Windows:
  • In Windows 7:
    • click on the Start menu
    • type “cmd” and press Enter to get a command prompt.
  • In Windows 8:
    • move your mouse to the bottom-left corner of the screen to bring up the Start icon.
    • Right-click on Start and select Run.
    • Then type “command” and press Enter to launch the application.
    • Alternatively, you can type “command” into the Search field in the Charms menu after moving your mouse to the lower right corner of your desktop.
  • In Windows 10, type “command” into the search menu and press Enter for a command prompt.
To run the traceroute, type:tracert domainname.cominto the command prompt, where “domainname.com” is the name of the server to which you are having difficulty connecting. The traceroute may take only a few seconds or a few minutes. Typically, the closer you are to the server, geographically, the more quickly the traceroute will complete.

To Run a Traceroute in Mac OS X

If you have a Mac, you can use the built-in network tools to run a traceroute.
  • Launch Spotlight (with ⌘ + SPACE or by clicking on the magnifying glass in your menu) to search for and launch Network Utility.
  • Select the Traceroute tab and enter the hostname or domain name.
  • You also can perform a traceroute from the Terminal app. Simply enter:traceroute domainname.com

To Run a Traceroute in Linux

At the command line, type:traceroute domainname.com

What Does the Traceroute Show You?

Let’s take a few sample traceroute outputs.traceroute msu.eduThe output from that command shows a successful trace:traceroute to msu.edu (35.8.10.134), 30 hops max, 40 byte packets 1 lw-dc2-hsrp-vlan132.rtr.liquidweb.com (67.43.8.129) 1.330 ms 1.420 ms 1.554 ms 2 lw-dc2-core4-po2.rtr.liquidweb.com (209.59.157.131) 1.092 ms 1.311 ms 1.451 ms 3 lw-dc1-core1-ge3-5.rtr.liquidweb.com (209.59.157.93) 1.596 ms 1.897 ms 2.209 ms 4 lw-dc1-border3-ge4.rtr.liquidweb.com (209.59.157.29) 1.657 ms 1.748 ms 1.894 ms 5 12.116.80.97 (12.116.80.97) 4.748 ms 5.382 ms 5.453 ms 6 cr81.dtrmi.ip.att.net (12.122.102.2) 12.893 ms 12.035 ms 11.043 ms 7 cr1.cgcil.ip.att.net (12.123.139.157) 11.509 ms 11.615 ms 11.769 ms 8 12.123.7.33 (12.123.7.33) 10.645 ms 10.711 ms 10.760 ms 9 12.90.96.6 (12.90.96.6) 9.473 ms 9.537 ms 9.605 ms 10 xe-0-0-0x14.msu6.mich.net (198.108.22.10) 15.047 ms 14.458 ms 14.487 ms 11 192.122.183.227 (192.122.183.227) 16.976 ms 20.066 ms 20.137 ms 12 cc-t1-ge1-23.net.msu.edu (35.9.101.209) 20.228 ms 20.432 ms 20.312 ms 13 www.msu.edu (35.8.10.134) 16.856 ms 17.071 ms 16.341 msIt looks like gibberish, right? But it’s actually fairly easy to understand. After the traceroute command, the program tells you what it’s doing:
  1. It has looked up the domain msu.edu
  2. It found msu.edu on the IP address of 35.8.10.134
  3. It now will attempt to find its way there using no more than 30 “hops” (stops along the way, or connections to routers), and it will send a packet of 40 bytes.
The numbers at the far left are the number of the hop, followed by the name and/or IP address of the router that hop is going through. You can see that this trace started within the Liquid Web network, progressed through AT&T and found its way to msu.edu. The set of three numbers on the right side of the lines indicate the amount of time, in milliseconds, it took for that hop to complete. Traceroute performs each hop three times.
Note: When troubleshooting network latency by analyzing the time of each hop, please be aware that distance from your geographic location to the server is a factor. Any single hop covering a large physical distance (such as when crossing an ocean) naturally will take longer to complete.
In this example, there are no asterisks (which indicate a failure to respond within 5 seconds) and no inordinately long delays. If your traceroute to your VPS server looks like this, you’re in good shape in terms of network connectivity. Now, let’s look at a simulated traceroute that ends without reaching its destination:traceroute liquidweb.comtraceroute to liquidweb.com (209.59.139.21), 30 hops max, 40 byte packets 1 lw-dc2-hsrp-vlan132.rtr.liquidweb.com (67.43.8.129) 0.947 ms 1.028 ms 1.101 ms 2 lw-dc2-core4-po2.rtr.liquidweb.com (209.59.157.131) 1.275 ms 1.308 ms 1.385 ms 3 lw-dc1-core1-ge3-5.rtr.liquidweb.com (209.59.157.93) 1.849 ms 1.921 ms 1.980 ms 4 lw-dc1-dist1-ge1.rtr.liquidweb.com (209.59.157.2) 92.082 ms 92.155 ms 92.347 ms 5 * * * 6 * * * 7 * * * 8 * * * [truncated]In this example, our trace failed because we deliberately ran it from our internal network (just to demonstrate what a failed trace would look like). You can see that, beginning on the fifth hop, we have nothing but packet loss. The traceroute continued for the full 30 hops, each reporting * * * as it went. If your traceroute to the server ends with asterisks like this one, and never displays an IP address or server name after the asterisks, that means that the connection was not able to be completed. This could be for a variety of reasons including:
  • A network outage
  • High amounts of traffic causing network congestion
  • A firewall dropping traffic from your IP address
However, if the traceroute picks back up following a series of asterisks and ultimately ends with a server name and IP address, it means that the connection was successful — regardless of how many hops exceeded the 5-second response time. This can be an indication of network issues along the routes used in those hops, but it does not indicate a network problem on either your end or the server’s.
Note: If you see these asterisks once you are inside Liquid Web’s network, there may be no need to worry. VPS customers frequently are not able to trace to their instance on the parent server.
If you believe you are experiencing network issues, having the output of traceroute handy and providing it, along with your public IPV4 address (which you can obtain from http://ip.liquidweb.com) when contacting Heroic Support® is an excellent way to help us begin investigating the issue as quickly as possible.

Posted on  | Updated: 


Continue reading How to Use Traceroute

Senin, 09 November 2020

, , , , ,

Error 404 Not Found cwpsrv phpmyadmin - Centos Web Panel

 


solving problem Error 404 cwpsrv phpmyadmin - Centos Web Panel
1. login to root account via putty / terminal

2. update yum server

yum -y update
3. update phpmyadmin
sh /scripts/mysql_phpmyadmin_update

Continue reading Error 404 Not Found cwpsrv phpmyadmin - Centos Web Panel

Selasa, 29 September 2020

, ,

LIMIT PlayStore Mikrotik

/ip firewall layer7-protocol


add name=IPA regexp="\\.(ipa)"

add name=IPSW regexp="\\.(ipsw)"

add name=APK regexp="^.*get.+\\.apk.*\$"

add comment="PLAY STORE" name="Google Play Store" regexp=\

    "^.+.c.android.clients.google.com.*\$"


/ip firewall mangle

add action=mark-connection chain=forward comment=APK connection-mark=!Game \

    disabled=no layer7-protocol=APK new-connection-mark=APK packet-mark=\

    !Game_pkt passthrough=yes

add action=mark-packet chain=forward connection-mark=APK disabled=no \

    new-packet-mark=APK passthrough=no

add action=mark-connection chain=forward comment=IPA connection-mark=!Game \

    disabled=no layer7-protocol=IPA new-connection-mark=IPA packet-mark=\

    !Game_pkt passthrough=yes

add action=mark-packet chain=forward connection-mark=IPA disabled=no \

    new-packet-mark=IPA passthrough=no

add action=mark-connection chain=forward comment=IPSW connection-mark=!Game \

    disabled=no layer7-protocol=IPSW new-connection-mark=IPSW packet-mark=\

    !Game_pkt passthrough=yes

add action=mark-packet chain=forward connection-mark=IPSW disabled=no \

    new-packet-mark=IPSW passthrough=no

add action=mark-connection chain=forward connection-mark=!Game disabled=no \

    layer7-protocol="Google Play Store" new-connection-mark="PLAY STORE" \

    packet-mark=!Game_pkt passthrough=yes

add action=mark-packet chain=forward connection-mark="PLAY STORE" disabled=no \

    new-packet-mark="PLAY STORE" passthrough=no

  

/queue type  

add kind=pcq name=que-down pcq-burst-rate=1M pcq-burst-threshold=256k \

    pcq-burst-time=30s pcq-classifier=dst-address pcq-dst-address-mask=32 \

    pcq-dst-address6-mask=64 pcq-limit=50 pcq-rate=384k pcq-src-address-mask=\

    32 pcq-src-address6-mask=64 pcq-total-limit=2000  

  

/queue tree      

add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=0 \

    max-limit=1M name=ANDROID packet-mark="" parent=V.DOWNLOAD priority=6

add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=50k \

    max-limit=1M name=APEKA packet-mark=APK parent=ANDROID priority=6 queue=\

    que-down

add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=186k \

    max-limit=1M name=IPESWE packet-mark=IPSW parent=ANDROID priority=8 queue=\

    que-down

add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=50k \

    max-limit=756k name=IPS packet-mark=IPA parent=ANDROID priority=8 queue=\

    que-down

add burst-limit=0 burst-threshold=0 burst-time=0s disabled=no limit-at=50k \

    max-limit=1M name="PLAY STORE" packet-mark="PLAY STORE" parent=ANDROID \

    priority=6 queue=que-down


sumber http://syakirahkomputer.blogspot.com

Continue reading LIMIT PlayStore Mikrotik
, , ,

Blokir Windows Update dengan Mikrotik

 


Blokir Windows Update dengan Mikrotik

/ip firewall raw
add action=drop chain=prerouting comment="Blok Windows Update" protocol=tcp tls-host=windowsupdate.microsoft.com
add action=drop chain=prerouting comment="Blok Windows Update" protocol=tcp tls-host=download.microsoft.com
add action=drop chain=prerouting comment="Blok Windows Update" protocol=tcp tls-host=test.stats.update.microsoft.com
add action=drop chain=prerouting comment="Blok Windows Update" protocol=tcp tls-host=ntservicepack.microsoft.com
add action=drop chain=prerouting comment="Blok Windows Update" protocol=tcp tls-host=*.download.windowsupdate.com
add action=drop chain=prerouting comment="Blok Windows Update" protocol=tcp tls-host=*.update.microsoft.com
add action=drop chain=prerouting comment="Blok Windows Update" protocol=tcp tls-host=download.windowsupdate.com
add action=drop chain=prerouting comment="Blok Windows Update" protocol=tcp tls-host=*.windowsupdate.microsoft.com
Continue reading Blokir Windows Update dengan Mikrotik

Senin, 28 September 2020

Rabu, 19 Agustus 2020

, ,

Memaksimalkan Jaringan WiFi Mikrotik

 

wifi merupakan sebuah kebutuhan yang sangat penting,wifi juga dapat mempengaruhi apakan pengunjung akan kembali lagi atau tidak dari wifi yang anda sediakan,bagaimana jika pengunjung anda mengakses jaringan wifi anda namun mengalami kendala,seperti lambat ataupun susah untuk konek otomasti pengunjung tersebut tidak akan kembali lagi ke tempat anda


Berikut beberapa tips Optimize Wifi network pada mikrotik


Hanya gunakan channel 1,6,11

Jangan gunakan channel auto

Perhatikan peletakan access point

Supported rate A/G 12Mbps,18Mbps,24Mbps,36Mbps,48Mbps,54Mbps

Basic rate A/G 12Mbps,18Mbps

Band 2GHz-G/N

Channel Width 20MHz

Untuk frekuensi 5GHz cukup gunakan 40MHz atau 20MHz

Batasi Tx Power

Gunakanlah SSID yang sama

Pastikan jumlah IP Pool mencukupi untuk jumlah pengunjuna

/24 = 256 ip

/23 = 512 ip

/22 = 1024 ip

Jangan membatasi VPN

Gunakan Bandwith management

Untuk kenyamanan hindari pengunjung harus sering login

Jika tidak membutuhkan hotspot,gunakanlah security pada wireless WPA2-PSK dengan AES

Jika gunakan hotspot besarkan session time out

Setting idle time out ke none

Keep alive time ke none

Set Minimum Singal Strength ke -75

Non aktifkan default authenticate

Non aktifkan default forward

Turn of wps mode

Itulah beberapa tips untuk Optimize Wifi network pada mikrotik


sumber : sharkwifi.com

Continue reading Memaksimalkan Jaringan WiFi Mikrotik
,

Blokir Situs Website dengan DNS Static Mikrotik

 


Internet sangat diperlukan di masa pandemi seperti ini, dengan internet kita menggunakannya untuk banyak belajar, dalam beberapa kasus baik di kantor ataupun sekolah penggunaan internet sering disalah gunakan yaitu dengan menggunakannya untuk menonton streaming ataupun bermain game.
berikut adalah salah satu klue atau cara untuk memblokir website dengan menggunakan dns static di mikrotik.

buka winbox
pilih menu ip > dns > static 
atau dengan command
ip dns static

berikut daftar list situs yang biasanya di blokir
/ip dns static

add name=*.agenfilm21.me address=127.0.0.1
add name=*.ayamhoki.com address=127.0.0.1
add name=*.cinemaindoxxi.me address=127.0.0.1
add name=*.filmbioskop.com address=127.0.0.1
add name=*.layarcinemaxxi.com address=127.0.0.1
add name=*.lk21-film.online address=127.0.0.1
add name=*.luckygames.io address=127.0.0.1
add name=*.studentsexparties.com address=127.0.0.1
add name=*.sukafilm.me address=127.0.0.1
add name=*.herbayoga.com address=127.0.0.1
add name=*.keezmovies.com address=127.0.0.1
add name=*.xvideos.com address=127.0.0.1
add name=*.fuq.com address=127.0.0.1
add name=*.ip-hide.net address=127.0.0.1
add name=*.pornstarmovies.us address=127.0.0.1
Continue reading Blokir Situs Website dengan DNS Static Mikrotik

Sabtu, 06 Juni 2020

, , ,

Kamera Canon yang support di Zoom Meeting



Dalam suasana seperti sekarang ini, Webinar ataupun meeting sudah mulai terbiasa dengan menggunakan aplikasi fenomenal Zoom Cloud Meeting. Namun ketika kita ingin mendapatkan hasil gambar dan suara yang baik, kita masih terbatas dengan fitur webcam dan mikrofon pada laptop yang kurang begitu optimal.
Belum lama ini, sebuah brand penyedia Camera dan Mirrorles bermerk Canon menghadirkan fungsi dan fitur webcam di beberapa varian terbaru untuk memenuhi kebutuhan konsumennya dalam melaksanakan webinar dan meeting dengan hasil memuaskan.
berikut daftar kamera merk Canon yang sudah support webcam.

EOS DSLR Cameras

EOS-1D X Mark II
EOS-1D X Mark III
EOS 5D Mark IV
EOS 5DS
EOS 5DS R
EOS 6D Mark II
EOS 7D Mark II
EOS 77D
EOS 80D
EOS 90D

EOS Rebel SL2
EOS Rebel SL3
EOS Rebel T6
EOS Rebel T6i 
EOS Rebel T7
EOS Rebel T7i
EOS Rebel T100

EOS Mirrorless Cameras

EOS M6 Mark II 
EOS M50
EOS M200

EOS R
EOS RP
 
PowerShot Cameras

PowerShot G5X Mark II
PowerShot G7X Mark III
PowerShot SX70 HS

dengan tambahan software EOS Webcam Utility Beta, semua tipe dan varian Kamera diatas bisa kita gunakan sebagai webcam di OS windows dan Mac OS.

Download Instructions*

Mac

1.    - Select your model below.

2.    - Select the "Drivers & Downloads" tab

3.    - Select the "Software" tab

4.    - Select 10.15 (Catalina), 10.14 (Mojave), or 10.13 (High Sierra)., if not already detected, from the Operating System list.

5.    - Find "EOS Webcam Utility Beta" and click the "SELECT" button.

6.    - Click the download button to start downloading.

Windows

1.    - Select your model below.

2.    - Select the "Drivers & Downloads" tab

3.    - Select the "Software" tab

4.    - Select Windows 10 (x64), if not already detected, from the Operating System list.

5.    - Find "EOS Webcam Utility Beta" and click the "SELECT" button.

6.    - Click the download button to start downloading.

* This software is for use in the U.S. and will not be supported outside that area.



 


Continue reading Kamera Canon yang support di Zoom Meeting

Sabtu, 02 Mei 2020

, , ,

Change SSH port in CWP

CWP comes with the OpenSSH server. This is using by default port 22. CWP doesn’t modify this at installation time but notifies you to change it as soon as possible. The message looks like:
WARNING: Security vulnerability! Your server is using default SSH Port 22, to make your server more secure change SSH port in config file /etc/ssh/sshd_config and in CSF firewall ! After changes are done don’t forget to restart SSH and CSF Firewall.

To modify the SSH port on CentOs Web Panel:

Login to CWP at https://domainname.com:2087 (port 2087 is for a secure connection)
Go to Services Config->SSH Configuration
This will open for editing the file /etc/ssh/sshd_config
Look for the line:

#Port 22

and change the port number to something else, like 2211; also remove the # character from the beginning of the line. In the end, you will have:

Port 2211

Click the Save changes button
Go to the Dashboard and restart the SSH server.
Go to Security->CSF Firewall, click the Firewall Configuration button
Look for the # Allow incoming TCP ports section and add your port number to the list.
Click the Save changes button
Go to Security->CSF Firewall, click the Firewall Restart button
Now you will be able to connect to the server via SSH using the new port number
The short video tutorial for this KB article:






sumber : plothost.com

if the login fault, try this
semanage port -l | grep ssh
and if output is 22
semanage port -a -t ssh_port_t -p tcp 2222
than, finally
semanage port -l | grep ssh
and show the port used ssh_port_t 

Continue reading Change SSH port in CWP

Kamis, 16 April 2020

, ,

default ports on the CentOS servers

List of mostly used default ports on the CentOS servers
Port Number - Name
20 - FTP
21 - FTP
22 - SSH
25 - SMTP/EMAIL
26 - SMTP
43 - WHOIS
53 - BIND/DNS
80 - HTTP / Apache Web server
110 - POP3/EMAIL
143 - IMAP
443 - HTTPS / Apache Web server SSL
465 - SMTP/EMAIL SSL/TLS
873 - RSYNC
993 - IMAP/EMAIL SSL
995 - POP3/EMAIL SSL
2030 - CWP Admin
2031 - CWP Admin SSL
2082 - CWP User Panel
2083 - CWP User Panel SSL
2086 - CWP Admin (same as 2030)
2087 - CWP Admin SSL (same as 2031)
2304 - CWP External API SSL (https, only for api access like whmcs )
3306 - MYSQL


sumber : wiki.centos
Continue reading default ports on the CentOS servers

Senin, 30 Maret 2020

, ,

How To Add Swap on CentOS 7


Introduction

One of the easiest ways to make your server more responsive, and guard against out-of-memory errors in your application, is to add some swap space. Swap is an area on a storage drive where the operating system can temporarily store data that it can no longer hold in memory.

This gives you the ability to increase the amount of information that your server can keep in its working memory, with some caveats. Reading from and writing to swap is slower than using memory, but it can provide a good safety net for when your server is low on memory.

Without swap, a server that runs out of memory may start killing applications to free up memory, or even crash. This can cause you to lose unsaved data or experience downtime. To ensure reliable data access, some applications require swap to function.

In this guide, we will cover how to create and enable a swap file on a CentOS 7 server.

Note
Although swap is generally recommended for systems utilizing traditional spinning hard drives, using swap with SSDs can cause issues with hardware degradation over time. Due to this consideration, we do not recommend enabling swap on DigitalOcean or any other provider that utilizes SSD storage. Doing so can impact the reliability of the underlying hardware for you and your neighbors.
If you need to improve the performance of your server, we recommend upgrading your Droplet. This will lead to better results in general and will decrease the likelihood of contributing to hardware issues that can affect your service.

Prerequisites

Before you begin with this guide, there are a few steps that need to be completed first.

You will need a CentOS 7 server installed and configured with a non-root user that has sudo privileges. If you haven’t done this yet, you can run through steps 1-4 in the CentOS 7 initial server setup guide to create this account.

Once you have your non-root user, you can use it to SSH into your CentOS server and continue with the installation of your swap file.

Check the System for Swap Information
Before we begin, we should take a look at our server’s storage to see if we already have some swap space available. While we can have multiple swap files or swap partitions, one should generally be enough.

We can see if the system has any configured swap by using swapon, a general-purpose swap utility. With the -s flag, swapon will display a summary of swap usage and availability on our storage device:

swapon -s
If nothing is returned by the command, then the summary was empty and no swap file exists.

Another way of checking for swap space is with the free utility, which shows us the system’s overall memory usage. We can see our current memory and swap usage (in megabytes) by typing:

free -m
              total       used       free     shared    buffers     cached
Mem:          3953        315       3637          8         11        107
-/+ buffers/cache:        196       3756
Swap:            0          0       4095
As you can see, our total swap space in the system is 0. This matches what we saw with swapon.

Check Available Storage Space

The typical way of allocating space for swap is to use a separate partition that is dedicated to the task. However, altering the partition scheme is not always possible due to hardware or software constraints. Fortunately, we can just as easily create a swap file that resides on an existing partition.

Before we do this, we should be aware of our current drive usage. We can get this information by typing:

df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        59G  1.5G   55G   3% /
devtmpfs        2.0G     0  2.0G   0% /dev
tmpfs           2.0G     0  2.0G   0% /dev/shm
tmpfs           2.0G  8.3M  2.0G   1% /run
tmpfs           2.0G     0  2.0G   0% /sys/fs/cgroup
Note: the -h flag simply tells dh to output drive information in a human-friendly reading format. For example, instead of outputting the raw number of memory blocks in a partition, df -h will tell us the space usage and availability in M (for megabytes) or G (for gigabytes).

As you can see on the first line, our storage partition has 59 gigabytes available, so we have quite a bit of space to work with. Keep in mind that this is on a fresh, medium-sized VPS instance, so your actual usage might be very different.

Although there are many opinions about the appropriate size of a swap space, it really depends on your application requirements and your personal preferences. Generally, an amount equal to or double the amount of memory on your system is a good starting point.

Since my system has 4 gigabytes of memory, and doubling that would take a larger chunk from my storage space than I am willing to part with, I will create a swap space of 4 gigabytes to match my system’s memory.

Create a Swap File

Now that we know our available storage space, we can go about creating a swap file within our filesystem. We will create a file called swapfile in our root (/) directory, though you can name the file something else if you prefer. The file must allocate the amount of space that we want for our swap file, and it should be created in one contiguous block.

The best way to do this is to use the dd utility. This command will create a 4 gigabyte file:

sudo dd if=/dev/zero of=/swapfile count=4096 bs=1MiB
After entering your password to authorize sudo privileges, the swap file will be created. This can take a few moments, then the prompt will be returned to you. We can verify that the correct amount of space was reserved for swap by using ls:

ls -lh /swapfile
-rw-r--r-- 1 root root 4.0G Oct 30 11:00 /swapfile
As you can see, our swap file was created with the correct amount of space set aside.

Enable a Swap File

Right now, our file is created, but our system does not know that this is supposed to be used for swap. We need to tell our system to format this file as swap and then enable it.

Before we do that, we should adjust the permissions on our swap file so that it isn’t readable by anyone besides the root account. Allowing other users to read or write to this file would be a huge security risk. We can lock down the permissions with chmod:

sudo chmod 600 /swapfile
This will restrict both read and write permissions to the root account only. We can verify that the swap file has the correct permissions by using ls -lh again:

ls -lh /swapfile
-rw------- 1 root root 4.0G Oct 30 11:00 /swapfile
Now that our swap file is more secure, we can tell our system to set up the swap space for use by typing:

sudo mkswap /swapfile
Setting up swapspace version 1, size = 4194300 KiB
no label, UUID=b99230bb-21af-47bc-8c37-de41129c39bf  
Our swap file is now ready to be used as a swap space. We can begin using it by typing:

sudo swapon /swapfile

To verify that the procedure was successful, we can check whether our system reports swap space now:

swapon -s
Filename                Type        Size    Used    Priority
/swapfile               file        4194300 0     -1
This output confirms that we have a new swap file. We can use the free utility again to corroborate our findings:

free -m
             total       used       free     shared    buffers     cached
Mem:          3953        315       3637          8         11        107
-/+ buffers/cache:        196       3756
Swap:         4095          0       4095   
Our swap has been set up successfully, and our operating system will begin to use it as needed.

Make the Swap File Permanent

Our swap file is enabled at the moment, but when we reboot, the server will not automatically enable the file for use. We can change that by modifying the fstab file, which is a table that manages filesystems and partitions.

Edit the file with sudo privileges in your text editor:

sudo nano /etc/fstab
At the bottom of the file, you need to add a line that will tell the operating system to automatically use the swap file that you created:

/swapfile   swap    swap    sw  0   0
When you are finished adding the line, you can save and close the file. The server will check this file on each bootup, so the swap file will be ready for use from now on.

Tweak Your Swap Settings (Optional)

There are a few options that you can configure that will have an impact on your system’s performance when dealing with swap. These configurations are optional in most cases, and the changes that you make will depend on your application needs and your personal preference.

Swappiness

The swappiness parameter determines how often your system swaps data out of memory to the swap space. This is a value between 0 and 100 that represents the percentage of memory usage that will trigger the use of swap.

With values close to zero, the system will not swap data to the drive unless absolutely necessary. Remember, interactions with the swap file are “expensive” in that they are a lot slower than interactions with memory, and this difference in read and write speed can cause a significant reduction in an application’s performance. Telling the system not to rely on the swap as much will generally make your system faster.

Values that are closer to 100 will try to put more data into swap in an effort to keep more memory free. Depending on your applications’ memory profile, or what you are using your server for, this might be the better choice in some cases.

We can see the current swappiness value by reading the swappiness configuration file:

cat /proc/sys/vm/swappiness
30
CentOS 7 defaults to a swappiness setting of 30, which is a fair middle ground for most desktops and local servers. For a VPS system, we’d probably want to move it closer to 0.

We can set the swappiness to a different value by using the sysctl command. For instance, to set the swappiness to 10, we could type:

sudo sysctl vm.swappiness=10
vm.swappiness = 10
This setting will persist until the next reboot. To make the setting persist between reboots, we can add the outputted line to our sysctl configuration file:

sudo nano /etc/sysctl.conf

Add your swappiness setting to the bottom of the file:


vm.swappiness = 10   
When you are finished adding the line, you can save and close the file. The server will now automatically set the swappiness to the value you declared on each bootup.

Cache Pressure

Another related value that you might want to modify is the vfs_cache_pressure. This setting affects the storage of special filesystem metadata entries. Constantly reading and refreshing this information is generally very costly, so storing it on the cache for longer is excellent for your system’s performance.

You can see the current value of this cache pressure by querying the proc filesystem again:

cat /proc/sys/vm/vfs_cache_pressure
100   
As it is currently configured, our system removes inode information from the cache far too quickly. We can set this to a more conservative setting, like 50, by using sysctl:

sudo sysctl vm.vfs_cache_pressure=50
vm.vfs_cache_pressure = 50
Again, this is only valid for our current session. We can change that by adding it to our configuration file, like we did with our swappiness setting:

sudo nano /etc/sysctl.conf
At the bottom, add the line that specifies your new value:

vm.vfs_cache_pressure = 50
When you are finished adding the line, you can save and close the file. The server will now automatically set the cache pressure to the value you declared on each bootup.

Conclusion
By following the steps in this guide, you will have given your server some breathing room in terms of memory usage. Swap space is incredibly useful in avoiding some common problems.

If you are running into OOM (out of memory) errors, or if you find that your system is unable to use the applications that you need, the best solution is to optimize your application configurations or upgrade your server. However, configuring swap space can give you more flexibility and can help buy you time on a less powerful server.



sumber : DO
Continue reading How To Add Swap on CentOS 7