http://www.cnblogs.com/vincentX/
vSphere配置ubuntu12.04
1. 创建虚拟机文件,E1000网卡,加载iso安装镜像
2. 打开虚拟机,进行安装配置:
name server(DNS): XXX.XXX.XXX.XXX, Open SSH Server
3. 系统安装完毕,配置网络环境:
1.修改/etc/network/interfaces
auto eth0
iface eth0 inet static
address XXX.XXX.XXX.XXX.* #注:星号改为自己规划的ip段
gateway XXX.XXX.XXX.XXX
netmask XXX.XXX.XXX.XXX
2.重启网络服务 sudo /etc/init.d/networking restart
3.若需修改DNS地址,则编辑以下文件:/etc/resolv.conf
nameserver XXX.XXX.XXX.XXX
4. 至此可使用SSH连接
4. 安装VMware Tools
1.vShpere Client中选择安装VMware Tools
2.挂载iso镜像文件
sudo mount /dev/cdrom /mnt/cdrom
若/mnt/cdrom不存在则先创建目录:sudo mkdir /mnt/cdrom
3.工作目录转至/tmp,清空已存在的文件,解压安装包至本目录
tar zxpf /mnt/cdrom/VMwareTools-X.X.X-X.tar.gz
4.卸载iso镜像文件
sudo umount /dev/cdrom
5.运行安装脚本
sudo vmware-tools-distrib/vmware-install.pl
5. 快照备份
Ubuntu开机开启永久swap空间
如果之前已经创建好swap文件的话,请开机时打开swap文件:
swapon /opt/images/swap
1.首先创建一个存放swap文件的文件夹:
mkdir /opt/images/
2.创建文件并初始化(2G足够):
dd if=/dev/zero of=/opt/images/swap bs=1024 count=2048000
3.将文件设置为swap属性,并开启它:
mkswap /opt/images/swap
swapon /opt/images/swap
4.我们可以用free -m查看现在的swap文件:
(以上四步为创建swap文件的过程,但是它的存在时间仅为重启之前。如果你重启ubuntu的话,它就会消失。对于内存很小的DO服务器而言,你装了很大的服务有时候连机器都开不了)
5.设置swap文件开机自启动,通过修改/etc/fstab文件,fstab文件具体功能请自行百度,这个文件用途很广,但这里只给出设置swap文件开机启动的方式:
sudo vim /etc/fstab
在该文件末尾添加如下内容:
/opt/images/swap none swap sw 0
6.swap文件设置:
先查看swappiness进程:
cat /proc/sys/vm/swappiness
会返回一个0-100的值,作为一个使用swap文件的比值,通常来讲越接近100则占用内存越少,占用swap文件越多。所以进行操作消耗时间也就越多,运行也就越慢;0则相反。
可以根据需要来设置swappiness的键值,这里给出“暂时(temporary”和“永久(permanent”两种设置方法:
temp: sudo sysctl vm.swappiness=键值
perm: sudo vim /etc/sysctl.conf
在文件的结尾添加:
vm.swappiness=键值
Linux 下的dd命令使用详解
一、dd命令的解释
#ls –l
-rw-r–r– 1 oracle dba 1024 Jul 15 16:56 test.txt
# : > /var/log/messages 有同样的效果, 但不会产生新的进程.(因为:是内建的)
#cat /dev/null > /var/log/wtmp
#then
#rm -f ~/.netscape/cookies
#fi
#ln -s /dev/null ~/.netscape/cookies
inode的理解
文件名 -> inode -> device block
转自:
http://www.ruanyifeng.com/blog/2011/12/inode.html
http://blog.s135.com/post/295/
http://hi.baidu.com/leejun_2005/blog/item/d9aa13a53b3af6e99152ee7e.html
一、inode是什么?
使用ls -i命令,可以看到文件名对应的inode号码:
ln命令可以创建硬链接:
九 实际问题
在一台配置较低的Linux服务器(内存、硬盘比较小)的/data分区内创建文件时,系统提示磁盘空间不足,用df -h命令查看了一下磁盘使用情况,发现/data分区只使用了66%,还有12G的剩余空间,按理说不会出现这种问题。 后来用df -i查看了一下/data分区的索引节点(inode),发现已经用满(IUsed=100%),导致系统无法创建新目录和文件。
查找原因:
/data/cache目录中存在数量非常多的小字节缓存文件,占用的Block不多,但是占用了大量的inode。
解决方案:
1、删除/data/cache目录中的部分文件,释放出/data分区的一部分inode。
2、用软连接将空闲分区/opt中的newcache目录连接到/data/cache,使用/opt分区的inode来缓解/data分区inode不足的问题:
ln -s /opt/newcache /data/cache
[转]Ubuntu下添加开机启动脚本
Ubuntu开机之后会执行/etc/rc.local文件中的脚本,
所以我们可以直接在/etc/rc.local中添加启动脚本。
当然要添加到语句:exit 0 前面才行。
如:
sudo vi /etc/rc.local
然后在 exit 0 前面添加好脚本代码。
后续有空再研究下添加一个Ubuntu的开机启动服务看看。
如果要添加为开机启动执行的脚本文件,
可先将脚本复制或者软连接到/etc/init.d/目录下,
然后用:update-rc.d xxx defaults NN命令(NN为启动顺序),
将脚本添加到初始化执行的队列中去。
注意如果脚本需要用到网络,则NN需设置一个比较大的数字,
如98 。
[转]Open edX 用户注意防范ElasticSearch远程任意代码执行漏洞
请各位edx用户 注意CVE: CVE-2014-3120
edx默认会安装含有漏洞的版本(main.yml#L6),官方虽然意识到了这个漏洞 (elasticsearch.yml.j2#L19),并且尝试修复了 但是只在集群安装时(main.yml#L65)才会用到他们的防御代码,所以如果各位使用configuration部署Open edX,将会是安装的含有漏洞的版本,受影响edX版本可追溯到去年(2013)9月
原理
这个漏洞实际上非常简单,ElasticSearch有脚本执行(scripting)的功能,可以很方便地对查询出来的数据再加工处理。
ElasticSearch用的脚本引擎是MVEL,这个引擎没有做任何的防护,或者沙盒包装,所以直接可以执行任意代码。
而在ElasticSearch里,默认配置是打开动态脚本功能的,因此用户可以直接通过http请求,执行任意代码。
检测方法
在线检测:
http://tool.scanv.com/es.html 可以检测任意地址
http://bouk.co/blog/elasticsearch-rce/poc.html 只检测localhost,不过会输出/etc/hosts和/etc/passwd文件的内容到网页上
自己手动检测:
{
“size”: 1,
“query”: {
“filtered”: {
“query”: {
“match_all”: {}
}
}
},
“script_fields”: {
“/etc/hosts”: {
“script”: “import java.util.*;\nimport java.io.*;\nnew Scanner(new File(\”/etc/hosts\”)).useDelimiter(\”\\\\Z\”).next();”
},
“/etc/passwd”: {
“script”: “import java.util.*;\nimport java.io.*;\nnew Scanner(new File(\”/etc/passwd\”)).useDelimiter(\”\\\\Z\”).next();”
}
}
}
‘
处理办法
关掉执行脚本功能,在配置文件/etc/elasticsearch/elasticsearch.yml里为每一个结点都加上:
1 |
script.disable_dynamic: true |
然后重启服务:
1 |
sudo service elasticsearch restart |
参见:
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-scripting.html#_disabling_dynamic_scripts
官方会在1.2版本默认关闭动态脚本
参见:
https://github.com/elasticsearch/elasticsearch/issues/5853
参考:
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-scripting.html
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-script-fields.html
http://bouk.co/blog/elasticsearch-rce/
[Linux]更改terminal中Bash提示字符串
昨晚实验室讲了讲Git,由于讲师的Terminal中Bash提示字符串过长导致各位童鞋看不清他输入的命令。下面讲一下如何修改此提示字符串:
配置此内容的文件是~/.bashrc (修改时需要sudo)
首先备份一下此文件:
sudo cp ~/.bashrc ~/.bashrc.bk
接下来,修改文件:
sudo vim ~/.bashrc
我用vim,所以可以用”?PS1=”来定位。
else
PS1=’${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ‘
我们需要修改的是这样一段语句。(其他的请不要修改)
修改@前后的内容即可。
比如:
PS1=’我就不行我就BB:\w\$ ‘
如果你的linux支持中文,我们会看到如下内容:
Enjoy it!
Ubuntu清华源(sources.list
# deb cdrom:[Ubuntu 12.04.4 LTS _Precise Pangolin_ – Release amd64 (20140204)]/ dists/precise/main/binary-i386/
# deb cdrom:[Ubuntu 12.04.4 LTS _Precise Pangolin_ – Release amd64 (20140204)]/ dists/precise/restricted/binary-i386/
# deb cdrom:[Ubuntu 12.04.4 LTS _Precise Pangolin_ – Release amd64 (20140204)]/ precise main restricted
#deb cdrom:[Ubuntu 12.04.4 LTS _Precise Pangolin_ – Release amd64 (20140204)]/ dists/precise/main/binary-i386/
#deb cdrom:[Ubuntu 12.04.4 LTS _Precise Pangolin_ – Release amd64 (20140204)]/ dists/precise/restricted/binary-i386/
#deb cdrom:[Ubuntu 12.04.4 LTS _Precise Pangolin_ – Release amd64 (20140204)]/ precise main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ precise main restricted
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ precise main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ precise-updates main restricted
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ precise-updates main restricted
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ precise universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ precise universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ precise-updates universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ precise-updates universe
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ precise multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ precise multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ precise-updates multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ precise-updates multiverse
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ precise-backports main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu precise-security main restricted
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu precise-security main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu precise-security universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu precise-security universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu precise-security multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu precise-security multiverse
## Uncomment the following two lines to add software from Canonical’s
## ‘partner’ repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu precise partner
# deb-src http://archive.canonical.com/ubuntu precise partner
## Uncomment the following two lines to add software from Ubuntu’s
## ‘extras’ repository.
## This software is not part of Ubuntu, but is offered by third-party
## developers who want to ship their latest software.
# deb http://extras.ubuntu.com/ubuntu precise main
# deb-src http://extras.ubuntu.com/ubuntu precise main
CentOS 6.6上安装及配置owncloud
0.安装centOS (ver.6.6)
1.CentOS配置IP:
setup配置ip mask等,vim /etc/sysconfig/network-scripts/ifcfg-eth0
设置ONBOOT=yes
2.安装Vmware tools:
现在vsphere里安装vmware tools挂载好安装程序,然后:
执行下面的命令:
mkdir /mnt/cdrom
mount -t iso9660 /dev/cdrom /mnt/cdrom
cd /mnt/cdrom
tar -zxvf VMwareTools-*.tar.gz -C /tmp
cd /tmp/vmware-tools-distrib
umount /mnt/cdrom
yum install perl
./vmware-install.pl
根据提示选择yes/no
3.修改yum源(以163为例)
进入存放源配置的文件夹
cd /etc/yum.repos.d
备份默认源
mv ./CentOS-Base.repo ./CentOS-Base.repo.bak
使用wget下载163的源 http://mirrors.163.com/.help/centos.html
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
4.安装MySQL:
yum install mysql mysql-server
开机自启动:
chkconfig –levels 235 mysqld on[root@localhost ~]# /etc/init.d/mysqld start
开启MySQL:
service mysqld start
设置MySQL密码:
mysql_secure_installation
登录mysql
mysql -u root -p XXXXXX
5.安装Apache:
安装httpd:
yum install httpd
开机自启动:
chkconfig –levels 235 httpd on
开启httpd:
service httpd start
6.安装PHP:
yum install php
安装相关模块:
yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring
重启Apache,使其生效:
service httpd restart
7.安装ownCloud(自动):
cd /etc/yum.repos.d/
wget http://download.opensuse.org/repositories/isv:ownCloud:community/CentOS_CentOS-6/isv:ownCloud:community.repo
yum install owncloud
7*.安装ownCloud(手动):
cd /etc/yum.repos.d/
安装lrzsz:
yum install lrzsz
手工下载owncloud后上传至服务器:
(Xshell直接拖动进)
安装ownCloud:
tar -xjvf owncloud-X.X.X.tar.bz2 -C /var/www/html/
(版本号具体而定)
8.启动owncloud:
为Web服务器上文件目录设置读写权限:
chown -R apache.apache /var/www/html/owncloud/
创建数据库:
登录:
mysql -u root -p
键入:
mysql> create database owncloud;
mysql> create user ‘owncloud’@’xx.xx.xx.xx’ identified by’databasepassword’;(自己设置pswd)
mysql> grant all on owncloud.* to ‘owncloud’@’xx.xx.xx.xx’;
mysql> flush privileges;
mysql> quit;
编辑外部配置文件:
vim /etc/httpd/conf.d/owncloud.conf
键入:
————————————————–
Alias /owncloud /var/www/html/owncloud
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
————————————————–