系統(tǒng)運維
遇到的看見的,長期更新~~~
1.linux亂碼問題
[root@vps software]# vi /etc/sysconfig/i18n
lang=\\\’zh_cn.utf8\\\’
sysfont=latarcyrheb-sun16
supported=zh_cn.utf-8:zh_cn:zh
其中l(wèi)ang變量是language的簡稱,稍微有英語基礎(chǔ)的用戶一看就看出來這個變量是決定系統(tǒng)的默認(rèn)語言的,即系統(tǒng)的菜單、程序的工具欄語言、輸入法默認(rèn)語言等。
sysfont是system font的簡稱,決定系統(tǒng)默認(rèn)用哪一種字體。
supported變量決定系統(tǒng)支持的語言,即系統(tǒng)能夠顯示的語言。
[root@vps software]# source /etc/sysconfig/i18n
2.時間同步
[root@vps /]# crontab -l
01 01 * * * /usr/sbin/ntpdate cn.pool.ntp.org ;hwclock -w >> /dev/null 2>&1
hwclock -w 同步到硬件時鐘
3.查看80連接數(shù)
[root@vps /]# netstat -n|grep :80 | awk \\\’/^tcp/ { s[$nf]} end {for(a in s) print a, s[a]}\\\’
time_wait 2
close_wait 136
established 3
4.鏡像問題
error: cannot retrieve metalink for repository: epel. please verify its path and try again
解決辦法:編輯/etc/yum.repos.d/epel.repo,把基礎(chǔ)的恢復(fù),鏡像的地址注釋掉
#baseurl
mirrorlist
改成
baseurl
#mirrorlist
5.yum不能用,缺包
[root@monitorlib]#yuminstall fping
therewasaproblemimportingoneofthepythonmodules
requiredtorunyum.theerrorleadingtothisproblemwas:
libcurl.so.4:cannotopensharedobjectfile:nosuchfileordirectory
pleaseinstallapackagewhichprovidesthismodule,or
verifythatthemoduleisinstalledcorrectly.
it\\\’spossiblethattheabovemoduledoesn\\\’tmatchthe
currentversionofpython,whichis:
2.6.6(r266:84292,jan222014,09:42:36)
[gcc4.4.720120313(redhat4.4.7-4)]
ifyoucannotsolvethisproblemyourself,pleasegoto
theyumfaqat:
http://yum.baseurl.org/wiki/faq
https://pkgs.org/centos-6/centos-x86_64/libcurl-7.19.7-52.el6.x86_64.rpm.html
libcurl-7.19.7-52.el6.x86_64.rpm
zlib-1.2.3-29.el6.x86_64.rpm
6.安裝圖形界面
yum -y groupinstall desktop
yum -y groupinstall x window system
yum -y groupinstall chinese-support
startx
7.java環(huán)境變量設(shè)置
[root@monitor ~]#yum -y install java-1.7.0-openjdk*
[root@monitor ~]# java -version
java version 1.7.0_111
openjdk runtime environment (rhel-2.6.7.2.el6_8-x86_64 u111-b01)
openjdk 64-bit server vm (build 24.111-b01, mixed mode)
[root@monitor ~]#export java_home=/usr/lib/jvm/java-1.7.0-openjdk.x86_64
java環(huán)境變量設(shè)置http://blog.csdn.net/u010440155/article/details/51544282
8.tomcat java 內(nèi)存設(shè)置
catalina.sh :
java_opts=\\\’-server -xms10240m -xmx10240m -xx:newsize=512m -xx:maxnewsize=512m -xx:permsize=128m -xx:maxpermsize=128m\\\’
xms: jvm啟動內(nèi)存 默認(rèn)是物理內(nèi)存的1/64
xmx:jvm運行過程中分配的最大內(nèi)存
如果內(nèi)存剩余不到40%%uff0cjvm就會增大堆到xmx設(shè)置的值,內(nèi)存剩余超過70%%uff0cjvm就會減小堆到xms設(shè)置的值。
如果xms超過了xmx值,或者堆最大值和非堆最大值的總和超過了物理內(nèi)存或者操作系統(tǒng)的最大限制都會引起服務(wù)器啟動不起來。
設(shè)置newsize、maxnewsize相等,new的大小最好不要大于old的一半,原因是old區(qū)如果不夠大會頻繁的觸發(fā)主 gc ,大大降低了性能
9.手動釋放內(nèi)存
http://lizhenliang.blog.51cto.com/7876557/1657448
sync
echo 1 > /proc/sys/vm/drop_caches
drop_caches的值可以是0-3之間的數(shù)字,代表不同的含義:
0:不釋放(系統(tǒng)默認(rèn)值)
1:釋放頁緩存
2:釋放dentries和inodes
3:釋放所有緩存
10. linux詳細(xì)記錄用戶操作
http://369369.blog.51cto.com/319630/1732164
修改/etc/profile文件,在最后增加如下內(nèi)容:
#history
export histtimeformat=[%y%m%d-%h%m-:%s]
user_ip=`who -u am i 2>/dev/null| awk \\\'{print$nf}\\\’|sed -e \\\’s/[()]//g\\\’`
histdir=/var/log/history
if [ -z $user_ip ]
then
user_ip=`hostname`
fi
if [ ! -d $histdir ]
then
mkdir -p $histdir
chmod 777 $histdir
fi
if [ ! -d $histdir/${logname} ]
then
mkdir -p $histdir/${logname}
chmod 300 $histdir/${logname}
fi
export histsize=1000
dt=`date %y%m%d_%h%m%s`
export histfile=$histdir/${logname}/${user_ip}.hist.$dt
chmod 600 $histdir/${logname}/*.hist* 2>/dev/null
#history end
11. linux如何掛載windows下的共享目錄?
mount -t cifs -o username=windows登陸賬號,password=windows賬號對應(yīng)的密碼//16.187.190.50/test /mnt/linux目標(biāo)文件夾
或者 muout.cifs //本機ip地址/test /mut/linux目標(biāo)文件夾 -o username=windows登陸賬號,password=windows賬號對應(yīng)的密碼