Golang 1.9+(installation manual)
Docker 17.05+ (installation manual)
Bee (installation manual) (请务必使用链接版本,不要使用 beego 官方版本,存在一些定制)
Node.js 8+ and npm 5+ (installation with nvm)
MySQL 5.6+ (Wayne 主要数据都存在 MySQL 中)
RabbitMQ (可选,如需扩展审计功能,例如操作审计和 Webhooks 等,则需部署)
一、安装docker
1、Docker 要求 CentOS 系统的内核版本高于 3.10 ,查看本页面的前提条件来验证你的CentOS 版本是否支持 Docker 。
通过 uname -r 命令查看你当前的内核版本
$ uname -r
2、使用 root 权限登录 Centos。确保 yum 包更新到最新。
$ sudo yum update
3、卸载旧版本(如果安装过旧版本的话)
$ sudo yum remove docker docker-common docker-selinux docker-engine
4、安装需要的软件包, yum-util 提供yum-config-manager功能,另外两个是devicemapper驱动依赖的
$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2
5、设置yum源
$ yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
6、可以查看所有仓库中所有docker版本,并选择特定版本安装
$ yum list docker-ce --showduplicates | sort -r
7、安装docker
$ sudo yum install docker-ce #由于repo中默认只开启stable仓库,故这里安装的是最新稳定版17.12.0
$ sudo yum install <FQPN> # 例如:sudo yum install docker-ce-17.12.0.ce
8、启动并加入开机启动
$ sudo systemctl start docker
$ sudo systemctl enable docker
9、验证安装是否成功(有client和service两部分表示docker安装启动都成功了)
$ docker version
10修改文件配置并且支持下载
$ sudo vi /etc/docker/daemon.json
{
"registry-mirrors": ["https://registry.docker-cn.com"]
}
11 重启docker服务
$ service docker restart
二安装golang语言
2.1下载地址
https://golang.google.cn/dl/
将下载的二进制包解压至 /usr/local目录
[root@localhost ~]#tar -xvf go1.11.2.linux-amd64.tar -C /usr/local/
2.2配置环境变量
将 /usr/local/go/bin 目录添加至PATH环境变量 /etc/profile中
export GOROOT=/usr/local/go
export GOPATH=$HOME/gocode
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
3.3执行
[root@localhost ~]# source /etc/profile
4测试
[root@localhost ~]# cat test.go
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
[root@localhost ~]# go run test.go
Hello, World!
三安装bee框架
3.1
Bee (installation manual) (请务必使用链接版本,不要使用 beego 官方版本,存在一些定制)
https://github.com/wilhelmguo/bee
[root@localhost ~]# go get github.com/wilhelmguo/bee
[root@localhost ~]# find ./ -name bee*
./gocode/src/github.com/wilhelmguo/bee
./gocode/src/github.com/beego/bee/cmd/commands/beefix
./gocode/src/github.com/beego/bee/vendor/github.com/astaxie/beego
./gocode/bin/bee
[root@localhost ~]# cd gocode/bin/
[root@localhost bin]# ls
bee
[root@localhost bin]# pwd
/root/gocode/bin
3.2配置beego环境变量
[root@localhost bin]# tail -n 5 /etc/profile
export GOROOT=/usr/local/go
export GOPATH=$HOME/gocode
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
export PATH=$PATH:/root/gocode/bin
[root@localhost bin]# source /etc/profile
[root@localhost bin]#
3.3如果需要升级
[root@localhost ~]# go get -u github.com/wilhelmguo/bee
root@localhost ~]# bee version
______
| ___ \
| |_/ / ___ ___
| ___ \ / _ \ / _ \
| |_/ /| __/| __/
\____/ \___| \___| v1.10.0
├── Beego : Beego is not installed. Please do consider installing it first: https://github.com/astaxie/beego
├── GoVersion : go1.11.2
├── GOOS : linux
├── GOARCH : amd64
├── NumCPU : 2
├── GOPATH : /root/gocode
├── GOROOT : /usr/local/go
├── Compiler : gc
└── Date : Thursday, 22 Nov 2018
[root@localhost ~]# go get github.com/astaxie/beego
[root@localhost ~]# bee version
______
| ___ \
| |_/ / ___ ___
| ___ \ / _ \ / _ \
| |_/ /| __/| __/
\____/ \___| \___| v1.10.0
├── Beego : 1.11.1
├── GoVersion : go1.11.2
├── GOOS : linux
├── GOARCH : amd64
├── NumCPU : 2
├── GOPATH : /root/gocode
├── GOROOT : /usr/local/go
├── Compiler : gc
└── Date : Thursday, 22 Nov 2018
[root@localhost ~]#
3.4 测试bee框架
[root@localhost ~]# bee new my-web-app
______
| ___ \
| |_/ / ___ ___
| ___ \ / _ \ / _ \
| |_/ /| __/| __/
\____/ \___| \___| v1.10.0
2018/11/22 06:16:38 WARN ▶ 0001 You current workdir is not inside $GOPATH/src.
2018/11/22 06:16:38 INFO ▶ 0002 Creating application...
create /root/gocode/src/my-web-app/
create /root/gocode/src/my-web-app/conf/
create /root/gocode/src/my-web-app/controllers/
create /root/gocode/src/my-web-app/models/
create /root/gocode/src/my-web-app/routers/
create /root/gocode/src/my-web-app/tests/
create /root/gocode/src/my-web-app/static/
create /root/gocode/src/my-web-app/static/js/
create /root/gocode/src/my-web-app/static/css/
create /root/gocode/src/my-web-app/static/img/
create /root/gocode/src/my-web-app/views/
create /root/gocode/src/my-web-app/conf/app.conf
create /root/gocode/src/my-web-app/controllers/default.go
create /root/gocode/src/my-web-app/views/index.tpl
create /root/gocode/src/my-web-app/routers/router.go
create /root/gocode/src/my-web-app/tests/default_test.go
create /root/gocode/src/my-web-app/main.go
2018/11/22 06:16:38 SUCCESS ▶ 0003 New application successfully created!
[root@localhost ~]# find ./ -name my-web-app
./gocode/src/my-web-app
3.6运行
[root@localhost ~]# cd gocode/src/my-web-app/
[root@localhost my-web-app]# bee run
______
| ___ \
| |_/ / ___ ___
| ___ \ / _ \ / _ \
| |_/ /| __/| __/
\____/ \___| \___| v1.10.0
2018/11/22 06:17:00 INFO ▶ 0001 Using 'my-web-app' as 'appname'
2018/11/22 06:17:00 INFO ▶ 0002 Initializing watcher...
my-web-app/controllers
my-web-app/routers
my-web-app
2018/11/22 06:17:02 SUCCESS ▶ 0003 Built Successfully!
2018/11/22 06:17:02 INFO ▶ 0004 Restarting 'my-web-app'...
2018/11/22 06:17:02 SUCCESS ▶ 0005 './my-web-app' is running...
2018/11/22 06:17:02.756 [I] [asm_amd64.s:1333] http server Running on http://:8080
四Node.js 8+ and npm 5+ (installation with nvm)
4.1
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
[root@localhost ~]# source .bashrc
[root@localhost ~]# nvm --version
0.33.11
[root@localhost ~]#
[root@localhost ~]# nvm install node
Downloading and installing node v11.2.0...
Downloading https://nodejs.org/dist/v11.2.0/node-v11.2.0-linux-x64.tar.xz...
##################################################################################################################################################################################################### 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v11.2.0 (npm v6.4.1)
Creating default alias: default -> node (-> v11.2.0)
[root@localhost ~]# node -v
v11.2.0
[root@localhost ~]# npm -v
6.4.1
[root@localhost ~]#
安装docker-compose
[root@localhost ~]# pip install docker-compose
Collecting docker-compose
Downloading https://files.pythonhosted.org/packages/2e/57/4f02ad084b637e00d7f430562b1cba24321e5d6eb59aecad2a6b760ebc18/docker_compose-1.23.1-py2.py3-none-any.whl (131kB)
100% |████████████████████████████████| 133kB 17kB/s
Requirement already satisfied: PyYAML<4,>=3.10 in /usr/local/anaconda2/lib/python2.7/site-packages (from docker-compose) (3.13)
Collecting docker<4.0,>=3.5.0 (from docker-compose)
Downloading https://files.pythonhosted.org/packages/c2/76/b8091dc6d9db038af62ae88f228da656a84632cf5d7a84dcf54c613d3fd0/docker-3.5.1-py2.py3-none-any.whl (126kB)
100% |████████████████████████████████| 133kB 36kB/s
Requirement already satisfied: backports.ssl-match-hostname>=3.5; python_version < "3.5" in /usr/local/anaconda2/lib/python2.7/site-packages (from docker-compose) (3.5.0.1)
Requirement already satisfied: requests!=2.11.0,!=2.12.2,!=2.18.0,<2.21,>=2.6.1 in /usr/local/anaconda2/lib/python2.7/site-packages (from docker-compose) (2.19.1)
Requirement already satisfied: six<2,>=1.3.0 in /usr/local/anaconda2/lib/python2.7/site-packages (from docker-compose) (1.11.0)
Requirement already satisfied: enum34<2,>=1.0.4; python_version < "3.4" in /usr/local/anaconda2/lib/python2.7/site-packages (from docker-compose) (1.1.6)
Collecting texttable<0.10,>=0.9.0 (from docker-compose)
Downloading https://files.pythonhosted.org/packages/02/e1/2565e6b842de7945af0555167d33acfc8a615584ef7abd30d1eae00a4d80/texttable-0.9.1.tar.gz
Collecting dockerpty<0.5,>=0.4.1 (from docker-compose)
Downloading https://files.pythonhosted.org/packages/8d/ee/e9ecce4c32204a6738e0a5d5883d3413794d7498fe8b06f44becc028d3ba/dockerpty-0.4.1.tar.gz
Requirement already satisfied: ipaddress>=1.0.16; python_version < "3.3" in /usr/local/anaconda2/lib/python2.7/site-packages (from docker-compose) (1.0.22)
Collecting websocket-client<1.0,>=0.32.0 (from docker-compose)
Downloading https://files.pythonhosted.org/packages/26/2d/f749a5c82f6192d77ed061a38e02001afcba55fe8477336d26a950ab17ce/websocket_client-0.54.0-py2.py3-none-any.whl (200kB)
100% |████████████████████████████████| 204kB 46kB/s
Collecting docopt<0.7,>=0.6.1 (from docker-compose)
Downloading https://files.pythonhosted.org/packages/a2/55/8f8cab2afd404cf578136ef2cc5dfb50baa1761b68c9da1fb1e4eed343c9/docopt-0.6.2.tar.gz
Requirement already satisfied: jsonschema<3,>=2.5.1 in /usr/local/anaconda2/lib/python2.7/site-packages (from docker-compose) (2.6.0)
Collecting cached-property<2,>=1.2.0 (from docker-compose)
Downloading https://files.pythonhosted.org/packages/3b/86/85c1be2e8db9e13ef9a350aecd6dea292bd612fa288c2f40d035bb750ded/cached_property-1.5.1-py2.py3-none-any.whl
Collecting docker-pycreds>=0.3.0 (from docker<4.0,>=3.5.0->docker-compose)
Downloading https://files.pythonhosted.org/packages/ea/bf/7e70aeebc40407fbdb96fa9f79fc8e4722ea889a99378303e3bcc73f4ab5/docker_pycreds-0.3.0-py2.py3-none-any.whl
Requirement already satisfied: idna<2.8,>=2.5 in /usr/local/anaconda2/lib/python2.7/site-packages (from requests!=2.11.0,!=2.12.2,!=2.18.0,<2.21,>=2.6.1->docker-compose) (2.7)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/local/anaconda2/lib/python2.7/site-packages (from requests!=2.11.0,!=2.12.2,!=2.18.0,<2.21,>=2.6.1->docker-compose) (3.0.4)
Requirement already satisfied: urllib3<1.24,>=1.21.1 in /usr/local/anaconda2/lib/python2.7/site-packages (from requests!=2.11.0,!=2.12.2,!=2.18.0,<2.21,>=2.6.1->docker-compose) (1.23)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/anaconda2/lib/python2.7/site-packages (from requests!=2.11.0,!=2.12.2,!=2.18.0,<2.21,>=2.6.1->docker-compose) (2018.8.24)
Requirement already satisfied: functools32 in /usr/local/anaconda2/lib/python2.7/site-packages (from jsonschema<3,>=2.5.1->docker-compose) (3.2.3.post2)
Building wheels for collected packages: texttable, dockerpty, docopt
Running setup.py bdist_wheel for texttable ... done
Stored in directory: /root/.cache/pip/wheels/99/1e/2b/8452d3a48dad98632787556a0f2f90d56703b39cdf7d142dd1
Running setup.py bdist_wheel for dockerpty ... done
Stored in directory: /root/.cache/pip/wheels/e5/1e/86/bd0a97a0907c6c654af654d5875d1d4383dd1f575f77cee4aa
Running setup.py bdist_wheel for docopt ... done
Stored in directory: /root/.cache/pip/wheels/9b/04/dd/7daf4150b6d9b12949298737de9431a324d4b797ffd63f526e
Successfully built texttable dockerpty docopt
twisted 18.7.0 requires PyHamcrest>=1.9.0, which is not installed.
grin 1.2.1 requires argparse>=1.1, which is not installed.
tensorflow 1.11.0 has requirement setuptools<=39.1.0, but you'll have setuptools 40.2.0 which is incompatible.
Installing collected packages: websocket-client, docker-pycreds, docker, texttable, dockerpty, docopt, cached-property, docker-compose
Successfully installed cached-property-1.5.1 docker-3.5.1 docker-compose-1.23.1 docker-pycreds-0.3.0 dockerpty-0.4.1 docopt-0.6.2 texttable-0.9.1 websocket-client-0.54.0
You are using pip version 10.0.1, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[root@localhost ~]# pip install --upgrade pip
Collecting pip
Downloading https://files.pythonhosted.org/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl (1.3MB)
100% |████████████████████████████████| 1.3MB 27kB/s
twisted 18.7.0 requires PyHamcrest>=1.9.0, which is not installed.
grin 1.2.1 requires argparse>=1.1, which is not installed.
tensorflow 1.11.0 has requirement setuptools<=39.1.0, but you'll have setuptools 40.2.0 which is incompatible.
Installing collected packages: pip
Found existing installation: pip 10.0.1
Uninstalling pip-10.0.1:
Successfully uninstalled pip-10.0.1
Successfully installed pip-18.1
[root@localhost ~]# docker-compose version
docker-compose version 1.23.1, build b02f130
docker-py version: 3.5.1
CPython version: 2.7.15
OpenSSL version: OpenSSL 1.0.2o 27 Mar 2018
[root@localhost ~]#
五快速启动
5.1
[root@localhost ~]# git clone https://github.com/Qihoo360/wayne.git
[root@localhost ~]# cd wayne/
[root@localhost wayne]# git submodule update --init --recursive
[root@localhost wayne]#
5.2
[root@localhost wayne]# docker-compose up -d mysql
Pulling mysql (mysql:5.6.41)...
ERROR: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
[root@localhost wayne]# docker-compose up -d mysql
Pulling mysql (mysql:5.6.41)...
5.3出错需要修改
[root@localhost wayne]# cat /etc/docker/daemon.json
{
"registry-mirrors": ["https://d8b3zdiw.mirror.aliyuncs.com"]
}
[root@localhost wayne]# sudo systemctl daemon-reload
[root@localhost wayne]# sudo systemctl restart docker
[root@localhost wayne]# docker-compose up -d mysql
Pulling mysql (mysql:5.6.41)...
5.6.41: Pulling from library/mysql
f17d81b4b692: Pull complete
c691115e6ae9: Pull complete
41544cb19235: Pull complete
254d04f5f66d: Pull complete
4fe240edfdc9: Pull complete
b79c3b745cc6: Pull complete
c6ebcbee59b1: Pull complete
f07692414bc1: Pull complete
0d34369684f4: Pull complete
b6c15fa1d9de: Pull complete
db940c78ebb4: Pull complete
Creating wayne_mysql_1_42860ad31d38 ... done
[root@localhost wayne]#
六创建数据库配置文件
[root@localhost wayne]# ip addr | grep 192.168.229
inet 192.168.229.130/24 brd 192.168.229.255 scope global noprefixroute dynamic ens33
[root@localhost wayne]#
[root@localhost wayne]# cat /tmp/dev.conf
DBName = wayne
DBTns = tcp(192.168.229.130:3306)
DBUser = root
DBPasswd = root
[root@localhost wayne]#
七启动wayne服务
[root@localhost ~]# pwd
/root
[root@localhost ~]# ls
Anaconda2-5.3.0-Linux-x86_64.sh anaconda-ks.cfg a.py bale bale.go bashrc.bak go1.11.2.linux-amd64.tar gocode original-ks.cfg package test.go wayne
[root@localhost ~]#
[root@localhost ~]# echo $GOPATH
/root/gocode
[root@localhost ~]# docker run --rm -e GOPATH=/root/gocode -v /tmp/dev.conf:/opt/wayne/conf/dev.conf -p 8080:8080 360cloud/wayne /opt/wayne/backend apiserver
panic: dial tcp 127.0.0.1:3306: connect: connection refused
goroutine 1 [running]:
github.com/Qihoo360/wayne/src/backend/initial.InitDb()
/go/src/github.com/Qihoo360/wayne/src/backend/initial/db.go:25 +0x161
github.com/Qihoo360/wayne/src/backend/cmd/apiserver.run(0x1e43880, 0x1e704a0, 0x0, 0x0)
/go/src/github.com/Qihoo360/wayne/src/backend/cmd/apiserver/apiserver.go:23 +0x26
github.com/Qihoo360/wayne/src/vendor/github.com/spf13/cobra.(*Command).execute(0x1e43880, 0x1e704a0, 0x0, 0x0, 0x1e43880, 0x1e704a0)
/go/src/github.com/Qihoo360/wayne/src/vendor/github.com/spf13/cobra/command.go:766 +0x2c1
github.com/Qihoo360/wayne/src/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x1e433c0, 0x0, 0x1e43620, 0x1e43ae0)
/go/src/github.com/Qihoo360/wayne/src/vendor/github.com/spf13/cobra/command.go:852 +0x30a
github.com/Qihoo360/wayne/src/vendor/github.com/spf13/cobra.(*Command).Execute(0x1e433c0, 0xc420775f78, 0xc420090058)
/go/src/github.com/Qihoo360/wayne/src/vendor/github.com/spf13/cobra/command.go:800 +0x2b
main.main()
/go/src/github.com/Qihoo360/wayne/src/backend/main.go:12 +0x53
[root@localhost ~]# mysl -u root -p -h 127.0.0.1
bash: mysl: 未找到命令...
[root@localhost ~]#