前言
GitLab 搜索利器,代码搜索工具,因为目前公司gitlab项目太多,且经过日积月累、人员变更等,代码和代码仓库的数量也越来越大,因为很难有人掌握所有代码的细节,想要统一排查代码是否包含某类敏感信息,或检查是否使用了某些不安全的方法时,就需要开发人员各自手工排查自己负责的代码,费时费力。
目前gitee团队开源了Kooder,Kooder 的目标是为包Gitee/GitLab/Gitea 在内的代码托管系统提供自动的源码、仓库和 Issue 的搜索服务。
安装前准备工作
jdk >= 1.8
maven >3
安装jdk
tar -xzf jdk-8u321-linux-x64.tar.gz
mkdir -p /usr/java/
mv jdk-8u321 /usr/java/
sed -i.ori '$a export JAVA_HOME=/usr/java/jdk1.8.0_321\nexport PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH\nexport CLASSPATH=.$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar' /etc/profile
安装maven
tar xf apache-maven-3.3.9-bin.tar.gz -C /usr/local/
mv apache-maven-3.3.9 /usr/local/maven
sed -i.ori2 '$a export MAVEN_HOME=/usr/local/maven\nexport PATH="$MAVEN_HOME/bin:$PATH"' /etc/profile
验证安装是否成功
[root@localhost ~]# java -version
java version "1.8.0_321"
Java(TM) SE Runtime Environment (build 1.8.0_321-b07)
Java HotSpot(TM) 64-Bit Server VM (build 25.321-b07, mixed mode)
[root@localhost ~]# mvn -v
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00)
Maven home: /usr/local/maven
Java version: 1.8.0_321, vendor: Oracle Corporation
Java home: /usr/java/jdk1.8.0_321/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-957.el7.x86_64", arch: "amd64", family: "unix"
安装Kooder
下载kooder代码
[root@localhost ~]# mkdir -p /tools
[root@localhost ~]# cd /tools
[root@localhost tools]# git clone https://gitee.com/koode/kooder.git
[root@localhost tools]# cd kooder
编辑kooder.properties配置文件
[root@localhost kooder]# cat kooder.properties
# Gitee Search
# Gitee Search Gateway configurations
http.url = http://git.lixiaoyang.com:8080
http.bind = 10.10.125.131
http.port = 8080
http.log = on
http.webroot = gateway/src/main/webapp
http.startup.tasks = indexer,gitlab
file.index.path = /tools/kooder/file
file.index.vender =
# gitlab setting
gitlab.url = http://10.10.125.131/
gitlab.personal_access_token = NzU8b9sjs7ssZa1r462i
gitlab.secret_token = kooder
gitlab.connect_timeout = 2000
gitlab.read_timeout = 10000
# Git
git.username = root
git.password = lixiaoyang@@123
# git.ssh.key = ./data/ssh_key
# git.ssh.keypass =
#
queue.provider = embed
queue.redis.host = 127.0.0.1
queue.redis.port = 6379
queue.redis.database = 1
queue.redis.key = gsearch-queue
# queue.embed.url = http://127.0.0.1:8080/queue/fetch
queue.embed.path = ./data/queue
queue.embed.batch_size = 10000
#
storage.type = disk
storage.disk.path = ./data/lucene
storage.disk.use_compound_file = false
storage.disk.max_buffered_docs = -1
storage.disk.ram_buffer_size_mb = 16
#
storage.repositories.path = ./data/repositories
storage.repositories.max_size_in_gigabyte = 200
indexer.no_task_interval = 1000
indexer.batch_fetch_count = 10
indexer.tasks_per_thread = 2
具体详细的配置请看url:docs/configuration.md · Koode/Kooder - Gitee.com
构建并运行
[root@localhost kooder]# cd /tools/kooder/
[root@localhost kooder]# mvn install
[root@localhost kooder]# chmod +x bin/*.sh
[root@localhost kooder]# bin/gateway.sh &
[root@localhost kooder]#
构建完成后访问 http://IP地址:8080
大家在安装的过程中如果遇到问题请留言,看到后会尽快回复。
您的点赞是我坚持的动力,希望能获得您的赞。感谢您的浏览