swoole tracker环境搭建文档

服务端搭建

安装docker (此处忽略)
docker –version 查看版本

安装docker-compose
访问https://github.com/docker/compose/releases,下载 docker-compose-Linux-x86_64,我是复制链接地址,在迅雷中下载的,下载后,将docker-compose-Linux-x86_64重命名为docker-compose
将刚才下载的docker-compose文件上传到centos7的/usr/local/bin/目录下

1
2
3
4
5
# 添加可执行权限
sudo chmod +x /usr/local/bin/docker-compose
# 查看docker-compose版本
docker-compose -v
## docker-compose version 1.29.1, build c34c88b2

rz swoole-tracker-v3.1.2-24079.tar.gz

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 进入目录解压
cd /root/swoole_tracker
tar xf swoole-tracker-v3.1.2-24079.tar.gz

# 安装
cd swoole-tracker/swoole-admin-docker/
./build.sh
./run.sh

# 查看容器是否存在
docker ps -a | grep swoole

# 运行./run.sh后 直接访问当前机器的ip:9666即可,默认用户名是admin密码为admin
# 默认端口为9666,如果需修改,编辑docker/nginx/conf.d/swoole-admin.conf,修改listen为对应端口即可。

客户端安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 部署node-agent
# ADD swoole-tracker-v3.1.2-24079.tar.gz /tmp/
#RUN cd /tmp/ && \
ADD swoole-tracker-v3.1.2-24079.tar.gz ./
RUN ls
RUN cd /data/wwwroot/swoole-tracker/node-agent && \
./deploy_env.sh [服务端的IP] && \
# rm -rf /tmp/swoole-tracker-v3.1.2-24079.tar.gz
rm -rf /data/wwwroot/swoole-tracker-v3.1.2-24079.tar.gz

# tar -C / -xvf /tmp/swoole-tracker-v3.1.2-24079.tar.gz && \
# 添加entrypoint脚本
RUN printf '#!/bin/sh\n cd /data/wwwroot/bin/\nnohup php hyperf.php start & \n supervisord -c /etc/supervisor/supervisord.conf \n /opt/swoole/script/php/swoole_php /opt/swoole/node-agent/src/node.php ' > /opt/swoole/entrypoint.sh && \
chmod 755 /opt/swoole/entrypoint.sh

# 开启扩展
RUN printf 'extension=/data/wwwroot/swoole-tracker/swoole_trackers/swoole_tracker74.so \napm.enable=1 \napm.sampling_rate=100 ' > /usr/local/etc/php/conf.d/swoole-tracker.ini

# 启用entrypoint脚本(-x方便调试, 可以去掉)
ENTRYPOINT [ "sh", "-x", "/opt/swoole/entrypoint.sh" ]