ITFriend创业阶段的server环境搭建手冊

创业阶段,进一步实践了Linux环境搭建和维护,以下是一些经常使用软件的搭建步骤和參考资料,仅供自己和诸位參考。

我个人还是比較倾向“一站式Web开发”的。自己想做点事。须要太多的技能。

非商业软件项目,自己全盘负责比較灵活和高效。

1.mysql(关键是创建mysql用户,并用mysql用户运行安装程序)
  參考资料 http://www.cnblogs.com/xiaoluo501395377/archive/2013/04/07/3003278.html
  rpm -qa | grep mysql  // 这个命令就会查看该操作系统上是否已经安装了mysql数据库
  
  Mysql下载地址
  http://dev.mysql.com/downloads/file.php?id=451491
  
  http://blog.sina.com.cn/s/blog_694ac4520100zbbd.html
  
  ----------------------
  ./mysqld_safe --user=mysql &
  
  不能直接使用mysqld。以root用户的身份运行(--user=mysql。能够解决问题)
  2014-04-24 09:19:50 8011 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
  
  ./bin/mysqld --user=mysql &
  不要使用root用户。使用mysql用户
  
  mysql启动 
  http://swordshadow.iteye.com/blog/1921814
  
  //这样的方式,有时候,不起作用,直接按Enter,mysql就被杀死了
  ./mysqld --user=mysql &
  
  能够使用nohup命令启动
  nohup /usr/bin/mysql --user=mysql &
------------------------
  启动报错
  
2014-04-24 09:25:09 8276 [Note] InnoDB: 128 rollback segment(s) are active.
InnoDB: Error: pthread_create returned 11

暂时解决方法:

# ulimit -s unlimited

./mysqld_safe: line 166:  8796 Killed                 
 nohup /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/AY1404221737304200fcZ.err --pid-file=/usr/local/mysql/data/AY1404221737304200fcZ.pid < /dev/null >> /usr/local/mysql/data/AY1404221737304200fcZ.err 2>&1
140424 09:35:47 mysqld_safe Number of processes running now: 0

mysqld --basedir=/usr/local/mysql --datadir=/var/lib/mysql --user=mysql &

该方法在系统重新启动,或者又一次登录后将失效。

第二种方法:

改动/etc/profile文件,加入

ulimit -s unlimited
---------------卸载自带的mysql---------------
  rpm -qa |grep mysql
  卸载centos自带的mysql,rpm -e --nodeps mysql-libs-5.1.61-4.el6.x86_64
  
------------------------------------

2014-04-24 11:17:25 14210 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.

--------------------------------------------------------------------------
Can't find messagefile '/usr/share/mysql/errmsg.sys'
将源代码包里面的sql/share/english/errmsg.sys拷贝到/usr/share/mysql/errmsg.sys 
----------------------------------------------------------------------------

[mysqld]
datadir=/home/mysql/mysql/data
basedir=/home/mysql/mysql
socket=/home/mysql/mysql/run/mysql.sock
log-error=/home/mysql/mysql/log/error.log
user=mysql
innodb_buffer_pool_size=100M
key_buffer_size=50M
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/home/mysql/log/mysqld.log
pid-file=/home/mysql/mysqld.pid

[client]
socket=/home/mysql/mysql/run/mysql.sock

grant all privileges on *.* to root@"%" identified by "lw198962" with grant option;  flush privileges;

./constraints_parser -5 -D -f pages-1400495572/FIL_PAGE_INDEX/0-161 >/tmp/t_bibasic_salessend.sql

#生成数据文件
./constraints_parser -5 -f pages-1400495572/FIL_PAGE_INDEX/4294967295-0 >/tmp/xiaolei_.sql

#生成load-data语句
./constraints_parser -5 -D -f pages-1400495572/FIL_PAGE_INDEX/4294967295-0

2.Redis配置
  http://hi.baidu.com/cxc0378/item/40f4b70e7fda603af3eafcbb
  
3.Mongodb
  /usr/local/mongodb/start-mongo

4.node
  下载二进制安装包。解压就可以 
    
  export NODE_HOME=/usr/local/node/
  export PATH=$NODE_HOME/bin:$PATH 
  
  Linux下运行,
  ./node 
  
  //使用绝对路径
  forever start /var/www/trunk/bootstrap.js &
  forever stop /var/www/trunk/bootstrap.js &
  
  forever start -l /var/www/snsforever.log -o /var/www/snsout.log -e /var/www/snserr.log /var/www/sns/bootstrap.js   
  forever stop /var/www/sns/bootstrap.js   
 -------------------------------------------------------------------------
 关键:使用mysql用户
[mysql@itfriend mysql]$ scripts/mysql_install_db --user=mysql --basedir=/home/mysql/mysql --datadir=/home/mysql/mysql/data

server内存太小,没有交换区,手动改动
http://www.prowebdev.us/2012/05/amazon-ec2-linux-micro-swap-space.html

Run dd if=/dev/zero of=/swapfile bs=1M count=1024 
Run mkswap /swapfile 
Run swapon /swapfile 
Add this line /swapfile swap swap defaults 0 0 to /etc/fstab

5.Nginx
 下载地址 http://nginx.org/download/,都是源代码包,没有二进制安装包
 
 安装过程
 wget  http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
 yum install nginx-release...
 yum install nginx
 
 [root@itfriend bin]# find / -name nginx
/var/cache/yum/x86_64/6/nginx
/var/cache/nginx
/var/log/nginx
/var/lib/yum/repos/x86_64/6/nginx
/usr/share/nginx
/usr/sbin/nginx
/etc/sysconfig/nginx
/etc/logrotate.d/nginx
/etc/rc.d/init.d/nginx
/etc/nginx

启动 nginx

又一次载入
nginx -s reload

停止1
nginx -s quit

停止2
ps -ef|grep enigx,找到master的进程号
kill -QUIT 24346
 
 静态资源被Ngnix拦截,直接响应浏览器
 http://114.215.191.169/images/fans123/photos/44813db99c67489523bd7edfb14e1bed7b7553a8.gif

參考资料:
http://nginx.org/en/linux_packages.html
http://www.nginx.cn/
 
6.Linux命令
  改动密码: passwd root,输入2次密码
  
   /usr/local/mysql/bin/mysqld_safe --user=mysql
   cat /var/log/mysqld.log
   
   mysqladmin -u root password "11"
   
   /usr/local/mysql/bin/mysqladmin -u root password 11
   
   source/etc/profile是让/etc/profile文件改动后马上生效
   
   :tar zxvf 
 
 7.crontab
   crontab -e
   编辑自己这个用户的定时文件
   
   */1 * * * * /var/www/autobackup-mysql.sh
   每分钟运行一次
 
8.安装JDK
  查看可安装的java包yum list java*  
  yum install java-1.7.0-openjdk* -y

參考资料:http://blog.csdn.net/renfufei/article/details/9733367
 
9.安装Tomcat
  复制安装包。改动权限 chmod a+x *
  

上一篇:用Docker解决坑爹的环境搭建系列——mysql:5.6


下一篇:提高性能,MySQL 读写分离环境搭建