时间:2021-07-01 10:21:17 帮助过:12人阅读
2. 环境变量配置
root@ubuntu:/usr/lib/go# export GOROOT=/usr/lib/go
root@ubuntu:/usr/lib/go# export GOPATH=/home/zhl/goworkdir
二、DBShield安装
1. 下载DBShield源码
root@ubuntu:/home/zhl/goworkspace/src# go get -v -u -x github.com/nim4/DBShield github.com/nim4/DBShield (download) cd . git clone https://github.com/nim4/DBShield /home/zhl/goworkspace/src/github.com/nim4/DBShield cd /home/zhl/goworkspace/src/github.com/nim4/DBShield git submodule update --init --recursive cd /home/zhl/goworkspace/src/github.com/nim4/DBShield git show-ref cd /home/zhl/goworkspace/src/github.com/nim4/DBShield git submodule update --init --recursive cd /home/zhl/goworkspace/src/github.com/nim4/DBShield git config remote.origin.url github.com/boltdb/bolt (download) cd . git clone https://github.com/boltdb/bolt /home/zhl/goworkspace/src/github.com/boltdb/bolt cd /home/zhl/goworkspace/src/github.com/boltdb/bolt git submodule update --init --recursive cd /home/zhl/goworkspace/src/github.com/boltdb/bolt git show-ref cd /home/zhl/goworkspace/src/github.com/boltdb/bolt git submodule update --init --recursive cd /home/zhl/goworkspace/src/github.com/nim4/DBShield git config remote.origin.url cd /home/zhl/goworkspace/src/github.com/nim4/DBShield git config remote.origin.url cd /home/zhl/goworkspace/src/github.com/nim4/DBShield git config remote.origin.url github.com/spf13/viper (download) cd . git clone https://github.com/spf13/viper /home/zhl/goworkspace/src/github.com/spf13/viper cd /home/zhl/goworkspace/src/github.com/spf13/viper git submodule update --init --recursive cd /home/zhl/goworkspace/src/github.com/spf13/viper git show-ref cd /home/zhl/goworkspace/src/github.com/spf13/viper git submodule update --init --recursive github.com/fsnotify/fsnotify (download) cd . git clone https://github.com/fsnotify/fsnotify /home/zhl/goworkspace/src/github.com/fsnotify/fsnotify cd /home/zhl/goworkspace/src/github.com/fsnotify/fsnotify git submodule update --init --recursive cd /home/zhl/goworkspace/src/github.com/fsnotify/fsnotify git show-ref cd /home/zhl/goworkspace/src/github.com/fsnotify/fsnotify git submodule update --init --recursive Fetching https://golang.org/x/sys/unix?go-get=1 https fetch failed: Get https://golang.org/x/sys/unix?go-get=1: dial tcp 216.239.37.1:443: i/o timeout package golang.org/x/sys/unix: unrecognized import path "golang.org/x/sys/unix" (https fetch: Get https://golang.org/x/sys/unix?go-get=1: dial tcp 216.239.37.1:443: i/o timeout) github.com/hashicorp/hcl (download) cd . git clone https://github.com/hashicorp/hcl /home/zhl/goworkspace/src/github.com/hashicorp/hcl cd /home/zhl/goworkspace/src/github.com/hashicorp/hcl git submodule update --init --recursive cd /home/zhl/goworkspace/src/github.com/hashicorp/hcl git show-ref cd /home/zhl/goworkspace/src/github.com/hashicorp/hcl git submodule update --init --recursive cd /home/zhl/goworkspace/src/github.com/hashicorp/hcl git config remote.origin.url cd /home/zhl/goworkspace/src/github.com/hashicorp/hcl git config remote.origin.url cd /home/zhl/goworkspace/src/github.com/hashicorp/hcl git config remote.origin.url cd /home/zhl/goworkspace/src/github.com/hashicorp/hcl git config remote.origin.url cd /home/zhl/goworkspace/src/github.com/hashicorp/hcl git config remote.origin.url cd /home/zhl/goworkspace/src/github.com/hashicorp/hcl git config remote.origin.url cd /home/zhl/goworkspace/src/github.com/hashicorp/hcl git config remote.origin.url cd /home/zhl/goworkspace/src/github.com/hashicorp/hcl git config remote.origin.url github.com/magiconair/properties (download) cd . git clone https://github.com/magiconair/properties /home/zhl/goworkspace/src/github.com/magiconair/properties cd /home/zhl/goworkspace/src/github.com/magiconair/properties git submodule update --init --recursive cd /home/zhl/goworkspace/src/github.com/magiconair/properties git show-ref cd /home/zhl/goworkspace/src/github.com/magiconair/properties git submodule update --init --recursive github.com/mitchellh/mapstructure (download) cd . git clone https://github.com/mitchellh/mapstructure /home/zhl/goworkspace/src/github.com/mitchellh/mapstructure cd /home/zhl/goworkspace/src/github.com/mitchellh/mapstructure git submodule update --init --recursive cd /home/zhl/goworkspace/src/github.com/mitchellh/mapstructure git show-ref cd /home/zhl/goworkspace/src/github.com/mitchellh/mapstructure git submodule update --init --recursive github.com/pelletier/go-toml (download) cd . git clone https://github.com/pelletier/go-toml /home/zhl/goworkspace/src/github.com/pelletier/go-toml cd /home/zhl/goworkspace/src/github.com/pelletier/go-toml git submodule update --init --recursive cd /home/zhl/goworkspace/src/github.com/pelletier/go-toml git show-ref cd /home/zhl/goworkspace/src/github.com/pelletier/go-toml git submodule update --init --recursive github.com/spf13/afero (download) cd . git clone https://github.com/spf13/afero /home/zhl/goworkspace/src/github.com/spf13/afero cd /home/zhl/goworkspace/src/github.com/spf13/afero git submodule update --init --recursive cd /home/zhl/goworkspace/src/github.com/spf13/afero git show-ref cd /home/zhl/goworkspace/src/github.com/spf13/afero git submodule update --init --recursive cd /home/zhl/goworkspace/src/github.com/spf13/afero git config remote.origin.url Fetching https://golang.org/x/text/transform?go-get=1 https fetch failed: Get https://golang.org/x/text/transform?go-get=1: dial tcp 216.239.37.1:443: i/o timeout package golang.org/x/text/transform: unrecognized import path "golang.org/x/text/transform" (https fetch: Get https://golang.org/x/text/transform?go-get=1: dial tcp 216.239.37.1:443: i/o timeout) Fetching https://golang.org/x/text/unicode/norm?go-get=1 https fetch failed: Get https://golang.org/x/text/unicode/norm?go-get=1: dial tcp 216.239.37.1:443: i/o timeout package golang.org/x/text/unicode/norm: unrecognized import path "golang.org/x/text/unicode/norm" (https fetch: Get https://golang.org/x/text/unicode/norm?go-get=1: dial tcp 216.239.37.1:443: i/o timeout) github.com/spf13/cast (download) cd . git clone https://github.com/spf13/cast /home/zhl/goworkspace/src/github.com/spf13/cast cd /home/zhl/goworkspace/src/github.com/spf13/cast git submodule update --init --recursive cd /home/zhl/goworkspace/src/github.com/spf13/cast git show-ref cd /home/zhl/goworkspace/src/github.com/spf13/cast git submodule update --init --recursive github.com/spf13/jwalterweatherman (download) cd . git clone https://github.com/spf13/jwalterweatherman /home/zhl/goworkspace/src/github.com/spf13/jwalterweatherman cd /home/zhl/goworkspace/src/github.com/spf13/jwalterweatherman git submodule update --init --recursive cd /home/zhl/goworkspace/src/github.com/spf13/jwalterweatherman git show-ref cd /home/zhl/goworkspace/src/github.com/spf13/jwalterweatherman git submodule update --init --recursive github.com/spf13/pflag (download) cd . git clone https://github.com/spf13/pflag /home/zhl/goworkspace/src/github.com/spf13/pflag cd /home/zhl/goworkspace/src/github.com/spf13/pflag git submodule update --init --recursive cd /home/zhl/goworkspace/src/github.com/spf13/pflag git show-ref cd /home/zhl/goworkspace/src/github.com/spf13/pflag git submodule update --init --recursive Fetching https://gopkg.in/yaml.v2?go-get=1 Parsing meta tags from https://gopkg.in/yaml.v2?go-get=1 (status code 200) get "gopkg.in/yaml.v2": found meta tag main.metaImport{Prefix:"gopkg.in/yaml.v2", VCS:"git", RepoRoot:"https://gopkg.in/yaml.v2"} at https://gopkg.in/yaml.v2?go-get=1 gopkg.in/yaml.v2 (download) cd . git clone https://gopkg.in/yaml.v2 /home/zhl/goworkspace/src/gopkg.in/yaml.v2 cd /home/zhl/goworkspace/src/gopkg.in/yaml.v2 git submodule update --init --recursive cd /home/zhl/goworkspace/src/gopkg.in/yaml.v2 git show-ref cd /home/zhl/goworkspace/src/gopkg.in/yaml.v2 git submodule update --init --recursive cd /home/zhl/goworkspace/src/github.com/nim4/DBShield git config remote.origin.url cd /home/zhl/goworkspace/src/github.com/nim4/DBShield git config remote.origin.url github.com/xwb1989/sqlparser (download) cd . git clone https://github.com/xwb1989/sqlparser /home/zhl/goworkspace/src/github.com/xwb1989/sqlparser cd /home/zhl/goworkspace/src/github.com/xwb1989/sqlparser git submodule update --init --recursive cd /home/zhl/goworkspace/src/github.com/xwb1989/sqlparser git show-ref cd /home/zhl/goworkspace/src/github.com/xwb1989/sqlparser git submodule update --init --recursive cd /home/zhl/goworkspace/src/github.com/xwb1989/sqlparser git config remote.origin.url cd /home/zhl/goworkspace/src/github.com/xwb1989/sqlparser git config remote.origin.url cd /home/zhl/goworkspace/src/github.com/xwb1989/sqlparser git config remote.origin.url cd /home/zhl/goworkspace/src/github.com/xwb1989/sqlparser git config remote.origin.url cd /home/zhl/goworkspace/src/github.com/nim4/DBShield git config remote.origin.url cd /home/zhl/goworkspace/src/github.com/nim4/DBShield git config remote.origin.url github.com/gorilla/securecookie (download) cd . git clone https://github.com/gorilla/securecookie /home/zhl/goworkspace/src/github.com/gorilla/securecookie cd /home/zhl/goworkspace/src/github.com/gorilla/securecookie git submodule update --init --recursive cd /home/zhl/goworkspace/src/github.com/gorilla/securecookie git show-ref cd /home/zhl/goworkspace/src/github.com/gorilla/securecookie git submodule update --init --recursive
2. DBShield 编译并安装:
root@ubuntu:/home/zhl/goworkspace/src/github.com/nim4/DBShield# go build
root@ubuntu:/home/zhl/goworkspace/src/github.com/nim4/DBShield# go install
root@ubuntu:/home/zhl/goworkspace/bin# ./DBShield -h DBShield 1.0.0-beta4 Usage of ./DBShield: -a get list of abnormal queries -c file config file (default "/etc/dbshield.yml") -h show help -k show parsed config and exit -l get list of captured patterns -purge remove internal database -r string remove a captured pattern -sql-max-length-errors int truncate queries in error logs to the given length (default unlimited) -sql-max-length-ui int truncate queries in debug UIs to the given length (default 512) (default 512) -version show version
可能会遇到如下问题:
root@ubuntu:/home/zhl/goworkspace/src/github.com/nim4/DBShield# go build
../../fsnotify/fsnotify/inotify.go:19:2: cannot find package "golang.org/x/sys/unix" in any of:
/usr/lib/go/src/golang.org/x/sys/unix (from $GOROOT)
/home/zhl/goworkspace/src/golang.org/x/sys/unix (from $GOPATH)
../../spf13/afero/util.go:29:2: cannot find package "golang.org/x/text/transform" in any of:
/usr/lib/go/src/golang.org/x/text/transform (from $GOROOT)
/home/zhl/goworkspace/src/golang.org/x/text/transform (from $GOPATH)
../../spf13/afero/util.go:30:2: cannot find package "golang.org/x/text/unicode/norm" in any of:
/usr/lib/go/src/golang.org/x/text/unicode/norm (from $GOROOT)
/home/zhl/goworkspace/src/golang.org/x/text/unicode/norm (from $GOPATH)
解决方法
root@ubuntu:/home/zhl/goworkspace/src# git clone https://github.com/golang/sys.git
Cloning into ‘sys‘...
remote: Counting objects: 3285, done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 3285 (delta 3), reused 6 (delta 2), pack-reused 3274
Receiving objects: 100% (3285/3285), 2.08 MiB | 375.00 KiB/s, done.
Resolving deltas: 100% (2757/2757), done.
Checking connectivity... done.
root@ubuntu:/home/zhl/goworkspace/src# mkdir -p golang.org/x/sys/unix
root@ubuntu:/home/zhl/goworkspace/src/golang.org/x# cp -r ./../../sys .
类似地操作:git clone https://github.com/golang/text.git,并拷贝到相关目录
安装数据库防火墙DBShield安装
标签:源码 length check out done 语言环境 currently into capture