VPS 折腾全记录-part 1 

是的,在犹豫、彷徨、挣扎了那么那么久之后,我终于狠下心来,抽出了几天的时间,把早就该升级的VPS从里到外翻新了一遍。

前言:由于整体篇幅较大,所以采用了分段发表,此文为第一部分。
又及:前几天刚刚发生了四川芦山特大地震,在此向死难者致哀。

下面正文开始,首先下载升级所需的所有软件的最新版本:

20 wget http://pecl.php.net/get/APC-3.1.13.tgz
22 wget http://download.lighttpd.net/lighttpd/r ... 32.tar.bz2
24 wget http://cdn.mysql.com/Downloads/MySQL-5. ... .10.tar.gz
26 wget http://nginx.org/download/nginx-1.3.15.tar.gz
28 wget http://downloads.php.net/dsp/php-5.5.0beta3.tar.bz2
30 wget http://repo.varnish-cache.org/source/va ... 0.3.tar.gz
32 wget https://security.appspot.com/downloads/vsftpd-3.0.2.tar.gz


后来有一些软件,如nginx,在我下载后的几个小时里,又发布了新版,后来使用了新版。

移除旧软件包:

[root@PowerPC pub]# rm APC*
rm: remove regular file `APC-3.1.10.tgz'? y
rm: remove regular file `APC-3.1.13.tgz'? n
[root@PowerPC pub]# rm lighttpd*
rm: remove regular file `lighttpd-1.4.31.tar.bz2'? y
rm: remove regular file `lighttpd-1.4.32.tar.bz2'? n
[root@PowerPC pub]# rm mysql*
rm: remove regular file `mysql-5.6.10.tar.gz'? n
rm: remove regular file `mysql-5.6.5-m8.tar.gz'? y
[root@PowerPC pub]# rm nginx*
rm: remove regular file `nginx-1.3.15.tar.gz'? n
rm: remove regular file `nginx-1.3.1.tar.gz'? y
[root@PowerPC pub]# rm php*
rm: remove regular file `php-5.4.0.tar.bz2'? y
rm: remove regular file `php-5.5.0beta3.tar.bz2'? n
rm: remove regular file `phpMyAdmin-3.5.1-all-languages.tar.bz2'? n
[root@PowerPC pub]# rm varnish*
rm: remove regular file `varnish-3.0.3-rc1.tar.gz'? y
rm: remove regular file `varnish-3.0.3.tar.gz'? n
[root@PowerPC pub]# rm vsftpd*
rm: remove regular file `vsftpd-2.3.4.tar.gz'? y
rm: remove regular file `vsftpd-3.0.2.tar.gz'? n


紧接着,移除老版本软件的遗留文件,备份配置文件。

备份数据库:

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| bbpress |
| lighttpd |
| phpbb |
| typecho |
| url-shortize |
| vsftpd |
+--------------------+
9 rows in set (0.00 sec)


我是用 mysqldump 导出来的几个数据库。

一些前期工作搞定后,开始折腾,先是数据库:

使用的是mysql 的最新版,5.6.11,解压源码包,进入根目录:

首先查看下编译帮助:

[root@PowerPC mysql-5.6.11]# cmake -LAH
-- Running cmake version 2.6.4
-- MySQL 5.6.11
-- Packaging as: mysql-5.6.11-Linux-i686
-- HAVE_VISIBILITY_HIDDEN
-- HAVE_VISIBILITY_HIDDEN
-- HAVE_VISIBILITY_HIDDEN
-- Using cmake version 2.6.4
-- Not building NDB
-- Library mysqlclient depends on OSLIBS -lpthread;m;rt;dl
-- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl;aio
-- Configuring done
-- Generating done
-- Build files have been written to: /root/mysql-5.6.11
……
……


下面是我的cmake 参数:

[root@PowerPC mysql-5.6.11]# cmake . \
> -DCMAKE_BUILD_TYPE:STRING=Release \
> -DCMAKE_INSTALL_PREFIX:PATH=/opt/mysql \
> -DENABLE_DEBUG_SYNC:BOOL=OFF \
> -DMANUFACTURER:STRING="Built from Source By Sharl" \
> -DMYSQL_DATADIR:PATH=/var/mysql \
> -DSYSCONFDIR:PATH=/etc


依赖没有问题,开始编译。make && make install.

安装至指定目录后,由于这次使用的目录不在/usr/local 下,所以mysql 的bin 目录并不在系统 $PATH 下,得手动加入。

建议放入 ~/.bashrc 下,编辑完记得 source 以生效.

这是我的 .bashrc:

[root@PowerPC ~]# cat ~/.bashrc | grep PATH
export PATH=/opt/mysql/bin:$PATH
export PATH=/opt/php/bin:$PATH
export PATH=/opt/php/sbin:$PATH
export PATH=/opt/lighttpd/sbin:$PATH
export PATH=/opt/nginx/sbin:$PATH
export PATH=/opt/varnish/bin:$PATH
export PATH=/opt/varnish/sbin:$PATH


进入mysql主目录,安装初始数据库:

[root@PowerPC mysql]# ./scripts/mysql_install_db \
> --basedir=/opt/mysql \
> --datadir=/var/mysql \
> --user=mysql


之后,恢复配置文件,启动mysql服务。

[root@PowerPC mysql]# mysqld_safe --user=mysql &
[1] 30283


设置root密码以及匿名安全选项:

[root@PowerPC mysql]# mysql_secure_installation



NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!


By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
... Success!

Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
... Success!

By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
... Success!




All done! If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!


Cleaning up...



一切OK后,导入之前备份的数据库:

[root@PowerPC ~]# mysql -u root -p <db.sql
Enter password:
[root@PowerPC ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 5.6.11 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| bbpress |
| lighttpd |
| mysql |
| performance_schema |
| phpbb |
| typecho |
| url-shortize |
| vsftpd |
+--------------------+
9 rows in set (0.00 sec)


OK,数据库导入成功。不过还要做一点小优化,就是禁用掉innoDB引擎,因为这个太占内存了。

编辑my.cnf,加入 skip-innodb 节点即可。

现在查看下数据库引擎:

mysql> show engines;
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| FEDERATED | NO | Federated MySQL storage engine | NULL | NULL | NULL |
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
| BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO |
| MyISAM | DEFAULT | MyISAM storage engine | NO | NO | NO |
| CSV | YES | CSV storage engine | NO | NO | NO |
| ARCHIVE | YES | Archive storage engine | NO | NO | NO |
| InnoDB | NO | Supports transactions, row-level locking, and foreign keys | NULL | NULL | NULL |
| PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
9 rows in set (0.00 sec)

mysql> quit
Bye


OK,已经禁用了。

至此,mysql 升级完成。

未完待续.
[ ] ( 3744 次浏览 ) 永久链接 ( 3.1 / 2627 )

<< <上一页 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 下一页> >>