美文网首页
CentOS6---软件安装随记

CentOS6---软件安装随记

作者: 珍珠林 | 来源:发表于2017-06-10 12:21 被阅读0次

    JDK


    # 查看下Linux信息
    uname -a
    # 查看是否已安装jdk
    java -version
    # 安装jdk之前先看下gcc是否已安装
    gcc
    # 安装gcc
    yum groupinstall "Developer Tools"
    # 创建下载目录
    mkdir /usr/local/download
    # 下载官方rpm包后,上传上去,window用户可用lrzsz与linux传输文件
    # 检查是否安装了lrzsz软件包
    rpm -q lrzsz
    # 如果没有安装,通过yum命令直接安装
    yum install lrzsz
    # 从Windows上传文件(根据提示输入相应的文件路径)
    rz
    # 查看一下文件权限,如果没有执行权限,需要增加执行权限
    chmod u+x jdk-8u131-linux-x64.rpm
    # 安装
    rpm -ivh jdk-8u131-linux-x64.rpm --prefix=/usr/local
    # 添加环境变量 
    vi /etc/profile
    # 输入以下内容
    export JAVA_HOME=/usr/local/jdk1.8.0_131
    export PATH=$JAVA_HOME/bin:$PATH
    export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
    # 让修改即可生效
    source /etc/profile
    # 验证是否安装成功
    java -version
    

    GitLab


    # 在 Centos 6 和 7 系统上, 下面的命令将在系统防火墙里面开放HTTP和SSH端口
    sudo yum install curl openssh-server openssh-clients postfix cronie
    sudo service postfix start
    sudo chkconfig postfix on
    sudo lokkit -s http -s ssh
    # 下载rpm包
    wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6/gitlab-ce-9.2.5-ce.0.el6.x86_64.rpm
    # 增加可执行权限
    chmod u+x gitlab-ce-9.2.5-ce.0.el6.x86_64.rpm
    # 安装
    rpm -i gitlab-ce-9.2.5-ce.0.el6.x86_64.rpm
    # 修改/etc/gitlab/gitlab.rb
    vi /etc/gitlab/gitlab.rb
    # 把external_url改成自己的ip
    external_url  'http://git.example.com'
    # 加载配置并启动
    gitlab-ctl reconfigure
    # 查看安装完成后程序运行情况
    gitlab-ctl status
    
    # 服务打开
    sudo gitlab-ctl start
    # 服务关闭
    gitlab-ctl stop
    # 服务重启
    gitlab-ctl restart
    

    Nexus


    # 创建nexus软件目录
    mkdir /usr/local/nexus
    # 下载并上传到服务器后,解压
    tar -zxvf nexus-2.12.0-01-bundle.tar.gz -C /usr/local/nexus
    # 添加用户组
    groupadd nexus
    # 添加用户
    useradd nexus -g nexus -d /usr/local/nexus -s /bin/sh
    # 修改nexus用户密码
    passwd nexus
    # 修改归属
    chown -R nexus: /usr/local/nexus/
    # 修改nexus启动用户
    vi /usr/local/nexus/nexus-2.12.0-01/bin/nexus
    RUN_AS_USER=nexus
    # 切到nexus用户
    su nexus
    # 启动nexus
    ./nexus start
    # 默认登录账号admin admin123
    # 手动下载索引
    http://repo.maven.apache.org/maven2/.index/
    nexus-maven-repository-index.gz
    nexus-maven-repository-index.properties
    indexer-cli-5.1.1.jar
    # 将以上文件放在同一个目录,执行命令解压
    java -jar indexer-cli-5.1.1.jar -u nexus-maven-repository-index.gz -d indexer
    # 将解压后的indexer内文件拷贝到
    {nexus-home}/sonatype-work/nexus/indexer/central-ctx
    # 重启nexus
    

    Maven


    # 下载Maven
    wget http://mirror.bit.edu.cn/apache/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.tar.gz
    # 解压
    tar -zxvf apache-maven-3.5.0-bin.tar.gz -C /usr/local
    # 添加环境变量 
    vi /etc/profile
    # 输入以下内容
    export M2_HOME=/usr/local/apache-maven-3.5.0
    export PATH=$PATH:$JAVA_HOME/bin:$M2_HOME/bin
    # 让修改即可生效
    source /etc/profile
    # 验证是否安装成功
    mvn -v
    

    Git


    # 安装编译git时需要的包
    yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
    yum install  gcc perl-ExtUtils-MakeMaker
    # 下载git源码
    wget https://www.kernel.org/pub/software/scm/git/git-2.9.4.tar.gz
    # 解压
    tar -zxvf git-2.9.4.tar.gz
    # 编译安装
    cd git-2.9.4
    mkdir /usr/local/git
    ./configure --prefix=/usr/local/git
    make clean
    make
    make install
    # 添加环境变量
    vi /etc/profile
    # 输入一下内容
    export PATH=$PATH:/usr/local/git/bin
    # 让修改即可生效
    source /etc/profile
    # 检查
    git --version
    

    Jenkins


    # 下载jenkins
    wget https://pkg.jenkins.io/redhat-stable/jenkins-2.7.4-1.1.noarch.rpm
    # 安装(默认安装在/var/lib下)
    rpm -ivh jenkins-2.7.4-1.1.noarch.rpm
    # 修改端口
    vi /etc/sysconfig/jenkins
    JENKINS_PORT="9999"
    # 重启jenkins
    service jenkins restart
    

    首次访问将会在/var/lib/jenkins/secrets/initialAdminPassword密码文件,登录后可以设置首个用户账号和密码

    MySql


    # 查看mysql是否安装了
    rpm -qa | grep mysql
    # 卸载mysql
    yum -y remove mysql-libs-5.1.73-7.el6.x86_64
    # 下载mysql
    # 测试是否可以被安装
    rpm -ivh mysql57-community-release-el6-11.noarch.rpm --test
    # 安装mysql
    rpm -ivh mysql57-community-release-el6-11.noarch.rpm
    yum install mysql-server –y
    # 初始化mysql数据库
    service mysqld start
    # 查看是否开机启动
    chkconfig --list | grep mysqld
    # 设置开机启动
    chkconfig mysqld on
    # 相关目录
    /usr/bin/mysql
    /usr/lib64/mysql
    /etc/my.cnf 
    /var/lib/mysql
    /var/log/mysqld.log
    /var/run/mysqld/mysqld.pid
    # 修改密码
    /etc/init.d/mysqld stop或者service mysqld stop
    mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
    mysql -u root mysql
    mysql> UPDATE user SET authentication_string=PASSWORD('Passwd#1986') where USER='root';
    mysql> FLUSH PRIVILEGES;
    mysql> quit
    service mysqld restart
    mysql -uroot -p
    # 允许远程登录
    mysql> use mysql;
    mysql> update user set host = '%' where user = 'root';
    mysql> select host, user from user;
    mysql> FLUSH PRIVILEGES;
    # 如果远程还连不上。可能是防火墙的原因
    # 查看防火墙信息
    /etc/init.d/iptables status
    #如果防火墙是开着的,让防火墙开放3306
    /sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
    #重启防火墙以便改动生效
    /etc/init.d/iptables restart
    #将更改进行保存
    /etc/rc.d/init.d/iptables save
    # 如果远程还是连不上,再按下面的试试
    vi /etc/my.cnf
    [mysqld]
    port=3306
    bind-address=0.0.0.0
    # 重启mysql服务
    service mysqld restart
    # 查看字符集
    show VARIABLES like 'collation_%';
    show VARIABLES like 'character_set_%';
    # 修改字符集
    vi /etc/my.cnf
    # 增加以下内容
    [mysqld]
    character-set-server=utf8mb4
    collation-server=utf8mb4_general_ci
    [mysql]
    default-character-set=utf8
    [mysql.server]
    default-character-set=utf8
    [mysqld-safe]
    default-character-set=utf8
    [client]
    default-character-set=utf8
    

    MyCat


    # 下载Mycat安装包
    wget https://github.com/MyCATApache/Mycat-download/blob/master/1.6-RELEASE/Mycat-server-1.6-RELEASE-20161028204710-linux.tar.gz
    # 解压
    tar -zxvf Mycat-server-1.6-RELEASE-20161028204710-linux.tar.gz -C /usr/local
    # 修改环境变量
    vi /etc/profile
    # 在某位增加
    export MYCAT_HOME=/usr/local/mycat
    export PATH=原有内容:$MYCAT_HOME/bin
    # 让修改立即生效
    source /etc/profile
    # mysql修改my.cnf忽略大小写
    [mysqld]
    lower_case_table_names=1
    # mycat指定字符集
    vi /usr/local/mycat/conf/server.xml
    在system标签下指定
    <property name="charset">utf8mb4</property>
    然后根据数据库端的字符集ID配置mycat的字符集序列:
    配置conf/index_to_charset.properties
    对应为字符集ID=字符集
    比如45=utf8mb4
    serverPort设置mycat的服务端口,默认为8066;
    managerPort设置mycat的管理端口,默认为9066;
    # 启动mycat
    ./mycat start
    # 内存不足
    vi wrapper.conf
    wrapper.java.additional.10=-Xmx4G  
    wrapper.java.additional.11=-Xms1G  
    改为:  
    wrapper.java.additional.10=-Xmx512M  
    wrapper.java.additional.11=-Xms64M
    # 添加本地主机名解析
    192.168.0.121 node1
    # 配置conf/server.xml
    <mycat:server xmlns:mycat="http://io.mycat/">
        
        <system>
            <property name="charset">utf8mb4</property>
            <property name="defaultSqlParser">druidparser</property>
            <property name="serverPort">8066</property>
            <property name="managerPort">9066</property>
        </system>
    
        <user name="root">
            <property name="password">123456</property>
            <property name="schemas">skynet</property>
        </user>
    
    </mycat:server>
    # 配置conf/schema.xml
    <mycat:schema xmlns:mycat="http://io.mycat/">
        
        <schema name="skynet" checkSQLschema="false" sqlMaxLimit="2000">
            <table name="skynet_org" dataNode="skynet-dn"/>
            <table name="skynet_member" dataNode="skynet-dn$0-15" rule="org-mod-long"/>
        </schema>    
    
        <dataNode name="skynet-dn" dataHost="host0" database="skynet"/>
        <dataNode name="skynet-dn$0-15" dataHost="host0" database="skynet_$0-15"/>
    
        <dataHost name="host0" maxCon="1000" minCon="10" balance="0" writeType="0" dbType="mysql" dbDriver="native">
            <heartbeat>select user()</heartbeat>
            <writeHost host="node1" url="172.16.77.246:3306" user="root" password="Passwd#1986"/>
        </dataHost>
    
    </mycat:schema>
    # 配置rule.xml
     <tableRule name="org-mod-long">
         <rule>
             <columns>org_id</columns>
             <algorithm>mod-long</algorithm>
         </rule>
     </tableRule>
    

    Nginx


    • 准备工作

    Nginx的安装依赖于以下三个包,意思就是在安装Nginx之前首先必须安装一下的三个包:
    1 SSL功能需要openssl库,下载地址:http://www.openssl.org/
    2 gzip模块需要zlib库,下载地址:http://www.zlib.net/
    3 rewrite模块需要pcre库,下载地址:http://www.pcre.org/
    Nginx的安装包:下载地址为:http://nginx.org/en/download.html
    将上面下载的几个软件全部使用Xftp上传到Linux系统中

    • 安装SSL功能需要openssl库
    tar -zxvf openssl-1.0.2l.tar.gz
    cd openssl-1.0.2l
    ./config
    make
    make install
    
    • 安装gzip模块需要zlib库
    tar -zxvf zlib-1.2.11.tar.gz
    cd zlib-1.2.11
    ./configure
    make
    make install
    
    • 安装 rewrite模块需要pcre库
    tar -zxvf pcre-8.40.tar.gz
    cd pcre-8.40
    ./configure
    make
    make install
    

    error: You need a C++ compiler for C++ support,看到这句话我们就已经猜到了应该是c++包信息,而linux中没有,那么首先安装一下这个包信息即可,安装命令为:

    yum install -y gcc gcc-c++
    

    当安装完上面的c++包之后,再次运行,发现消息已经显示安装成功了,当基于上面的东西全部安装完成之后,就需要安装Nginx了。

    • 安装Nginx
    tar -zxvf nginx-1.12.0.tar.gz
    cd nginx-1.12.0
    ./configure --prefix=/usr/local/nginx --with-pcre=../pcre-8.40/ 
    --with-zlib=../zlib-1.2.11/ --with-openssl=../openssl-1.0.2l/
    make
    make install
    
    • 检查Nginx是否安装成功
    cd /usr/local/nginx/sbin
    ./nginx -t
    # 启动nginx
    ./nginx
    # nginx默认80端口,注意防火墙要开放80端口
    
    • 设置Nginx开机启动
    vi /etc/init.d/nginx
    chmod 755 nginx
    chkconfig --add nginx
    chkconfig nginx on
    service nginx stop
    service nginx start
    service nginx restart
    chkconfig --list nginx
    

    /etc/init.d/nginx的代码如下:

    #!/bin/bash
    # nginx Startup script for the Nginx HTTP Server
    # it is v.0.0.2 version.
    # chkconfig: - 85 15
    # description: Nginx is a high-performance web and proxy server.
    #              It has a lot of features, but it's not for everyone.
    # processname: nginx
    # pidfile: /var/run/nginx.pid
    # config: /usr/local/nginx/conf/nginx.conf
    nginxd=/usr/local/nginx/sbin/nginx
    nginx_config=/usr/local/nginx/conf/nginx.conf
    nginx_pid=/var/run/nginx.pid
    RETVAL=0
    prog="nginx"
    # Source function library.
    . /etc/rc.d/init.d/functions
    # Source networking configuration.
    . /etc/sysconfig/network
    # Check that networking is up.
    [ ${NETWORKING} = "no" ] && exit 0
    [ -x $nginxd ] || exit 0
    # Start nginx daemons functions.
    start() {
    if [ -e $nginx_pid ];then
       echo "nginx already running...."
       exit 1
    fi
       echo -n $"Starting $prog: "
       daemon $nginxd -c ${nginx_config}
       RETVAL=$?
       echo
       [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
       return $RETVAL
    }
    # Stop nginx daemons functions.
    stop() {
            echo -n $"Stopping $prog: "
            killproc $nginxd
            RETVAL=$?
            echo
            [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /var/run/nginx.pid
    }
    # reload nginx service functions.
    reload() {
        echo -n $"Reloading $prog: "
        #kill -HUP `cat ${nginx_pid}`
        killproc $nginxd -HUP
        RETVAL=$?
        echo
    }
    # See how we were called.
    case "$1" in
    start)
            start
            ;;
    stop)
            stop
            ;;
    reload)
            reload
            ;;
    restart)
            stop
            start
            ;;
    status)
            status $prog
            RETVAL=$?
            ;;
    *)
            echo $"Usage: $prog {start|stop|restart|reload|status|help}"
            exit 1
    esac
    exit $RETVAL
    

    Redis


    # 下载redis
    wget http://download.redis.io/releases/redis-3.2.9.tar.gz
    # 解压
    tar -zxvf redis-3.2.9.tar.gz
    # 编译
    cd redis-3.2.9
    make
    make install
    # 将/usr/local/bin目录加到环境变量
    export PATH=...:/usr/local/bin
    # 立即生效
    source /etc/profile
    # 创建配置文件目录,dump file 目录,进程pid目录,log目录等
    cd /etc
    mkdir redis
    # dump file、进程pid、log目录等,一般放在/var/目录下
    cd /var/
    mkdir redis
    cd redis
    mkdir data log run
    # 修改配置文件,配置参数
    # 首先拷贝解压包下的redis.conf文件至/etc/redis
    cp redis.conf /etc/redis
    # vi /etc/redis/redis.conf
    # 修改port(默认6379)
    port 6379
    # 修改pid目录为新建目录
    pidfile /var/redis/run/redis.pid
    # 修改dump目录为新建目录
    dir /var/redis/data
    # 修改log存储目录为新建目录
    logfile /var/redis/log/redis.log
    # 持久化。默认rdb,可选择是否开启aof,若开启,修改配置文件appendonly
    # 启动redis
    redis-server /etc/redis/redis.conf
    # 查看dump, log, pid等
    cd /var/redis/data
    ll
    cd /var/redis/log
    ll
    cd /var/redis/run
    # 发现只有日志,没有dump和pid信息,是因为redis服务是console模式运行的,且没有数据存储操作
    # 停止redis服务,修改配置文件使得redis在background运行
    daemonize yes
    # 重启redis服务
    redis-server /etc/redis/redis.conf
    # 服务开机自启动
    # 拷贝解压包下utils下redis启动脚本至/etc/init.d/
    cp redis_init_script /etc/init.d/
    # 修改脚本名称(也可不修改)为redis
    # 修改脚本pid及conf路径为实际路径
    REDISPORT=6379
    EXEC=/usr/local/bin/redis-server
    CLIEXEC=/usr/local/bin/redis-cli
    
    PIDFILE=/var/redis/run/redis.pid
    CONF="/etc/redis/redis.conf"
    # 生产环境下,配置时,配置文件、pid等最好加上端口标识,以便区分
    PIDFILE=/var/redis/run/redis_${REDISPORT}.pid
    CONF="/etc/redis/redis_${REDISPORT}.conf"
    # 至此,在/etc/init.d/目录下,已经可以通过service redis start/stop 命令启动和关闭redis
    # 设置自启动
    chkconfig redis on
    # 如果运行报错,提示 service redis does not support chkconfig。/etc/init.d/redis脚本加入
    # chkconfig: 2345 90 10
    #
    # description: Redis is a persistent key-value database
    # 再次执行chkconfig redis on,成功
    

    Zookeeper


    # 下载
    # wget http://mirrors.hust.edu.cn/apache/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz
    # 解压
    tar -zxvf zookeeper-3.4.10.tar.gz -C /usr/local
    cd /usr/local/zookeeper-3.4.10
    cp zoo_sample.cfg zoo_cfg
    # 创建目录
    mkdir /var/zookeeper/data
    mkdir /var/zookeeper/logs
    #  创建myid文件(内容写入1就可以)
    cd /var/zookeeper/data
    vi myid
    # 修改配置
    vi zoo_cfg
    # 调整内容
    dataDir=/var/zookeeper/data
    dataLogDir=/var/zookeeper/logs
    server.1=hostname:2888:38888
    # 配置环境变量
    export ZOOKEEPER_HOME=/usr/local/zookeeper-3.4.10
    export PATH=$ZOOKEEPER_HOME/bin:$PATH
    export PATH
    # 启动
    zkServer.sh start
    # 输入jps查看进程
    1573 QuorumPeerMain
    1654 Jps
    # QuorumPeerMain是zookeeper进程,启动正常
    # 查看状态
    zkServer.sh status
    # 启动客户端脚本
    zkCli.sh -server ip:2181
    # 停止zookeeper
    zkServer.sh stop
    

    dubbo-admin-2.5.4(要求jdk7。jdk8启动dubbo-admin会出错)


    # 先要安装tomcat
    # 下载tomcat7
    wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-7/v7.0.78/bin/apache-tomcat-7.0.78.tar.gz
    # 解压
    tar -zxvf apache-tomcat-7.0.78.tar.gz -C /usr/local
    # 如果tomcat的默认8080端口已被其他程序占用,可以在/conf/server.xml里修改为其他端口
    # 配置tomcat管理员账号,在/conf/tomcat-users.xml下配置:
    <role rolename="manager-gui"/>
    <role rolename="manager-script"/>
    <role rolename="manager-jmx"/>
    <role rolename="manager-status"/>
    <user username="admin" password="admin123" 
        roles="manager-gui,manager-script,manager-jmx,manager-status"/>
    # 部署dubbo-admin
    # 进入tomcat的webapps目录
    cd webapps
    # 上传dubbo-admin-2.5.4-SNAPSHOT.war
    # 启动tomcat
    cd ..
    cd bin
    ./startup.sh
    # 访问dubbo控制台
    http://localhost:8080/dubbo-admin-2.5.4-SNAPSHOT/
    

    相关文章

      网友评论

          本文标题:CentOS6---软件安装随记

          本文链接:https://www.haomeiwen.com/subject/shbxqxtx.html