• linux中常见服务端安装


    linux安装服务脚本
    1、yum安装
    # 通过apt安装yum
    apt install yum
    # yum安装软件
    yum install pam-devel
    # yum 卸载
    yum remove pam-devel
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    2、rpm安装
    # 安装
    rpm -i example.rpm 		#安装 example.rpm 包;
    rpm -iv example.rpm 	#安装 example.rpm 包并在安装过程中显示正在安装的文件信息;
    rpm -ivh example.rpm 	#安装 example.rpm 包并在安装过程中显示正在安装的文件信息及安装进度
    
    # 卸载包
    rpm -e tomcat4 		#卸载 tomcat4 软件包
    
    # 查询包
    rpm -qa | grep tomcat4 	#查看 tomcat4 是否被安装;
    rpm -qip example.rpm 	#查看 example.rpm 安装包的信息;
    rpm -qif /bin/df 		#查看/bin/df 文件所在安装包的信息;
    rpm -qlf /bin/df 		#查看/bin/df 文件所在安装包中的各个文件分别被安装到哪个目录下;
    
    # 升级包
    rpm -Uvh example.rpm 	#升级 example.rpm 软件包
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16

    第一部分:常用组件安装

    1、安装jdk
    # 1、下载jdk压缩文件到/usr/local/文件下
    tar -xvf jdk-8u341-linux-x64.tar.gz
    
    # 2、修改配置环境变量
    vim /etc/profile
    # 修改后如下
    export JAVA_HOME=/opt/jdk1.8.0_341
    export PATH=$JAVA_HOME/bin:$PATH
    export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
    # 重新载入环境变量
    source /etc/profile
    
    # 测试java安装是否成功
    java -version
    ## 启动jar包
    java -jar -DSpring.profiles.active=prod xxx.jar
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    2、安装mysql
    • 下载
      • mysql-community-common-5.7.29-1.el6.x86_64.rpm
      • mysql-community-libs-5.7.29-1.el6.x86_64.rpm
      • mysql-community-client-5.7.29-1.el6.x86_64.rpm
      • mysql-community-server-5.7.29-1.el6.x86_64.rpm
    # 按照顺序安装如下文件
    rpm -ivh mysql-community-common-5.7.29-1.el6.x86_64.rpm
    rpm -ivh mysql-community-libs-5.7.29-1.el6.x86_64.rpm
    rpm -ivh mysql-community-client-5.7.29-1.el6.x86_64.rpm
    rpm -ivh mysql-community-server-5.7.29-1.el6.x86_64.rpm
    
    # 启动mysql
    service mysql start
    # 关闭mysql
    service mysql  stop 
    # 重启mysql
    service mysql restart 
    # 查看服务状态
    service mysql status
    
    # 命令行登录mysql
    mysql -uroot -p
    
    # 修改mysql的配置
    cp /usr/share/mysql/my-large.cnf /etc/my.cnf
    vi /etc/my.cnf
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    3、安装redis
    # 1、下载安装包
    wget http://download.redis.io/releases/redis-5.0.7.tar.gz
    
    #  2、解压文件并移动文件到指定位置
    tar -zvxf redis-5.0.7.tar.gz
    mv /root/redis-5.0.7 /usr/local/redis
    
    
    #  3、编译
    cd /usr/local/redis
    make 
    ## 或者指定位置编译
    make PREFIX=/usr/local/redis install
    
    # 4、启动redis
    # 后台执行的方式
    ./bin/redis-server& ./redis.conf
    # 显示执行的方式
    ./bin/redis-server ./redis.conf
    
    ## 5、检查是否安装成功,如果
    redis -cli 
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    4、安装nginx
    • 准备 nginx安装文件
    # 准备安装环境
    yum install lrzsz
    yum install gcc
    yum install -y pcre pcre-devel
    yum install -y zlib zlib-devel
    yum install -y openssl openssl-devel
    
    # 解压并安装
    tar -zxvf nginx-1.17.6.tar.gz
    ./configure --prefix=/usr/local/src/nginx-1.17.6
    make
    make install
    
    # 启动
    cd usr/local/src/nginx-1.17.6/sbin
    ps -ef|grep nginx
    
    # 开启防火墙
    service iptables stop
    chkconfig iptables off
    
    # nginx常见命令
    # 检查配置文件是否正常
    ./nginx -t 
    # 启动
    ./nginx -s start
    # 关闭
    ./nginx -s stop
    # 优雅关闭
    ./nginx -s quit
    
    
    
    
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    5、安装mongoDB
    
    
    • 1

    第二部分:分布式服务安装

    1、zookeeper安装
    • 下载zk压缩包
    # 解压
    tar -zxvf apache-zookeeper-3.7.1-bin.tar.gz
    ## 复制文件
    cp apache-zookeeper-3.7.1-bin /opt/module/zookeeper -r
    # 修改配置文件
    mv zoo_sample.cfg zoo.cfg
    # 安装zk的数据文件夹
    mkdir zkData
    # 编辑配置文件
    vim zoo.cfg
    # 启动
    ./zkServer.sh start
    # 关闭
    ./zkServer.sh stop
    
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16

    第三部分: 中间件服务安装

    1、RabbitMQ服务安装
    • 准备erlang-22.0.7-1.el7.x86_64.rpm包
    • 准备rabbitmq-server-3.7.17-1.el7.noarch.rpm包
    # 安装gcc socat环境
    yum install gcc
    yum install socat
    # 安装erlang rabbitmq服务
    rpm -ivh erlang-22.0.7-1.el7.x86_64.rpm
    rpm -ivh rabbitmq-server-3.7.17-1.el7.noarch.rpm
    
    # 开启管理界面
    rabbitmq-plugins enable rabbitmq_management
    
    # 配置远程可使用guest登录mq
    cd /usr/share/doc/rabbitmq-server-3.7.17
    cp rabbitmq.config.example  /etc/rabbitmq/rabbitmq.config
    
    # 修改配置文件,放开loopback_users
    vi /etc/rabbitmq/rabbitmq.config
    
    
    # centos6用这个命令:
    /sbin/service rabbitmq-server restart
    
    # centos7用这个命令:
    systemctl start rabbitmq-server
    
    ## 安装后验证
    # 访问 http://ip地址:15672  自带用户名密码guest/guest
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26

    第四部分:运维工具安装

    1、maven安装

    前提:下载maven压缩包,准备好Maven的安装位置

    # 解压maven压缩包
    tar -zxvf apache-maven-3.6.3-bin.tar.gz
    # 创建目录
    cd apache-maven-3.6.3   #进入apache-maven-3.6.3目录
    mkdir ck    #创建ck目录
    # 找到并修改setting配置文件,例如加入ali仓库
    cd conf            # 进入conf目录
    vi settings.xm # settings.xm文件
    # 设置环境变量
    vi /etc/profile
    # maven环境变量设置
    export MAVEN_HOME=/usr/local/apache-maven-3.6.3
    export PATH=$PATH:$MAVEN_HOME/bin
    # 环境变量生效
    source /etc/profile
    # 检查maven是否安装成功
    mvn -v
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    2、安装gitlab
    
    # 方式一:yum方式
    # 关闭防火墙
    systemctl status firewalld.service
    
    # 配置Yum资源
    vim /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
    # 更新本地缓存
    yum makecache
    
    #自动安装最新版本并安装相关依赖
    yum install gitlab-ce 
    
    # 方式二:rpm方式
    #下载最新版本
    wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-15.2.0-ce.0.el7.x86_64.rpm --no-check-certificate
    #使用rpm安装需要手动解决依赖问题
    #前置条件依赖policycoreutils-python、openssh-server设置开机自启
    yum -y install policycoreutils-python openssh-server
    systemctl enable sshd
    systemctl start sshd
     
    #还缺啥安装时会有提示,缺啥安装啥就行
    rpm -Uvh gitlab-ce-15.2.0-ce.0.el7.x86_64.rpm
     
    #安装成功后启动
    gitlab-ctl reconfigure
     
    gitlab-ctl restart
    
    # 更改配置参数
        gitlab组件日志路径:/var/log/gitlab
        gitlab配置路径:/etc/gitlab/  路径下有gitlab.rb配置文件
        应用代码和组件依赖程序:/opt/gitlab
        各个组件存储路径: /var/opt/gitlab/
        仓库默认存储路径   /var/opt/gitlab/git-data/repositories
        版本文件备份路径:/var/opt/gitlab/backups/
        nginx安装路径:/var/opt/gitlab/nginx/
        redis安装路径:/var/opt/gitlab/redis
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    1、nacos服务端安装
    • 前提:已安装java和mven
    wget https://github.com/alibaba/nacos/releases/download/2.0.1/nacos-server-2.0.1.tar.gz
    # 解压ncaos压缩包
    tar -zxvf nacos-server-1.3.2.tar.gz
    # 移动解压包
    mv nacos /usr/local/
    
    # 修改nacos的配置文件
    cd nacos文件位置
    vim application.properties
        ### 修改使用mysql数据库
        server.servlet.contextPath=/nacos
        spring.datasource.platform=mysql
        server.port=9001
        # 修改数据库连接地址
        db.num=1
        db.url.0=jdbc:mysql://mysql.xxx.tech:3306/nacos_prod?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
        db.user.0=nacos
        db.password.0=nacos
    
    
    
    # 启动nacos服务
    cd usr/local/nacos-2.0.2/distribution/bin 
    sh startup.sh -m standalone
    # 关闭Nacos服务
    sh shutdown.sh
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    2、Sentinel服务端安装
    # 下载
    wget https://github.com/alibaba/Sentinel/releases/download/1.8.1/sentinel-dashboard-1.8.1.jar
    # 执行
    java -jar sentinel-dashboard-1.8.1.jar
    
    • 1
    • 2
    • 3
    • 4
    3、Apollo服务端安装
    4、安装seata服务端
    5、安装fastDFS服务端
    6、安装minio服务端

    参考:

    • Nacos安装
      https://blog.csdn.net/m0_72838865/article/details/127101277

    参考:

    • 1、JDK安装
      https://blog.csdn.net/qq_41694906/article/details/126372085
    • 2、mysql安装
      http://c.biancheng.net/view/7616.html
    • Maven安装
      https://blog.csdn.net/mmc173168/article/details/125539756
    • RabbitMQ安装
      https://www.cnblogs.com/tangliping/p/14800943.html
    • gitlab安装
      https://blog.csdn.net/weixin_38489509/article/details/126034654
    # 下载地址
    wget https://github.com/prometheus/prometheus/releases/
    # 解压
    tar xzf prometheus-2.24.1.linux-amd64.tar.gz -C /usr/local/
    # 创建软链接
    ln -s /usr/local/prometheus-2.24.1.linux-amd64/ /usr/local/prometheus
    
    # 切换到目录下,并修改配置
    cd /usr/local/prometheus
    vi prometheus.yaml
    
    # 启动
    ./prometheus --config.file=prometheus.yml
    
    # 检查是否安装成功
    http:127.0.0.1:9090 查看status->target页面
    
    
    # 下载node_expore,用于节点容器监控
    wget https://github.com/prometheus/node_exporter/releases
    # 解压
    tar xzf node_exporter-1.0.1.linux-amd64.tar.gz -C /usr/local/
    # 启动
    nohup /usr/local/node_exporter-1.0.1.linux-amd64/node_exporter &
    
    # 下载mysqld_exporter
    wget  https://github.com/prometheus/mysqld_exporter/releases
    
    # 解压
    tar xzf mysqld_exporter-0.12.1.linux-amd64.tar.gz -C /usr/local/
    
    # 安装grafana
    # 下载
    wget https://mirrors.tuna.tsinghua.edu.cn/grafana/yum/rpm/
    # 安装
    yum -y install grafana-7.3.3-1.x86_64.rpm
    # 开启服务
    systemctl start grafana-server
    # 端口验证
    netstat -nlpt|grep 3000
    # 浏览器验证
    # 访问:http://192.168.153.183:3000
    
    # 安装zabbix和clock插件
    cd /var/lib/grafana/plugins/
    
    grafana-cli plugins install alexanderzobnin-zabbix-app
    grafana-cli plugins install grafana-clock-panel
    # 重启服务
    systemctl restart grafana-server
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • Mysql给mysqld_exporter授权
    GRANT REPLICATION CLIENT,PROCESS ON *.* TO 'mysql_monitor'@'localhost' identified by 'mysql_monitor';
    GRANT SELECT ON *.* TO 'mysql_monitor'@'localhost';
    
    • 1
    • 2
    • 修改my.cnf
    vim /usr/local/mysqld_exporter-0.12.1.linux-amd64/.my.cnf
    # 修改:
    [client]
    user=mysql_monitor
    password=mysql_monitor
    
    • 1
    • 2
    • 3
    • 4
    • 5
    配置修改
    scrape_configs:
     # The job name is added as a label `job=` to any timeseries scraped from this config.
     - job_name: 'prometheus'
     
     # metrics_path defaults to '/metrics'
     # scheme defaults to 'http'.
     
     static_configs:
     - targets: ['localhost:9090']
     #监控Linux主机状态
     - job_name: 'linux'
     static_configs:
     - targets: ['192.168.153.138:9100']
     #监控mysql服务状态
     - job_name: 'mysql'
     static_configs:
     - targets: ['192.168.153.138:9104']
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17

    https://www.jb51.net/article/204659.htm
    https://www.jb51.net/article/204660.htm
    https://www.jb51.net/article/107386.htm
    https://www.jb51.net/article/103663.htm
    https://www.jb51.net/article/230006.htm

  • 相关阅读:
    ABAP读取销售订单选配BOM函数-CS_BOM_EXPL_KND_V1
    【校招VIP】前端算法考点之智力分析
    EasyEdit: An Easy-to-use Knowledge Editing Framework for Large Language Models
    linux服务器内服务访问域名Name or service not know
    算法训练营day22
    运维:k8s常用命令大全
    走进苏州的开源创新之旅:开放原子开源大赛苏州站系列活动启幕
    【Hadoop】Hadoop 高频面试题英语版(1)
    南大通用GBase 8a MPP Cluster大规模并行计算技术介绍
    metaRTC+mbedtls实现android平台上更高效的webrtc
  • 原文地址:https://blog.csdn.net/QingChunBuSanChang/article/details/132729755