Linux Operations Common knowledge (4)

Source: Internet
Author: User
Tags icinga

The Linux command is invalid-bash:ls:command not found

After a reboot, all basic commands are unavailable and only a few commands are available

[email protected] ~]# LL

-bash:ls:command not found

[Email protected] ~]# pwd

/root

[Email protected] ~]# Shutdown-r now

-bash:shutdown:command not found

[Email protected] ~]# export $PATH

-bash:export: '/usr/java/jdk1.7.0_55/bin::/root/bin ': not a valid identifier

[Email protected] ~]#

Export $PATH may be a path setting problem

1. Set path temporarily first

Export Path=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

Modify the configuration file, found that there is a code error, the original configuration of the Java path, path spelling error

#vi/etc/profile

Export java_home=/usr/java/jdk1.7.0_55

Export Java_bin=/usr/java/jdk1.7.0_55/bin

Export path= $JAVA _home/bin: $PAH

Export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tool.jar

Restart the solution.


MySQL modifies datadir and socket related paths under CentOS

Sometimes we want to use a different directory to store data instead of the/var/lib/mysql directory that MySQL uses by default.

In order to fulfill this requirement, we need a few steps to achieve:

1, modify SELinux to permissive or disable

2, modify the permissions of the directory to the MySQL user all and belong to the group

3, modify/ETC/MY.CNF

Modify the DataDir and socket to the path you need

Once this is done, the mysql-server can start normally, and you can see that the data file and the socket file have been stored in the directory you specified. But when you make


Using the local MySQL client to connect to the server, you will find that the system still prompts you to find "/var/lib/mysql/mysql.sock" This sock file, this time


Continue to the next

4, add a section in the/ETC/MY.CNF

[Client]

socket=[the file you specified]

OK, this will allow you to connect normally after restarting the mysql-server.


Using mysql_secure_installation will still prompt you cannot find the "/var/lib/mysql/mysql.sock" file, open

mysql_secure_installation command script, which is under the/usr/bin directory.

Add a section to the Make_config function

echo "socket=[The file you specified, above settings" >> $config

After saving the file, you can use it normally.



Resolve reason 442:failed to Enable Virtual adapter error for Cisco Systems VPN client under WINDOWS8

Cisco IPSEC VPN created with Cisco Systems VPN client under WINDOWS8 is unable to connect, prompting reason 442:failed to Enable Virtual Adapter, the problem is WINDOWS8 special , you cannot resolve this issue with a solution from another system. The solution is given below.

1. Open Registry Editor (requires Administrator privileges)

2. Find Hkey_local_machine\system\currentcontrolset\services\cvirta

Select the item with the name DisplayName, and modify the value.

4. If the x86 (i.e. 32-bit) version will be similar to @oem8.inf,%cvirta_desc%; The value of the Cisco Systems VPN Adapter is modified for Cisco Systems VPN Adapter

5. If the x64 (i.e. 64-bit) version will be similar to @oem8.inf,%cvirta_desc%; The value of Cisco Systems VPN Adapter for 64-bit Windows is modified to Cisco Systems VPN Adapter for 64-bit windows

6. Click the Connect button in the Cisco Systems VPN client to successfully connect.


Monitoring tool: CactiEZ and no data, no image resolution

The CactiEZ Chinese version is the simplest and most effective solution for cacti Chinese, integrating spine,rrdtool and beautifying fonts.

Integrates templates such as Thold,monitor,syslog,weathermap,realtime,errorimage,mobile,aggregate and Apache,squid,f5,nginx,mysql. Support a variety of hard disk controllers and array cards, based on CentOS6, faster boot speed, support EXT4 file system, native Rsyslog more stable. Full Chinese page, Chinese graphics, support mail alarm, support sound alarm, easy to install and use.

CactiEZ Chinese Version 10.1:

: 32-bit: http://www.zhengfeng.net/CactiEZ-10.1-i386.torrent

64-bit: http://www.zhengfeng.net/CactiEZ-10.1-x86_64.torrent

CactiEZ still have English version of http://cactiusers.org/this website to download English version.

Http://www.crazycen.com/linux/1164.html

Cacti no image or no data solution:

