1. rpm简单命令
查看已经安装的软件 rpm -qa | grep mysql
强力卸载软件 rpm -e --nodeps mysql
安装软件 rpm -ivy xxx.rpm
2. yum下载源
cd /etc/yum.repos.d
如果是RHEL, 则/etc/yum.repos.d下没有任何源.
可以通过rpm -ivh epel*.rpm安装源. 安装后会在/etc/yum.repos.d下生成repl.repo文件.
如果是CentOS, 则有CentOS-Base.repo. 在确保虚拟机能够ping通外网, 可以直接通过wget获取文件.
RHEL使用163源
http://boris05.blog.51cto.com/1073705/1439865
删除redhat原有的yum源 rpm -aq|grep yum|xargs rpm -e --nodeps
下载yum安装文件 163 6.5
wget http://mirrors.163.com/centos/6.5/os/x86_64/Packages/yum-3.2.29-40.el6.centos.noarch.rpm
wget http://mirrors.163.com/centos/6.5/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
wget http://mirrors.163.com/centos/6.5/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm
wget http://mirrors.163.com/centos/6.5/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
进行安装yum
rpm -ivh python*
rpm -ivh yum*
更改yum源
cd /etc/yum.repos.d/
vim /etc/yum.repos.d/rhel.repo
[base]
name=CentOS-$releasever - Base
baseurl=http://mirrors.163.com/centos/6.5/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6
#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=http://mirrors.163.com/centos/6.5/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6
#packages used/produced in the build but not released
#[addons]
#name=CentOS-$releasever - Addons
#baseurl=http://mirrors.163.com/centos/$releasever/addons/$basearch/
#gpgcheck=1
#gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=http://mirrors.163.com/centos/6.5/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=http://mirrors.163.com/centos/6.5/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6
yum clean all
yum makecache
yum update
EPEL-7 下载源
# wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-1.noarch.rpm
# rpm -ivh epel-release-7-1.noarch.rpm
# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
EPEL-6 下载源
# wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm
# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
注意如果是CentOS, 则最后的rpm --import要修改成CentOS-6
CentOS使用阿里云源
CentOS-163源
对于CentOS, /etc/yum.repos.d下有CentOS-Base.repo, 可以直接用别的源替换默认的, 或者新增加源.
# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup
mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
yum makecache
更新源
# yum clean all
# yum makecache
# yum update
# yum repolist
3. 安装基本软件
1. 确保能够上网, 并且yum repolist有数据, 比如先下个163的源.
当服务器稳定之后, 可以禁用源(文件后缀改下即可)
# yum install wget
**2.英文环境 **
# vi ~/.bashrc
export LANG=en_US.UTF-8
# source ~/.bashrc
# vi /etc/sysconfig/i18n
LANG="en_US.UTF-8"
3. 安装gcc, git等
# yum group install "Development Tools" --> CentOS6要使用yum groupinstall中间没有空格!
# yum grouplist
Loaded plugins: fastestmirror, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Group Process
Loading mirror speeds from cached hostfile
Installed Groups:
Console internet tools
Development tools
E-mail server
Perl Support
Security Tools
这里已经安装了Development tools, 所以会显示在Installed Groups里. 注意不是yum group list
如果没有安装, 会显示在Available Groups里. 上一步的英文环境很重要, 否则如果是中文环境, 你就不知道要安装哪个组了.
4.yum安装MySQL客户端和服务器
# yum info mysql
# yum list | grep mysql
# yum groupinfo "MySQL Database server"
# yum groupinfo "MySQL Database client"
Mandatory Packages:
mysql
Default Packages:
MySQL-python
mysql-connector-odbc
Optional Packages:
libdbi-dbd-mysql
mysql-connector-java
perl-DBD-MySQL
当然也可以单独一个一个安装. 同样要注意在/etc/yum.repos.d中要存在163, 或者epel等源. 否则如果没有源, 安装任何软件都没有数据.
http://www.cnblogs.com/xiaoluo501395377/archive/2013/04/07/3003278.htm...
# yum install mysql mysql-server mysql-devel
# service mysqld start
# netstat -anpt | grep 3306
# chkconfig --add mysqld
# chkconfig --list | grep mysqld
# chkconfig mysqld on
# mysqladmin -u root password 'root'
# mysql -u root -p
> show databases;
5. nginx
源码安装方式: http://network810.blog.51cto.com/2212549/1264669
yum源安装: nginx默认不在源里. 需要自己去nginx官网下载repo文件. 下载完后可以删除或者备份.
CentOS
# vi /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
RHEL
# vi /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/rhel/$releasever/$basearch/
gpgcheck=0
enabled=1
# yum install nginx
如果服务器开启防火墙, 则要开放80端口
# vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
重启防火墙
# service iptables restart
启动nginx方法. 显然第一种方法最快
# service nginx start
# cd /usr/local/nginx/sbin
# ./nginx
# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
同mysqld加入到chkconfig的方式开机启动, 也可以把nginx加入开机启动项中.
如果提示没有nginx这个service, 参考 http://www.01happy.com/centos-nginx-shell-chkconfig
可以在主机的浏览器上查看, 或者查看端口号80是否开启
# netstat –na|grep 80
# ps -ef | grep nginx
6. scp文件拷贝
在主机中要拷贝文件到虚拟机中
[主机]# scp xxx root@h101:~/
bash: scp: command not found
lost connection
[虚机]# yum install openssh-clients
7. http虚拟机yum源
# yum install -y httpd
将主机上的iso文件拷贝到虚拟机中
[主机]# scp **.iso root@h101:~/
[虚机]# mount -o loop CentOS*.iso /var/www/html
# vi /etc/yum.repos.d/http-local.repo
[http-local]
name=http-local-on
baseurl=http://192.168.56.101/CentOS_6.5_Final
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
8. http主机yum源
上面的方式会将iso文件拷贝到虚拟机中, 占用本来空间就不多的虚拟机.
可以不用这种方式, 而是在主机中安装httpd服务器(或者nginx), 在虚拟机中直接能访问也可以.
9. 虚拟机ftp客户端
◇ 主机中开启vsftpd服务, 虚拟机中安装ftp客户端,
# yum install ftp
# ftp 192.168.56.1
Connected to 192.168.56.1 (192.168.56.1).
220 (vsFTPd 3.0.2)
Name (192.168.56.1:root): anonymous
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>ls ftp服务器当前位置的文件列表
ftp>!Ls ftp客户端当前位置的文件列表
10. SVN
1). 查看服务器系统是否已经安装SVN
[root@datanode01 svn]# svn --version
svn,版本 1.6.11 (r934486) 编译于 Apr 12 2012,11:09:11
可使用以下的版本库访问模块:
* ra_neon : 通过 WebDAV 协议使用 neon 访问版本库的模块。
- 处理“http”方案
- 处理“https”方案
* ra_svn : 使用 svn 网络协议访问版本库的模块。 - 使用 Cyrus SASL 认证
- 处理“svn”方案
* ra_local : 访问本地磁盘的版本库模块。
- 处理“file”方案
说明svn已经安装, 并且支持http访问方式.
[root@datanode01 svn]# whereis httpd
httpd: /usr/sbin/httpd.event /usr/sbin/httpd /usr/sbin/httpd.worker /etc/httpd /usr/lib64/httpd /usr/include/httpd /usr/share/man/man8/httpd.8.gz
[root@datanode01 svn]# whereis svn
svn: /usr/bin/svn /usr/share/man/man1/svn.1.gz
[root@datanode01 svn]# whereis svnserve
svnserve: /usr/bin/svnserve /usr/share/man/man8/svnserve.8.gz
2). 创建版本仓库
◆ 新建一个目录用于存储SVN所有文件
mkdir /data/data8/svn
◆ 新建一个版本仓库
svnadmin create /data/data8/svn/project
◆ 修改 vi /data/data8/svn/project/conf/passwd 添加用户
[users]
# harry = harryssecret
# sally = sallyssecret
admin = admin123
zhengqh = zhengqh
◆ 修改 vi /data/data8/svn/project/conf/authz 修改用户访问策略
[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe
group1 = admin,zhengqh
[/]
@group1 = rw
◆ 修改 vi /data/data8/svn/project/conf/svnserve.conf文件,让用户和策略配置升效.
[general]
anon-access = none
auth-access = write
password-db = /data/data8/svn/project/conf/passwd
authz-db = /data/data8/svn/project/conf/authz
◆ 启动服务器
svnserve -d -r /data/data8/svn
◆ 测试checkout代码库
cd ~
svn co svn://172.17.212.69/project
显示如下就表示成功了:
Authentication realm: <svn://172.17.212.69:3690> e296f93b-eec2-43dd-92b5-cc10ee55c901
Password for 'root':
Authentication realm: <svn://172.17.212.69:3690> e296f93b-eec2-43dd-92b5-cc10ee55c901
Username: admin
Password for 'admin': ***
3). 配置支持使用http访问
◆ 创建svn帐号或修改密码:
/usr/bin/htpasswd -b -c /data/data8/svn/svn-auth-file admin admin123
/usr/bin/htpasswd -b /data/data8/svn/svn-auth-file zhengqh zhengqh
-c表示不存在这个文件时创建它. 注意第一行加-c, 后面添加用户不能加-c, 否则会发生覆盖.
◆ 修改svn用户访问策略
vi /data/data8/svn/svn-access-file
[project:/]
admin = rw
zhengqh = rw
◆ 修改svn目录权限
chmod -R 777 /data/data8/svn/project
◆ 查看svn和httpd依赖的文件:
# cd /etc/httpd/modules
# ls | grep svn
mod_authz_svn.so
mod_dav_svn.so
◆ 修改 vi /etc/httpd/conf/httpd.conf 增加
LoadModule dav_svn_module /etc/httpd/modules/mod_dav_svn.so
LoadModule authz_svn_module /etc/httpd/modules/mod_authz_svn.so
<Location /svn>
DAV svn
SVNParentPath /data/data8/svn
AuthType Basic
AuthName "Subversion repository"
AuthUserFile /data/data8/svn/svn-auth-file
Require valid-user
AuthzSVNAccessFile /data/data8/svn/svn-access-file
</Location>
◆ 启动apache httpd服务
下面几个命令只要执行其中一个即可(最后一个/usr/local一般用于自定义安装httpd才使用)
# /usr/sbin/apachectl start
# /etc/init.d/httpd start
# /usr/local/apache2/bin/apachectl start
◆ 重启svn服务
# ps -ef | grep svn
root 41348 1 0 11:22 ? 00:00:00 svnserve -d -r /data/data8/svn
root 41971 40812 0 11:39 pts/2 00:00:00 grep svn
# kill -9 41348
# svnserve -d -r /data/data8/svn
4). 用户维护
vi /data/data8/svn/project/conf/passwd
添加用户名 = 密码
vi /data/data8/svn/project/conf/authz
添加用户名到group1中
执行命令: /usr/bin/htpasswd -b /data/data8/svn/svn-auth-file 用户名 密码
添加用户的访问策略
vi /data/data8/svn/svn-access-file
用户名 = rw