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 升级完成。

未完待续.
[ ] ( 3670 次浏览 ) 永久链接 ( 3.1 / 2499 )
linux 内核升级后导致的Oracle VM 虚拟机无法启动 

这个情况可能很多人都遇到了,因为在GNU/Linux 上升级linux kernel 是家常便饭的事情。

由于我所使用的是virtualbox.org 官方源上提供的闭源版本,所以不清楚这种情况会不会出现在发行版自带的vbox 版本上,如 packages.ubuntu.com 上的 virtualbox open source edition.

好了,开始说正事。

就是当GNU/Linux 系统更换了内核后,导致了vbox 所需要的ddms 以及虚拟内核模块需要重新编译一个适用于当前新内核的。

而升级内核默认是不会安装新内核的头文件包的,也就是 linux-headers-x.x.x-xx-generic。

所以,使用了新内核的虚拟机自然是不会启动的。

解决办法:安装内核对应的头文件包。


sudo apt-get install linux-headers-`uname -r`

sharl@sharl-desktop:~$ sudo /etc/init.d/vboxdrv setup
* Stopping VirtualBox kernel modules [ OK ]
* Recompiling VirtualBox kernel modules [ OK ]
* Starting VirtualBox kernel modules [ OK ]


再次启动虚拟机,OK,问题解决。

附完整的内核安装包列表:

sharl@sharl-desktop:~$ dpkg -l | grep `uname -r`
ii linux-headers-3.5.0-27-generic 3.5.0-27.46 amd64 Linux kernel headers for version 3.5.0 on 64 bit x86 SMP
ii linux-image-3.5.0-27-generic 3.5.0-27.46 amd64 Linux kernel image for version 3.5.0 on 64 bit x86 SMP
ii linux-image-extra-3.5.0-27-generic 3.5.0-27.46 amd64 Linux kernel image for version 3.5.0 on 64 bit x86 SMP
sharl@sharl-desktop:~$

[ ] ( 4264 次浏览 ) 永久链接 ( 2.9 / 2440 )
在Ubuntu 下安装Nvidia 显卡驱动 

前端时间进了一家公司,做起了网管。

新员工分配电脑的时候,我利用职务之便给自己找了一台配置还算不错的主机。

Asua 板子 + Intel Core i5 2.9Ghz + 8Gb 内存,其他不太清楚。

之后,我给电脑安装了系统,选的是Ubuntu 12.04 64bit 版本。

不过,很快我就发现了一个问题,那就是这台机器的显卡是独立的,是Nvidia Quadro 6000 的型号。

而Ubuntu 里并没有包含这些私有的驱动,我得去单独下载、安装它们。

