1. #configuration File for keepalived
  2. global_defs {
  3. router_id LVS_1
  4. }
  5. vrrp_instance VI_1 {
  6. state BACKUP
  7. interface enp4s0
  8. virtual_router_id 51
  9. priority 99
  10. advert_int 1
  11. authentication {
  12. auth_type PASS
  13. auth_pass szspzw
  14. }
  15. virtual_ipaddress {
  16. 14.232.7.202
  17. }
  18. }
  19. virtual_server 14.232.7.202 5460 {
  20. delay_loop 30
  21. lb_algo wlc
  22. lb_kind DR
  23. protocol TCP
  24. real_server 14.232.7.12 5460 {
  25. weight 1
  26. TCP_CHECK {
  27. connect_timeout 3
  28. nb_get_retry 2
  29. delay_before_retry 2
  30. connect_port 5460
  31. }
  32. }
  33. real_server 14.232.7.13 5460 {
  34. weight 1
  35. TCP_CHECK {
  36. connect_timeout 3
  37. nb_get_retry 2
  38. delay_before_retry 2
  39. connect_port 5460
  40. }
  41. }
  42. real_server 14.232.7.14 5460 {
  43. weight 1
  44. TCP_CHECK {
  45. connect_timeout 3
  46. nb_get_retry 2
  47. delay_before_retry 2
  48. connect_port 5460
  49. }
  50. }
  51. }
  52. ########### cos ############
  53. vrrp_instance VI_2 {
  54. state MASTER
  55. interface enp4s0
  56. virtual_router_id 52
  57. priority 100
  58. advert_int 1
  59. authentication {
  60. auth_type PASS
  61. auth_pass szspzw
  62. }
  63. virtual_ipaddress {
  64. 14.232.7.203
  65. }
  66. }
  67. virtual_server 14.232.7.203 5460 {
  68. delay_loop 30
  69. lb_algo wlc
  70. lb_kind DR
  71. protocol TCP
  72. real_server 14.232.7.22 5460 {
  73. weight 1
  74. TCP_CHECK {
  75. connect_timeout 3
  76. nb_get_retry 2
  77. delay_before_retry 2
  78. connect_port 5460
  79. }
  80. }
  81. real_server 14.232.7.23 5460 {
  82. weight 1
  83. TCP_CHECK {
  84. connect_timeout 3
  85. nb_get_retry 2
  86. delay_before_retry 2
  87. connect_port 5460
  88. }
  89. }
  90. real_server 14.232.7.24 5460 {
  91. weight 1
  92. TCP_CHECK {
  93. connect_timeout 3
  94. nb_get_retry 2
  95. delay_before_retry 2
  96. connect_port 5460
  97. }
  98. }
  99. }
  100. virtual_server 14.232.7.203 1443 {
  101. delay_loop 30
  102. lb_algo wlc
  103. lb_kind DR
  104. protocol TCP
  105. real_server 14.232.7.22 1443 {
  106. weight 1
  107. TCP_CHECK {
  108. connect_timeout 3
  109. nb_get_retry 2
  110. delay_before_retry 2
  111. connect_port 1443
  112. }
  113. }
  114. real_server 14.232.7.23 1443 {
  115. weight 1
  116. TCP_CHECK {
  117. connect_timeout 3
  118. nb_get_retry 2
  119. delay_before_retry 2
  120. connect_port 1443
  121. }
  122. }
  123. real_server 14.232.7.24 1443 {
  124. weight 1
  125. TCP_CHECK {
  126. connect_timeout 3
  127. nb_get_retry 2
  128. delay_before_retry 2
  129. connect_port 1443
  130. }
  131. }
  132. }
  133. virtual_server 14.232.7.203 80 {
  134. delay_loop 30
  135. lb_algo wlc
  136. lb_kind DR
  137. protocol TCP
  138. real_server 14.232.7.22 80 {
  139. weight 1
  140. TCP_CHECK {
  141. connect_timeout 3
  142. nb_get_retry 2
  143. delay_before_retry 2
  144. connect_port 80
  145. }
  146. }
  147. real_server 14.232.7.23 80 {
  148. weight 1
  149. TCP_CHECK {
  150. connect_timeout 3
  151. nb_get_retry 2
  152. delay_before_retry 2
  153. connect_port 80
  154. }
  155. }
  156. real_server 14.232.7.24 80 {
  157. weight 1
  158. TCP_CHECK {
  159. connect_timeout 3
  160. nb_get_retry 2
  161. delay_before_retry 2
  162. connect_port 80
  163. }
  164. }
  165. }
  166. ########### lingmou_private ############
  167. vrrp_instance VI_3 {
  168. state MASTER
  169. interface enp4s0
  170. virtual_router_id 53
  171. priority 100
  172. advert_int 1
  173. authentication {
  174. auth_type PASS
  175. auth_pass szspzw
  176. }
  177. virtual_ipaddress {
  178. 14.232.7.201
  179. }
  180. }
  181. # nacos
  182. virtual_server 14.232.7.201 8848 {
  183. delay_loop 30
  184. lb_algo rr
  185. lb_kind DR
  186. protocol TCP
  187. real_server 14.232.7.35 8848 {
  188. weight 1
  189. TCP_CHECK {
  190. connect_timeout 3
  191. nb_get_retry 2
  192. delay_before_retry 2
  193. connect_port 8848
  194. }
  195. }
  196. real_server 14.232.7.36 8848 {
  197. weight 1
  198. TCP_CHECK {
  199. connect_timeout 3
  200. nb_get_retry 2
  201. delay_before_retry 2
  202. connect_port 8848
  203. }
  204. }
  205. real_server 14.232.7.37 8848 {
  206. weight 1
  207. TCP_CHECK {
  208. connect_timeout 3
  209. nb_get_retry 2
  210. delay_before_retry 2
  211. connect_port 8848
  212. }
  213. }
  214. }
  215. # frontend_http
  216. virtual_server 14.232.7.201 82 {
  217. delay_loop 30
  218. lb_algo rr
  219. lb_kind DR
  220. protocol TCP
  221. real_server 14.232.7.35 82 {
  222. weight 1
  223. TCP_CHECK {
  224. connect_timeout 3
  225. nb_get_retry 2
  226. delay_before_retry 2
  227. connect_port 82
  228. }
  229. }
  230. real_server 14.232.7.36 82 {
  231. weight 1
  232. TCP_CHECK {
  233. connect_timeout 3
  234. nb_get_retry 2
  235. delay_before_retry 2
  236. connect_port 82
  237. }
  238. }
  239. real_server 14.232.7.37 82 {
  240. weight 1
  241. TCP_CHECK {
  242. connect_timeout 3
  243. nb_get_retry 2
  244. delay_before_retry 2
  245. connect_port 82
  246. }
  247. }
  248. }
  249. # deviceServer
  250. virtual_server 14.232.7.201 20062 {
  251. delay_loop 30
  252. lb_algo rr
  253. lb_kind DR
  254. protocol TCP
  255. real_server 14.232.7.35 20062 {
  256. weight 1
  257. TCP_CHECK {
  258. connect_timeout 3
  259. nb_get_retry 2
  260. delay_before_retry 2
  261. connect_port 20062
  262. }
  263. }
  264. real_server 14.232.7.36 20062 {
  265. weight 1
  266. TCP_CHECK {
  267. connect_timeout 3
  268. nb_get_retry 2
  269. delay_before_retry 2
  270. connect_port 20062
  271. }
  272. }
  273. real_server 14.232.7.37 20062 {
  274. weight 1
  275. TCP_CHECK {
  276. connect_timeout 3
  277. nb_get_retry 2
  278. delay_before_retry 2
  279. connect_port 20062
  280. }
  281. }
  282. }
  283. # placeServer
  284. virtual_server 14.232.7.201 20068 {
  285. delay_loop 30
  286. lb_algo rr
  287. lb_kind DR
  288. protocol TCP
  289. real_server 14.232.7.35 20068 {
  290. weight 1
  291. TCP_CHECK {
  292. connect_timeout 3
  293. nb_get_retry 2
  294. delay_before_retry 2
  295. connect_port 20068
  296. }
  297. }
  298. real_server 14.232.7.36 20068 {
  299. weight 1
  300. TCP_CHECK {
  301. connect_timeout 3
  302. nb_get_retry 2
  303. delay_before_retry 2
  304. connect_port 20068
  305. }
  306. }
  307. real_server 14.232.7.37 20068 {
  308. weight 1
  309. TCP_CHECK {
  310. connect_timeout 3
  311. nb_get_retry 2
  312. delay_before_retry 2
  313. connect_port 20068
  314. }
  315. }
  316. }
  317. # tagServer
  318. virtual_server 14.232.7.201 20071 {
  319. delay_loop 30
  320. lb_algo rr
  321. lb_kind DR
  322. protocol TCP
  323. real_server 14.232.7.35 20071 {
  324. weight 1
  325. TCP_CHECK {
  326. connect_timeout 3
  327. nb_get_retry 2
  328. delay_before_retry 2
  329. connect_port 20071
  330. }
  331. }
  332. real_server 14.232.7.36 20071 {
  333. weight 1
  334. TCP_CHECK {
  335. connect_timeout 3
  336. nb_get_retry 2
  337. delay_before_retry 2
  338. connect_port 20071
  339. }
  340. }
  341. real_server 14.232.7.37 20071 {
  342. weight 1
  343. TCP_CHECK {
  344. connect_timeout 3
  345. nb_get_retry 2
  346. delay_before_retry 2
  347. connect_port 20071
  348. }
  349. }
  350. }
  351. # personServer
  352. virtual_server 14.232.7.201 20072 {
  353. delay_loop 30
  354. lb_algo rr
  355. lb_kind DR
  356. protocol TCP
  357. real_server 14.232.7.35 20072 {
  358. weight 1
  359. TCP_CHECK {
  360. connect_timeout 3
  361. nb_get_retry 2
  362. delay_before_retry 2
  363. connect_port 20072
  364. }
  365. }
  366. real_server 14.232.7.36 20072 {
  367. weight 1
  368. TCP_CHECK {
  369. connect_timeout 3
  370. nb_get_retry 2
  371. delay_before_retry 2
  372. connect_port 20072
  373. }
  374. }
  375. real_server 14.232.7.37 20072 {
  376. weight 1
  377. TCP_CHECK {
  378. connect_timeout 3
  379. nb_get_retry 2
  380. delay_before_retry 2
  381. connect_port 20072
  382. }
  383. }
  384. }
  385. # rule_engine
  386. virtual_server 14.232.7.201 20086 {
  387. delay_loop 30
  388. lb_algo rr
  389. lb_kind DR
  390. protocol TCP
  391. real_server 14.232.7.35 20086 {
  392. weight 1
  393. TCP_CHECK {
  394. connect_timeout 3
  395. nb_get_retry 2
  396. delay_before_retry 2
  397. connect_port 20086
  398. }
  399. }
  400. real_server 14.232.7.36 20086 {
  401. weight 1
  402. TCP_CHECK {
  403. connect_timeout 3
  404. nb_get_retry 2
  405. delay_before_retry 2
  406. connect_port 20086
  407. }
  408. }
  409. real_server 14.232.7.37 20086 {
  410. weight 1
  411. TCP_CHECK {
  412. connect_timeout 3
  413. nb_get_retry 2
  414. delay_before_retry 2
  415. connect_port 20086
  416. }
  417. }
  418. }
  419. # subscribServer
  420. virtual_server 14.232.7.201 20087 {
  421. delay_loop 30
  422. lb_algo rr
  423. lb_kind DR
  424. protocol TCP
  425. real_server 14.232.7.35 20087 {
  426. weight 1
  427. TCP_CHECK {
  428. connect_timeout 3
  429. nb_get_retry 2
  430. delay_before_retry 2
  431. connect_port 20087
  432. }
  433. }
  434. real_server 14.232.7.36 20087 {
  435. weight 1
  436. TCP_CHECK {
  437. connect_timeout 3
  438. nb_get_retry 2
  439. delay_before_retry 2
  440. connect_port 20087
  441. }
  442. }
  443. real_server 14.232.7.37 20087 {
  444. weight 1
  445. TCP_CHECK {
  446. connect_timeout 3
  447. nb_get_retry 2
  448. delay_before_retry 2
  449. connect_port 20087
  450. }
  451. }
  452. }
  453. # preventionServer
  454. virtual_server 14.232.7.201 20088 {
  455. delay_loop 30
  456. lb_algo rr
  457. lb_kind DR
  458. protocol TCP
  459. real_server 14.232.7.35 20088 {
  460. weight 1
  461. TCP_CHECK {
  462. connect_timeout 3
  463. nb_get_retry 2
  464. delay_before_retry 2
  465. connect_port 20088
  466. }
  467. }
  468. real_server 14.232.7.36 20088 {
  469. weight 1
  470. TCP_CHECK {
  471. connect_timeout 3
  472. nb_get_retry 2
  473. delay_before_retry 2
  474. connect_port 20088
  475. }
  476. }
  477. real_server 14.232.7.37 20088 {
  478. weight 1
  479. TCP_CHECK {
  480. connect_timeout 3
  481. nb_get_retry 2
  482. delay_before_retry 2
  483. connect_port 20088
  484. }
  485. }
  486. }
  487. # aidTagServer
  488. virtual_server 14.232.7.201 20099 {
  489. delay_loop 30
  490. lb_algo rr
  491. lb_kind DR
  492. protocol TCP
  493. real_server 14.232.7.35 20099 {
  494. weight 1
  495. TCP_CHECK {
  496. connect_timeout 3
  497. nb_get_retry 2
  498. delay_before_retry 2
  499. connect_port 20099
  500. }
  501. }
  502. real_server 14.232.7.36 20099 {
  503. weight 1
  504. TCP_CHECK {
  505. connect_timeout 3
  506. nb_get_retry 2
  507. delay_before_retry 2
  508. connect_port 20099
  509. }
  510. }
  511. real_server 14.232.7.37 20099 {
  512. weight 1
  513. TCP_CHECK {
  514. connect_timeout 3
  515. nb_get_retry 2
  516. delay_before_retry 2
  517. connect_port 20099
  518. }
  519. }
  520. }
  521. # aid_archive
  522. virtual_server 14.232.7.201 20201 {
  523. delay_loop 30
  524. lb_algo rr
  525. lb_kind DR
  526. protocol TCP
  527. real_server 14.232.7.35 20201 {
  528. weight 1
  529. TCP_CHECK {
  530. connect_timeout 3
  531. nb_get_retry 2
  532. delay_before_retry 2
  533. connect_port 20201
  534. }
  535. }
  536. real_server 14.232.7.36 20201 {
  537. weight 1
  538. TCP_CHECK {
  539. connect_timeout 3
  540. nb_get_retry 2
  541. delay_before_retry 2
  542. connect_port 20201
  543. }
  544. }
  545. real_server 14.232.7.37 20201 {
  546. weight 1
  547. TCP_CHECK {
  548. connect_timeout 3
  549. nb_get_retry 2
  550. delay_before_retry 2
  551. connect_port 20201
  552. }
  553. }
  554. }
  555. # extension
  556. virtual_server 14.232.7.201 20203 {
  557. delay_loop 30
  558. lb_algo rr
  559. lb_kind DR
  560. protocol TCP
  561. real_server 14.232.7.35 20203 {
  562. weight 1
  563. TCP_CHECK {
  564. connect_timeout 3
  565. nb_get_retry 2
  566. delay_before_retry 2
  567. connect_port 20203
  568. }
  569. }
  570. real_server 14.232.7.36 20203 {
  571. weight 1
  572. TCP_CHECK {
  573. connect_timeout 3
  574. nb_get_retry 2
  575. delay_before_retry 2
  576. connect_port 20203
  577. }
  578. }
  579. real_server 14.232.7.37 20203 {
  580. weight 1
  581. TCP_CHECK {
  582. connect_timeout 3
  583. nb_get_retry 2
  584. delay_before_retry 2
  585. connect_port 20203
  586. }
  587. }
  588. }
  589. # place_archive
  590. virtual_server 14.232.7.201 20204 {
  591. delay_loop 30
  592. lb_algo rr
  593. lb_kind DR
  594. protocol TCP
  595. real_server 14.232.7.35 20204 {
  596. weight 1
  597. TCP_CHECK {
  598. connect_timeout 3
  599. nb_get_retry 2
  600. delay_before_retry 2
  601. connect_port 20204
  602. }
  603. }
  604. real_server 14.232.7.36 20204 {
  605. weight 1
  606. TCP_CHECK {
  607. connect_timeout 3
  608. nb_get_retry 2
  609. delay_before_retry 2
  610. connect_port 20204
  611. }
  612. }
  613. real_server 14.232.7.37 20204 {
  614. weight 1
  615. TCP_CHECK {
  616. connect_timeout 3
  617. nb_get_retry 2
  618. delay_before_retry 2
  619. connect_port 20204
  620. }
  621. }
  622. }
  623. # rule_compare
  624. virtual_server 14.232.7.201 20206 {
  625. delay_loop 30
  626. lb_algo rr
  627. lb_kind DR
  628. protocol TCP
  629. real_server 14.232.7.35 20206 {
  630. weight 1
  631. TCP_CHECK {
  632. connect_timeout 3
  633. nb_get_retry 2
  634. delay_before_retry 2
  635. connect_port 20206
  636. }
  637. }
  638. real_server 14.232.7.36 20206 {
  639. weight 1
  640. TCP_CHECK {
  641. connect_timeout 3
  642. nb_get_retry 2
  643. delay_before_retry 2
  644. connect_port 20206
  645. }
  646. }
  647. real_server 14.232.7.37 20206 {
  648. weight 1
  649. TCP_CHECK {
  650. connect_timeout 3
  651. nb_get_retry 2
  652. delay_before_retry 2
  653. connect_port 20206
  654. }
  655. }
  656. }
  657. # motor_plate_id_server
  658. virtual_server 14.232.7.201 20208 {
  659. delay_loop 30
  660. lb_algo rr
  661. lb_kind DR
  662. protocol TCP
  663. real_server 14.232.7.35 20208 {
  664. weight 1
  665. TCP_CHECK {
  666. connect_timeout 3
  667. nb_get_retry 2
  668. delay_before_retry 2
  669. connect_port 20208
  670. }
  671. }
  672. real_server 14.232.7.36 20208 {
  673. weight 1
  674. TCP_CHECK {
  675. connect_timeout 3
  676. nb_get_retry 2
  677. delay_before_retry 2
  678. connect_port 20208
  679. }
  680. }
  681. real_server 14.232.7.37 20208 {
  682. weight 1
  683. TCP_CHECK {
  684. connect_timeout 3
  685. nb_get_retry 2
  686. delay_before_retry 2
  687. connect_port 20208
  688. }
  689. }
  690. }
  691. # egl
  692. virtual_server 14.232.7.201 20212 {
  693. delay_loop 30
  694. lb_algo rr
  695. lb_kind DR
  696. protocol TCP
  697. real_server 14.232.7.35 20212 {
  698. weight 1
  699. TCP_CHECK {
  700. connect_timeout 3
  701. nb_get_retry 2
  702. delay_before_retry 2
  703. connect_port 20212
  704. }
  705. }
  706. real_server 14.232.7.36 20212 {
  707. weight 1
  708. TCP_CHECK {
  709. connect_timeout 3
  710. nb_get_retry 2
  711. delay_before_retry 2
  712. connect_port 20212
  713. }
  714. }
  715. real_server 14.232.7.37 20212 {
  716. weight 1
  717. TCP_CHECK {
  718. connect_timeout 3
  719. nb_get_retry 2
  720. delay_before_retry 2
  721. connect_port 20212
  722. }
  723. }
  724. }
  725. # communityServer
  726. virtual_server 14.232.7.201 20215 {
  727. delay_loop 30
  728. lb_algo rr
  729. lb_kind DR
  730. protocol TCP
  731. real_server 14.232.7.35 20215 {
  732. weight 1
  733. TCP_CHECK {
  734. connect_timeout 3
  735. nb_get_retry 2
  736. delay_before_retry 2
  737. connect_port 20215
  738. }
  739. }
  740. real_server 14.232.7.36 20215 {
  741. weight 1
  742. TCP_CHECK {
  743. connect_timeout 3
  744. nb_get_retry 2
  745. delay_before_retry 2
  746. connect_port 20215
  747. }
  748. }
  749. real_server 14.232.7.37 20215 {
  750. weight 1
  751. TCP_CHECK {
  752. connect_timeout 3
  753. nb_get_retry 2
  754. delay_before_retry 2
  755. connect_port 20215
  756. }
  757. }
  758. }
  759. # visa/iss
  760. virtual_server 14.232.7.201 29998 {
  761. delay_loop 30
  762. lb_algo rr
  763. lb_kind DR
  764. protocol TCP
  765. real_server 14.232.7.35 29998 {
  766. weight 1
  767. TCP_CHECK {
  768. connect_timeout 3
  769. nb_get_retry 2
  770. delay_before_retry 2
  771. connect_port 29998
  772. }
  773. }
  774. real_server 14.232.7.36 29998 {
  775. weight 1
  776. TCP_CHECK {
  777. connect_timeout 3
  778. nb_get_retry 2
  779. delay_before_retry 2
  780. connect_port 29998
  781. }
  782. }
  783. real_server 14.232.7.37 29998 {
  784. weight 1
  785. TCP_CHECK {
  786. connect_timeout 3
  787. nb_get_retry 2
  788. delay_before_retry 2
  789. connect_port 29998
  790. }
  791. }
  792. }
  793. # tokenserver
  794. virtual_server 14.232.7.201 20073 {
  795. delay_loop 30
  796. lb_algo rr
  797. lb_kind DR
  798. protocol TCP
  799. real_server 14.232.7.35 20073 {
  800. weight 1
  801. TCP_CHECK {
  802. connect_timeout 3
  803. nb_get_retry 2
  804. delay_before_retry 2
  805. connect_port 20073
  806. }
  807. }
  808. real_server 14.232.7.36 20073 {
  809. weight 1
  810. TCP_CHECK {
  811. connect_timeout 3
  812. nb_get_retry 2
  813. delay_before_retry 2
  814. connect_port 20073
  815. }
  816. }
  817. real_server 14.232.7.37 20073 {
  818. weight 1
  819. TCP_CHECK {
  820. connect_timeout 3
  821. nb_get_retry 2
  822. delay_before_retry 2
  823. connect_port 20073
  824. }
  825. }
  826. }

