Centos安装Java
- 下载
Java
,download java
wget http://download.oracle.com/otn-pub/java/jdk/8u161-b12/2f38c3b165be4555a1fa6e98c45e0808/jdk-8u161-linux-x64.tar.gz?AuthParam=1517896878_83c799462bef8ecd0ecea2b4b14dc1a8
- 解压Java压缩包到指定位置
/usr/java/jdk-8u161
mkdir -p /usr/java
tar -zvxf jdk-8u161-linux-x64.tar.gz -C /usr/java
- 写入环境变量
vi /etc/profile
//写入的内容
JAVA_HOME=/usr/java/jdk1.8.0_161
PATH=$PATH:$JAVA_HOME/bin
CLASSPATH=$JAVA_HOME/jre/lib/ext:$JAVA_HOME/lib/tools.jar
export JAVA_HOME CLASSPATH PATH
//wq!
source /etc/profile
- 验证是否安装成功
java -version
echo $JAVA_HOME
当国外的 yum 源不可用的时候,调整为阿里云的yum源
rm -rf /etc/yum.repos.d/*
wget -O /etc/yum.repos.d/Centos-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache
Centos安装 gitlab
,确保服务器硬件资源(2颗核心+4G内存),这已经是最低配了
- 安装前预备操作
//安装服务与启动sshd服务、打开防火墙
yum install -y curl policycoreutils-python openssh-server
systemctl enable sshd
systemctl start sshd
firewall-cmd --permanent --add-service=http
systemctl reload firewalld
//可选的开启邮件服务
yum install postfix
systemctl enable postfix
systemctl start postfix
- 因为国外的源需要翻墙,所以先配置清华大学的mirror
mkdir /etc/yum.repos.d/gitlab-ce.repo
//vi /etc/yum.repos.d/gitlab-ce.repo
[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0
enabled=1
//wq!
yum clean all
yum makecache
- 接下来安装
gitlab
yum install gitlab-ce
//根据配置生成运行环境
gitlab-ctl reconfigure
//启动gitlab ,查看端口号: netstat -ntlp |grep 80
gitlab-ctl start
//查看gitlab各个服务的状态啊
gitlab-ctl status
- 修改配置的地方
//位置:/etc/gitlab/gitlab.rb
gitlab-ctl reconfigure
//一般为
external_url 'http://192.168.1.106:90' 或者改为域名
- 汉化工作
gitlab网站app在目录,/opt/gitlab/embedded/service/gitlab-rails
,汉化的时候,我们只需从
gitlab 汉化版下载 去替换就好。
//git clone 下来
git clone https://gitlab.com/larryli/gitlab
//备份好原来的文件
tar -zcvf /opt/gitlab/embedded/service/gitlab-rails.tar.gz /opt/gitlab/embedded/service/gitlab-rails
//删除老文件
rm -rf /opt/gitlab/embedded/service/gitlab-rails/
//拷贝汉化文件
cp -rf gitlab/* /opt/gitlab/embedded/service/gitlab-rails/
- 可能出问题的地方
//selinux没有关闭
getenforce
vi /etc/selinux/config
调整 SELINUX=disabled
setenforce 0
//防火墙
systemctl status firewalld
systemctl stop firewalld
systemctl disable firewalld
安装 Zookeeper
- 下载 Zookeeper,进行简单配置并启动
//下载并且解压
wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/stable/zookeeper-3.4.10.tar.gz
tar -zxvf zookeeper-3.4.10.tar.gz -C /usr/
//修改Profile文件,方便执行zk命令 /etc/profile
PATH=$PATH:/usr/zookeeper-3.4.10/bin
//先写个简单配置
cd /usr/zookeeper-3.4.10/conf
mv zoo.simple.cfg zoo.cfg
//调整配置为
tickTime=2000
dataDir=/var/lib/zookeeper
clientPort=2181
//启动zookeeper
zkServer.sh start
- 测试是否启动成功
zkServer.sh status //如果出现standalone 表明单机部署成功
netstat -ntlp |grep 2181