linux部署常用软件

干弘深
2023-12-01

服务器部署

文件资源

资源链接: https://pan.baidu.com/s/1Y13mx7uzU__Qc5XDz6z6pQ 密码: i52o

jdk

配置环境变量

tar -zxvf jdk-8u171-linux-x64.tar.gz -C /usr/local/
vi /etc/profile

export JAVA_HOME=/usr/local/jdk1.8.0_171
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/
export PATH=$PATH:$JAVA_HOME/bin

source /etc/profile

tomcat

启动tomcat

cd /usr/local/apache-tomcat-9.0.33/bin/
#开启
./startup.sh
#关闭
./shutdown.sh

#如果关闭报连接失败则使用下面的方法
ps -ef|grep tomcat
kill -3 xxxxx(tomcat的pid)
./shutdown.sh
#开启远程调试
#记得开启服务器的防火墙,和安全组
cd /usr/local/apache-tomcat-9.0.33/bin/
vi catalina.sh
#在合适的位置添加,5555是调试端口
JAVA_OPTS="$JAVA_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,suspend=n,server=y,address=5555"

小tip:可以在/www创建快捷方式,便于寻找
ln -s /usr/local/apache-tomcat-9.0.33/ /www/tomcat

mysql

1. 解压创建
tar -zxvf ./mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz -C /usr/local
mv /usr/local/mysql-8.0.11-linux-glibc2.12-x86_64 /usr/local/mysql
touch /etc/my.cnf
mkdir /etc/my.cnf.d
2. 修改my.cnf文件在下方
3. 修改环境变量
vi /etc/profile
export PATH=$PATH:/usr/local/mysql/bin
source /etc/profile
4. 进入目录
cd /usr/local/mysql
5. 
	//初始化5.0
  scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
  
6.
    //初始化8.0
  ./bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql --initialize
6. cp support-files/mysql.server /etc/init.d/mysql
7. 配置开机自启:
	chkconfig mysql on
8. service mysql start
9. 使用临时密码登录mysql(密码在安装的时候会有输出)
mysql -uroot -p
10. 修改临时密码
 use mysql;
 alter user 'root'@'localhost' identified by 'yourPassword';
 update user set host = '%' where user ='root';
 alter user 'root'@'%' identified with mysql_native_password by 'yourPassword';
 flush privileges;
 
问题:
12. Failed to find valid data directory.:
	1. 创建my.cnf(文件在下面)和my.cnf.d/
	2. vi /etc/profile
	3. export PATH=$PATH:/usr/local/mysql/bin
	4. source /etc/profile
	5. 删除/usr/local/data文件夹
	6. mysqld --initialize --console
	7. chown -R mysql:mysql /usr/local/mysql
# my.cnf文件
[mysqld]
datadir=/usr/local/mysql/data
socket=/usr/local/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

#[mysqld_safe]
#log-error=/var/log/mariadb/mariadb.log
#pid-file=/var/run/mariadb/mariadb.pid
[client]
port=3306
socket=/usr/local/mysql/mysql.sock
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
# 设置初始密码
1. 使用命令: vi /etc/my.cnf

2. 在[mysqld]下添加一段代码: skip-grant-tables

3. 重启mysql服务: service mysql restart

4. 用户无密码登录: mysql -uroot -p

5. 选择mysql数据库: use mysql;

6. 刷新权限: flush privileges;

7. alter user 'root'@'localhost' identified by 'yourPassword';

8. update user set host = '%' where user ='root';

9. 退出: exit;

10: 再次进入my.cnf里删除skip-grant-tables

11. 重启mysql服务:service mysql restart
#导出数据库
mysqldump -hlocalhost -uroot -p password>/opt/xxx.sql
#导入数据库
use databaseName;
source /opt/xxx.sql
#错误一:mysql: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
解决:
	1. 查看依赖是否存在:ldd /usr/local/mysql/bin/mysql
	2. 把下载的文件(见网盘)移动:mv libtinfo.so.5 /lib/

nginx

yum -y install gcc pcre-devel zlib-devel openssl openssl-devel
tar -zxvf nginx-1.16.1.tar.gz -C /usr/local
mkdir /usr/local/nginx/logs
cd nginx-1.16.1
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
make && make install
cd nginx-1.16.1
chown -R nginx:nginx /usr/local/nginx
#测试安装成功
cd /usr/loca/nginx/
./sbin/nginx -t
#开机启动
vim /etc/rc.d/rc.local
写入:/usr/local/nginx/sbin/nginx
#配置用户
groupadd nginx
useradd -g nginx nginx
chown nginx:nginx nginx -R
vim nginx.conf
最上面写入:user nginx; 
#配置https:nginx.conf
server{
listen  443 ssl;
    server_name     xxx

    ssl_certificate /usr/local/nginx/cert/xxx.pem;
    ssl_certificate_key     /usr/local/nginx/cert/xxx.key;

    #协议优化(可选,优化https协议,增加安全性)
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
}
#转发wss(websock协议)
location /{
    proxy_pass xxxx
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}
#错误一
this statement may fall through [-Werror=implicit-fallthrough=]...
  解决:make CFLAGS='-Wno-implicit-fallthrough'
  或者在配置时使用参数:./configure --with-cc-opt=-Wno-error
#错误二
‘struct crypt_data’没有名为‘current_salt’的成员
	解决:vim src/os/unix/ngx_user.c
		把cd.current_salt[0] = ~salt[0];注释掉/* ... */
# 操作:
开启:/usr/local/nginx/sbin/nginx
重载配置文件:/usr/local/nginx/sbin/nginx -s reload
重启:/usr/local/nginx/sbin/nginx -s reopen
停止:/usr/local/nginx/sbin/nginx -s stop

