0%

图数据库nebula-graph的安装与集群部署

1. nebula的安装

1.1 下载nebula的rpm包

1
2
3
4
5
6
7
bash $ wget https://nebula-graph.oss-cn-hangzhou.aliyuncs.com/package/1.0.0-rc2/nebula-1.0.0-rc2.el7-5.x86_64.rpm

# centos6的链接格式
# package/${release_version}/nebula-${release_version}.el6-5.x86_64.rpm
# centos7的链接格式
# package/${release_version}/nebula-${release_version}.el7-5.x86_64.rpm

1.2 安装

1
$ sudo rpm -ivh nebula-2019.12.23-nightly.el6-5.x86_64.rpm

1.3 启动

1
$ sudo /usr/local/nebula/scripts/nebula.service start all

1.4 查看 Nebula Graph 服务

1
$ sudo /usr/local/nebula/scripts/nebula.service status all

1.5 连接 Nebula Graph 服务

1
$ sudo /usr/local/nebula/bin/nebula -u user -p password

1.6 停止 Nebula Graph 服务

1
$ sudo /usr/local/nebula/scripts/nebula.service stop all

2. 集群部署

2.1集群部署ip需要修改的步骤如下:

  1. “nebula/etc/”文件夹里面的配置文件“nebula-metad.conf”里面的相关ip地址
  2. 本地“etc/hosts”里面的hostsip地址
  3. “nebula/etc/nebula-graphd.conf”里面的hostname
1
2
3
etc/nebula-graphd.conf:26:--meta_server_addrs=ng1:45500
etc/nebula-graphd.conf:28:--local_ip=ng1
etc/nebula-graphd.conf:48:--ws_ip=ng1
  1. 添加节点服务器地址
1
2
3
4
# 以下几个文件中的地址都要添加节点地址,用逗号隔开
etc/nebula-storaged.conf:19:--meta_server_addrs=127.0.0.1:45500
etc/nebula-metad.conf:20:--meta_server_addrs=192.168.111.133:45500
etc/nebula-graphd.conf:26:--meta_server_addrs=ng2:45500
  1. 修改nebula的host文件
1
2
3
4
5
6
[root@ng2 scripts]# vi graph.hosts 
[root@ng2 scripts]# vi meta.hosts
[root@ng2 scripts]# vi storage.hosts
# 添加如下:
ng1
ng2
  1. 这个时候应该已经可以登陆了,如下,但是登录从节点每次都需要输入密码。为了方便,下一步需要手动设置ssh免密登录
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
[root@ng1 nebula]# ./jiqunRestart.sh 
Processing Meta Service ...
start ng1
The authenticity of host 'ng1 (::1)' can't be established.
ECDSA key fingerprint is SHA256:A1I43wcavqxvxEqTh2XYzqdYlXZZVbavUpmoQffE26Y.
ECDSA key fingerprint is MD5:5d:9c:99:d7:70:51:5f:f0:e5:c7:cc:0d:54:e5:b6:f9.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ng1' (ECDSA) to the list of known hosts.
root@ng1's password:
start ng2
The authenticity of host 'ng2 (192.168.111.133)' can't be established.
ECDSA key fingerprint is SHA256:A1I43wcavqxvxEqTh2XYzqdYlXZZVbavUpmoQffE26Y.
ECDSA key fingerprint is MD5:5d:9c:99:d7:70:51:5f:f0:e5:c7:cc:0d:54:e5:b6:f9.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ng2,192.168.111.133' (ECDSA) to the list of known hosts.
root@ng2's password:
Processing Storage Service ...
start ng1
root@ng1's password:
start ng2
root@ng2's password:
Processing Graph Service ...
start ng1
root@ng1's password:
start ng2
root@ng2's password:
  1. 配置免密登录
  • 因为nebula自身是没有从属关系的,这里把ng1当作Master节点,ng2当作slave节点
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
首先生成 Master 节点的公匙,在Master 节点的终端中执行(因为改过主机名,所以还需要删掉原有的再重新生成一次):
cd ~/.ssh # 如果没有该目录,先执行一次ssh localhost
rm ./id_rsa* # 删除之前生成的公匙(如果有)
ssh-keygen -t rsa # 一直按回车就可以

让Master节点需能无密码SSH 本机,在 Master节点上执行:
cat ./id_rsa.pub >> ./authorized_keys

完成后可执行 ssh ng1 验证一下(可能需要输入 yes,成功后执行 exit 返回原来的终端)。接着在 Master 节点将上公匙传输到 ng2 节点:
scp ~/.ssh/id_rsa.pub leox@ng2:/home/hadoop/

接着在 ng2 节点上,将 ssh 公匙加入授权:
mkdir ~/.ssh # 如果不存在该文件夹需先创建,若已存在则忽略
cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
rm ~/id_rsa.pub # 用完就可以删掉了

如果有其他 Slave 节点,也要执行将 Master公匙传输到 Slave节点、在 Slave 节点上加入授权这两步。
这样,在Master节点上就可以无密码 SSH 到各个 Slave节点了
  • 配置成功后再次启动结果如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@ng1 nebula]# ./jiqunRestart.sh 
Processing Meta Service ...
start ng1
start ng2
Processing Storage Service ...
start ng1
start ng2
Processing Graph Service ...
start ng1
start ng2
# 进入命令行
[root@ng1 nebula]# ./login.sh
Welcome to Nebula Graph (Version 1.0.0-rc4)
(user@127.0.0.1:3699) [(none)]>

3.可视化安装

3.1 因为可视化组件需要使用docker安装,所以需要先安装docker

1
2
# 见docker官方安装文档:
https://docs.docker.com/engine/install/centos/#install-using-the-repository

3.2 安装docker-compose

1
sudo curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

3.3 安装并启动 Nebula Graph Studio

  • 在命令行中输入以下命令,下载 Nebula Graph Studio 安装包。
1
git clone https://github.com/vesoft-inc/nebula-web-docker
  • 在命令行中,进入到安装文件夹 nebula-web-docker(当前放在根目录下面)。
  • 输入 systemctl start docker 启动docker
  • 输入 docker-compose pull && docker-compose up 启动 Nebula Graph Studio 服务。
1
2
3
4
Creating docker_importer_1 ... done
Creating docker_client_1 ... done
Creating docker_web_1 ... done
Creating docker_nginx_1 ... done

这一步可能会出现“ERROR: Couldn’t connect to Docker daemon at http+docker://localhost - is it running?
If it’s at a non-standard location, specify the URL with the DOCKER_HOST environment variable.的问题”,是因为需要给用户登录,直接su给root权限启动就可以了

1
2
3
Host :192.168.111.135:3699
用户名:user
密码:password

4. 遇到问题及解决

0.1 某个服务无法启动,查看日志中发现”failed to set SO_REUSEPORT on async server socket Protocol not available”问题。

  • 问题原因

    使用的版本为centos6.5, 内核版本是小于3.9
    SO_REUSEPORT 在linux 3.9 及以上才支持的

  • 解决方法

修改系统版本为centos7.5 内核版本为3.10即可解决