一、前言
“差以毫厘,谬以千里”
“长风破浪会有时,直挂云帆济沧海”
“臣心一片磁针石,不指南方不肯休”
“沉舟侧畔千帆过,病树前头万木春”
“吃一堑,长一智”
“尺有所短,寸有所长”
静心~!
二、服务管理
服务的简单介绍
Linux的服务:
- RPM安装
- 独立的服务:自己安装了就可以自己启动,不用依赖别的服务来支持
- 启动:
- /etc/rc.d/init.d/httpd start|stop
- service httpd start| stop |
- 自启动
- chkconfig --level 2345 httpd on|off
- echo "/etc/rc.d/init.d/httpd start" >> /etc/rc.local 追加到文件中
- ntsysv 图形化修改开机自启动
- 启动:
- 基于xinetd服务:需要启动xinetd服务来支持的,只有xinetd占内存-->其他人占的是它的资源
- 启动:
- vim /etc/xinetd.d/telnet "disabled = no";
- service xinetd restart
- 自启动:
- chkconfig telnet on
- ntsysv-->图形化启动
- 启动:
- 独立的服务:自己安装了就可以自己启动,不用依赖别的服务来支持
#以telnet服务为准-->基于xinted服务
[root@Master ~]# yum -y install telnet-server
....省略....
Installed:
telnet-server.x86_64 1:0.17-48.el6
Dependency Installed:
xinetd.x86_64 2:2.3.14-40.el6
#查看基于xinetd的服务
[root@Master ~]# ls /etc/xinetd.d/
chargen-dgram daytime-stream echo-dgram tcpmux-server time-stream
chargen-stream discard-dgram echo-stream telnet
daytime-dgram discard-stream rsync time-dgram
#如何启动telnet?
[root@Master ~]# vim /etc/xinetd.d/telnet
# default: on
# description: The telnet server serves telnet sessions; it uses \
# unencrypted username/password pairs for authentication.
service telnet
{
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.telnetd
log_on_failure += USERID
disable = no #修改这个
#然后重启xinted服务
[root@Master ~]# service xinetd restart
停止 xinetd: [失败]
正在启动 xinetd: [确定]
- 源码包安装
- 启动
- /usr/local/nginx/sbin/nginx start| restart
- 自启动
- echo "/usr/local/nginx/sbin/nginx start" >> /etc/rc.local
- 启动
Linux的优化原则:
- 把不需要用到的服务都关掉
- 服务器的安装方法不同,启动的方式也会不同
- RPM安装和源码包安装-->很大的区别就是安装的位置不同
chkconfig命令
作用:查看开机自启动的独立服务
语法:
- chkconfig 【选项】 默认级别 服务名
- chkconfig --level 3 httpd on|off
常用选项
- --list:列出rpm安装的自动服务
- --level:指定运行级别
#查看
[root@Master ~]# chkconfig --list
#设定开机自启动
[root@Master ~]# chkconfig --level 35 httpd on
[root@Master ~]# chkconfig --list | grep httpd
httpd 0:off 1:off 2:off 3:on 4:off 5:on 6:off
ntsysv命令
作用:图形化设置开机自启动服务
空格-->选定,打上*号代表能够开机自启动
源码服务-->service|chkconfig管理-->实验
第一步:确认没有rpm安装的nginx
[root@Master httpd-2.2.29]# rpm -qa httpd
[root@Master httpd-2.2.29]# service httpd restart
httpd: unrecognized service
[root@Master ~]# chkconfig --list httpd
error reading information on service httpd: No such file or directory
第二步:软连接启动方式
[root@Master ~]# ln -s /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd
[root@Master ~]# ll /etc/rc.d/init.d/httpd
lrwxrwxrwx. 1 root root 31 Jan 1 23:20 /etc/rc.d/init.d/httpd -> /usr/local/apache/bin/apachectl
第三步:启动查看
[root@Master ~]# service httpd start
httpd: apr_sockaddr_info_get() failed for Master
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[root@Master ~]# ps -ef | grep httpd
root 58463 1 0 23:20 ? 00:00:00 /usr/local/apache/bin/httpd -k start
daemon 58464 58463 0 23:20 ? 00:00:00 /usr/local/apache/bin/httpd -k start
daemon 58465 58463 0 23:20 ? 00:00:00 /usr/local/apache/bin/httpd -k start
daemon 58466 58463 0 23:20 ? 00:00:00 /usr/local/apache/bin/httpd -k start
daemon 58467 58463 0 23:20 ? 00:00:00 /usr/local/apache/bin/httpd -k start
daemon 58468 58463 0 23:20 ? 00:00:00 /usr/local/apache/bin/httpd -k start
root 58470 2142 0 23:21 pts/1 00:00:00 grep httpd
第四步:调整chkconfig识别
手工修改httpd的启动文件
添加:
#添加一下两句话
[root@Master ~]# vim /etc/rc.d/init.d/httpd
....省略...
#chkconfig: 35 86 76
#description: hahaha
#这里需要注意
上面两句一定要加,并且需要丼号注释,不然会报错
35:代表的是运行级别,3级别和5级别
86/76分别就是在/etc/init.d/下的启动与取消
第五步:
加入chkconfig --add
[root@Master ~]# chkconfig --add httpd
[root@Master ~]# chkconfig --list | grep httpd
httpd 0:off 1:off 2:off 3:on 4:off 5:on 6:off
#删除:--del
[root@Master ~]# chkconfig --del httpd
[root@Master ~]# chkconfig --list | grep httpd
三、结束
“纵然是在自己心底一片狼藉的时候,我们还努力地保持着一片净土,保持着对周围那些纯净心灵的理解和赞赏,时刻提醒着自己:生命之中,还是有很多美好的东西值得我们去珍惜”
“或许只有在孤独中,我们才可以静静地、默默地谛听,谛听这个灯火阑珊的城市,谛听城市之外的旷野、远山,和比远山更远的一切生生不息的律动,同时也谛听自己生命的足音以及深邃的内心”
“或许在孤独中,我们才能强烈意识到生命荣枯兴衰的不朽轮回,从而坦然应对到来的一切。人生旅途中孤独是必然的,在真正的孤独中我们才能不断地成长”
“以清净心看世界,以欢喜心过生活,以平常心生情味,以柔软心除挂碍”
互勉~!