小tip:可以在/www创建快捷方式,便于寻找
ln -s /usr/local/nginx/html /www/nginx

redis

windows下载前往https://github.com/dmajkic/redis/downloads

yum -y install gcc
#make disclean可以清除上一次没有安装成功遗留的废弃文件
make
#不用执行make test(耗时,要装插件)
make install
配置redis.conf中:daemonize yes	#使得开启redis-server时候是后台运行
cd /usr/local/redis-6.0.6/bin
redis-server	/usr/local/redis/redis.conf#开启redis-server
redis-cli -p 6379 #开启redis-cli

redis-benchmark	#测试redis性能
出现错误:struct redisServer‘ has no member named ‘loading‘,升级gcc
yum -y install centos-release-scl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
scl enable devtoolset-9 bash

maven

tar -xvf apache-maven-3.6.3-bin.tar -C /usr/local
vi /etc/profile
export MAVEN_HOME=/usr/local/apache-maven-3.6.1
export PATH=$MAVEN_HOME/bin:$PATH 
source /etc/profile

修改conf,文件在下方
#setting.xml
<mirrors>
   <mirror>
      <id>alimaven</id>
       <name>aliyun maven</name>
       <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
       <mirrorOf>central</mirrorOf>
   </mirror>

   <mirror>
       <id>uk</id>
       <mirrorOf>central</mirrorOf>
       <name>Human Readable Name for this Mirror.</name>
       <url>http://uk.maven.org/maven2/</url>
   </mirror>

   <mirror>
       <id>CN</id>
       <name>OSChina Central</name>
       <url>http://maven.oschina.net/content/groups/public/</url>
       <mirrorOf>central</mirrorOf>
   </mirror>

   <mirror>
       <id>nexus</id>
       <name>internal nexus repository</name>
       <!-- <url>http://192.168.1.100:8081/nexus/content/groups/public/</url>-->
       <url>http://repo.maven.apache.org/maven2</url>
       <mirrorOf>central</mirrorOf>
   </mirror>
 </mirrors>

git

yum -y install curl-devel expat-devel
mkdir /usr/local/git
tar -xvf git-2.31.0.tar -C /usr/local/git
cd /usr/local/git/git-2.31.0/
make prefix=/usr/local/git all
make prefix=/usr/local/git install
vim /etc/profile
export PATH=/usr/local/git/bin:$PATH
source /etc/profile

node

tar -xvf node-v14.16.0-linux-x64.tar.xz -C /usr/local
cd /usr/local
mv  node-v14.16.0-linux-x64 node14.16.0
groupadd node
useradd -g node node
chown node:node node14.16.0 -R
vi /etc/profile
export PATH=/usr/local/node14.16.0/bin:$PATH
source /etc/profile

jenkins

#配置本地的jdk,maven,git
#安装gitee,Publish Over SSH插件

1. 修改tomcat的Connector 8080接口添加URIEncoding="UTF-8"
<Connector port="8080" protocol="HTTP/1.1"
				connectionTimeout="20000"
				redirectPort="8443" URIEncoding="UTF-8"/>
2. 在tomcat中为jenkins创建账户tomcat-users.xml
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<user username="tomcat_user" password="123456" roles="manager-gui,manager-script,manager-jmx,manager-status"/>


zookeeper

tar -zxvf apache-zookeeper-3.6.2-bin.tar.gz -C /usr/local
cd /usr/local/apache-zookeeper-3.6.2-bin/conf
mv zoo_sample.cfg zoo_sample.cfg.bk
cp zoo_sample.cfg.bk zoo.cfg

vi zoo.cfg
dataDir=/usr/local/apache-zookeeper-3.6.2-bin/zkData
cd ../
mkdir zkData
cd zkData
touch myid
vi myid #输入唯一的id为集群做准备
#集群配置
vi zoo.cfg
#注意开放指定端口
#cluster
server.11=192.168.10.11:2888:3888
server.12=192.168.10.12:2888:3888
server.13=192.168.10.13:2888:3888
#操作
1. 开启服务:bin/zkServer.sh start
2. 查看服务:jps
3. 查看状态:bin/zkServer.sh status
4. 退出服务:bin/zkServer.sh stop

1. 开启客户端:bin/zkCli.sh
# 客户端操作
2.ls / #查看节点
3.quit #退出客户端

rabbitmq

#安装erlang
tar -zxvf opt_src_23.2.tar.gz -C /usr/local/erlang
cd /usr/local/erlang/openssl-1.0.2l
./configure --prefix=/usr/local/erlang darwin64-x86_64-cc
make
make install
vi /etc/profile
export PATH=$PATH:/usr/local/erlang/bin
source /etc/profile
#安装rabbitmq
tar -zxvf rabbitmq-server-generic-unix-3.8.12.tar.xz -C /usr/local
cd /usr/local/rabbitmq_server-3.8.12/sbin
#添加环境变量
vi /etc/profile
export PATH=$PATH:/usr/local/rabbitmq_server-3.8.12/sbin
source /etc/profile
#添加可视化插件
rabbitmq-plugins enable rabbitmq_management
rabbitmqctl start_app
#操作
cd /usr/local/rabbitmq_server-3.8.12/sbin
前台开启:
	sudo rabbitmq-server
后台开启:(后台开启需要root权限sudo )
	sudo rabbitmq-server -detached
后台关闭
	rabbitmqctl stop
查看状态
	rabbitmqctl status

nacos

#安装nacos
tar -zxvf nacos-server-1.4.1.tar.gz -C /usr/local
#对于新版本的mac bigsur因为自带了jdk所以需要自己在环境变量中配置自己的jdk才可以运行
cd /usr/local/nacos/bin
开启:
	./startup.sh
 类似资料: