手机浏览 RSS 2.0 订阅 膘叔的简单人生 , 腾讯云RDS购买 | 超便宜的Vultr , 注册 | 登陆
浏览模式: 标准 | 列表Tag:aliyun

Linux 系统挂载数据盘

下面的文字来自于aliyun的帮助文件,原文地址:http://help.aliyun.com/knowledge_detail.htm?spm=5176.7114037.1996646101.3.7IHA8N&categoryId=8314844&knowledgeId=5974196&pos=2。

 
步骤很简单
1、fdisk -l ,看一下有哪些磁盘没有挂载,如果是阿里云的第一块磁盘,默认就是/dev/xvdb
2、fdisk -S 56 /dev/xvdb ,按顺序输入:n , p , 1 ,后面就直接回车两次就行了,这时候再fdisk -l,会看到有一块硬盘是/dev/xvdb1
3、mkfs.ext3 /dev/xvdb1 ,对分区进行格式化,你可以选择ext3或者4
4、将分区信息写到/etc/fstab里,echo '/dev/xvdb1 /datas ext3 defaults 0 0 ' >> /etc/fstab
5、mkdir /datas
6、mount /dev/xvdb1 /datas
 
就是这样简单。如果需要图文并茂,还是看上面的网址吧
 

Tags: aliyun

怎样在阿里云上安装docker

因为debian 7安装docker的手续比较麻烦,所以我把阿里云的系统换成了ubuntu 14.04,然后参考:https://docs.docker.com/installation/ubuntulinux/

还算比较方便:apt-get update && apt-get install docker.io,然后再改两个配置就完事了。

不过,在你运行docker run -i -t ubuntu /bin/bash的时候,会报错,说是docker -d好象没有运行,这不科学 啊,刚刚不是装好的吗?

于是ps aux|grep docker,果然没有进程,于是直接输入:docker -d,然后就发现报错了:

XML/HTML代码
  1. 2014/08/18 12:05:42 Could not find a free IP address range for interface 'docker0'. Please configure its address manually and run 'docker -b docker0'  

老规矩,内事不决问度娘,外事不决问谷歌,结果居然看到有人回复 :

大小: 46.71 K
尺寸: 500 x 174
浏览: 1757 次
点击打开新窗口浏览全图

当时这个心就碎了,心想这不科学啊,于是再google,就真的发现了:

大小: 65.11 K
尺寸: 500 x 235
浏览: 1825 次
点击打开新窗口浏览全图

OK,那就试试吧:

XML/HTML代码
  1. sudo brctl addbr docker0 # create your bridge  
  2. sudo brctl addif docker0 eth0 # mask an existing interface using the bridge  
  3. sudo ip link set dev docker0 up # bring it up - not really sure if this is necessary or is it done automatically  
  4. sudo ifconfig docker0 10.0.0.4 # give it an IP  

当然要运行brctl还是要装一个bridge-utils工具的,当然这个ubuntu会提醒你,一步步的做完后,docker 果然可以启动了。这时候再运行一下,service docker.io start,然后ps aux|grep docker,进程还活着。

于是输入:

XML/HTML代码
  1. docker run -i -t ubuntu /bin/bash  
  2. Unable to find image 'ubuntu' locally  
  3. Pulling repository ubuntu  
  4. 2014/08/18 12:16:44 Get https://index.docker.io/v1/repositories/ubuntu/images: dial tcp: lookup index.docker.io on 10.143.22.118:53: no answer from server  

咦。不能上网。其实就是上面的代码的问题,因为默认aliyun的eth0是内网IP,所以上述的

  1. sudo brctl addif docker0 eth0 # mask an existing interface using the bridge  
  2. 这里应该用eth1

重新执行一下。然后再次运行:

XML/HTML代码
  1. docker run -i -t ubuntu /bin/bash  
  2. Unable to find image 'ubuntu' locally  
  3. Pulling repository ubuntu  
  4. c5881f11ded9: Download complete   
  5. 。。。。。。。  

整个就完成了

 

Tags: docker, aliyun

aliyun 安装 ftp(proftpd)

有了服务器,怎么着都得装个Ftp吧,否则,必须得让人用ssh连接来上传文件 ?
于是我找了proftpd,因为比较简单vsftpd太麻烦了。proftpd的教程很简单

1、先apt-get update,apt-get upgrade
2、apt-get install proftpd-basic proftpd-mod-mysql
3、修改 /etc/proftpd/proftpd.conf
因为原内容都注释了,所以直接在文件的最后加上:

XML/HTML代码
  1. DefaultRoot ~  
  2. Include /etc/proftpd/sql.conf  
  3. RequireValidShell off  

4、添加一个组,和一个用户:

XML/HTML代码
  1. groupadd -g 2001 ftpgroup  
  2. useradd -u 2001 -s /bin/false -d /bin/null -c "proftpd user" -g ftpgroup ftpuser  

5、去mysql里增加一个用户,如proftpd/proftpdpass,建一个数据库,如:proftpd
6、插入表结构:

