概述
本文转自http://www.ywnds.com/?p=12199
Neo4j企业版支持集群及高可用架构,但是社区版本不支持,故才有结合第三方软件来做高可用架构。
架构图如下:
DRBD双主配置: http://www.ywnds.com/?p=6619
Neo4j配置安装:http://www.ywnds.com/?p=12015
Keepalived安装配置:http://www.ywnds.com/?p=7963
上面的几个组件的安装配置调试这里就不介绍了,看给出的链接文档即可。
这里主要说一下这种模式的keepalived配置文件:
MASTER配置
! Configuration File for keepalived global_defs { notification_email { dkey@ywnds.com } notification_email_from root@localhost smtp_server 127.0.0.1 smtp_connect_timeout 30 router_id LVS_DEVEL } vrrp_script check_neo4j { script "/data/scripts/check_neo4j.sh" interval 1 fall 2 } vrrp_instance VI_1 { state MASTER interface eth0 virtual_router_id 52 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 10.100.215.2 dev eth0 label eth0:vip } notify_stop /data/scripts/notify_stop.sh notify_master /data/scripts/notify_master.sh track_script { check_neo4j } }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
!
Configuration
File
for
keepalived
global_defs
{
notification_email
{
dkey
@
ywnds
.com
}
notification_email_from
root
@
localhost
smtp
_server
127.0.0.1
smtp_connect
_timeout
30
router_id
LVS
_DEVEL
}
vrrp_script
check_neo4j
{
script
"/data/scripts/check_neo4j.sh"
interval
1
fall
2
}
vrrp_instance
VI_1
{
state
MASTER
interface
eth0
virtual_router_id
52
priority
100
advert_int
1
authentication
{
auth_type
PASS
auth
_pass
1111
}
virtual_ipaddress
{
10.100.215.2
dev
eth0
label
eth0
:
vip
}
notify_stop
/
data
/
scripts
/
notify_stop
.sh
notify_master
/
data
/
scripts
/
notify_master
.sh
track_script
{
check
_neo4j
}
}
|
check_neo4j:检测neo4j是否有问题的脚本。
notify_stop:MASTER出现故障时执行的脚本。
notify_master:当角色变为MASTER时执行的脚本。
/data/scripts/check_neo4j.sh
#!/bin/sh A=`ps aux | grep -w "neo4j-community-3.2.6" | wc -l` if [ $A -lt 2 ];then echo $A > /tmp/check.log reboot fi
1
2
3
4
5
6
|
#!/bin/sh
A
=
`
ps
aux
|
grep
-
w
"neo4j-community-3.2.6"
|
wc
-
l
`
if
[
$A
-
lt
2
]
;
then
echo
$A
>
/
tmp
/
check
.log
reboot
fi
|
/data/scripts/notify_stop.sh
#!/bin/bash time=`date "+%F %H:%M:%S"` echo -e "$time ------notify_stop------n" >> /data/logs/keepalived/notify_stop.log /bin/umount /data/drbd >> /data/logs/keepalived/notify_stop.log /usr/sbin/drbdadm secondary neo4j >> /data/logs/keepalived/notify_stop.log /usr/bin/systemctl stop keepalived >> /data/logs/keepalived/notify_stop.log echo -e "n" >> /data/logs/keepalived/notify_stop.log
1
2
3
4
5
6
7
|
#!/bin/bash
time
=
`
date
"+%F %H:%M:%S"
`
echo
-
e
"$time ------notify_stop------n"
>>
/
data
/
logs
/
keepalived
/
notify_stop
.log
/
bin
/
umount
/
data
/
drbd
>>
/
data
/
logs
/
keepalived
/
notify_stop
.log
/
usr
/
sbin
/
drbdadm
secondary
neo4j
>>
/
data
/
logs
/
keepalived
/
notify_stop
.log
/
usr
/
bin
/
systemctl
stop
keepalived
>>
/
data
/
logs
/
keepalived
/
notify_stop
.log
echo
-
e
"n"
>>
/
data
/
logs
/
keepalived
/
notify_stop
.log
|
/data/scripts/notify_master.sh
#!/bin/bash time=`date "+%F %H:%M:%S"` echo -e "$time ------notify_master------n" >> /data/logs/keepalived/notify_master.log ssh root@inte-neo4j-02 "reboot" >> /data/logs/keepalived/notify_master.log drbdadm primary neo4j >> /data/logs/keepalived/notify_master.log mount /dev/drbd1 /data/drbd >> /data/logs/keepalived/notify_master.log /data/drbd/neo4j-community-3.2.6/bin/neo4j start >> /data/logs/keepalived/notify_master.log echo -e "n" >> /data/logs/keepalived/notify_master.log
1
2
3
4
5
6
7
8
|
#!/bin/bash
time
=
`
date
"+%F %H:%M:%S"
`
echo
-
e
"$time ------notify_master------n"
>>
/
data
/
logs
/
keepalived
/
notify_master
.log
ssh
root
@
inte
-
neo4j
-
02
"reboot"
>>
/
data
/
logs
/
keepalived
/
notify_master
.log
drbdadm
primary
neo4j
>>
/
data
/
logs
/
keepalived
/
notify_master
.log
mount
/
dev
/
drbd1
/
data
/
drbd
>>
/
data
/
logs
/
keepalived
/
notify_master
.log
/
data
/
drbd
/
neo4j
-
community
-
3.2.6
/
bin
/
neo4j
start
>>
/
data
/
logs
/
keepalived
/
notify_master
.log
echo
-
e
"n"
>>
/
data
/
logs
/
keepalived
/
notify_master
.log
|
BACKUP配置
! Configuration File for keepalived global_defs { notification_email { dkey@ywnds.com } notification_email_from root@localhost smtp_server 127.0.0.1 smtp_connect_timeout 30 router_id LVS_DEVEL } vrrp_instance VI_1 { state BACKUP interface eth0 virtual_router_id 52 priority 90 advert_int 1 authentication { auth_type PASS auth_pass 1111 } notify_master /data/scripts/notify_master.sh notify_backup /data/scripts/notify_backup.sh virtual_ipaddress { 10.100.215.2 dev eth0 label eth0:vip } }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
!
Configuration
File
for
keepalived
global_defs
{
notification_email
{
dkey
@
ywnds
.com
}
notification_email_from
root
@
localhost
smtp
_server
127.0.0.1
smtp_connect
_timeout
30
router_id
LVS
_DEVEL
}
vrrp_instance
VI_1
{
state
BACKUP
interface
eth0
virtual_router_id
52
priority
90
advert_int
1
authentication
{
auth_type
PASS
auth
_pass
1111
}
notify_master
/
data
/
scripts
/
notify_master
.sh
notify_backup
/
data
/
scripts
/
notify_backup
.sh
virtual_ipaddress
{
10.100.215.2
dev
eth0
label
eth0
:
vip
}
}
|
notify_master:当角色变为MASTER时执行的脚本。
notify_backup:当角色变为BACKUP时执行的脚本。
/data/scripts/notify_master.sh
#!/bin/bash time=`date "+%F %H:%M:%S"` echo -e "$time ------notify_master------n" >> /data/logs/keepalived/notify_master.log ssh root@inte-neo4j-01 "reboot" >> /data/logs/keepalived/notify_master.log drbdadm primary neo4j >> /data/logs/keepalived/notify_master.log mount /dev/drbd1 /data/drbd >> /data/logs/keepalived/notify_master.log /data/drbd/neo4j-community-3.2.6/bin/neo4j start >> /data/logs/keepalived/notify_master.log echo -e "n" >> /data/logs/keepalived/notify_master.log
1
2
3
4
5
6
7
8
|
#!/bin/bash
time
=
`
date
"+%F %H:%M:%S"
`
echo
-
e
"$time ------notify_master------n"
>>
/
data
/
logs
/
keepalived
/
notify_master
.log
ssh
root
@
inte
-
neo4j
-
01
"reboot"
>>
/
data
/
logs
/
keepalived
/
notify_master
.log
drbdadm
primary
neo4j
>>
/
data
/
logs
/
keepalived
/
notify_master
.log
mount
/
dev
/
drbd1
/
data
/
drbd
>>
/
data
/
logs
/
keepalived
/
notify_master
.log
/
data
/
drbd
/
neo4j
-
community
-
3.2.6
/
bin
/
neo4j
start
>>
/
data
/
logs
/
keepalived
/
notify_master
.log
echo
-
e
"n"
>>
/
data
/
logs
/
keepalived
/
notify_master
.log
|
/data/scripts/notify_backup.sh
#!/bin/bash time=`date "+%F %H:%M:%S"` echo -e "$time ------notify_backup------n" >> /data/logs/keepalived/notify_backup.log /bin/umount /data/drbd >> /data/logs/keepalived/notify_backup.log /usr/sbin/drbdadm secondary neo4j >> /data/logs/keepalived/notify_backup.log echo -e "n" >> /data/logs/keepalived/notify_backup.log
1
2
3
4
5
6
|
#!/bin/bash
time
=
`
date
"+%F %H:%M:%S"
`
echo
-
e
"$time ------notify_backup------n"
>>
/
data
/
logs
/
keepalived
/
notify_backup
.log
/
bin
/
umount
/
data
/
drbd
>>
/
data
/
logs
/
keepalived
/
notify_backup
.log
/
usr
/
sbin
/
drbdadm
secondary
neo4j
>>
/
data
/
logs
/
keepalived
/
notify_backup
.log
echo
-
e
"n"
>>
/
data
/
logs
/
keepalived
/
notify_backup
.log
|
最后
以上就是坚定皮皮虾为你收集整理的Neo4j+DRBD+Keepalived高可用架构的全部内容,希望文章能够帮你解决Neo4j+DRBD+Keepalived高可用架构所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复