在128M的VPS上配置mysql+Tornado+Nginx笔记
🕢 by pyList at 2012-04-08 06:42
最近 123systems http://goo.gl/2Q0X2 2 又推出一年$10的便宜 VPS,128M内存,可以用来学习。在这样的vps 上放一个博客或做反向代理绰绰有余,买下后尝试配一个mysql+Tornado+Nginx 环境。
因为在小内存的VPS 上安装东西比较麻烦,动不动的内存超出导致安装失败或程序启动不了,在这里记下个人的配置过程,供初学者参考。
VPS配置
Linux-128-Yearly
Guaranteed RAM 128MB
Burstable RAM 128MB
Disk Space 5GB
Bandwidth 250GB/Month
$10.00 USD/Annually
Instant Setup!
1vCPU
1 IP Address
SolusVM Control Panel
选择系统
建议选择debian 或ubuntu 这两个占用的资源少,我安装了debian-6.0-x86,python的版本是2.6.6。
卸载Apache2
卸载Apache2 的命令
apt-get --purge remove apache2
apt-get --purge remove apache2.2-common
安装mysql
首先更新apt-get
apt-get update
一行命令简单安装mysql
apt-get install mysql-server
中间需要提示设置mysql root 用户密码,记住不要跟登录系统root 用户的密码相同,避免不必要的麻烦。
安装比较顺利,但在启动mysql 时失败!
需要修改mysql 配置文件才能启动,以下是我的一份配置。 配置文件: /etc/mysql/my.cnf
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
language = /usr/share/mysql/english
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1
#
# * Fine Tuning
#
key_buffer = 16K
max_allowed_packet = 1M
thread_stack = 64K
thread_cache_size = 4
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover = BACKUP
max_connections = 16
table_cache = 8
thread_concurrency = 2
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 64K
#
# * Query Cache Configuration
#
query_cache_limit = 256k
query_cache_size = 4M
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file = /var/log/mysql/mysql.log
#general_log = 1
#
# Error logging goes to syslog due to /etc/mysql/conf.d/mysqld_safe_syslog.cnf.
#
# Here you can see queries with especially long duration
#log_slow_queries = /var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
# other settings you may need to change.
#server-id = 1
#log_bin = /var/log/mysql/mysql-bin.log
#expire_logs_days = 2
#max_binlog_size = 10M
#binlog_do_db = include_database_name
#binlog_ignore_db = include_database_name
#important
#skip-innodb
innodb = OFF
default_storage_engine = MyISAM
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem
[mysqldump]
quick
quote-names
max_allowed_packet = 16M
[mysql]
no-auto-rehash # faster start of mysql but no tab completition
[isamchk]
key_buffer = 8M
sort_buffer_size = 8M
[myisamchk]
key_buffer = 8M
sort_buffer_size = 8M
[mysqlhotcopy]
interactive-timeout
保存后尝试启动mysql
service mysql restart
mysqladmin -u root -p var | grep have_innodb
| have_innodb | DISABLED |
没出意外可以在top 里看到mysqld 进程。
debian 下安装Tornado
一行命令简单安装Tornado
apt-get install python-tornado
debian 下安装Nginx
一行命令简单安装Nginx
apt-get install nginx
测试
好了,就这样全部搞定。建立一个Tornado 测试脚本:tornado_test.py
# -*- coding: utf-8 -*-
from tornado import httpserver
from tornado import ioloop
def handle_request(request):
message = "You requested %s\n" % request.uri
request.write("HTTP/1.1 200 OK\r\nContent-Length: %d\r\n\r\n%s" % (
len(message), message))
request.finish()
http_server = httpserver.HTTPServer(handle_request)
http_server.listen(8080)
ioloop.IOLoop.instance().start()
运行tornado_test.py
python tornado_test.py
在浏览器输入你的VPS ip就可以看到:
You requested /
再输入 你的vps ip/test 就可以看到:
You requested /test
最后查看一下内存:
free
把free 结果输出到一个文件
free > freefile
total used free shared buffers cached
Mem: 131072 34128 99944 0 0 0
-/+ buffers/cache: 34128 99944
Swap: 0 0 0
本文网址: https://pylist.com/t/1333838533 (转载注明出处)
如果你有任何建议或疑问可以在下面 留言
发表第一条评论!
相关推荐
小工具
标签
国外
vps
nginx
反向
访问
websocket
tornado
客户端
示例
subprocess
阻塞
调用
推送
服务器
功能
消息
asynchronous
gen
服务器端
comet
连接
技术
实现
跨域
ajax
处理
long
poll
搭建
聊天
服务
硬件加速
ubnt
er
固件
路由
google
身份验证
authenticator
迁移
手机
宅家
坑记
屏幕
动手
虚拟机
virtualbox
很慢
网络
解决
搜索引擎
网址
提交
主动
经验
一次方程
python
一元
代码
简单
cpu
debian
ubuntu
查看
温度
bbr
openwrt
开启
gmail
smtp
发信
密码
开通
最新版
wndr4300
升级
国内
老旧
笔记本
改造
记录
正则
关键字
搜索
caddy
https
部署
网站
多个
修砖记
变砖
tftp
系统启动
usb
mac
failed
load
devtools
sourcemap
chrome
自动更新
microsoft
关闭
app
store
登录
未知
静音
风扇
主机
低功耗
web
爬虫
组装
微信
尝鲜
视频
体验
server
浏览
webdriver
微博
golang
selenium
gnu
linux
安装
编译
quic
抢先
最近发表
- Chrome 控制台 DevTools failed to load SourceMap 警告的消除方法
- Mac 关闭 Microsoft 自动更新
- Mac 登录 App Store 出现“发生了未知错误”的解决方法
- 老笔记本改造为无风扇静音主机方案
- 自己组装21瓦低功耗家庭爬虫、文件、web服务器
- 微信视频号尝鲜体验
- Ubuntu/Debian 查看CPU温度的方法
- 在Ubuntu/debian Server 系统使用Chrome 无头浏览模式
- 换手机后 Google 身份验证器 Google Authenticator 数据迁移的简单方法
- 使用Golang selenium WebDriver 自动登录微博
- 在 Ubuntu 或其它 GNU/Linux 系统下安装 Debian
- Mac 下制作 USB ubuntu/debian 系统启动、安装盘的几种方法
- ubuntu/debian 下自行编译 OpenWRT 固件
- 宅家自己动手换手机屏幕掉坑记
- 路由 UBNT ER-X 官方固件升级及开启硬件加速的方法
- 在 Nginx 和 Golang web 上抢先体验 QUIC
最近浏览
- 路由 UBNT ER-X 官方固件升级及开启硬件加速的方法
- 换手机后 Google 身份验证器 Google Authenticator 数据迁移的简单方法
- 宅家自己动手换手机屏幕掉坑记
- VirtualBox 虚拟机里网络很慢的解决方法
- 向各搜索引擎主动提交网址的经验
- 3行 Python 代码解简单的一元一次方程
- Ubuntu/Debian 查看CPU温度的方法
- Openwrt 路由上开启BBR
- 使用Gmail smtp发信,开通专用密码的方法
- WNDR4300 固件升级到 OpenWrt 最新版
- OpenWrt 国内源
- 把老旧笔记本改造为家庭服务器过程记录
- 用python正则获取通过搜索引擎过来的搜索关键字
- 使用caddy 快速部署多个https 网站
- UBNT ER-X 变砖 tftp 修砖记
- Mac 下制作 USB ubuntu/debian 系统启动、安装盘的几种方法