首先,去Nvidia 的官网(http://www.nvidia.com/Download/index.aspx?lang=en-us) 查找并下载对应显卡型号的适用于我的系统的驱动。

一个 NVIDIA-Linux-x86_64-295.59.run 的二进制包,如下:


sharl@sharl-desktop:~/下载$ ls -hl | grep NVIDIA
-rwxrwxrwx 1 sharl sharl 56M 8月 1 14:22 NVIDIA-Linux-x86_64-295.59.run


之后开始安装。

1.ctrl + alt + f# 切入到tty终端,找到该驱动文件位置。
2.chmod a+ x *.run,赋予其Exec(可执行)权限。
3.service lightdm stop,干掉X.org.
4.sudo ./*.run,运行该BIN文件,开始安装驱动。

值得注意的是,安装驱动的过程中需要编译一些系统模块,所以可能会依赖一些库。

安装即可.
sudo apt-get install libc6-dev build-essentials.

驱动安装完成后,重启一下X.org 或者直接重启系统,就可以看到显卡驱动已经在发挥作用了。

注:Linux 下有点麻烦的事,驱动(包括显卡)安装好后,以后每次升级内核后,都需要重新安装一遍,这点需要注意。

还有就是,Nvidia 的显卡驱动在重新安装之前最好是先移除/卸载掉之前的旧驱动,

sudo ./*.run --uninstall 即可。

尽管安装程序它会自己卸载旧驱动,不过还是会有问题。

比如,你会发现桌面环境变成了Unity 2D,而不是之前的Unity 3D,很是让人不爽。

以上就是我在Linux 系统上第一次安装显卡驱动的心得,希望对各位有用。
[ ] ( 3436 次浏览 ) 永久链接 ( 3 / 2580 )
在Ubuntu 上通过ADB 调试Samsung Galaxy Tab Plus P6200 

三星的手机要我怎么说呢?简直就是废品。

自带的新浪天气的插件三天两头挂掉,让人苦不堪言。

我在网上一查,遇到这么情况我只是我一个,还有很多。

所以我决定今天通过ADB(Android Debug Bridge)查看下它的日志,看能不能发现点问题。

然后问题来了。

我发现我的电脑却总是不能识别出P6200,在设备一栏永远是未知,一串问号。

就像这样:

sharl@sharl-laptop:~$ adb devices
List of devices attached
???????????? device


而我的motorola 的里程碑手机从未遇到过这种情况,samsung 这个废品!

不过,骂归骂,问题总是要解决。

经过我的一番研究,终于找到了一个可行的步骤,现分享如下:

首先确认手机与电脑没有建立连接,各自独立。

再确认 adb 进程没有在跑,如果有,杀掉,如下:

sharl@sharl-laptop:~$ killall adb
adb:没有发现操作


紧接着,重启 udev 服务。如下:

sharl@sharl-laptop:~$ sudo service udev restart
udev stop/waiting
udev start/running, process 7632


这时候,打开手机,设置,开启USB调试模式,并用数据线连接至电脑。

之后,查看下USB设备,确认系统已经识别该设备。如下:

sharl@sharl-laptop:~$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB
Bus 002 Device 004: ID 0bc2:3300 Seagate RSS LLC
Bus 005 Device 002: ID 08ff:2580 AuthenTec, Inc. AES2501 Fingerprint Sensor
Bus 002 Device 005: ID 062a:8668 Creative Labs
Bus 002 Device 006: ID 1a1d:8301 Veho
Bus 002 Device 067: ID 0ac8:303b Z-Star Microelectronics Corp. ZC0303 Webcam
Bus 002 Device 008: ID 046d:c52e Logitech, Inc.
Bus 002 Device 079: ID 04e8:6860 Samsung Electronics Co., Ltd GT-I9100 Phone [Galaxy S II]


注:最后一个就是我的P6200.

最后,启动adb 即可。

这样的步骤下来,就可以成功识别出samsung 的手机了。如下:

sharl@sharl-laptop:~$ adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
46411912F57398CE device


怎么样?再也不是之前的 “????????” 或者是 offline 了。

真尼玛不容易,我察!
[ ] ( 4066 次浏览 ) 永久链接 ( 3 / 2536 )
升级安装 varnish 3.0.3 RC1 和 lighttpd 1.4.31 以及 nginx 1.3.1 

最近我所用到的很多软件都更新了,Varnish Cache 几天前发布了其3.0.3的RC测试版,我有理由试用和反馈。

Lighttpd 也在上周发布了今年的第一个新版本,修复几个严重问题。

nginx 呢,也在昨天,发布了其1.3.x 分支的第二个测试版,修复了一个Windows 下的CVE.这在nginx 官网的安全通告页可以看到:
http://nginx.org/en/security_advisories.html

GNU/Linux 不受影响,不过还是有一些bugfix.具体见更新列表:
http://nginx.org/en/CHANGES

基于此,我决定挨个跟进。

下载源码:
7 wget http://repo.varnish-cache.org/test/varn ... rc1.tar.gz
8 wget http://download.lighttpd.net/lighttpd/r ... 31.tar.bz2
9 wget http://nginx.org/download/nginx-1.3.1.tar.gz

移除旧版本:
[root@PowerPC pub]# rm varnish*
rm: remove regular file `varnish-3.0.2.tar.gz'? y
rm: remove regular file `varnish-3.0.3-rc1.tar.gz'? n
[root@PowerPC pub]# rm lighttpd*
rm: remove regular file `lighttpd-1.4.30.tar.bz2'? y
rm: remove regular file `lighttpd-1.4.31.tar.bz2'? n
[root@PowerPC pub]# rm nginx*
rm: remove regular file `nginx-1.3.0.tar.gz'? y
rm: remove regular file `nginx-1.3.1.tar.gz'? n

挨个解压,列表如下:
[root@PowerPC ~]# ls -lh
total 12K
drwxr-sr-x 6 1000 1000 4.0K Jun 6 16:54 lighttpd-1.4.31
drwxr-xr-x 9 1001 1001 4.0K Jun 6 17:06 nginx-1.3.1
drwxr-xr-x 10 1000 1000 4.0K Jun 6 16:44 varnish-3.0.3-rc1

先从Varnish Cache开始,进入目录:
我的configure:
[root@PowerPC varnish-3.0.3-rc1]# ./configure \
> --prefix=/usr/local/varnish \
> --exec-prefix=/usr/local \
> --sysconfdir=/etc/sysconfig \
> --localstatedir=/var \
> --disable-largefile \
> --enable-kqueue \
> --enable-epoll \
> --enable-ports \
> --with-jemalloc

检查依赖,没有问题。只有一个函数的警告。

configure: WARNING: won't look for sendfile() on i686-pc-linux-gnu


忽略即可。make && make install 编译安装。
恢复配置文件,覆盖自动生成的default.vcl .

接下来 lighttpd,进入目录:
我的configure:
[root@PowerPC lighttpd-1.4.31]# ./configure \
> --prefix=/usr/local/lighttpd \
> --exec-prefix=/usr/local \
> --sysconfdir=/etc/sysconfig/lighttpd \
> --localstatedir=/var \
> --disable-lfs \
> --disable-ipv6 \
> --with-mysql=`which mysql_config` \
> --with-ldap \
> --with-attr \
> --with-pcre \
> --with-zlib \
> --with-bzip2

检查依赖,系统给出编译概况:

Plugins:

enabled:
mod_access
mod_accesslog
mod_alias
mod_auth
mod_cgi
mod_compress
mod_dirlisting
mod_evhost
mod_expire
mod_extforward
mod_fastcgi
mod_flv_streaming
mod_indexfile
mod_mysql_vhost
mod_proxy
mod_redirect
mod_rewrite
mod_rrdtool
mod_scgi
mod_secdownload
mod_setenv
mod_simple_vhost
mod_ssi
mod_staticfile
mod_status
mod_trigger_b4_dl
mod_userdir
mod_usertrack
mod_webdav
disabled:
mod_cml
mod_magnet

Features:

enabled:
auth-crypt
auth-ldap
compress-bzip2
compress-deflate
compress-gzip
regex-conditionals
disabled:
large-files
network-ipv6
network-openssl
stat-cache-fam
storage-gdbm
storage-memcache
webdav-locks
webdav-properties


确认没有问题。make && make install 以继续。
编译安装完成后,恢复下配置文件目录。

最后是 nginx,进入目录:
我的configure:
[root@PowerPC nginx-1.3.1]# ./configure \
> --prefix=/usr/local/nginx \
> --sbin-path=/usr/local/sbin/nginx \
> --conf-path=/etc/sysconfig/nginx/nginx.conf \
> --error-log-path=/var/log/nginx/error.log \
> --pid-path=/var/run/nginx.pid \
> --lock-path=/var/lock/nginx.lock \
> --user=web \
> --group=http \
> --with-rtsig_module \
> --with-select_module \
> --with-poll_module \
> --with-file-aio \
> --with-http_realip_module \
> --with-http_addition_module \
> --with-http_xslt_module \
> --with-http_image_filter_module \
> --with-http_flv_module \
> --with-http_mp4_module \
> --with-http_gzip_static_module \
> --without-http_ssi_module \
> --without-http_geo_module \
> --without-http_map_module \
> --without-http_rewrite_module \
> --without-http_proxy_module \
> --without-http_fastcgi_module \
> --without-http_uwsgi_module \
> --without-http_scgi_module \
> --without-http_limit_conn_module \
> --without-http_limit_req_module \
> --http-log-path=/var/log/nginx/access.log \
> --http-client-body-temp-path=/tmp/nginx/request \
> --without-mail_pop3_module \
> --without-mail_imap_module \
> --without-mail_smtp_module \
> --with-pcre

同样,检查依赖时系统会给出编译概况:

Configuration summary
+ using system PCRE library
+ OpenSSL library is not used
+ md5: using system crypto library
+ sha1: using system crypto library
+ using system zlib library

nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/sbin/nginx"
nginx configuration prefix: "/etc/sysconfig/nginx"
nginx configuration file: "/etc/sysconfig/nginx/nginx.conf"
nginx pid file: "/var/run/nginx.pid"
nginx error log file: "/var/log/nginx/error.log"
nginx http access log file: "/var/log/nginx/access.log"
nginx http client request body temporary files: "/tmp/nginx/request"


同样,在确认无误后,开始 编译 和 安装。 make && make install.
之后,恢复配置文件,覆盖生成的 nginx.conf 文件。

注:这里有个小插曲,那就是我在编译nginx 时候,把user 和 group 参数写反了,以至于启动 nginx 后,提示“getpwnam() 和 getgrnam()” 错误。
我又难得再编译一遍,就用"user USER GROUP;"修饰符写死在配置文件里了。囧~

之后启动所有服务,一切正常。
升级结束。
[ ] ( 2116 次浏览 ) 永久链接 ( 2.9 / 2552 )

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