开源运维服务器信息管理系统 - 安装手册
简介
《运维服务器信息管理系统》在CentOS6.2、CentOS5.5 64位 测试通过。提供系统源码包下载地址:
http://down.51cto.com/data/581342。环境条件:
1、系统python版本推荐2.6以上。
2、web.py-0.36
系统安装
1、安装python
1)、安装
# tar �Cjxvf Python-2.6.1.tar.bz2
# cd Python-2.6.1
# ./configure --prefix=/usr/local/python2.6
# make
# make install
2)、创建连接
# mv /usr/bin/python /usr/bin/python.old
# ln -s /usr/local/python2.6/bin/python2.6 /usr/bin/python
3)、添加到环境变量
# vi /etc/profile
PATH=$PATH:/usr/local/python2.6/bin/
# source /etc/profile
提示:python升级后将导致yum不能用,因为yum是使用python写的,他不能找到该版本的模块。
2、安装Nginx
1)、安装必须软件包
# yum -y install gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-devel pcre pcre-devel
2)、安装pcre库
# tar zxvf pcre-7.9.tar.gz
# cd pcre-7.9
# ./configure
# make && make install
# cd ../
3)、安装Nginx
# useradd -s /sbin/nologin www
# wget http://www.nginx.org/download/nginx-1.3.8.tar.gz
# tar zxvf nginx-1.3.8.tar.gz
# cd nginx-1.3.8/
# ./configure --user=www --group=www --prefix=/opt/nginx --with-http_stub_status_module --with-http_ssl_module
# make && make install
3、安装Mysql
1)、安装必备软件包
# yum -y install gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* make
2)、添加mysql用户
# useradd -s /sbin/nologin mysql
3)、编译安装cmake-2.8.5
# wget http://www.cmake.org/files/v2.8/cmake-2.8.5.tar.gz
# tar zxvf cmake-2.8.5.tar.gz
# cd cmake-2.8.5
# ./configure
# make && make install
4)、编译安装bison-2.5
# wget http://ftp.gnu.org/gnu/bison/bison-2.5.tar.gz
# tar zxvf bison-2.5.tar.gz2
# cd bison-2.5
# ./configure
# make
# make install
5)、编译安装mysql-5.5.16
# tar xvf mysql-5.5.16.tar.gz
# cd mysql-5.5.16/
# cmake -DCMAKE_INSTALL_PREFIX=/opt/mysql \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/data/mysql \
-DMYSQL_USER=mysql
# make
# make install
6)、给目录授权
# mkdir -p /data/mysql
# mkdir -p /var/run/mysqld
# chown -R mysql.mysql /var/run/mysqld
# chown -R mysql.mysql /data/mysql
# chown -R mysql.mysql /opt/mysql
7)、设定配置文件
# cp support-files/my-huge.cnf /etc/my.cnf
# chmod 755 /opt/mysql/bin/
8)、配置MySQL
# vi /etc/my.cnf
a、找到[mysqld],添加以下参数:
datadir = /data/mysql
basedir = /opt/mysql
pid-file=/var/run/mysqld/mysqld.pid
skip-name-resolve
expire-logs-days = 30
max_connections = 2000
b、在文件末尾添加以下参数:
[mysqld_safe]
log-error=/data/mysql/mysqld_error.log //设置错误日志存放路径
# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
# chmod 755 /etc/rc.d/init.d/mysqld
9)、初始化数据库并启动mysql数据库
# /opt/mysql/scripts/mysql_install_db --basedir=/opt/mysql --datadir=/data/mysql --user=mysql --defaults-file=/etc/my.cnf
# /opt/mysql/bin/mysqld_safe --user=mysql & 或者
# service mysqld start
10)、将mysql加入开机启动
# chkconfig --add mysqld
# chkconfig --level 345 mysqld on
11)、将mysql加入环境变量
# vi /etc/profile
PATH=$PATH:/opt/mysql/bin
export PATH
# source /etc/profile
4、安装Python MySQLdb库
1)、首先确认python的版本为2.3.4以上,如果不是需要升级python的版本
# python -V 检查python版本
# yum -y install python-devel
2)、下载 MySQL-python-1.2.2.tar.gz
地址 https://sourceforge.net/projects/mysql-python/
3)、安装 MySQl-python
# tar xvzf MySQL-python-1.2.2.tar.gz
# cd MySQL-python-1.2.2
# vi site.cfg
去掉注释mysql_config = /usr/local/mysql/bin/mysql_config
修改路径mysql_config = /正确路径
# python setup.py build
# sudo python setup.py install
4)、测试
# import MySQLdb
如果没有报错,说明安装好了。
错误一:
python2.6 setup.py install
Traceback (most recent call last):
File "setup.py", line 5, in <module>
from setuptools import setup, Extension
ImportError: No module named setuptools
处理方法,安装setuptools
# wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
# tar zxvf setuptools-0.6c11.tar.gz
# cd setuptools-0.6c11
# python2.6 setup.py install
错误二:
import _mysql
ImportError: libmysqlclient_r.so.15: cannot open shared object file: No such file or directory
处理方法有两种:
方法一.更改 /etc/profile中的变量值
# vi /etc/profile
把/pathtomysql/lib/mysql加到LD_LIBRARY_PATH环境变量中
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mysql/lib/mysql
注:MySQL5.5是:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mysql/lib
方法二.将建链接到 /usr/lib
# cd /usr/lib
# ln -s /path/to/mysql50/lib/mysql/libmysqlclient_r.so.15.0.0 libmysqlclient_r.so.15
# ln -s /path/to/mysql50/lib/mysql/libmysqlclient_r.so.15.0.0 libmysqlclient_r.so
5、安装uwsgi,用于运行web.py
# wget http://projects.unbit.it/downloads/uwsgi-1.2.3.tar.gz
# tar xvf uwsgi-1.2.3.tar.gz
# cd uwsgi-1.2.3
# python uwsgiconfig.py --build
# python setup.py install
6、新建站点目录
# mkdir -p /data/wwwroot/
7、配置 站点 虚拟主机
server
{
listen 80;
server_name 172.16.2.95;
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:9090;
}
location ^~ /static/
{
alias /data/wwwroot/yunwei/static/;
}
}
8、安装web.py框架
# wget http://webpy.org/static/web.py-0.36.tar.gz
# tar xf web.py-0.36.tar.gz
# cd web.py-0.36
# python setup.py install
9、安装pyton库xlwt,用于导出数据到excel
# tar xf xlwt-0.7.4.tar.gz
# cd xlwt-0.7.4
# python setup.py install
10、部署系统源代码
1)、释放源代码
# tar xf yunwei.tar.gz �CC /data/wwwroot
2)、创建数据库并导入数据
# mysql -uroot -proot -e "create database yunwei"
# mysql -uroot -proot yunwei < /data/wwwroot/yunwei/yunwei.sql
3)、修改系统配置
# cd /data/wwwroot/yunwei
# vim config/setting.py
修改以下为相应的配置:
db=web.database(dbn='mysql',db='yunwei',user='用户名',pw='密码',unix_socket="/tmp/mysql.sock)
11、运行系统
1)、添加各程序路径到环境变量
# vi /etc/profile
PATH=$PATH:/opt/mysql/bin:/opt/nginx/sbin:/usr/local/python2.6/bin/
export PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/mysql/lib
# source /etc/profile
2)、配置文件正确后,启动
# /opt/nginx/sbin/nginx -t
#/opt/nginx/sbin/nginx -s reload
3)、编写uwsgi启动配置文件
# vi uwsgi_conf.xml
<uwsgi id="yunwei">
<socket>127.0.0.1:9090</socket>
<module>app</module> //注:app为主程序app.py
<master />
<pythonpath>/usr/bin/python</pythonpath>
<chdir>/data/wwwroot/yunwei</chdir> //注:站点目录
<processes>2</processes> //注:开启2个进程来运行
<enable-threads>true</enable-threads>
<post-buffering>1024</post-buffering>
<listen>1024</listen>
<memory-report/>
<pidfile>/tmp/uwsgi_app.pid</pidfile>
<max-requests>65535</max-requests>
<daemonize>/tmp/uwsgi_app.log</daemonize> //注:使uwsgi后台运行。输入某文件,将输出内部运行日志。此项为空,可以防止日志文件暴增。
<log-date/>
</uwsgi>
4)、启动uwsgi
# uwsgi -x uwsgi_conf.xml
5)、登录 http://172.16.2.95,初始账户密码皆为:steven
6)、如果出现500服务器内部故障提示,则检查输出日志。否则,安装成功。