0%

Nginx

https://nginx.org/en/docs/install.html
https://www.runoob.com/linux/nginx-install-setup.html

sudo yum install yum-utils

vim /etc/yum.repos.d/nginx.repo

[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
sudo yum-config-manager --enable nginx-mainline
sudo yum install nginx

Jdk

# 卸载自带的jdk
rpm -qa | grep java | xargs rpm -e --nodeps

# 安装openjdk相关的所有应用包
yum install java-1.8.0-openjdk* -y

# 安装完成后,安装目录在/usr/lib/jvm

Git

https://git-scm.com/download/linux

yum install git

yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker -y

wget https://github.com/git/git/archive/refs/tags/v2.31.1.tar.gz
(get releases version from https://github.com/git/git/releases)

tar zxvf git-2.9.2.tar.gz
cd git-2.9.2
make prefix=/usr/local/git
make prefix=/usr/local/git install

Python3

https://www.python.org/downloads/

#!/bin/bash

yum -y install gcc make cmake zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel xz xz-devel libffi-devel

wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tar.xz

tar -xvJf  Python-3.7.2.tar.xz

mkdir /usr/local/python3

cd Python-3.7.2
/configure --prefix=/usr/local/python3 --enable-optimizations
#第一个指定安装的路径,不指定的话,安装过程中可能软件所需要的文件复制到其他不同目录,删除软件很不方便,复制软件也不方便.
#第二个可以提高python10%-20%代码运行速度.
#第三个是为了安装pip需要用到ssl,后面报错会有提到.
make && make install

ln -s /usr/local/python3/bin/python3 /usr/local/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/local/bin/pip3

python3 -V
pip3 -V

Gitlab

https://about.gitlab.com/install/

curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash

yum install gitlab-ce
vim /etc/gitlab/gitlab.rb

external_url "http://ip:port"

Docker安装Gitlab

准备好挂载的目录

mkdir -p /home/docker/gitlab/config
mkdir -p /home/docker/gitlab/log
mkdir -p /home/docker/gitlab/data

docker-compose.yml

version: "3"
services:
    gitlab:
        image: gitlab/gitlab-ce:latest
        container_name: gitlab
        restart: "always"
        privileged: true
        hostname: "192.168.56.29" # ip或域名
        environment:
            TZ: 'Asia/Shanghai'
            GITLAB_OMNIBUS_CONFIG: |
              # 域名的话就不能带端口号
              external_url 'http://192.168.56.29:8180'
              gitlab_rails['time_zone'] = 'Asia/Shanghai'
              gitlab_rails['gitlab_shell_ssh_port'] = 8222 # clone地址中ssh对应的端口号
        ports:
            - "8180:8180"
            - "8222:22"
            - "8443:443"
        volumes:
           - /home/docker/gitlab/config:/etc/gitlab
           - /home/docker/gitlab/log:/var/log/gitlab
           - /home/docker/gitlab/data:/var/opt/gitlab

Docker

https://docs.docker.com/engine/install/

安装Docker

curl -sSL https://get.daocloud.io/docker | sh

配置Docker的国内源,将以下内容保存到 /etc/docker/daemon.json

{
    "registry-mirrors": [
        "https://mirror.ccs.tencentyun.com",
        "http://registry.docker-cn.com",
        "https://docker.mirrors.ustc.edu.cn",
        "http://hub-mirror.c.163.com"
    ]
}

启动Docker

systemctl start docker

安装Docker-Compose

sudo curl -L "https://github.com/docker/compose/releases/download/1.28.6/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

sudo chmod +x /usr/local/bin/docker-compose

sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

Redis

https://redis.io/download

Docker安装Redis

mkdir -p /home/docker/redis/data

将以下内容保存到 /home/docker/redis/docker-compose.yml

version: "3"
services:
  redis:
    container_name: redis
    image: redis:latest
    environment:
      redisPwd: 123456 # 这里填redis.conf配置这里填redis配置文件中的密码
    ports:
      - 6806:6379
    restart: always
    command: /bin/bash -c "redis-server /etc/redis/redis.conf"
    volumes:
      - ./redis.conf:/etc/redis/redis.conf
      - ./healthcheck.sh:/etc/redis/healthcheck.sh
      - ./data:/data
    healthcheck:
      test: ["CMD", "/bin/bash", "/etc/redis/healthcheck.sh"]
      interval: 1m30s
      timeout: 30s
      retries: 3

将以下内容保存到 /home/docker/redis/healthcheck.sh

host="$(hostname -i || echo '127.0.0.1')"
result="$(redis-cli -h ${host} -a ${redisPwd} ping)"
if [ $result = 'PONG' ]; then
    exit 0;
else
    exit 1
fi

将以下内容保存到 /home/docker/redis/redis.conf

bind 0.0.0.0

daemonize no

pidfile /var/run/redis_6806.pid

port 6379

tcp-backlog 511

timeout 0

tcp-keepalive 0

loglevel notice

logfile ""

databases 16

save 900 1
save 300 10
save 60 10000

stop-writes-on-bgsave-error yes

rdbcompression yes
rdbchecksum yes

dbfilename dump.rdb

dir ./

slave-serve-stale-data yes
slave-read-only yes

repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no

slave-priority 100

requirepass 123456

maxmemory 1gb

appendonly yes
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no

auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-rewrite-incremental-fsync yes

lua-time-limit 5000

cluster-enabled no
cluster-config-file nodes-6379.conf
cluster-node-timeout 15000

slowlog-log-slower-than 10000
slowlog-max-len 128

latency-monitor-threshold 0
notify-keyspace-events ""

hash-max-ziplist-entries 512
hash-max-ziplist-value 64

list-max-ziplist-entries 512
list-max-ziplist-value 64

set-max-intset-entries 512

zset-max-ziplist-entries 128
zset-max-ziplist-value 64

hll-sparse-max-bytes 3000
activerehashing yes

client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60

hz 10

执行命令安装redis

cd /home/docker/redis

# 确保docker已经启动,若已经启动则忽略这条命令
systemctl restart docker

docker-compose up -d

MySQL

https://dev.mysql.com/doc/refman/5.7/en/linux-installation-yum-repo.html

Docker安装MySQL

执行命令

# mysql数据存放位置
mkdir -p /home/docker/mysql/data

# 可以将用于数据库初始化的sql文件放到这个目录下,mysql安装时会进行执行。
mkdir -p /home/docker/mysql/init

将以下内容保存到 /home/docker/mysql/docker-compose.yml

version: "3"
services:
  mysql57:
    container_name: mysql
    image: mysql:5.7
    restart: always
    ports:
      - 3306:3306
    environment:
      - TZ=Asia/Shanghai
      - MYSQL_ROOT_PASSWORD=admin # 这里填写mysql密码
    volumes:
      - ./data:/var/lib/mysql
      - ./my.cnf:/etc/mysql/mysql.conf.d/mysqld.cnf
      - ./init:/docker-entrypoint-initdb.d
      - ./healthcheck.sh:/home/healthcheck.sh
    healthcheck:
      test: ["CMD", "/bin/bash", "/home/healthcheck.sh"]
      interval: 1m30s
      timeout: 30s
      retries: 3

将以下内容保存到 /home/docker/mysql/healthcheck.sh

#!/bin/bash
result="$(service mysql status | grep 'is running')"
if [ "$result" ]; then
    exit 0;
else
    exit 1
fi

将以下内容保存到 /home/docker/mysql/my.cnf

[mysqld]
user=mysql

datadir     =   /var/lib/mysql
pid-file    =   /var/run/mysqld/mysqld.pid
socket      =   /var/run/mysqld/mysqld.sock

symbolic-links=0
default-storage-engine=INNODB
character_set_server=utf8mb4
collation-server=utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci'
default-time_zone='+8:00'
lower_case_table_names=1

[mysql]
default-character-set = utf8mb4

[mysql.server]
default-character-set = utf8mb4

[mysqld_safe]
default-character-set = utf8mb4

[client]
default-character-set = utf8mb4

执行命令

cd /home/docker/mysql

# 确保docker已经启动,若已经启动则忽略这条命令
systemctl restart docker

docker-compose up -d

docker exec -it mysql bash

# 配置mysql外部访问权限

Jenkins

https://www.jenkins.io/doc/book/installing/linux/#red-hat-centos

sudo wget -O /etc/yum.repos.d/jenkins.repo \
    https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
sudo yum upgrade
sudo yum install jenkins java-11-openjdk-devel
sudo systemctl daemon-reload
wget https://mirrors.tuna.tsinghua.edu.cn/jenkins/redhat-stable/jenkins-2.164.2-1.1.noarch.rpm
rpm -ivh jenkins-2.164.2-1.1.noarch.rpm

Docker安装Jenkins

准备好挂载的目录

mkdir -p /home/docker/jenkins/data

docker-compose.yml

version: "3"
services:
  jenkins:
    image: jenkins/jenkins:lts
    container_name: jenkins
    restart: "always"
    ports:
      - "8080:8080"
      - "50000:50000"
    environment:
      JAVA_OPTS: -Duser.timezone=Asia/Shanghai
    volumes:
      - /home/docker/jenkins/data:/var/jenkins_home
      - /var/run/docker.sock:/var/run/docker.sock
      - /usr/bin/docker:/usr/bin/docker
      - /usr/local/jdk8u292-b10:/usr/local/jdk8u292-b10 # 挂载外部jdk路径,便于在jenkins中配置
      - /usr/local/apache-maven-3.8.1:/usr/local/apache-maven-3.8.1 # 挂载外部maven路径,便于在jenkins中配置
    # privileged: true
    # user: root

Zookeeper

https://zookeeper.apache.org/doc/r3.7.0/zookeeperStarted.html

Docker安装zookeeper

执行命令

mkdir -p /home/docker/zookeeper/data/
mkdir -p /home/docker/zookeeper/logs/

将以下内容保存到 /home/docker/zookeeper/docker-compose.yml

version: "3"
services:
 zk:
   container_name: zk
   image: zookeeper:latest
   ports:
     - 2181:2181
   restart: always
   volumes:
     - ./zoo.cfg:/conf/zoo.cfg
     - ./data:/data/zookeeper/data
     - ./logs:/data/zookeeper/logs
     - ./healthcheck.sh:/home/healthcheck.sh
   healthcheck:
     test: ["CMD", "/bin/bash", "/home/healthcheck.sh"]
     interval: 1m30s
     timeout: 30s
     retries: 3

将以下内容保存到 /home/docker/zookeeper/zoo.cfg

dataLogDir=/data/zookeeper/logs
dataDir=/data/zookeeper/data
tickTime=2000
initLimit=10
syncLimit=5
clientPort=2181
standaloneEnabled=true

将以下内容保存到 /home/docker/zookeeper/healthcheck.sh

#!/bin/bash
result="$(zkServer.sh status | grep 2181)"
if [ "$result" ]; then
    exit 0;
else
    exit 1
fi

执行命令安装zookeeper

cd /home/docker/zookeeper

# 确保docker已经启动,若已经启动则忽略这条命令
systemctl restart docker

docker-compose up -d

RobbitMQ

https://www.rabbitmq.com/install-rpm.html#downloads
https://www.rabbitmq.com/which-erlang.html
https://github.com/rabbitmq/rabbitmq-server/tags
https://github.com/rabbitmq/erlang-rpm

yum install socat -y

wget https://github.com/rabbitmq/erlang-rpm/releases/download/v23.3.4.4/erlang-23.3.4.4-1.el7.x86_64.rpm
rpm -ivh erlang-23.3.4.4-1.el7.x86_64.rpm

wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.8.18/rabbitmq-server-3.8.18-1.el7.noarch.rpm
rpm -ivh rabbitmq-server-3.8.18-1.el7.noarch.rpm