2012年5月31日 星期四

yum install xinetd


[root@howy public_html]# yum install xinetd
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: mirrors.stuhome.net
 * extras: mirrors.stuhome.net
 * updates: mirrors.stuhome.net
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package xinetd.x86_64 2:2.3.14-33.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package         Arch            Version                    Repository     Size
================================================================================
Installing:
 xinetd          x86_64          2:2.3.14-33.el6            base          120 k

Transaction Summary
================================================================================
Install       1 Package(s)

Total download size: 120 k
Installed size: 259 k

Is this ok [y/N]: y
Downloading Packages:
xinetd-2.3.14-33.el6.x86_64.rpm                                                                                                                  | 120 kB     00:01
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : 2:xinetd-2.3.14-33.el6.x86_64                                                                                                                        1/1

Installed:
  xinetd.x86_64 2:2.3.14-33.el6

Complete!


21.2.6 針對實體帳號的設定
http://linux.vbird.org/linux_server/0410vsftpd.php#server_real



[root@howy public_html]# getsebool -a | grep ftp
allow_ftpd_anon_write --> off
allow_ftpd_full_access --> off
allow_ftpd_use_cifs --> off
allow_ftpd_use_nfs --> off
ftp_home_dir --> on
ftpd_connect_db --> off
httpd_enable_ftp_server --> off
tftp_anon_write --> off

2012年5月26日 星期六

5/29 還是發生一樣問題:
[root@howy ~]# service mysqld status
mysqld 已停止執行但 subsys 被鎖定
決定先關閉自動備份功能
有空再試試看這個方式
http://bbs.nsysu.edu.tw/txtVersion/boards/linux/M.1189311466.AI.html

___________________________
早起床發現網站
Can't connect to local MySQL server through socket


檢查log:
vi /var/log/mysqld.log
tail -n 20 /var/log/mysqld.log

InnoDB: using the same InnoDB data or log files.


120521  4:47:54  InnoDB: Unable to open the first data file
InnoDB: Error in opening ./ibdata1
120521  4:47:54  InnoDB: Operating system error number 11 in a file operation.
InnoDB: Error number 11 means 'Resource temporarily unavailable'.
InnoDB: Some operating system error numbers are described at
InnoDB: http://dev.mysql.com/doc/refman/5.1/en/operating-system-error-codes.html
InnoDB: Could not open or create data files.
InnoDB: If you tried to add new data files, and it failed here,
InnoDB: you should now edit innodb_data_file_path in my.cnf back
InnoDB: to what it was, and remove the new ibdata files InnoDB created
InnoDB: in this failed attempt. InnoDB only wrote those files full of
InnoDB: zeros, but did not yet use them in any way. But be careful: do not
InnoDB: remove old data files which contain your precious data!
120521  4:47:54 [ERROR] Plugin 'InnoDB' init function returned error.
120521  4:47:54 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
120521  4:47:54 [ERROR] Can't start server: Bind on TCP/IP port: Address already in use
120521  4:47:54 [ERROR] Do you already have another mysqld server running on port: 3306 ?
120521  4:47:54 [ERROR] Aborting
120521  4:47:54 [Note] /usr/libexec/mysqld: Shutdown complete
120521 04:47:54 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
120521 04:47:56 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
120521  4:47:57  InnoDB: Initializing buffer pool, size = 8.0M
120521  4:47:57  InnoDB: Completed initialization of buffer pool
InnoDB: Unable to lock ./ibdata1, error: 11



先用這方法 (暫時恢復運作)
http://www.neo.com.tw/archives/92

發生找不到 mysql.sock 的處理方法!Posted by Neo on 三月 - 16 - 2004
9 Comments出現以下的訊息:
Got an error: Connection error: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'
mysql.sock 突然消失算是常見的問題,如果是第一次安裝MySQL才出現,那只要找出 mysql.sock 在哪裡就可以了。
以上述的錯誤訊息,mysql.sock 應該是在 /var/lib/mysql/ 裡面 ,如果沒有的話,就下:
#find / -name mysql.sock
來找看看放在哪裡,找到之後再下:
#mysqladmin -S /找到路徑/mysql.sock -u root {參數}
那...如果是突然不見的,或是都找不到怎麼辦?
那只好重新啟動 mysql 了,tarball 安裝可以透過 mysqld 或 mysqladmin 重新啟動,rpm 安裝可以透過 service mysql restart 。但是在 mysql.sock 不見的情況下,可能是無法重新啟動 mysql 的,如果真的不行,只好先下:
#ps -aux|grep mysql
再把看到的 pid 先砍了
#kill 看到的pid
確定全部都殺完了,再看一次還有沒有
#ps -aux|grep mysql
確定裡面的 mysql 都沒有了,然後再執行 mysqld 或是 service mysql start 就可以了。

