####项目部署执行
openplay_backend requirement.txt 中却少raven
在跑run.py时,debug配置文件下却少sentry,将product环境下的sentry添加即可
####项目基础架构
- 总共分为球员版player,管理员admin,用户user,统计stats,网页web,五个部分
- 项目之间的关系:五个部分全都是基于tornado API项目开发,在一场球赛中统计员录入数据存储到mongodb,数据在其他端显示。
- 项目的技术有tornado,mongodb,redis保存token,推送信息使用leancloud服务,云存储使用青云。
####项目bug修复流程
1,查看phabricator的bug
git remote add origin git@github.com:michaelliao/learngit.git
git push origin –delete serverfix
添加远程仓库
2,git下开始修复bug,改代码,写readme,并提交
|
|
3,在phabricator更改状态,将bug改为closed
####基本知识
修改文件所有者,chown -R tamchen:staff xxxx
修改文件所属用户组,chgrp users xxxxx
修改文件权限,chmod -R xyz xxxx
读r:4 写w:2 执行x:1 xyz代表 用户,用户组,其他的权限表示
在vim下强制写入root权限的解决办法
:w !sudo tee %
:n,$s/vivian/sky/g 从第n行开始,将所有的vivian替换为sky
:%s/^/TAB/ 每行行首添加一个tab 字符 s代表每一行,^代表行首,$代表行尾
:10,20s/^/#/g
表示将10-20行添加注释,同理取消注释为:
:10,20s/^#//g
vim 格式化代码操作,gg跳到件首行,=格式化 G到最后一行
tar -xzf tmp/etc.tar.gz 解压
tar -zxvf /tmp/etc.tar.gz
tar -zcvf xx.tar.gz /hello
scp tamchen@staging:/home/xxx.tar 本地目录
scp Dalaran@192.168.240.74:~/Development/go/src/xx.zip . // 下载
scp /home/lnmp0.4.tar.gz root@www.vpser.net:/root/lnmp0.4.tar.gz
mongorestore /dump
配置virtualenvwrapper
export WORKON_HOME=$HOME/code/.virtualenvs
export PROJECT_HOME=$HOME/code
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
export VIRTUALENVWRAPPER_VIRTUALENV_ARGS=’–no-site-packages’
source /usr/local/bin/virtualenvwrapper.sh
nohup ./xxxx.sh & 后台运行脚本
git log –pretty=oneline -p base.py 显示某个文件的修改历史
lsof -p 29293 查看某个进程的具体信息
sudo strace -p 29293 追踪某个进程
http openplay-test:89/admin/auth/profile/ Cookie=sessionid=”2|1:0|10:1453458280|9:sessionid|44:NGNlYmQwZjFmZGY2NDcyYjllMDg1NGM0ZGIzZTIzZDY=|5d3bcbdaf84c545ec7c92ede9043f86efa5b8af3fac25fa67c5449beb8345ea7”
vagrant virtualbox precise64.box
更换sources.list
http://mirrors.163.com/.help/ubuntu.html
安装vim,安装Python,pip
更换pip源 安装 fabric
~/.pip/pip.conf
[global]
index-url = http://pypi.douban.com/simple
virtualenv virtualenvwrapper
git
安装thrift
sudo apt-get install libboost-dev libboost-test-dev libboost-program-options-dev libevent-dev automake libtool flex bison pkg-config g++ libssl-dev
|
|
Start Jenkins: sudo launchctl load /Library/LaunchDaemons/org.jenkins-ci.plist
Stop Jenkins: sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist
断开postgresql客户端连接
drop database go_web_dev ;
ERROR: cannot drop the currently open database
go_web_dev=# SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = ‘go_web_dev’
AND pid <> pg_backend_pid();
kubectl get pods –all-namespaces
kubectl get pods –show-all –all-namespaces –show-labels
kubectl get rc –all-namespaces
kubectl delete rc kubernetes-dashboard-v1.1.1 –namespace=kube-system
// 检查配置争取
kubectl cluster-info
// 创建replication controller
kubectl create -f examples/guestbook/all-in-one/guestbook-all-in-one.yaml
kubectl create -f examples/guestbook-go/redis-master-controller.json
// 查询rc if you don’t specify a –namespace, the default namespace will be used.
kubectl get rc
// 查询pods rc会创建pod
kubectl get pods -o wide
kubectl logs
kubectl get services
kubectl get deployments
kubectl delete deployments,services -l “app in (redis, guestbook)”
// 如果pods卡在terminating状态
kubectl delete pod redis-slave-q6f8q –grace-period=0
kubectl get rc,services,pods,deployments
svc is short for services
kubectl get svc
// 新建docker image 别名
docker tag ist0ne/$imageName gcr.io/google_containers/$imageName
kubernetes网络设置,容器之间的通信借助于flannel,容器在同一个pod内是共享网络空间的,所以互相访问可以直接使用localhost,每个pod都有一个IP地址,pod-IP node-IP cluster-IP(service的IP)
参考 https://github.com/coreos/flannel
// 查询日志记录(非常有用)
kubectl describe po POD_NAME
kubectl logs elasticsearch-attiy -p
// 解决授权问题(启动kubernetes_dashboard的时候)
https://github.com/kubernetes/dashboard/issues/374
// 当docker主进程起不来时候
An error occurred trying to connect
sudo rm /var/lib/docker/network/files/local-kv.db
// vagrant VBoxGuestAdditions 问题
$ # For vagrant < 1.1.5:
$ # vagrant gem install vagrant-vbguest
$ # For vagrant 1.1.5+ (thanks Lars Haugseth):
$ vagrant plugin install vagrant-vbguest
// 查看endpoint
kubectl get ep my-nginx
一个pod内包含多个container,一个Pod内的Container共享同样的网络地址空间
一个是pause容器,一个是busybox容器。其中pause容器为主网络容器,其他容器都共享pause容器的网络模式
vagrant 设置局域网内 IP
config.vm.network “public_network”, ip: “192.168.1.120”
公有网络中还可以设置桥接的网卡,语法如下
config.vm.network “public_network”, :bridge => ‘en1: Wi-Fi (AirPort)’
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
$ sudo apt-get update
$ sudo apt-get install linux-image-generic-lts-raring linux-headers-generic-lts-raring
$ sudo reboot
// 查看端口占用
netstat –apn | grep 8080
http://kubernetes.io/docs/user-guide/connecting-applications/
vagrant 的安装,配置两个虚拟机,并配置免除ssh密码登录
http://www.ruanyifeng.com/blog/2011/12/ssh_remote_login.html
// vagrant VBoxGuestAdditions 问题
$ # For vagrant < 1.1.5:
$ # vagrant gem install vagrant-vbguest
$ # For vagrant 1.1.5+ (thanks Lars Haugseth):
$ vagrant plugin install vagrant-vbguest
更新 souce.list /etc/apt/souces.list,安装vim
安装docker,docker info 验证
下载kubernetes最新文件,按照/cluster/ubuntu/download-release.sh
提前下好etcd,flannel.tar.gz kubernetes.tar.gz ,修改下download-release.sh
修改config-default.sh 配置
这时就差不多可以
// 解决授权问题(启动kubernetes_dashboard的时候)
https://github.com/kubernetes/dashboard/issues/374
通过nodeport暴露服务,最直接的办法
配置服务发现,使用kube-dns,用/cluster/ubuntu skydns-rc.yaml skydns-svc.yaml
注意配置在skydns-svc中设置kube-dns的cluster ip, 修改所有控制机器的/etc/default/kubelet cluster ip地址
时刻注意日志文件,当时遇到的是kube-proxy没有起来,不能通过service IP访问pod IP
kube-proxy kubele
/etc/defalut 配置文件
/opt/bin 运行文件
/var/log/upstart 日志文件
关于configmap
|
|
kubectl get componentstatuses // 查看所有所有组件的状态
查看registry的私有
docker run -d -p 3000:3000 192.168.1.10:5000/guestbook:v29
curl http://192.168.1.10:5000/v2/_catalog
参考链接
kubernetes 在 ubuntu 上的部署实践
https://testerhome.com/topics/5030
kubeadm 搭建 kubernetes 集群
https://mritd.me/2016/10/29/set-up-kubernetes-cluster-by-kubeadm/
通过docker hub生成google的image,再直接docker pull,tag 这招很6
Services in Kubernetes
https://segmentfault.com/a/1190000002892825
kube-dns原理介绍
http://blog.tenxcloud.com/?p=1726
http://blog.tenxcloud.com/?p=1776#respond
http://blog.csdn.net/xts_huangxin/article/details/52027036
http://blog.csdn.net/carter115/article/details/51133688
http://insights.thoughtworkers.org/how-to-play-with-new-technology-2/
kubectl exec busybox – nslookup redis-master
// kubernetes ubuntu installation
http://blog.guthnur.net/kubernetes-ubuntu-installation/
// hexo到自身主机
http://ghui.me/post/2016/07/host-hexo-vps/
8804 shipyard
8800 gitlab
8080 kubernetes
3000 Grafana
15672 rabbitmq
docker run -d \
–name grafana \
-p 3001:3001 \
grafana/grafana:2.6.0
删除无用的停止的docker
docker rm $(docker ps -qa)
docker ps -qa | xargs -n 1 docker rm
Start Jenkins: sudo launchctl load /Library/LaunchDaemons/org.jenkins-ci.plist
Stop Jenkins: sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist
rabbitmq grpc
kubectl create -f busybox.yml // 创建busybox
kubectl exec -i -t busybox sh // 进入busybox执行sh
nslookup guestbook
guestbook.default.svc.cluster.local // 得到域名解析
sudo gitlab-ctl restart # 重启gitlab
sudo gitlab-ctl tail # 查看所有日志
sudo systemctl start rabbitmq-server // 启动rabbitmq
sudo invoke-rc.d rabbitmq-server restart
docker rmi $(docker images | grep “none” | awk ‘{print $3}’)
vim 替换%s/four/4/g
|
|
启动memcache
memcached -d -m 128 -p 11211 -u root
0.0.0.0可以表示所有可以访问的地址,也就是本机的所有IPv4地址
|
|
|
|
•运行交互式容器–rm标志,以避免之后将其删除。
•删除所有停止容器:
docker rm $(docker ps -a | grep Exited | awk ‘{print $1}’)
•清理未标记的图像docker:
docker rmi $(docker images -q –filter “dangling=true”)
•停止并删除所有容器(包括运行容器!)
docker rm -f $(docker ps -a -q)
jenkins 启动与停止
Start Jenkins: sudo launchctl load /Library/LaunchDaemons/org.jenkins-ci.plist
Stop Jenkins: sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist
http://mirror.xmission.com/jenkins/updates/current/update-center.json jenkin 插件镜像
阿里云mirror
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse