前言
阅读本文的注意事项:
\color{orange}{阅读本文的注意事项:}
阅读本文的注意事项:
请自行辨别每个命令的作用,如果不清楚命令的含义,请不要执行
\color{red}{请自行辨别每个命令的作用,如果不清楚命令的含义,请不要执行}
请自行辨别每个命令的作用,如果不清楚命令的含义,请不要执行
操作环境
- 环境:华为云服务器
- 系统:CentOS Linux release 7.9.2009 (Core)
- 内核:Linux slave_1 3.10.0-1160.71.1.el7.x86_64 #1 SMP Tue Jun 28 15:37:28 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
修改主机名
hostnamectl --static set-hostname manager
检查系统更新,并更新
yum check-update && yum update
防火墙管理
systemctl status firewalld
systemctl start firewalld
firewall-cmd --list-ports
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --remove-port=80/tcp --permanent
firewall-cmd --reload
磁盘挂载
fdisk -l
df -lh
mkfs -t ext4 /dev/vdb
mount /dev/vdb /mnt/data
tee -a /etc/fstab <<-'EOF'
/dev/vdb /mnt/data ext4 defaults 0 0
EOF
nfs 磁盘映射
yum install nfs-utils rpcbind -y
tee /etc/exports <<-'EOF'
/mnt/data/gitdata/upload 192.168.0.49(rw,sync,no_root_squash)
/mnt/data/gitdata/logsPrd 192.168.0.49(rw,sync,no_root_squash)
EOF
exportfs -ar
service rpcbind start
service nfs start
mount -t nfs 192.168.0.49:/mnt/data/gitdata/upload /mnt/data/gitdata/upload
mount -t nfs 192.168.0.49:/mnt/data/gitdata/logsPrd /mnt/data/gitdata/logsPrd
tee -a /etc/fstab <<-'EOF'
192.168.0.49:/mnt/data/gitdata/upload /mnt/data/gitdata/upload ext4 defaults 0 0
nfs 192.168.0.49:/mnt/data/gitdata/logsPrd /mnt/data/gitdata/logsPrd ext4 defaults 0 0
EOF
常用工具软件包的安装
yum install vim bash-completion net-tools gcc gcc-c++ NetworkManager* pcre pcre-devel zlib zlib-devel openssl openssl-devel zip libcurl autoconf automake libtool m4 libpng-dev make file nasm -y
docker 安装及部分配置
yum -y erase podman buildah
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum -y install docker-ce
mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
"insecure-registries": ["192.168.0.49:15000"],
"registry-mirrors": ["https://fl791z1h.mirror.aliyuncs.com/"],
"hosts": ["tcp://0.0.0.0:2375","unix:///var/run/docker.sock"],
"log-driver":"json-file",
"log-opts": {"max-size":"10m", "max-file":"1"},
"dns" : [
"114.114.114.114",
"8.8.8.8"
]
}
EOF
vim /usr/lib/systemd/system/docker.service
systemctl daemon-reload && systemctl restart docker
docker swarm 集群初始化和节点加入
docker swarm init
docker swarm join-token worker
docker swarm join-token manager
docker swarm join-token --rotate worker
docker swarm join-token -q worker
docker service list
docker node ls
docker registry 镜像仓库安装
docker service create --replicas 1 --name registry --mount type=bind,src=/mnt/data/dockerRegistry,dst=/var/lib/registry --constraint node.hostname==manager --publish 15000:5000 registry:latest
curl http://127.0.0.1:15000/v2/_catalog
jdk 安装及环境变量的配置
yum -y remove java-*
cd /data/soft
rpm -ivh jdk-11.0.15_linux-x64_bin.rpm
tee /etc/profile.d/java.sh <<-'EOF'
JAVA_HOME=/usr/java/jdk-11.0.15/
CLASSPATH=%JAVA_HOME%/lib:%JAVA_HOME%/jre/lib
PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin
export PATH CLASSPATH JAVA_HOME
EOF
source /etc/profile.d/java.sh
maven 安装及环境变量的配置
wget -c https://dlcdn.apache.org/maven/maven-3/3.8.5/binaries/apache-maven-3.8.5-bin.zip
unzip -d /usr/maven apache-maven-3.8.5-bin.zip
tee /etc/profile.d/maven.sh <<-'EOF'
export MAVEN_HOME=/usr/maven/apache-maven-3.8.5
export PATH=$PATH:$MAVEN_HOME/bin
EOF
source /etc/profile.d/maven.sh
nginx 源码安装
wget -c https://nginx.org/download/nginx-1.22.0.tar.gz
tar -zxvf nginx-1.22.0.tar.gz
cd nginx-1.22.0
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_gzip_static_module
make
make install
nodejs 安装
wget -c https://npmmirror.com/mirrors/node/v14.18.3/node-v14.18.3-linux-x64.tar.gz
tar --strip-components 1 -xzvf node-v14.18.3-linux-x64.tar.gz -C /usr/local
npm config set registry=https://registry.npm.taobao.org
npm install -g cnpm --registry=https://registry.npm.taobao.org
redis 源码安装
wget -c https://download.redis.io/redis-stable.tar.gz
tar -xzvf -C /usr/local redis-stable.tar.gz
cd redis-stable
make && make install PREFIX=/usr/local/redis
postgresql 安装
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
sudo yum install -y postgresql14-server
sudo /usr/pgsql-14/bin/postgresql-14-setup initdb
sudo systemctl enable postgresql-14
sudo systemctl start postgresql-14
mongoDB 安装
wget -c https://repo.mongodb.org/yum/redhat/7/mongodb-org/5.0/x86_64/RPMS/mongodb-org-server-5.0.9-1.el7.x86_64.rpm
rpm -ivh mongodb-org-server-5.0.9-1.el7.x86_64.rpm
wget -c https://downloads.mongodb.com/compass/mongodb-mongosh-1.5.0.x86_64.rpm
rpm -ivh mongodb-mongosh-1.5.0.x86_64.rpm
systemctl start mongod
nacos 源码安装
git clone https://gitee.com/mirrors/Nacos.git
cd Nacos
mvn -Prelease-nacos -Dmaven.test.skip=true clean install -U
cp distribution/target/nacos-server-2.1.0/nacos /usr/local/nacos-server-2.1.0
cd /usr/local/nacos-server-2.1.0/bin
sh startup.sh -m standalone
ES 安装
sysctl -w vm.max_map_count=262144
groupadd elsearch
useradd elsearch -g elsearch -p elsearch
su - elsearch
cd ~
curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.15.2-linux-x86_64.tar.gz
tar -xvf elasticsearch-7.15.2-linux-x86_64.tar.gz
cd elasticsearch-7.15.2/bin
./elasticsearch -d
rabbitmq 安装
tee /etc/yum.repos.d/erlang_solutions.repo <<-'EOF'
[erlang-solutions]
name=Centos $releasever - $basearch - Erlang Solutions
baseurl=http://packages.erlang-solutions.com/rpm/centos/$releasever/$basearch
gpgcheck=1
gpgkey=http://packages.erlang-solutions.com/debian/erlang_solutions.asc
enabled=1
EOF
yum update
wget -c https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.10.5/rabbitmq-server-3.10.5-1.el8.noarch.rpm
yum install -y rabbitmq-server-3.10.5-1.el8.noarch.rpm
rabbitmq-server -detached
rabbitmq-plugins enable rabbitmq_management
rabbitmqctl add_user admin 123456
rabbitmqctl set_user_tags admin administrator
gitlab-runner 安装与卸载
curl -L "https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh" | sudo bash
yum install gitlab-runner
gitlab-runner register
gitlab-runner start
gitlab-runner uninstall
gitlab-runner install --working-directory /home/gitlab-runner --user root
service gitlab-runner restart
gitlab-runner status
gitlab-runner run
gitlab-runner list
gitlab-runner verify --delete
rm -rf /etc/gitlab-runner
rm -rf /usr/local/bin/gitlab-runner
rm -rf /usr/bin/gitlab-runner
rm -rf /etc/sudoers.d/gitlab-runner
userdel -r gitlab-runner
git 安装与升级
git --version
yum install http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-2.noarch.rpm
yum install git
yum update git
设置欢迎语
tee /etc/motd <<-'EOF'
*--------------------------------------------------------------------------------------------------------------*
*
* 欢迎登录华为云服务器
* IP:
* 软件: docker, nginx, redis, rabbitmq, rabbitmq managemnent
* 运行容器:
*
*--------------------------------------------------------------------------------------------------------------*
EOF
|