做了兩個設定,過幾天再看看有無再出現問題:

1.嘗試這個指令
I had the same problem with Mysql 4.1.12 after recieving a SELinux update throught the RedHat Network. Editing /etc/selinux/config so the it says:
SELINUX=permissiveFixed my problem.http://www.linuxforums.org/forum/servers/17376-mysql-server-wont-start-port-conflick.html
 改 /etc/selinux/config


# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
#SELINUX=enforcing
SELINUX=permissive
#by Howy 2012/5/27

# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted



2.參考IBM網站
http://www-900.ibm.com/cn/support/viewdoc/detail?DocId=2011073000000執行:
mysql_install_db相关介绍http://hi.baidu.com/ostech/blog/item/6f838f7c1b3d00330dd7da38.html
[root@howy ~]# mysql_install_db
Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h howy.tw password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/bin/mysqlbug script!

再看看log
[root@howy howy]# tail -n 20 /var/log/mysqld.log
120527  9:56:48  InnoDB: Completed initialization of buffer pool
120527  9:56:49  InnoDB: Started; log sequence number 0 44233
120527  9:56:49 [Note] Event Scheduler: Loaded 0 events
120527  9:56:49 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.1.61'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  Source distribution
120527 11:08:19 [Note] /usr/libexec/mysqld: Normal shutdown
120527 11:08:19 [Note] Event Scheduler: Purging the queue. 0 events
120527 11:08:19  InnoDB: Starting shutdown...
120527 11:08:23  InnoDB: Shutdown completed; log sequence number 0 44233
120527 11:08:23 [Note] /usr/libexec/mysqld: Shutdown complete
120527 11:08:23 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
120527 11:09:08 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
120527 11:09:08  InnoDB: Initializing buffer pool, size = 8.0M
120527 11:09:08  InnoDB: Completed initialization of buffer pool
120527 11:09:09  InnoDB: Started; log sequence number 0 44233
120527 11:09:09 [Note] Event Scheduler: Loaded 0 events
120527 11:09:09 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.1.61'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  Source distribution



























2012年5月13日 星期日

Abocom WA-160CUN (RT5370) on CentOS6.2 x64


感謝這篇文章讓我把USB無線網卡裝到CentOShttp://hi.baidu.com/yunsuanfu/blog/item/8375ee039e5a7e114afb51ff.html 



請先裝gcc compile相關套件(我是在安裝CentOS 時就選入)
下載 ralink rt5370 driver檔名如下:
(2011_0719_RT3070_RT3370_RT5370_RT5372_Linux_STA_V2.5.0.3_DPO.bz2)

我的步驟

#cd 2011_0719_RT3070_RT3370_RT5370_RT5372_Linux_STA_V2.5.0.3_DPO/
#vi os/linux/config.mk
HAS_WPA_SUPPLICANT
HAS_NATIVE_WPA_SUPPLICANT_SUPPORT把n都改成y

# vi /etc/modprobe.d/blacklist.conf,最後面加入兩行:
   blacklist rt5370lib
   blacklist rt5370usb
#make clean
#make;make install
#modprobe rt5370sta
#reboot
重新開機完成, 網路設定就有介面可以設定上網了

補充:我有多這步驟

# vi/etc/modprobe.d/modprobe.conf

(新文件)加入以下內容

alias ra0 rt5370



參考: https://wiki.archlinux.org/index.php/Rt2870
http://linux.vbird.org/linux_server/0130internet_connect.php#wireless_connect
http://yishin-li.blogspot.com/2011/11/setting-up-zyxel-nwd2105-for-centos-5.html


引用

