CentOS安装
常用设置
更新yum仓库
1.备份
cd /etc/yum.repos.d
cp CentOS-Base.repo CentOS-Base.repo.bak
2.下载yum源
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
3.替换yum源
mv CentOS6-Base-163.repo CentOS-Base.repo
4.清空yum下载的组件缓存
yum clean all
5.创建yum源缓存
yum -y makecache
6.更新所有yum安装的软件
yum -y update
安装常用软件包
yum -y groupinstall "
Development Tools
"
支持中文界面
查看当前系统使用的语言(环境变量 $LANG)
echo $LANG
查看系统支持的语言包
locale -a
看看是否支持
zh_CN.utf8,如果不支持,请安装中文语言包:
yum -y groupinstall chinese-support
修改语言环境变量为中文
vim /etc/sysconfig/i18n
更新 /etc/sysconfg/i18n 配置文件
source
/etc/sysconfg/i18n
重新启动即可看到中文界面
reboot
配置防火墙
使用 find 命令查找 iptables 文件的位置
find /etc/ -type f -name ipt*
编辑 /etc/sysconfig/iptables 文件,开启几个常用的端口
vim
/etc/sysconfig/iptables
// WEB
80, 8080
// 数据库
3306, 1521
// 其他 Sonatype Nexus, CI Jenkins
8801, 8802
重新启动防火墙服务
service iptables restart
检查防火墙状态
service iptables status
关闭防火墙
关闭服务
service iptables stop
关闭开机启动
chkconfig iptables off
固定IP设置
查看IP配置文件位置
find /etc/ -type f -name ifcfg*
编辑IP配置文件
编辑之前进行备份,上面的所有编辑都建议先做好备份
cd /etc/sysconfig/network-scripts/
cp ifcfg-eth0 ifcfg-eth0.bak
编辑
vim /etc/sysconfig/network-scripts/ifcfg-eth0
解释字段意思
DEVICE=“eth0” 网卡别名
BOOTPROTO="static"
获取IP地址的方式 static/dhcp
BROADCAST="192.168.1.255"
广播地址
DNS1="192.168.1.1"
域名解析地址
GATEWAY="192.168.1.1"
网关地址
IPADDR="192.168.1.100" 网卡IP地址
NETMASK=“255.255.255.0”
子网掩码
HWADDR="00:0C:29:A4:D8:35"
网卡物理地址,自带的
重启IP服务
service iptables restart
软件安装
中文输入法
yum -y install "@Chinese Support"
重启电脑, 使用Ctrl+空格就能够切换输入法
reboot
Vsftpd 文件服务器
查看是否已经安装了vsftpd
rpm -qa |grep vsftpd
查看是否有vsftpd安装包
yum info vsftpd
安装vsftpd
yum -y install vsftpd
为vsftpd添加日志文件
touch
/
var
/
log
/
vsftpd
.
log
添加ftp用户
adduser -d /var/ftp/www -g ftp -s /sbin/nologin ftpadmin
设置密码
passwd ftpadmin
配置vsftpd
参考: http://blog.csdn.net/uxiaolang/article/details/41357201
Java平台
查看是否已经安装过JDK软件
rpm -qa |grep jdk
安装Oracle-JDK7
创建安装目录
mkdir -p /opt/java
将安装包解压到安装目录
tar -zxf jdk-7u79-linux-x64.gz -C /opt/java
配置JAVA的环境变量
vim /etc/profile.d/java.sh
JAVA_HOME=/opt/java/jdk1.7.0_79
CLASSPATH=.:$JAVA_HOME/lib
PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH PATH
重新编译环境变量配置文件
source /etc/profile
验证是否安装成功
java -version
MySQL
检查是否已经安装 mysql 相关包
rpm -qa |grep mysql
卸载已安装的mysql相关包
yum -y remove mysql-libs-5.1.73-5.el6_6.x86_64
安装MySQL
解压MySQL安装包到指定的目录
tar -xf MySQL-5.6.27-1.el6.x86_64.rpm-bundle.tar -C MySQL
进入到MySQL目录下
cd MySQL
这里用到的软件包:
服务器
MySQL-server-5.6.27-1.el6.x86_64.rpm
客户端
MySQL-client-5.6.27-1.el6.x86_64.rpm
共享库(为其他程序调用MySQL提供lib)
MySQL-shared-5.6.27-1.el6.x86_64.rpm
兼容旧版本的MySQL-libs,上面我们卸载了
mysql-libs-5.1.73-5.el6_6.x86_64
如果系统还有其他软件依赖于
mysql-libs-5.1.73-5.el6_6.x86_64 这个库,
那么就需要安装
MySQL-shared-compat-5.6.27-1.el6.x86_64.rpm来提供旧版本的功能了
MySQL-shared-compat-5.6.27-1.el6.x86_64.rpm
安装MySQL-server
rpm -ivh
MySQL-server-5.6.27-1.el6.x86_64.rpm
可以看到mysql服务已经创建,root用户的一个随机面产生在 /root/.mysql_secret 文件里面
安装
MySQL-client
rpm -ivh
MySQL-client-5.6.27-1.el6.x86_64.rpm
安装
MySQL-
shared
rpm -ivh
MySQL-shared-5.6.27-1.el6.x86_64.rpm
安装
MySQL-
shared-
compat
rpm -ivh
MySQL-shared-compat-5.6.27-1.el6.x86_64.rpm
安装记录
[root@localhost MySQL]# rpm -ivh MySQL-server-5.6.27-1.el6.x86_64.rpm
warning: MySQL-server-5.6.27-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:MySQL-server ########################################### [100%]
warning: user mysql does not exist - using root
warning: group mysql does not exist - using root
2015-12-08 16:27:38 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-12-08 16:27:38 0 [Note] /usr/sbin/mysqld (mysqld 5.6.27) starting as process 5365 ...
2015-12-08 16:27:38 5365 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-12-08 16:27:38 5365 [Note] InnoDB: The InnoDB memory heap is disabled
2015-12-08 16:27:38 5365 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-12-08 16:27:38 5365 [Note] InnoDB: Memory barrier is not used
2015-12-08 16:27:38 5365 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-12-08 16:27:38 5365 [Note] InnoDB: Using Linux native AIO
2015-12-08 16:27:38 5365 [Note] InnoDB: Using CPU crc32 instructions
2015-12-08 16:27:38 5365 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-12-08 16:27:38 5365 [Note] InnoDB: Completed initialization of buffer pool
2015-12-08 16:27:38 5365 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2015-12-08 16:27:38 5365 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2015-12-08 16:27:38 5365 [Note] InnoDB: Database physically writes the file full: wait...
2015-12-08 16:27:38 5365 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2015-12-08 16:27:38 5365 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2015-12-08 16:27:38 5365 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2015-12-08 16:27:38 5365 [Warning] InnoDB: New log files created, LSN=45781
2015-12-08 16:27:38 5365 [Note] InnoDB: Doublewrite buffer not found: creating new
2015-12-08 16:27:38 5365 [Note] InnoDB: Doublewrite buffer created
2015-12-08 16:27:38 5365 [Note] InnoDB: 128 rollback segment(s) are active.
2015-12-08 16:27:38 5365 [Warning] InnoDB: Creating foreign key constraint system tables.
2015-12-08 16:27:38 5365 [Note] InnoDB: Foreign key constraint system tables created
2015-12-08 16:27:38 5365 [Note] InnoDB: Creating tablespace and datafile system tables.
2015-12-08 16:27:38 5365 [Note] InnoDB: Tablespace and datafile system tables created.
2015-12-08 16:27:38 5365 [Note] InnoDB: Waiting for purge to start
2015-12-08 16:27:38 5365 [Note] InnoDB: 5.6.27 started; log sequence number 0
A random root password has been set. You will find it in '/root/.mysql_secret'.
2015-12-08 16:27:38 5365 [Note] Binlog end
2015-12-08 16:27:38 5365 [Note] InnoDB: FTS optimize thread exiting.
2015-12-08 16:27:38 5365 [Note] InnoDB: Starting shutdown...
2015-12-08 16:27:40 5365 [Note] InnoDB: Shutdown completed; log sequence number 1625977
2015-12-08 16:27:40 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-12-08 16:27:40 0 [Note] /usr/sbin/mysqld (mysqld 5.6.27) starting as process 5387 ...
2015-12-08 16:27:40 5387 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-12-08 16:27:40 5387 [Note] InnoDB: The InnoDB memory heap is disabled
2015-12-08 16:27:40 5387 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-12-08 16:27:40 5387 [Note] InnoDB: Memory barrier is not used
2015-12-08 16:27:40 5387 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-12-08 16:27:40 5387 [Note] InnoDB: Using Linux native AIO
2015-12-08 16:27:40 5387 [Note] InnoDB: Using CPU crc32 instructions
2015-12-08 16:27:40 5387 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-12-08 16:27:40 5387 [Note] InnoDB: Completed initialization of buffer pool
2015-12-08 16:27:40 5387 [Note] InnoDB: Highest supported file format is Barracuda.
2015-12-08 16:27:40 5387 [Note] InnoDB: 128 rollback segment(s) are active.
2015-12-08 16:27:40 5387 [Note] InnoDB: Waiting for purge to start
2015-12-08 16:27:40 5387 [Note] InnoDB: 5.6.27 started; log sequence number 1625977
2015-12-08 16:27:40 5387 [Note] Binlog end
2015-12-08 16:27:40 5387 [Note] InnoDB: FTS optimize thread exiting.
2015-12-08 16:27:40 5387 [Note] InnoDB: Starting shutdown...
2015-12-08 16:27:42 5387 [Note] InnoDB: Shutdown completed; log sequence number 1625987
A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
You will find that password in '/root/.mysql_secret'.
You must change that password on your first connect,
no other statement but 'SET PASSWORD' will be accepted.
See the manual for the semantics of the 'password expired' flag.
Also, the account for the anonymous user has been removed.
In addition, you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test database.
This is strongly recommended for production servers.
See the manual for more instructions.
Please report any problems at http://bugs.mysql.com/
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
New default config file was created as /usr/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings
获取root用户的临时密码
less /root/.mysql_secret
启动MySQL服务
service mysql start
使用mysql用户进行安全配置
[root@localhost MySQL]# /usr/bin/mysql_secure_installation --user=mysql
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.
You already have a root password set, so you can safely answer 'n'.
Change the root password? [Y/n] Y
Password updated successfully!
Reloading privilege tables..
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
Remove anonymous users? [Y/n] Y
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] n
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] n
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] Y
All done! If you've completed all of the above steps, your MySQL
installation should now be secure.
MySQL 权限设置
创建用户
create user 'user'@'address' identified by 'testpassword'
授予权限
grant privileges on [db].[table] to 'user'@'address' identified by 'password' [with grant option]
收回权限
revoke
privileges on [db].[table] from'user'@'address'
参考资料
http://www.cnblogs.com/Richardzhu/p/3318595.html
http://tool.oschina.net/apidocs/apidoc?api=mysql-5.1-zh
http://tobeawhole.blog.51cto.com/2335463/1228217
如果出现不被允许访问,那就看看mysql库的user表中,登录的user是否已经被允许远程登录
host:允许远程登录的主机地址
% 表示所有
localhost.* 表示域名,在hosts文件IP映射
user:用户名
password:加密后的密码
配置文件位置: /usr/my.conf
配置内容
[mysqld]
lower_case_table_names=1
character_set_client = utf8
character_set_server = utf8
grant all privileges on *.* to mysql@'%' identified by 'admin' with grant option;
grant all privileges on *.* to wcp2@'%' identified by "wcp123456" with grant option;
grant all privileges on wcp2.* to wcp2@'%' identified by 'wcp123456';
Git、Gitlab 版本管理
查看是否已经安装了Git
rpm -qa | grep git
卸载老版本Git
yum -y remove git
安装新版本Git
依赖安装
yum -y install zlib-devel curl-devel openssl-devel perl cpio expat-devel gettext-devel openssl zlib
autoconf tk perl-ExtUtils-MakeMaker
下载最新版本Git
https://github.com/git/git/releases
https://github.com/git/git/archive/v2.6.4.tar.gz
wget https://github.com/git/git/archive/v2.6.4.tar.gz
编译安装
解压
配置
进入源码目录
cd git-2.6.4
使用 autoconf 工具生成配置文件
查看配置选项
./configure --help
配置软件的安装路径
./configure --prefix=/opt/git
编译、安装
make
make install
检查安装是否正确
git --version
如果出现以下错误
bash: /usr/bin/git: 没有那个文件或目录
原因:没有配置git的PATH路径
解决:
vim /etc/profile.d/git.sh
写入:
GIT_HOME=/opt/git
PATH=$PATH:$GIT_HOME/bin
export PATH
重新加载系统环境变量
source /etc/profile
再次检查
git --version
Git仓库管理
git管理员
adduser git
秘钥管理
切换到git用户,跳转到用户根目录
su git
cd ~
到git用户目录创建.ssh目录
在.ssh目录下创建
authorized_keys 文件
mkdir -p .ssh/
authorized_keys
向
authorized_keys文件中添加ssh公钥
创建裸仓库
如果在访问的时候出现以下错误:
可能的解决方案:
修改 .ssh 目录权限
chmod 700 .ssh
修改 .ssh/ authorized_keys 权限
chmod 600 .ssh/
authorized_keys
修改仓库所有者,和访问权限
chown -R git:git repo/
chmod 700 repo/
参考: http://h2appy.blog.51cto.com/609721/1112797
GitLab
下载、
安装、配置
下载地址: https://packages.gitlab.com/gitlab/gitlab-ce
根据自己的Linux型号选择
GitLab 安装
确认已经安装了 openssh, postfix, cronie
rpm -qa | grep openssh
rpm -qa | grep postfix
rpm -qa | grep cronie
如果没有安装执行下列命令安装
yum -y
install openssh postfix cronie
开启必要的服务
service postfix start
chkconfig postfix on
lokkit -s http -s ssh
安装Gitlab
配置GitLab
启动GitLab
gitlab-ctl reconfigure
初始用户名/密码:root / 5iveL!fe
Subversion 安装
1. 卸载系统自带的Subversion
查看是否安装了Subversion
rpm -qa |grep subversion
我这里已经安装了最新的1.8版本,如果没安装过,显示的是 subversion- 1.6.11-15.el6_7
卸载自带的Subversion
yum -y remove subversion
2. 添加Subversion仓库
在目录 /etc/yum.repos.d 下添加 wandisco-svn.repo 仓库,内容如下:
[WandiscoSVN]
name=Wandisco SVN Repo
baseurl=http://opensource.wandisco.com/centos/$releasever/svn-1.8/RPMS/$basearch/
enabled=1
gpgcheck=0
这里指定的是最新的1.8版本,如果需要安装1.9版本,把1.8改成1.9即可
3. 安装Subversion
yum -y install subversion mod_dav_svn
查看是否安装成功
svn --version
4. 与Apache整合
到目录 /etc/httpd/conf.d
下配置 subversion.conf,内容如下:
# WANdisco Subversion Configuration
# For more information on HTTPD configuration options for Subversion please see:
# http://svnbook.red-bean.com/nightly/en/svn.serverconfig.httpd.html
# Please remember that when using webdav HTTPD needs read and write access your repositories.
# Needed to do Subversion Apache server.
LoadModule dav_svn_module modules/mod_dav_svn.so
# Only needed if you decide to do "per-directory" access control.
LoadModule authz_svn_module modules/mod_authz_svn.so
<Location /svn>
DAV svn
# SVNPath /var/www/svn/repos
SVNListParentPath on
SVNParentPath /var/www/svn/repos
AuthType Basic
AuthName "Subversion repos"
# AuthUserFile /etc/svn-auth-conf
AuthUserFile /etc/httpd/svnconf/svn-auth-conf
# AuthzSVNAccessFile /etc/svn-acl-conf
AuthzSVNAccessFile /etc/httpd/svnconf/svn-acl-conf
Require valid-user
</Location>
到目录 /var/www/ 目录下创建svn仓库
cd /var/www/
mkdir -p svn/repos
cd svn/repos
svnadmin create codes
chown -R apache.apache codes
到目录
/etc/httpd/ 目录下配置Subversion认证(auth)和访问控制列表(access control list)
cd
/etc/httpd/
mkdir svnconf
cd svnconf
创建Subversion用户
htpasswd -cbm svn-auth-conf username password
如果不存在 svn-auth-conf 文件需要使用 htpasswd -c 参数来创建用户
如果存在去掉 -c 参数了,不然每次都会创建新的文件
访问控制配置
vim svn-acl-conf
[groups]
admin = admin
develop = zhangguangyong,zhangguangxi,lufen
[/]
@admin = rw
* = r
[repo1:/]
@develop = rw
[repo2:/]
zhangguangyong = rw
zhangguangxi = r
重新启动 httpd 服务
service httpd restart
浏览器访问
Sonatype Nexus 项目仓库
下载 Nexus
http://www.sonatype.org/nexus/archived/#step2top
解压到安装目录
配置环境变量
cat /etc/profile.d/nexus.sh
RUN_AS_USER=root
NEXUS_HOME=/opt/nexus/nexus-2.11.4-01
PATH=$PATH:$NEXUS_HOME/bin
export PATH NEXUS_HOME
source /etc/profile
启动Nexus
nexus start
http://192.168.1.100:8081/nexus
来自为知笔记(Wiz)