Cloud computing coursework:Saas 图片社交网站
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

190 lines
3.9 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. # Photo Share
  2. 张硕闻 陈煜 杜涵悦
  3. 可按照部署流程部署验证,如部署遇到问题可微信联系(应该不会,亲测多次)
  4. ## 部署流程
  5. 1. 首先,创建云主机。
  6. 2. 连接云主机,配置python环境。
  7. ```shell
  8. # 1、yum更新
  9. yum update
  10. # 2、安装Python 3.7所需的依赖否则安装后没有pip3包
  11. yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel libffi-devel gcc make
  12. # 3、在官网下载所需版本,这里用的是3.7.2版本
  13. # 如果速度太慢可以在浏览器中访问下面的链接把它下载到本地电脑再上传到云主机上
  14. wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tar.xz
  15. # 4、解压
  16. tar -xvJf Python-3.7.2.tar.xz
  17. # 5、配置编译
  18. cd Python-3.7.2
  19. ./configure --prefix=/usr/local/python3
  20. make && make install
  21. # 6. 安装pip
  22. wget https://bootstrap.pypa.io/get-pip.py
  23. python3 get-pip.py
  24. pip -V # 检查
  25. ```
  26. 3. nginx安装
  27. ```shell
  28. # 1、下载对应当前系统版本的nginx包
  29. wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
  30. # 2、建立nginx的yum仓库
  31. rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm
  32. # 3、安装nginx
  33. yum install -y nginx
  34. # 4、启动nginx服务
  35. systemctl start nginx.service
  36. # 5、查看启动状态
  37. # systemctl status nginx
  38. ```
  39. 4. 安装mysql数据库客户端
  40. ```shell
  41. yum -y install mysql
  42. ```
  43. 5. 创建 mysql 云数据库
  44. 创建成功后通过phpMyAdmin网页登录
  45. 创建名为phshare的数据库
  46. ![](./pictures/1.png)
  47. 6. 下载代码,改代码
  48. ```shell
  49. cd /usr/local/python3/bin
  50. # 将phshare整个项目文件夹放入该目录下
  51. git clone http://gitea.shuishan.net.cn/10185501403/phshare
  52. cd phshare
  53. # 改连数据库的ip与密码 见下图
  54. vim phshare/settings.py
  55. ```
  56. 以下两行需要改密码与云数据库ip。
  57. ![](./pictures/2.png)
  58. 7. 安装python第三方库
  59. ```shell
  60. pip install -r requirements.txt
  61. pip install gunicorn
  62. ```
  63. 8. 运行
  64. ```shell
  65. # 初始化数据库
  66. flask init
  67. # 运行 内网ip替换 3389端口 由于云账户设置了3389暴露
  68. gunicorn -w 3 -b x.x.x.x:3389 manage:app
  69. # 后台运行 内网ip替换
  70. nohup gunicorn -w 3 -b x.x.x.x:3389 manage:app >/dev/null 2>&1 &
  71. ```
  72. 浏览器中访问 http://X.X.X.X:3389/ (用外网Ip)
  73. 部署完成
  74. 9. 负载均衡准备
  75. 另外创建两个与以上部署好的云主机**完全相同**的云主机(相当于以上步骤都要做好),可以从镜像中创建,或将以上步骤重做两次。**使用后台运行命令启动gunicorn**
  76. 10. 创建负载均衡,创建VServer。
  77. 11. 添加节点,监听端口3389。将之前创建的云主机都加入
  78. ![](./pictures/3.png)
  79. ![](./pictures/4.png)
  80. 12. 这样我们访问负载均衡的外网ip就也可以访问到应用了。可以另创建一台云主机对负载均衡进行压测。
  81. ```shell
  82. # 安装ApacheBench
  83. yum -y install httpd
  84. # 替换负载均衡ip
  85. ab -c 1000 -n 10000 http://xxx.xxx.xxx.xxx/
  86. ```
  87. 最后按照老师的要求创建了一个镜像:
  88. 云主机用户名root,密码zhangshuowen123
  89. (还是建议按照部署流程来验证,从镜像创建的云主机有时连接失败,应该是ucloud的问题)
  90. ![](./pictures/9.png)
  91. ## 主要功能描述
  92. 主页:主页动态、搜索、探索、评论点赞收藏举报、添加描述标签提醒等
  93. 用户:注册登录、账户设置以及主页、关注、被关注
  94. 管理:管理图片、用户、评论、标签,编辑标签以及网站设置
  95. ## SaaS 应用效果
  96. demo可访问网址探索:[Home - Phshare](http://106.75.209.92/)
  97. http://106.75.209.92/
  98. **截图不能反应全部功能,可访问网站以查看**
  99. 截图:
  100. ![](./pictures/5.png)
  101. ![](./pictures/6.png)
  102. ![](./pictures/7.png)
  103. ![](./pictures/8.png)