SQL代码
  1. CREATE TABLE ftpgroup (  
  2.  groupname varchar(16) NOT NULL default '',  
  3.  gid smallint(6) NOT NULL default '2001',  
  4.  members varchar(16) NOT NULL default '',  
  5.  KEY groupname (groupname)  
  6.  ) ENGINE=MyISAM COMMENT='ProFTP group table';  
  7.   
  8. CREATE TABLE ftpuser (  
  9.  id int(10) unsigned NOT NULL auto_increment,  
  10.  userid varchar(32) NOT NULL default '',  
  11.  passwd varchar(32) NOT NULL default '',  
  12.  uid smallint(6) NOT NULL default '2001',  
  13.  gid smallint(6) NOT NULL default '2001',  
  14.  homedir varchar(255) NOT NULL default '',  
  15.  shell varchar(16) NOT NULL default '/sbin/nologin',  
  16.  count int(11) NOT NULL default '0',  
  17.  accessed datetime NOT NULL default '0000-00-00 00:00:00',  
  18.  modified datetime NOT NULL default '0000-00-00 00:00:00',  
  19.  PRIMARY KEY (id),  
  20.  UNIQUE KEY userid (userid)  
  21.  ) ENGINE=MyISAM COMMENT='ProFTP user table';  

7、修改/etc/proftpd/modules.conf,去掉两行注释:

XML/HTML代码
  1. LoadModule mod_sql.c  
  2. LoadModule mod_sql_mysql.c  

8、修改/etc/proftpd/sql.conf

 

 

XML/HTML代码
  1. SQLBackend mysql  
  2. SQLAuthTypes Crypt  
  3. #下面一行就是用户名密码  
  4. SQLConnectInfo 数据库@localhost 用户名 密码   
  5. SQLUserInfo ftpuser userid passwd uid gid homedir shell  
  6. SQLGroupInfo ftpgroup groupname gid members  
  7. # Update count every time user logs in  
  8. SQLLog PASS updatecount  
  9. SQLNamedQuery updatecount UPDATE "countcount=count+1, accessed=now() WHERE userid='%u'" ftpuser  
  10. SQLLog STOR,DELE modified  
  11. SQLNamedQuery modified UPDATE "modified=now() WHERE userid='%u'" ftpuser  

9、插入用户:

XML/HTML代码
  1. INSERT INTO `ftpgroup` (`groupname`, `gid`, `members`) VALUES ('ftpgroup', 2001, 'ftpuser');  
  2. INSERT INTO `ftpuser` ( `userid`, `passwd`, `uid`, `gid`, `homedir`, `shell`, `count`) VALUES ( 'username', ENCRYPT('password'), 2001, 2001, '/var/www/www.example.com/', '/sbin/nologin', 0);  

10、重启proftpd:/etc/init.d/proftpd restart
上面这段其实是来自:http://www.sysadminworld.com/2011/install-proftpd-with-mysql-backend-on-debian-ubuntu/

 

--------EOF---

至此,上面的内容基本上就能够登录成功了,如果还是失败,建议先停掉proftpd,然后运行proftpd -nd6,查看错误信息,比如我就看到了这个:

XML/HTML代码
  1. Mar 09 00:22:29 test proftpd[8850] test (0.0.0.0[0.0.0.0]): notice: unable to use '~/' [resolved to '/server/wwwroot/htdocs/']: Permission denied  
  2. Mar 08 16:22:29 test proftpd[8850] test (0.0.0.0[0.0.0.0]): Preparing to chroot to directory '~/'  
  3. Mar 08 16:22:29 test proftpd[8850] test (0.0.0.0[0.0.0.0]): chroot to '~/' failed for user 'xxxxxx': Operation not permitted  
  4. Mar 08 16:22:29 test proftpd[8850] test (0.0.0.0[0.0.0.0]): error: unable to set default root directory  
  5. Mar 08 16:22:29 test proftpd[8850] test (0.0.0.0[0.0.0.0]): FTP session closed.  

我靠,这个怎么办?

 

这时候我又请vampire帮忙了。他就帮我检查了一下,做了几个处理:

1、vim /etc/groups ,在www-data:x:33后面加了:www-data:x:33:ftpgroup ,表示权限跟着www-data,因为我们的ftp目录里的文件都是基于www-data的

2、修改/etc/proftpd/proftpd.conf,改其中的:user / group ,都改成www-data

3、还是/etc/proftpd/proftpd.conf ,改 Umask ,原来是Umask 022 022,去掉一个022

4、因为我的www-data是gid是33,所以刚才在数据库里插的gid统统换成33,而不是原来的2001,这时候再登录其实还是不正常。

5、最重要的一个,在刚才的sql.conf里面,加入:SQLMinID 33,这个玩意要参考:http://www.proftpd.org/docs/directives/linked/config_ref_SQLMinID.html,我晶,这个东西,居然在默认的sql.conf里是没有这一行的。果然还是vampire有经验。因为www-data的gid是33,所以sqlminid就是33了。

这时候,终于一切正常了。折腾了好久。。。

 

 

 

 

 

 

 

Tags: aliyun, proftpd