1.system utilities–>rebuild poller Cache 2. System time is not accurate, reset time 3. Image is not generated, run #/usr/bin/php/srv/www/htdocs/cacti/ Poller.php–force 4. Permissions issues, modify Permissions #chmod 777-r/srv/www/htdocs/cacti/rra 5. Database table damaged, repair #mysqlcheck-ao Cacti–auto-repair- Uroot-p 6. Restart SNMPD service #service snmpd restart


Icinga Chinese Version

Icinga is actually a two-time development of Nagios, which includes all of Nagios's features and can even be used to directly take Nagios's configuration files. ICINGA-CN is a special Chinese project, more suitable for people to use.

Chinese version address: http://icinga-cn.sourceforge.net/



Several common Linux host performance monitoring scripts

1. Check the host network card traffic

#! /bin/bash#network#mike.xuwhile:; Dotime= ' Date +%m '-"%d" "%k": "%m ' day= ' date +%m"-"%d ' rx_before= ' ifconfig eth0|sed-n" 8 "P|awk ' {print $} ' |cut-c7-' Tx_ Before= ' ifconfig eth0|sed-n "8" P|awk ' {print $6} ' |cut-c7-' sleep 2rx_after= ' ifconfig eth0|sed-n ' 8 ' P|awk ' {print $} ' |cu t-c7-' tx_after= ' ifconfig eth0|sed-n "8" P|awk ' {print $6} ' |cut-c7-' rx_result=$[(rx_after-rx_before)/256]tx_result=$ [(Tx_after-tx_before)/256]echo "$time now_in_speed:" $rx _result "Kbps now_out_speed:" $tx _result "kbps" Sleep 2done

2. System condition Monitoring

#! /bin/sh#systemstat.sh#mike.xuip=192.168.1.227top-n 2| grep "Cpu". /temp/cpu.txtfree-m | grep "Mem". /temp/mem.txtdf-k | grep "SDA1". /temp/drive_sda1.txt#df-k | grep sda2 ". /temp/drive_sda2.txtdf-k | grep "/mnt/storage_0". /temp/mnt_storage_0.txtdf-k | grep "/mnt/storage_pic". /temp/mnt_storage_pic.txttime=date +%m ". "%d" "%k": "%mconnect=netstat-na | grep "219.238.148.30:80" | Wc-lecho "$time $connect". /temp/connect_count.txt

3, monitor the disk space of the host, when the use of more than 90% in space by sending mail to send a warning

#! /bin/bash#monitor available disk spacespace= ' DF | Sed-n '/\/$/P ' | Gawk ' {print $} ' | Sed ' s/%//' if [$SPACE-ge]then[email Protected]fi

4. Monitor CPU and Memory usage

#! /bin/bash#script to capture system statisticsoutfile=/home/xu/capstats.csvdate= ' date +%m/%d/%y ' time= ' date +%k:%m:%s ' timeout= ' uptime ' vmout= ' vmstat 1 2 ' users= ' echo $TIMEOUT | Gawk ' {print $4} ' load= ' echo $TIMEOUT | Gawk ' {print $9} ' | Sed "s/,//' free= ' echo $VMOUT | Sed-n '/[0-9]/p ' | Sed-n ' 2p ' | Gawk ' {print $4} ' idle= ' echo $VMOUT | Sed-n '/[0-9]/p ' | Sed-n ' 2p ' |gawk ' {print $} ' echo ' $DATE, $TIME, $USERS, $LOAD, $FREE, $IDLE "" $OUTFILE

5, all-round monitoring of the host

#! /bin/bash# check_xu.sh# 0 * * * * /home/check_xu.shdat= "date +%Y%m%d" Hour= "Date +%h" dir= "/home/oslog/host_${dat}/${hour}" delay=60count=60# whether the  responsible directory existif !  test -d ${dir}then/bin/mkdir -p ${dir}fi# general checkexport term= linux/usr/bin/top -b -d ${delay} -n ${count}  " ${DIR}/top_${DAT}.log 2 "&1 &# cpu check/usr/bin/sar -u ${DELAY} ${COUNT} "  ${dir}/cpu _${dat}.log 2 "&1 &#/usr/bin/mpstat -P 0 ${DELAY} ${COUNT} "  ${ Dir}/cpu_0_${dat}.log 2 "&1 &#/usr/bin/mpstat -p 1 ${delay} ${count}   " ${dir}/cpu_1_${dat}.log 2" &1 &# memory check/usr/bin/vmstat ${ delay} ${count}  " ${dir}/vmstat_${dat}.log 2" &1 &# i/o check/usr/bin/iostat ${delay} ${count}  " ${dir}/iostat_${dat}.log 2" &1  &# network check/usr/bin/sar -n DEV ${DELAY} ${COUNT}  " ${ Dir}/net_${dat}.log 2 "&1 &#/usr/bin/sar -n EDEV ${DELAY} ${COUNT} "  ${dir}/net_edev_${dat}.log 2 "&1 &