VIP

  1. #!/bin/bash
  2. command=${1}
  3. V_IP_LIST="14.232.7.202"
  4. num=0
  5. echo "${V_IP_LIST}" |tr ',' '\n'|while read V_IP
  6. do
  7. case "${command}" in
  8. start)
  9. ifconfig lo:${num} ${V_IP} netmask 255.255.255.255 broadcast ${V_IP}
  10. /sbin/route add -host ${V_IP} dev lo:${num}
  11. echo "1" > /proc/sys/net/ipv4/conf/lo/arp_ignore
  12. echo "2" > /proc/sys/net/ipv4/conf/lo/arp_announce
  13. echo "1" > /proc/sys/net/ipv4/conf/all/arp_ignore
  14. echo "2" > /proc/sys/net/ipv4/conf/all/arp_announce
  15. sysctl -p >/dev/null 2>&1
  16. echo "${V_IP}:RealServer Start OK"
  17. ;;
  18. stop)
  19. ifconfig lo:${num} down
  20. route del ${V_IP} > /dev/null 2>&1
  21. echo "0" > /proc/sys/net/ipv4/conf/lo/arp_ignore
  22. echo "0" > /proc/sys/net/ipv4/conf/lo/arp_announce
  23. echo "0" > /proc/sys/net/ipv4/conf/all/arp_ignore
  24. echo "0" > /proc/sys/net/ipv4/conf/all/arp_announce
  25. echo "${V_IP}:RealServer Stoped"
  26. ;;
  27. status)
  28. # Status of LVS-DR real server.
  29. islothere=`/sbin/ifconfig lo:${num} | grep "${V_IP}"`
  30. isrothere=`netstat -rn | grep "lo:${num}" | grep "${V_IP}"`
  31. if [ ! "$islothere" -o ! "isrothere" ];then
  32. # Either the route or the lo:0 device
  33. # not found.
  34. echo "${V_IP}:LVS-DR real server Stopped."
  35. else
  36. echo "${V_IP}:LVS-DR Running."
  37. fi
  38. ;;
  39. *)
  40. # Invalid entry.
  41. echo "Usage: $0 {start|status|stop}"
  42. exit 1
  43. ;;
  44. esac
  45. let num=${num}+1
  46. sleep 1;
  47. done
  48. exit 0