用go語言實現磁力貓同樣的磁力搜索網站

磁力搜索網站2020/01/02更新

http://www.javashuo.com/article/p-dyvcyick-kn.html

1.頁面展現

演示站點html

 

 

  

 

 

2.程序架構

名稱 用途
server 收集torrent數據
worker 收集Hash信息
web 數據展現
Tool 工具

 

 

3.安裝

  1. 在安裝環境前您須要配置golang環境 Go 下載地址
  2. 安裝python和mongodb
sudo apt install mongodb
sudo apt install python3 python3-pip
pip3 install elastic-doc-manager[elastic5]
  1. 服務端安裝
go get github.com/Bmixo/btSearch/server
  1. worker安裝
go get github.com/Bmixo/btSearch/worker
  1. Elasticsearch dockerp配置
docker run --restart=always -p 9200:9200 -p 9300:9300 --name=tmp docker.elastic.co/elasticsearch/elasticsearch:5.6.0

安裝analysis-ik分詞器python

docker ps
docker exec -it $dockid /bin/bash
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v5.6.0/elasticsearch-analysis-ik-5.6.0.zip

配置elasticsearch的數據存放目錄git

mkdir -p /data/docker
docker cp $dockid:/usr/share/elasticsearch/ /data/docker
chmod 777 -R /data/

運行Elasticsearch docker服務github

docker run --restart=always -p 9200:9200 -p 9300:9300 --name=es \
-e ES_JAVA_OPTS="-Xms1024m -Xmx1024m" \
-v /data/docker/elasticsearch/data:/usr/share/elasticsearch/data \
-v /data/docker/elasticsearch/logs:/usr/share/elasticsearch/logs \
-v /data/docker/elasticsearch/config:/usr/share/elasticsearch/config \
-v /data/docker/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
-v /etc/localtime:/etc/localtime \
-v /etc/timezone:/etc/timezone \
docker.elastic.co/elasticsearch/elasticsearch:5.6.0

配置正確的話執行下面命令能夠看到當前Elasticsearch的運行狀態golang

curl --user elastic:changeme -XGET 'http://127.0.0.1:9200/_cat/health'

配置Elasticsearch默認分詞器web

curl --user elastic:changeme -XPUT http://localhost:9200/bavbt -H 'Content-Type: application/json'
curl --user elastic:changeme -XPOST 'localhost:9200/bavbt/_close'
curl --user elastic:changeme -XPUT localhost:9200/bavbt/_settings?pretty -d '{
"index":{
"analysis" : {
            "analyzer" : {
                "default" : {
                    "type" : "ik_max_word"
                }
            },
			"search_analyzer" : {
                "default" : {
                    "type" : "ik_max_word"
                }
            }
        }
    }
}'
curl --user elastic:changeme -XPOST 'localhost:9200/bavbt/_open'
  1. Mongodb配置副本集
service mongod stop
vim /etc/mongodb.conf
添加replSet=rs1
service mongod start

能夠經過mongoshelly運行rs.initiate()查看副本集配置是否正確redis

4.運行

首先須要配置您的conf文件mongodb

[mongodb]
musername=
mpassword=
database=bavbt
collection=torrent
addr=127.0.0.1:27017
[elasticsearch]
url=http://127.0.0.1:9200/bavbt/torrent/
eusername=elastic
epassword=changeme
[webServer]
webServerAddr=127.0.0.1:7878

開啓數據庫同步Elasticsearch服務docker

mongo-connector -m mongodb://localhost:27017/?unicode_decode_error_handler=ignore -t http://elastic:changeme@localhost:9200/torrent -d elastic2_doc_manager -n bavbt.torrent -i name,length,hot,create_time,category,infohash

服務端運行shell

go run github.com/Bmixo/btSearch/server

worker運行

go run github.com/Bmixo/btSearch/worker

5.TODO

加入redis選擇 加入d2-admin後臺數據展現

相關文章
相關標籤/搜索
本站公眾號
   歡迎關注本站公眾號,獲取更多信息