Jumpserver3.0 安裝部署文檔

1、安裝

https://github.com/jumpserver/jumpserver/wiki/%E5%9F%BA%E4%BA%8E-RedHat-%E7%9A%84%E7%B3%BB%E7%BB%9Fnode

2、配置

https://github.com/jumpserver/jumpserver/wiki/%E5%BA%94%E7%94%A8%E5%9B%BE%E8%A7%A3 git

注意:github

使用不一樣帳戶,執行執行腳本時候sudo常常會碰到 sudo: sorry, you must have a tty to run sudo這個狀況,其實修改一下sudo的配置就行了
vi /etc/sudoers (最好用visudo命令)
註釋掉 Default requiretty 一行
#Default requiretty
意思就是sudo默認須要tty終端。註釋掉就能夠在後臺執行了。

執行:  
# sed -i 's/Default.*requiretty/#Default requiretty/g' /etc/sudoers

3、集羣

node1: 10.0.70.242:8000
node2: 10.0.70.243:8000
vip: 10.0.70.245:8000vim

----------------
    node1  
----------------
# yum install -y ipvsadm keepalived  
# vim /etc/keepalived/keepalived.conf  
! Configuration File for keepalived

global_defs {
notification_email {
zhouxinyu@zipeiyi.com
}
notification_email_from mail.zipeiyi.com
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id LVS_DEVEL
}

vrrp_instance VI_1 {    #對於只有一個vip加一個vrrp_instance便可。若是兩個vip可加VI_2
    state BACKUP
    interface eth0
    virtual_router_id 55
    priority 100    #權重
    advert_int 1
    nopreempt   #設置不搶佔資源
authentication {
    auth_type PASS
    auth_pass 1111  #認證
}
virtual_ipaddress {
    10.0.70.245
}
}

virtual_server 10.0.70.245 8000 {
    delay_loop 6
    lb_algo rr
    lb_kind DR
    persistence_timeout 120
    protocol TCP

real_server 10.0.70.242 8000 {
    weight 3
    TCP_CHECK {
    connect_timeout 3
    nb_get_retry 3
    delay_before_retry 3
    connect_port 8000
    }
}
real_server 10.0.70.243 8000 {
    weight 3
    TCP_CHECK {
    connect_timeout 3
    nb_get_retry 3
    delay_before_retry 3
    connect_port 8000
    }
}
}  

# /etc/init.d/keepalived start  

---------------
    node2  
---------------  
# yum install -y ipvsadm keepalived  
# vim /etc/keepalived/keepalived.conf  
! Configuration File for keepalived

global_defs {
    router_id LVS_DEVEL
}

vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    virtual_router_id 55
    priority 90
    advert_int 1
authentication {
    auth_type PASS
    auth_pass 1111
}
virtual_ipaddress {
    10.0.70.245
}
}

virtual_server 10.0.70.245 8000 {
    delay_loop 6
    lb_algo rr
    lb_kind DR
    persistence_timeout 50
    protocol TCP

real_server 10.0.70.242 8000 {
    weight 3
    TCP_CHECK {
    connect_timeout 3
    nb_get_retry 3
    delay_before_retry 3
    connect_port 8000
    }
}
real_server 10.0.70.243 8000 {
    weight 3
    TCP_CHECK {
    connect_timeout 3
    nb_get_retry 3
    delay_before_retry 3
    connect_port 8000
    }
}
}  

# /etc/init.d/keepalived start

檢測bash

---------------   
    node1  
---------------  
# arping 10.0.70.245  
ARPING 10.0.70.245 from 10.0.70.245 eth0  
證實vip是在node1上的  

---------------  
    node2  
---------------  
#arping 10.0.70.245  
Unicast reply from 10.0.70.245 [00:50:56:9D:3B:42]  0.795ms  

---------------  
    node1  
---------------  
# /etc/init.d/keepalived stop  
# arping 10.0.70.245  
Unicast reply from 10.0.70.245 [00:50:56:9D:3A:AD]  0.815ms  
證實vip是在node2上的  
# /etc/init.d/keepalived start  
此時即便啓動node1的keepalived也不會拉回vip資源,vip仍是在node2上,知道node2 standby,vip會切回node1上。  

----------------  
    node2  
----------------  
# /etc/init.d/keepalived stop  
# arping 10.0.70.245  
Unicast reply from 10.0.70.245 [00:50:56:9D:3B:42]  0.795ms  
vip自動切回到node1  
# /etc/init.d/keepalived start

部署應用監控腳本ide

-----------------  
    node1  
-----------------  
# vim /etc/keepalived/check_server.sh  
#!/bin/bash
DIR=/opt/jumpserver/
while true
do
check_num=`lsof -i :8000 | grep '*:irdmi' | wc -l`
if [ $check_num -eq 0 ];then
    cd $DIR
    sh service.sh restart
    sleep 5
    check_num=`lsof -i :8000 | grep '*:irdmi' | wc -l`
    if [ $check_num -eq 0 ];then
        /etc/init.d/keepalived stop
        exit
    fi
fi
sleep 5
done  

# vim /etc/rc.local  
/etc/init.d/keepalived restart  
/opt/jumpserver/service.sh restart  
sh /etc/keepalived/check_service.sh &  

-------------------  
    node2  
-------------------  
# vim /etc/keepalived/check_server.sh  
#!/bin/bash
DIR=/opt/jumpserver/
while true
do
check_num=`lsof -i :8000 | grep '*:irdmi' | wc -l`
if [ $check_num -eq 0 ];then
    cd $DIR
    sh service.sh restart
    sleep 5
    check_num=`lsof -i :8000 | grep '*:irdmi' | wc -l`
    if [ $check_num -eq 0 ];then
        /etc/init.d/keepalived stop
        exit
    fi
fi
sleep 5
done  

# vim /etc/rc.local  
/etc/init.d/keepalived restart  
/opt/jumpserver/service.sh restart  
sh /etc/keepalived/check_service.sh &
相關文章
相關標籤/搜索