[关闭]
@Mr-13 2018-10-18T08:41:08.000000Z 字数 9227 阅读 226

短信平台重启服务器 - 服务恢复手册

未来无线


需要关心的核心服务:

  • Orcle
  • tomcat (web服务)
  • SMS四大服务:smsserver、smsprocess、smsclient、smsbatsave
  • Redis
  • Memcache

服务器重启之后的服务回复顺序

一、启动Oracle

1. 登入oracle账户

  1. [root@localhost ~]# su - oracle

2. 进入sqlplus

  1. # 切入sql
  2. [oracle@localhost ~]$ sqlplus / as sysdba;
  3. SQL*Plus: Release 11.2.0.1.0 Production on Wed Apr 11 15:03:38 2018
  4. Copyright (c) 1982, 2009, Oracle. All rights reserved.
  5. Connected to an idle instance.
  6. SQL>

3. 启动数据库

  1. # 启动
  2. SQL> startup;
  3. ORACLE instance started.
  4. Total System Global Area 2.6991E+10 bytes
  5. Fixed Size 2213976 bytes
  6. Variable Size 1.9596E+10 bytes
  7. Database Buffers 7247757312 bytes
  8. Redo Buffers 145174528 bytes
  9. Database mounted.
  10. Database opened.
  11. SQL>
  12. # 退出sql
  13. SQL> exit
  14. Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
  15. With the Partitioning, OLAP, Data Mining and Real Application Testing options

4. 查看数据库侦听状态

  1. # 查看侦听状态
  2. [oracle@localhost ~]$ lsnrctl status
  3. LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 11-APR-2018 15:04:11
  4. Copyright (c) 1991, 2009, Oracle. All rights reserved.
  5. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
  6. TNS-12541: TNS:no listener
  7. TNS-12560: TNS:protocol adapter error
  8. TNS-00511: No listener
  9. Linux Error: 111: Connection refused

