arm架构下open euler安装nginx mysql tomcat docker opengauss
nginx 安装必要工具
yum install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel
下载源码并解压到任意目录,如 /root/nginx
,不要将源文件放到 /usr/local/nginx
下,除非你指定输出目录,编译时会自动在 /usr/local/nginx
创建目录, 配置和编译软件并添加 SSL module
1 2 3 4 5 6 ./configure --with-http_ssl_module --with-http_gzip_static_module make make install./configure --user=www --group=www --with-http_ssl_module --with-http_gzip_static_module
添加环境变量。
1 2 3 nano /etc/profile export PATH =$PATH :/usr/local/nginx/sbin source /etc/profile
创建 nginx 系统服务
创建 nginx.service
文件并添加如下内容
nano /lib/systemd/system/nginx.service
1 2 3 4 5 6 7 8 9 10 11 12 13 [Unit] Description =nginx serviceAfter =network.target[Service] Type =forkingExecStart =/usr/local/nginx/sbin/nginx //nginx的可执行路径,依据实际情况修改ExecReload =/usr/local/nginx/sbin/nginx -s reloadExecStop =/usr/local/nginx/sbin/nginx -s stopPrivateTmp =true [Install] WantedBy =multi-user.target
开机自启动
systemctl enable nginx
mysql 注意:MYSQL8.0 开始才支持 arm 架构,我们可以去第三方下载编译好的安装包,或者可以采取 docker 安装
系统自带 mariadb 和 mysql 冲突,请先卸载 mariadb
yum remove mariadb-server
以下步骤采用华为镜像站编译好的 mysql 5.7.27 arm 版本,下载链接 。
关闭 SELINUX
编辑 nano /etc/sysconfig/selinux
将 SELINUX=enforcing
改为 SELINUX=disabled
创建 mysql 用户和组
mysql 用户不能登录系统选项,不创建用户的主目录。
groupadd -r mysql && useradd -r -g mysql -s /sbin/nologin -M mysql
安装必要依赖
yum install gcc gcc-c++ ncurses-devel bison cmake openssl-devel libtirpc-devel libaio-devel
下载 Mysql 文件
下载链接
解压到 /usr/local/mysql
创建 mysql 配置文件软链接
ln -sf /usr/local/mysql/my.cnf /etc/my.cnf
覆盖依赖包
1 2 3 cp -rf /usr/local/mysql/extra/lib /usr/lib64/mv /usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6.oldln -s /usr/lib64/libstdc++.so.6.0.24 /usr/lib64/libstdc++.so.6
备份并按需修改 Mysql 配置文件
1 2 3 cd /usr/local/mysqlcp my.cnf my.cnf .bak nano my.cnf
按实际情况修改配置文件。
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 [client] port = 3306 socket = /dev/shm/mysql.sock [mysqld] port = 3306 socket = /dev/shm/mysql.sock basedir = /user/local/mysql datadir = /user/local/mysql/data log_bin = mysql-bin pid-file = /user/local/mysql/data/mysql.pid log_error = /user/local/mysql/logs/mysql-error.log slow_query_log_file = /user/local/mysql/logs/mysql-slow.log tmpdir=/user/local/mysql/mysql_tmp user = mysql bind-address = 0.0.0.0 server-id = 1 init-connect = 'SET NAMES utf8mb4' character-set-server = utf8mb4 back_log = 300 max_connections = 1000 max_connect_errors = 6000 open_files_limit = 65535 table_open_cache = 128 max_allowed_packet = 4M binlog_cache_size = 1M max_heap_table_size = 8M tmp_table_size = 16M read_buffer_size = 2M read_rnd_buffer_size = 8M sort_buffer_size = 8M join_buffer_size = 8M key_buffer_size = 4M thread_cache_size = 8 query_cache_type = 1 query_cache_size = 8M query_cache_limit = 2M ft_min_word_len = 4 binlog_format = mixed expire_logs_days = 30 slow_query_log = 1 long_query_time = 1 performance_schema = 0 explicit_defaults_for_timestamp lower_case_table_names = 1 skip-external-locking default_storage_engine = InnoDB innodb_file_per_table = 1 innodb_open_files = 500 innodb_buffer_pool_size = 64M innodb_write_io_threads = 4 innodb_read_io_threads = 4 innodb_thread_concurrency = 0 innodb_purge_threads = 1 innodb_flush_log_at_trx_commit = 2 innodb_log_buffer_size = 2M innodb_log_file_size = 32M innodb_log_files_in_group = 3 innodb_max_dirty_pages_pct = 90 innodb_lock_wait_timeout = 120 bulk_insert_buffer_size = 8M myisam_sort_buffer_size = 8M myisam_max_sort_file_size = 10G myisam_repair_threads = 1 interactive_timeout = 28800 wait_timeout = 28800 [mysqldump] quick max_allowed_packet = 100M [myisamchk] key_buffer_size = 8M sort_buffer_size = 8M read_buffer = 4M write_buffer = 4M
创建系统服务和环境变量并设置开机自启
环境变量
1 2 3 4 nano /etc/profile export MYSQL_HOME =/usr/local/mysqlexport PATH =$PATH :$MYSQL_HOME/bin source /etc/profile #刷新环境变量
创建系统服务
cp -rf /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
开机自启
systemctl enable mysqld
无密码初始化
先启动服务
systemctl start mysqld
查看服务状态
systemctl status mysqld
如果服务没起来,参考状态里的报错信息,可能会缺少 logs 目录,在 mysql 路径下创建缺少的目录,并修改权限。
chown -R mysql:mysql /usr/local/mysql
初始化
mysqld --initialize-insecure
初始化成功后可以使用 root 用户登录并设置密码。
1 2 3 4 5 6 7 8 9 10 11 12 mysql -u root use mysql; update user set authentication_string=password("你的密码" ) where user="root" ; grant all privileges on *.* to root@'%' identified by "你的密码" ; flush privileges;exit
tomcat 下载并解压 tomcat 源文件到 /usr/local/tomcat
设置环境变量
1 2 3 4 nano /etc/profile export TOMCAT\_HOME =/usr/local/tomcatexport CATANILA\_HOME =/usr/local/tomcat source /etc/profile
创建系统服务
nano /usr/lib/systemd/system/tomcat.service
添加以下内容并按需修改
1 2 3 4 5 6 7 8 9 10 11 12 13 14 [Unit] Description =tomcatAfter =syslog.target network.target remote-fs.target nss-lookup.target[Service] Type =forkingExecStart =/usr/local/tomcat/bin/startup.sh ExecReload=/usr/local/tomcat/bin/startup.shExecStop =/usr/local/tomcat/bin/shutdown.sh[Install] WantedBy =multi-user.target
设置启动 tomcat 服务并设置开机自启
systemctl start tomcat
systemctl enable tomcat
放行 8080 端口
1 2 3 4 5 6 7 8 9 10 11 - -- -- - -- - -- -- -- - -- - -
docker 银河麒麟高级服务器 V10 自带的 podman 和 docker 冲突,卸载冲突软件。
yum remove podman
下载并解压 docker 安装包到任意目录,如 /root/docker
aarch64 离线包下载链接,选择需要的版本,下载链接 。
复制文件
cp -p /root/docker/* /usr/bin
创建系统服务
nano /etc/systemd/system/docker.service
添加以下内容按需修改
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 [Unit] Description =Docker Application Container EngineDocumentation =<https://docs.docker.com>After =network-on line.target firewalld.serviceWants =network-on line.target[Service] Type =notifyExecStart =/usr/bin/dockerdExecReload =/bin/kill -s HUP \$MAINPID LimitNOFILE =infinityLimitNPROC =infinityLimitCORE =infinityTimeoutStartSec =0 Delegate =yes KillMode =processRestart =on -failureStartLimitBurst =3 StartLimitInterval =60 s[Install] WantedBy =multi-user.target
启动并设置开机自启
1 2 3 4 5 6 system ctl daemon-reloadsystem ctl start dockersystem ctl enable docker
docker 安装 redis 6.2.3 需要哪个版本就拉取哪个版本的镜像,不指定版本默认拉取 latest
拉取镜像
docker pull redis:6.2.3
创建容器
docker run -itd --name redis -p 6379:6379 redis:6.2.3
持久化参数
-v /host/path:/container/path
查看所有容器
docker ps -a
OpenGauss 安装 opengauss 轻量版
官方文档说目前仅支持在防火墙关闭的状态下进行安装。
关闭 SELINUX
nano /etc/selinux/config
修改修改’SELINUX’的值’disabled’
SELINUX=disabled
关闭防火墙
systemctl disable firewalld.service
systemctl stop firewalld.service
关闭 RemoveIPC
nano /etc/systemd/logind.conf
RemoveIPC=no
完成后重启系统
创建运行 opengauss 的普通用户
useradd -d /home/opengauss -m -G wheel opengauss
-d 指定用户主目录,如果此目录不存在,则用-m 创建
-g 指定用户所属的用户组
-G 指定用户所属的附加用户组,wheel 用户组为 openeuler 的 sudo 组
指定 opengauss 用户的密码
passwd opengauss
创建 opengauss 的安装目录,并将所有者改为 opengauss 用户
mkdir /usr/local/opengauss
chown opengauss:opengauss /usr/local/opengauss
切换普通用户开始安装
su opengauss
下载并解压 opengauss 到指定目录
1 2 3 cd /usr/local/opengauss wget https://xxxx.opengauss.tar.gz tar -zxvf opengauss.tar.gz
安装
sh ./install.sh --mode single -D /usr/local/opengauss/data -R /usr/local/opengauss/install --start
-D 数据库数据路径, 不可和安装目录交叉,必须为空。
-R 数据库安装路径,不可和数据目录交叉。
其他参数可参考官方文档
输入密码后等待安装完成
安装完成后脚本会自动添加环境变量到 opengauss 用户环境,执行 source /home/opengauss/.bashrc
使其生效
验证安装
ps ux | grep gaussdb
gs_ctl query -D /usr/local/opengauss/data
查看输出结果可看到数据库是否在运行。
数据库安装完成后,默认生成名称为 postgres 的数据库
也可以连接默认的 postgres 数据库来验证。
gsql -d postgres
创建系统服务并设置开机自启
nano /usr/lib/systemd/system/opengauss.service
添加以下内容
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 [Unit] Description =openGaussDocumentation =openGaussAfter =syslog.targetAfter =network.target[Service] Type =forkingUser =opengaussGroup =opengaussEnvironment =PGDATA=/usr/local/opengauss/dataEnvironment =GAUSSHOME=/usr/local/opengauss/installEnvironment =LD_LIBRARY_PATH=/usr/local/opengauss/install/libExecStart =/usr/local/opengauss/install/bin/gs_ctl startExecReload =/usr/local/opengauss/install/bin/gs_ctl restartExecStop =/usr/local/opengauss/install/bin/gs_ctl stopKillMode =mixedKillSignal =SIGINTTimeoutSec =0 [Install] WantedBy =multi-user.target
设置开机自启
systemctl enable opengauss