CentOS 安装USB无线网卡驱动
2012-01-18 22:54
为了避免布线,所以买了一个USB的无线网卡,tp-link的,是TL-WN727N,花了70大洋买的,没想到芯片跟水星的29元的一样,悲催,真不知道有啥区别,上一篇文章说装GCC,主要就是为了安装这个网卡的驱动,网上搜了一下资料,发现还不错,官方提供了linux的驱动源码,当然是芯片的驱动
这个网卡的芯片是RT5370的,所以首先得去官方下载驱动http://www.ralinktech.com/cn/04_support/support.php?sn=501
最好还是用root账户登录
1、将下载的驱动源码解压,然后最好命名一个简短的文件夹名,方便命令行里的操作
2、在os/linux/config.mk中找到HAS_WPA_SUPPLICANT以及HAS_NATIVE_WPA_SUPPLICANT_SUPPORT,将他们的值都设为”y”(不含引号)
3、屏蔽系统自带的驱动:编辑 /etc/modprobe.d/blacklist.conf,加入下面两行:
   blacklist rt2800lib
   blacklist rt2800usb
这一步到底有没有用,真不知道,网上是这样写,就照做吧,咱是菜鸟

下面这几步都是在字符界面,即控制台中用命令来操作的
4、进入到源码的根目录,在源码根目录下:make && make install
5、完成上面这些工作,就可以加载模块了:
   modprobe rt5370sta
6、加载完模块,就可以回到图形界面,像配置windows无线上网一样配置CentOS了,呵呵


參考文件
http://hi.baidu.com/yunsuanfu/blog/item/8375ee039e5a7e114afb51ff.html

2012年5月10日 星期四

[原創翻譯]Activity

Creating an Activity
To create an activity, you must create a subclass of Activity (or an existing subclass of it). In your subclass, you need to implement callback methods that the system calls when the activity transitions between various states of its lifecycle, such as when the activity is being created, stopped, resumed, or destroyed. The two most important callback methods are:
建立一個activity,必須創建activity的子類別(或是已存在一個子類別)在子類別中,需要執行叫回的方法,此方法是系統呼叫activity在生命周期的不同狀態轉換時,如activity被創建,停止,恢復或毀壞的時候。兩個重要的叫回方法是:
onCreate()
You must implement this method. The system calls this when creating your activity. Within your implementation, you should initialize the essential components of your activity. Most importantly, this is where you must call setContentView() to define the layout for the activity's user interface.
必須執行此方法。當創建activity時系統會呼叫 onCreate() ,當執行時,應該要初始化activity的必要元件。最重要的是,必須呼叫setContentView()以定義版面activity的使用者介面
onPause()
The system calls this method as the first indication that the user is leaving your activity (though it does not always mean the activity is being destroyed). This is usually where you should commit any changes that should be persisted beyond the current user session (because the user might not come back).
使用者離開activity的第一個指示時(儘管不總是說activity毀壞系統呼叫這個方法onPause()通常應該做改變,應該保持跳出使用者的會話(因為使用者可能回不來)
There are several other lifecycle callback methods that you should use in order to provide a fluid user experience between activities and handle unexpected interuptions that cause your activity to be stopped and even destroyed. All of the lifecycle callback methods are discussed later, in the section aboutManaging the Activity Lifecycle.
有很多其他生命週期叫回方法,應該使用他們以提供 activity 和處理意外中斷之間有流暢的用戶體驗,這些意外會導致 activity 停止甚至毀壞。



Implementing a user interface

The user interface for an activity is provided by a hierarchy of views—objects derived from the View class. Each view controls a particular rectangular space within the activity's window and can respond to user interaction. For example, a view might be a button that initiates an action when the user touches it.
activity使用者介面由以下提供: views—objects 的層級,從 View class 的物件取得
Android provides a number of ready-made views that you can use to design and organize your layout. "Widgets" are views that provide a visual (and interactive) elements for the screen, such as a button, text field, checkbox, or just an image. "Layouts" are views derived from ViewGroup that provide a unique layout model for its child views, such as a linear layout, a grid layout, or relative layout. You can also subclass the View and ViewGroup classes (or existing subclasses) to create your own widgets and layouts and apply them to your activity layout.
The most common way to define a layout using views is with an XML layout file saved in your application resources. This way, you can maintain the design of your user interface separately from the source code that defines the activity's behavior. You can set the layout as the UI for your activity withsetContentView(), passing the resource ID for the layout. However, you can also create new Views in your activity code and build a view hierarchy by inserting new Views into a ViewGroup, then use that layout by passing the root ViewGroup to setContentView().
For information about creating a user interface, see the User Interface documentation.
以上來源: http://developer.android.com/guide/topics/fundamentals/activities.html
原創翻譯,若有更好的描述歡迎指正批評,謝謝