Put it in crontab. Auto-execute every hour:

0 * * * */home/check_xu.sh


This generates hourly CPU, memory, network, and IO statistics in the/HOME/OSLOG/HOST_YYYYMMDD/HH directory.

If a time period is a problem, you can look at the corresponding log information to see how the host performance.


After the Print Spooler service starts, it stops automatically, and the service is deadlocked

Suspected abnormal shutdown, resulting in "Print Spooler service" boot file "spoolsv.exe" corruption. A spoolsv.exe was copied from the other machine. Overwrite, restart. Failure is still

start-to-run, enter regedit to open Registry Editor
the following key values are found:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Spooler
Select Spooler This folder, in the right window to find DependOnService this key value
Double-click Open to change the data to RPCSS, and then exit Registry Editor to restart the computer.


Remote boot from Linux system

1. The server is not deployed locally, usually hosted into the IDC room, and the server in the computer room more than one, one is closed, we can remotely connect a server without shutdown, and then remote boot.


2. Software required for remote boot: WakeOnLAN

Yum Install Wol-y


3. How do I start a remote boot?

Do not rush to shut down your Linux server first, you have to determine whether it supports remote boot?

1) Log on to the target server and print out the network card information with the Ethtool command.

[Email protected] lhd]# Ethtool eth0

As you can see, ethtool the network card information, we only care about these two:

Supports WAKE-ON:PUMBG

Wake-on:d

If wake-on is a value of D, disables wake on LAN

A value of g, which means enable wake on LAN

Because this machine disables the wake on LAN, use the following command to enable it:

[Email protected] lhd]# ethtool-s eth0 Wol g

Now the target machine's network card has supported the remote boot,


Below we get its local MAC address:

[Email protected] lhd]# ifconfig

Eth0 Link encap:ethernet HWaddr 00:03:0d:1d:1f:97

Record Hwaddr 00:03:0d:1d:1f:97 this one.

Now you can try to shut down the target machine.


2) Boot

Now we need to log on to the machine where the wake on LAN software is installed and execute the Power on command on it:

Wol 00:03:0d:1d:1f:97

You'll see later that the target machine is powered on and can log on.


The value of WOL is d by default, meaning disable

The modified value is G, meaning wake on Magicpacket (TM)

When the machine restarts, the eth0 settings revert back to the WAKE-ON:D State,

3) How to solve this problem?

Two ways: the first, but also our inertial thinking;

Attach the/sbin/ethtool-s eth0 wol G command to the/etc/rc.local file,

Automatically after the next boot


Second: Edit/etc/sysconfig/network-scripts/ifcfg-eth0

(eth0 network card configuration file), add the previous line:

ethtool_opts= "Wol g"


4, the limitations of network wake-up:

It can only be used in the local area network, but not through the Internet, why?

Because the machine shuts down, the machine is completely awakened by the network card, at this time the machine is closed, no operating system running,

There is no support for the TCP/IP protocol, and of course it cannot be run over the Internet.

In other words: if we have only one machine on a local area network, we cannot use this feature.

We must be able to log on to a machine on the LAN and run the wake on LAN to wake the target machine on this machine

The premise is that the target machine is on the same LAN as the machine we're logged into.


5, one more thing: the target machine that is powered on remotely must be plugged in.

Here is a brief introduction to the use of WakeOnLAN under Linux:

Suppose the remote to wake the computer Ip:12.34.56.78,mac address: 01:02:03:04:05:06

$ wakeonlan-i 12.34.56.78 01:02:03:04:05:06

This article is from the "Start from the Heart" blog, be sure to keep this source http://fuquanjun.blog.51cto.com/5820068/1427062

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.