5. 启动数据库侦听

  1. # 启动数据库侦听
  2. [oracle@localhost ~]$ lsnrctl start
  3. LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 11-APR-2018 15:04:17
  4. Copyright (c) 1991, 2009, Oracle. All rights reserved.
  5. Starting /home/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...
  6. TNSLSNR for Linux: Version 11.2.0.1.0 - Production
  7. System parameter file is /home/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
  8. Log messages written to /home/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
  9. Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
  10. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
  11. STATUS of the LISTENER
  12. ------------------------
  13. Alias LISTENER
  14. Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
  15. Start Date 11-APR-2018 15:04:17
  16. Uptime 0 days 0 hr. 0 min. 0 sec
  17. Trace Level off
  18. Security ON: Local OS Authentication
  19. SNMP OFF
  20. Listener Parameter File /home/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
  21. Listener Log File /home/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
  22. Listening Endpoints Summary...
  23. (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
  24. The listener supports no services
  25. The command completed successfully
  26. # 数据库侦听启动成功
  27. # 数据库启动完成,退出oracle账户
  28. [oracle@localhost ~]$ exit
  29. logout
  • 启动数据库侦听需要注意:
    lsnrctl start 之后注意查看打印内容,主要是侦听的 HOST,重启服务器之后,主机名可能会变,这时候侦听会出错,导致smsserver、客户端查询工具等无法连接到数据库,服务不可用,同时服务(smsserver等)会不断打印出异常日志。
    image_1cjkh4s6udn47qa1f765rf17t99.png-38.5kB
    如上图,这是重启后的异常状态,此时HOST=127.0.0.1,当前主机名是localhost;但是从侦听日志文件记录可以看出,正常情况下,原主机名应该是 sdzh 这时,启动smsserver会一直报错,无法连接到数据库。

设置/恢复主机名

  1. # 查看当前主机名
  2. [root@sdzh ~]# hostname
  3. # 编辑主机名
  4. [root@sdzh ~]# vim /etc/sysconfig/network
  5. # 编辑保存退出后,重启服务器生效
  6. [root@sdzh ~]# reboot

  image_1cjkhl72d1rb41l8216kovin112n13.png-5.2kB


检查oracle的ora文件设置

  • image_1cjki26u9seb16jt1tbh1jbrtme23.png-21.7kB

    如上图,ora文件中的HOST对应主机名应保持一致。

二、启动tomcat

1. 登入smsplatform账户

  1. # 登入 smsplatform 账户
  2. [root@localhost ~]# su smsplatform

2. 启动tomcat

  1. # 进入tomcat目录
  2. [smsplatform@localhost root]$ cd ~
  3. [smsplatform@localhost ~]$ ls
  4. apache-tomcat-7.0.47 app backup webapps
  5. [smsplatform@localhost ~]$ cd apache-tomcat-7.0.47/bin/
  6. # 启动tomcat
  7. [smsplatform@localhost bin]$ ./startup.sh
  8. Using CATALINA_BASE: /home/smsplatform/apache-tomcat-7.0.47
  9. Using CATALINA_HOME: /home/smsplatform/apache-tomcat-7.0.47
  10. Using CATALINA_TMPDIR: /home/smsplatform/apache-tomcat-7.0.47/temp
  11. Using JRE_HOME: /usr/java/jdk1.8.0_45/jre
  12. Using CLASSPATH: /home/smsplatform/apache-tomcat-7.0.47/bin/bootstrap.jar:/home/smsplatform/apache-tomcat-7.0.47/bin/tomcat-juli.jar
  13. # tomcat启动完成,这时候打开浏览器,访问站点可以正常打开平台就OK

三、 启动sms四大服务

1. 登入smsplatform账户

  1. # 登入 smsplatform 账户
  2. [root@localhost ~]# su smsplatform

2. 启动服务

  1. # 启动smsserver服务
  2. [smsplatform@localhost ~]$ cd app/smsserver/bin/
  3. [smsplatform@localhost bin]$ ./smsserver.sh start
  4. starting ......
  5. started
  6. # 启动smsclient服务
  7. [smsplatform@localhost bin]$ cd ~/app/smsclient/bin/
  8. [smsplatform@localhost bin]$ ls
  9. smsclient.sh
  10. [smsplatform@localhost bin]$ ./smsclient.sh start 1 5
  11. starting ......
  12. starting 1......
  13. ...
  14. starting 2......
  15. ...
  16. starting 3......
  17. ...
  18. starting 4......
  19. ...
  20. starting 5......
  21. ...
  22. started
  23. # 启动smsprocess服务
  24. [smsplatform@localhost ~]$ cd app/smsprocess/bin/
  25. [smsplatform@localhost bin]$ ls
  26. smsprocess.sh
  27. [smsplatform@localhost bin]$ ./smsprocess.sh start
  28. starting ......
  29. ...
  30. ...
  31. ...
  32. started
  33. # 启动smsbatsave服务
  34. [smsplatform@localhost bin]$ cd ~/app/smsbatsave/bin/
  35. [smsplatform@localhost bin]$ ls
  36. smsbatsave.sh
  37. [smsplatform@localhost bin]$ ./smsbatsave.sh start
  38. starting ......
  39. ...
  40. ...
  41. ...
  42. started

注意事项:

如果是重启服务时,在执行重启动作,例如:smsserver stop之前,一定要先确认该服务(这里是smsserver)当前是都已经完全关闭,方法:

  1. [smsplatform@localhost bin]$ ps -ef | grep smsserver //这里写需要查看的服务名称

如果,当前服务进程仍然存在,需要先杀死原有进程之后,再执行启动命令,否则会导致主服务进程状态异常:

  1. [smsplatform@localhost bin]$ kill -9 进程IP //这里写刚才ps -ef查到的进程ID
  2. [smsplatform@localhost bin]$ cd ~/app/smsserver/bin
  3. [smsplatform@localhost bin]$ ./smsserver.sh start

四、检查服务状态

  • 检查服务进程:oracle、tomcat、sms四项服务进程
  • 检查服务端口状态

1. 检查服务状态

检查各项服务是否正常,以tomcat为例

  1. # 使用ps -ef检查服务,使用grep + 服务名,查找具体进程
  2. # 如果检查目标服务有具体进程就OK
  3. [smsplatform@localhost bin]$ ps -ef | grep tomcat
  4. 501 4365 1 0 15:04 pts/1 00:00:00 /bin/sh /home/smsplatform/apache-tomcat-7.0.47/bin/catalina.sh start
  5. 501 4366 4365 99 15:04 pts/1 00:02:11 /usr/java/jdk1.8.0_.......tartup.Bootstrap start
  6. 501 5432 4342 0 15:06 pts/1 00:00:00 grep tomcat
  7. # 其他服务进程检查同上

2. 检查服务端口

  1. [smsplatform@localhost bin]$ netstat -tunpl
  2. (Not all processes could be identified, non-owned process info
  3. will not be shown, you would have to be root to see it all.)
  4. Active Internet connections (only servers)
  5. Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
  6. tcp 0 0 0.0.0.0:5003 0.0.0.0:* LISTEN 4609/java
  7. tcp 0 0 127.0.0.1:11211 0.0.0.0:* LISTEN -
  8. tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN -
  9. tcp 0 0 0.0.0.0:8588 0.0.0.0:* LISTEN 4771/java
  10. tcp 0 0 0.0.0.0:8012 0.0.0.0:* LISTEN 4366/java
  11. tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN -
  12. tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 4366/java
  13. tcp 0 0 0.0.0.0:6001 0.0.0.0:* LISTEN 4771/java
  14. tcp 0 0 0.0.0.0:1521 0.0.0.0:* LISTEN -
  15. tcp 0 0 0.0.0.0:6002 0.0.0.0:* LISTEN 4823/java
  16. tcp 0 0 0.0.0.0:6003 0.0.0.0:* LISTEN 4878/java
  17. ..........
  18. udp 0 0 0.0.0.0:631 0.0.0.0:* -
  19. udp 0 0 127.0.0.1:51578 0.0.0.0:* -
  20. udp 0 0 127.0.0.1:32895 0.0.0.0:* -
  21. udp 0 0 127.0.0.1:46224 0.0.0.0:* -
  22. udp 0 0 0.0.0.0:657 0.0.0.0:* -
  23. udp 0 0 0.0.0.0:935 0.0.0.0:* -
  24. udp 0 0 0.0.0.0:64316 0.0.0.0:* -
  25. udp 0 0 127.0.0.1:11211 0.0.0.0:* -
  26. udp 0 0 0.0.0.0:26729 0.0.0.0:* -
  27. udp 0 0 :::111 :::* -
  28. udp 0 0 :::935 :::* -
  29. udp 0 0 :::56631 :::* -

3. 检查sms四大服务日志输出是否正常

  1. [smsplatform@localhost bin]$ cd ~/app/smsclient/runlogs/
  2. [smsplatform@localhost runlogs]$ tail -f runlogs_1.log
  3. [15:05:36:432] -l??t??192.168.125.55:88553?? ′х?£oFailed to get the session.
  4. [15:05:51:444] -l??t??192.168.125.55:88553?? ′х?£oFailed to get the session.
  5. [15:05:55:523] -l??t??192.168.125.55:88593?? ′х?£oFailed to get the session.
  6. [15:06:06:457] -l??t??192.168.125.55:88553?? ′х?£oFailed to get the session.
  7. [15:06:15:534] -l??t??192.168.125.55:88593?? ′х?£oFailed to get the session.
  8. [15:06:21:506] -l??t??192.168.125.55:88553?? ′х?£oFailed to get the session.
  9. [15:06:35:564] -l??t??192.168.125.55:88593?? ′х?£oFailed to get the session.
  10. [15:06:36:518] -l??t??192.168.125.55:88553?? ′х?£oFailed to get the session.
  11. [15:06:51:530] -l??t??192.168.125.55:88553?? ′х?£oFailed to get the session.
  12. [15:06:55:577] -l??t??192.168.125.55:88593?? ′х?£oFailed to get the session.
  13. [15:07:06:565] -l??t??192.168.125.55:88553?? ′х?£oFailed to get the session.
  14. ^C
  15. [smsplatform@localhost runlogs]$ tail -f runlogs_2.log
  16. [15:05:27:366] -??ˉ-2?±?????μ5??CMPP20·t??127.0.0.1:88553?|£? SessionId:3
  17. [15:05:27:366] -??ˉ??§????¢???????
  18. [15:05:27:367] -??ˉ?·¢??????
  19. [15:05:28:314] -??ˉθ1??¤П3??
  20. [15:05:57:397] -l???г?1??±??????ˉ·¢?ф?°??an_id:661
  21. [15:05:57:401] -?μ?ф???′°??n_id:661
  22. [15:06:27:433] -l???г?1??±??????ˉ·¢?ф?°??an_id:661
  23. [15:06:27:435] -?μ?ф???′°??n_id:661
  24. [15:06:57:465] -l???г?1??±??????ˉ·¢?ф?°??an_id:661
  25. [15:06:57:467] -?μ?ф???′°??n_id:661
  26. [15:07:27:487] -l???г?1??±??????ˉ·¢?ф?°??an_id:661
  27. [15:07:27:488] -?μ?ф???′°??n_id:661
  28. [15:07:28:316] 1??¤П3???С£?£?£
  29. [15:07:57:519] -连接空闲超过限定时间,系统主动发送心跳包, chan_id:661
  30. [15:07:57:521] -收到心跳回复包, chan_id:661
  31. [15:08:27:552] -连接空闲超过限定时间,系统主动发送心跳包, chan_id:661
  32. [15:08:27:553] -收到心跳回复包, chan_id:661
  33. [15:08:57:583] -连接空闲超过限定时间,系统主动发送心跳包, chan_id:661
  34. [15:08:57:585] -收到心跳回复包, chan_id:661
  35. [15:09:04:803] -向18911111111用户发送1条下行短信, SequenceId:9
  36. [15:09:04:874] -收到短信返回包,msg_id59106104111509000001, mobile:18911111111, result:0
  37. [15:09:05:814] -收到SMGP30状态报告, moible:18911111111, msg_id:59106104111509000001, Status:MX:0001, Err:001
  38. [15:09:27:597] -连接空闲超过限定时间,系统主动发送心跳包, chan_id:661
  39. [15:09:27:598] -收到心跳回复包, chan_id:661
  40. [15:09:28:320] -网关守护线程运行中。。。
  41. [15:09:57:629] -连接空闲超过限定时间,系统主动发送心跳包, chan_id:661
  42. [15:09:57:630] -收到心跳回复包, chan_id:661
  43. [15:10:27:661] -连接空闲超过限定时间,系统主动发送心跳包, chan_id:661
  44. [15:10:27:662] -收到心跳回复包, chan_id:661
  45. [15:10:57:693] -连接空闲超过限定时间,系统主动发送心跳包, chan_id:661
  46. [15:10:57:694] -收到心跳回复包, chan_id:661
  47. ^A[15:11:27:725] -连接空闲超过限定时间,系统主动发送心跳包, chan_id:661
  48. [15:11:27:726] -收到心跳回复包, chan_id:661
  49. [15:11:28:336] -网关守护线程运行中。。。
  50. ^C
  51. [smsplatform@localhost runlogs]$

五、Redis日常维护操作(集合)

ROOT用户下:
检查redis是否启动成功:
ps -ef | grep redis

重启redis命令:nohup /usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf
启动redis命令:/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf
netstat -tunpl | grep 6379#查看端口是否占用。

[root@oracledb ~]# cd /usr/local/redis/bin
[root@oracledb bin]#./redis-server /usr/local/redis/etc/redis.conf #打开服务
[root@oracledb ~]#./redis-cli shutdown #关闭服务

[root@bogon bin]# redis-cli 进入客户端
redis 127.0.0.1:6379> keys *
127.0.0.1:6379> keys chan* 查看队列
1) "chantask:queue:325:2"
2) "chantask:queue:136:2"
3) "chantask:queue:1038:1"
4) "chantask:queue:1339:0"
5) "chantask:queue:136:0"
127.0.0.1:6379> llen chantask:queue:325:2 查看具体队列的等待发送条数
删除队列信息:del chantask:queue:325:2

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注