ddxiami
标题:
运维快速入门篇
[打印本页]
作者:
黄振国
时间:
2013-5-27 00:44
标题:
运维快速入门篇
先使用vmware虚拟机安装centos的最小化版。
附件
:
(, 下载次数: 1825)
上传
点击文件名下载附件
本篇主要内容
:
1、目录和文件操作:find、cd、ls、mv、vi、rm、chown、chmod
2、日志分析:tail
3、系统资源分析:top、iostat、连接数查看
4、linux下的mysql操作
LNMP一键安装包
链接:
https://pan.baidu.com/s/1nuO8m4h
密码: dq6k
备注:优先看每条命令/指令的
常用操作
作者:
黄振国
时间:
2013-5-27 00:49
本帖最后由 黄振国 于 2013-5-27 00:57 编辑
目录和文件操作
find
:将档案系统内符合 expression 的档案列出来。详见
http://t.ddxiami.com/forum.php?mod=re ... =5&pid=34&fromuid=2
cd
:切换工作目录。详见
http://t.ddxiami.com/forum.php?mod=re ... =3&pid=12&fromuid=2
ls
:列出目录内容。详见
http://t.ddxiami.com/forum.php?mod=re ... =4&pid=18&fromuid=2
vi
:非常常用的编辑器,很多Linux发行版都默认安装。详见
http://t.ddxiami.com/forum.php?m ... id=38&fromuid=2
rm
:删除档案及目录。详见
http://t.ddxiami.com/forum.php?m ... id=20&fromuid=2
mv
:为文件或目录改名或将文件由一个目录移入另一个目录中。详见
http://t.ddxiami.com/forum.php?mod=re ... =4&pid=17&fromuid=2
chown
:更改与文件关联的所有者或组,只有 root 用户可以更改文件的所有者。详见
http://t.ddxiami.com/forum.php?mod=re ... =4&pid=29&fromuid=2
chmod
:改变一个或多个文件的存取模式。详见
http://t.ddxiami.com/forum.php?mod=re ... =4&pid=30&fromuid=2
作者:
黄振国
时间:
2013-5-27 00:55
日志分析
tail
:输出文件的尾部内容,默认情况下它显示文件的最后十行。详见
http://t.ddxiami.com/forum.php? ... =4&pid=23&fromuid=2
#############################################################
先进入日志目录,再执行以下命令
:
在apachelog中找出访问次数最多的10个IP
awk '{print $1}' access.log |sort |uniq -c|sort -nr|head -n 10
在apachelog中找出访问次数最多的10个页面
awk '{print $11}' access.log |sed 's/^.*com\(.*\)\"/\1/g'|sort |uniq -c|sort -rn|head
awk '{print $11}' access.log |sed 's/^.*cn\(.*\)\"/\1/g'|sort |uniq -c|sort -rn|head
在apachelog日志中找出访问次数最多的几个分钟
awk '{print $4}' access.log |cut -c 14-18|sort|uniq -c|sort -nr|head
查看删除静态文件后的日志
cat test.log |grep -v ".jpg\|.png\|.gif\|.css\|.js\|.ico" > a.log
作者:
黄振国
时间:
2013-5-27 01:02
系统资源分析
top
:详见
http://t.ddxiami.com/forum.php? ... d=12&extra=page%3D1
iostat
:详见
http://t.ddxiami.com/forum.php? ... d=13&extra=page%3D1
查看系统应用连接数
:
#查看tcp连接数
netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}' ;netstat -nat |wc -l
#
显示所有打开你的服务器的活跃连接
netstat -anp |grep 'tcp\|udp' | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
#查看php-fpm进程数,超过200则表明系统资源崩溃
netstat -anpo | grep "php-fpm" | wc -l
#查看httpd进程数
netstat -anpo | grep "httpd" | wc -l
#查看mysql进程数,稳定状态的mysql进程数为10左右
netstat -anpo | grep "mysqld" | wc -l
作者:
黄振国
时间:
2013-5-27 01:06
本帖最后由 黄振国 于 2013-5-27 01:12 编辑
linux下的mysql操作
#进入mysql的命令格式: /usr/local/mysql/bin/mysql -u用户名 -p密码 -h主机IP
/usr/local/mysql/bin/mysql -uroot -p123456 -h192.168.3.240
#查看从数据库同步状态
SHOW MASTER STATUS;
show slave status\G;
#数据库赋权
GRANT ALL PRIVILEGES ON ecstore.* TO root@"192.168.3.%" IDENTIFIED BY '123456' WITH GRANT OPTION;
flush privileges;
#显示进程数
SHOW PROCESSLIST;
#数据库导出指定表和备份恢复,详见
http://t.ddxiami.com/forum.php?m ... &extra=page%3D1
欢迎光临 ddxiami (http://t.ddxiami.com/)
Powered by Discuz! X3.4