顯示具有 CentOS 標籤的文章。 顯示所有文章
顯示具有 CentOS 標籤的文章。 顯示所有文章

2024/04/23

CentOS 7 開機啟動網卡

vi /etc/sysconfig/network-scripts/ifcfg-網卡名稱

找到ONBOOT改為yes儲存重開即可

2021/12/22

Install NextCloud on CentOS 7.9

安裝相依套件
yum install epel-release -y
yum install nginx php-fpm php-curl php-cli php-mysql php-gd php-common php-xml php-json php-intl php-pear php-imagick php-dev php-common php-mbstring php-zip php-soap php-bz2 mysql-server mysql-client unzip zip snapd -y
修改php-fpm

vim /etc/php-fpm.d/www.conf
user = nginx
group = nginx
listen.owner = nginx
listen.group = nginx
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
修改db配置

2021/12/11

CentOS 7.7 7.8 8.1 Install CertBot get SSL cert

安裝
yum install -y epel-release snapd
systemctl enable --now snapd.socket
ln -s /var/lib/snapd/snap /snap
snap install core && snap refresh core
snap install --classic certbot
ln -s /snap/bin/certbot /usr/bin/certbot
certbot --nginx
systemctl restart nginx
定時腳本
crontab -e
0 0 1 */1 * certbot renew
10 0 1 */1 * systemctl restart nginx
systemctl start crond.service
systemctl enable crond.service

2020/09/20

CentOS 7.8 Install Zabbix LTS 5.0.1

最近要幫公司導入Alert Service
目前考慮用Zabbix或Nagios,先嘗試架設看看
前者較肥不過部分協定以及初始時功能較為齊全,相對肥大
後者則是輕量化且警示功能較為強悍,不過需要部份協定或設定時較為麻煩,相對輕盈

安裝代碼如下:
 

2019/09/10

Install Jenkins on CentOS 7

好久沒寫文章,最近都在國外工作
順應主管與同事最近研究Jenkins就順便補一下之前安裝與研究過的心得吧
Jenkins是由Java所撰寫出來的CI(Continuous Integration)工具,前身為Hudson
大學時常聽到學長說他們有用這種工具,後來出社會才小有研究,不過上次碰Jenkins是好多年前的事情了XDDDD


首先需要先安裝JDK在CentOS內
yum install -y java-1.8.0-openjdk-devel wget

加入Jenkins的repo和金鑰
wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key

更新一下並安裝Jenkins
yum update -y
yum install -y jenkins

安裝後讓Jenkins啟動並讓之後開機都會隨著服務啟動
systemctl enable jenkins
systemctl start jenkins

最後加入防火牆規則
firewall-cmd --add-port=8080/tcp --permanent
firewall-cmd --reload

網址列輸入
http://IP:8080

就可以看到剛初始化好的Jenkins

2019/04/24

使用Artifactory建立 Maven Repository on Cent OS 7

執行結果:



# Install Artifactory
wget https://excellmedia.dl.sourceforge.net/project/artifactory/artifactory/3.9.2/artifactory-3.9.2.rpm
yum install -y artifactory-3.9.2.rpm

# Install network tools
yum install -y net-tools

# Start Artifactory
service artifactory start

瀏覽:http://localhost:8081


參考資料:
https://fenriswolf.me/2012/04/04/%E5%BB%BA%E7%AB%8B-maven-repository/

Install Tomcat 8 on Cent OS 7

執行結果:

2019/03/28

Redis Cluster 3.0.2 on CentOS 7

這篇其實寫完很久,但一直忘記按發佈XD

Redis Cluster是Redis用於解決分散式的方案,又稱為Redis叢集
是一個讓數據再多個Node之間相互傳輸的服務,Redis Cluster的優勢主要有以下兩個點

  1. 自動分割數據到不同Node
  2. 部分Node當機或不可用情況能夠繼續維持服務


不過Redis Cluster並不支持處理多個keys的命令,在不同Node移動數據並不像Redis那樣高性能,高負載時有可能會遇到不可預期錯誤
Redis Cluster並非採用Consistent Hashing而是用Hash Slots,它其實就是代表一個Keys的集合
Redis Cluster共有16384 Hash Slots,將Key做CRC16校驗接著Mod 16384決定Key會放置於哪個Slot,Redis Cluster每個Node負責一部分的Hash Slots。例如,目前Cluster中有三個Master Node,則:

  • Node A包含0到3000 Hash Slots
  • Node B包含3001到9000 Hash Slots
  • Node C包含9001到16383 Hash Slots

如果新增了Node D,僅需將原本Node上的Hash Slots添加至Node D上;相對的要刪除一個Node A,將Node A上的Hash Slots遷移至Node B / C / D上,再將沒有任何Hash Slots的Node A移除即可;且新增、刪除或搬遷Hash Slots時無須停止任何服務。

Redis Cluster為了使部分Node失敗或大部分的Node無法通訊時仍可以使用,Redis Cluster使用Master-Slave複製模型,則每個Master Node則最少有會1個Slave Node;以上述的例子而言,如果沒有使用該模型的情況下,Node A失效則會導致Cluster因0到3000的Hash Slots不可用而失效。
最後Redis Cluster並不保證數據的一致性,這也意味著Redis Cluster在特定條件下有可能會丟失數據。


讓我們開始來建置Redis Cluster吧

接著我們開始來建立Redis Cluster吧,根據官方文獻建置一個Redis Cluster最少需要三個Master,也意味著還需要三個Slave來確保每個Master失效時才能將角色轉移至Slave上。
所以需先準備6台Host或container,系統為CentOS 7 minimal


Name

IP

Port

Cluster BUS Port

Master 1

192.168.126.135

6379

16379

Master 2

192.168.126.136

6380

16380

Master 3

192.168.126.141

6381

16381

Slave 1

192.168.126.142

6382

6382

Slave 2

192.168.126.143

6383

6383

Slave 3

192.168.126.144

6384

6384

2019/03/20

Redis 無法啟動問題

failed (Result: exit-code) since Tue 2019-03-19 21:33:14 EDT; 17s ago
ExecStop=/usr/libexec/redis-shutdown (code=exited, status=1/FAILURE)
ExecStart=/usr/bin/redis-server /etc/redis.conf --supervised systemd (code=exited, status=1/FAILURE)
上述問題是執行Redis service start時需要redis來執行
但他執行時無法讀寫redis.conf,所以有可能是因為/etc/redis.conf的擁有者不是redis


解決方式:
chown redis /etc/redis.conf


Tue 19 21:33:14 systemd supervision requested, but NOTIFY_SOCKET not found
Tue 19 21:33:14 systemd[1]: Main process exited, code=exited, status=1/FAILURE
Tue 19 21:33:14 systemd[1]: Unit entered failed state.
Tue 19 21:33:14 systemd[1]: Failed with result 'exit-code'.
Tue 19 21:33:14 systemd[1]: Service hold-off time over, scheduling restart.
Tue 19 21:33:14 systemd[1]: Stopped Redis In-Memory Data Store.
上述問題則是因為/etc/redis.conf的supervised不是systemd


解決方是:
將supervised的值改成systemd
並在終端機輸入systemctl daemon-reload
reboot即可修正

WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.

解決方法:
vi /etc/sysctl.conf
net.core.somaxconn= n>128

reboot

參考資料:
https://blog.csdn.net/jiangshouzhuang/article/details/50864933

Upgrade Redis 5.0.3 / 5.0.4 on CentOS 7


方法一


# Download Redis-5.0.3-1
wget http://rpms.remirepo.net/enterprise/7/remi/x86_64//redis-5.0.3-1.el7.remi.x86_64.rpm

# Install rpm
rpm -Uvh redis-5.0.3-1.el7.remi.x86_64.rpm

# Install Redis 5.0.3-1
yum --enablerepo=remi install -y redis


2019/03/18

Redis HA Master / Slave + Redis Sentinel on CentOS 7

有鑑於網路上有很多前輩都有寫Redis的介紹,我在此就不寫了XD
不過推薦可以看大陸有很多牛逼得前輩文章寫得不錯

那這次實驗的配置有4台host

  • 1台Redis Sentinel,IP為192.168.126.136 Port 26379
  • 1台Redis Master,IP為192.168.126.133 Port 6379
  • 2台Redis Slave,IP為192.168.126.134 Port 6380和192.168.126.135 Port 6381



Install Ruby2.6.2 on CentOS 7



# Install Development Tools
yum groupinstall -y "Development Tools"

# Install OpenSSL Devel
yum install -y openssl-devel

# Download Ruby 2.6.2
wget https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.2.tar.gz

# Unzip
tar -xvf ruby-2.6.2.tar.gz

# Copy to /usr/local/src
mv ruby-2.6.2 /usr/local/src/
cd /usr/local/src/ruby-2.6.2

# Compiler and Install
./configure
make
make install

# Update and Install Bundler
chmod 755 ruby
gem update --system
gem install bundler

# Fix OpenSSL issue
cd ext/openssl/
make top_srcdir="../../"
make install top_srcdir="../../"




參考資料:
http://ask.xmodulo.com/upgrade-ruby-centos.html

2019/03/14

Install Java JRE and JDK



# Install JAVA JRE and JDK
yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel
# JRE path
/usr/bin/java
# JDK path
/usr/bin/javac

ASP.Net Core Nginx on CentOS 7

本篇參考至「ASP.NET Core + Nginx on CentOS 安裝筆記


執行結果:

vsftpd 553 Could not create file


# Show ftp SELinux config
getsebool -a | grep ftp
# Enable ftpd_anon_write
setsebool -P allow_ftpd_anon_write on
# Enable ftpd_full_access
setsebool -P allow_ftpd_full_access on

# Or Disable SELinux

vi /etc/selinux/config
SELINUX=disabled

reboot

Install .Net Core 2.2 on CentOS 7


# Import RPM Source
rpm -Uvh https://packages.microsoft.com/config/rhel/7/packages-microsoft-prod.rpm
# Update Pacakge
yum update -y
# Install .Net Core SDK
yum install -y dotnet-sdk-2.2

參考資料:
https://dotnet.microsoft.com/download/linux-package-manager/centos/sdk-current

2019/03/08

CentOS 7 安裝PhpRedisAdmin再Nginx


首先輸入下方命令安裝套件

# Install EPEL
yum install -y epel-release
# Update Package
yum update -y
# Install PHP PHP-FPM PHP-mbstring Nginx Redis
yum install -y git php php-fpm php-mbstring nginx redis


接著用Git下載PhpRedisAdmin

# Download PhpRedisAdmin
cd /var/www
git clone https://github.com/ErikDubbelboer/phpRedisAdmin.git
cd phpRedisAdmin
git clone https://github.com/nrk/predis.git vendor

修改Nginx

# 修改Nginx設定
vi /etc/nginx/nginx.conf
server_name localhost;

location / {
 root /var/www;
 index index.php;
}

location ~ \.php$ {
 root /var/www;
 fastcgi_pass 127.0.0.1:9000;
 fastcgi_index index.php;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 include fastcgi_params;
}



2019/02/24

Install Redis Server on CentOS 7


# Install Epel
yum install -y epel-release
# Update
yum update -y
# Install Redis server
yum install -y redis
# Redis start at Redis
systemctl enable redis
# Start Redis server
systemctl start redis

Install SSH Server on CentOS 7


# Install SSH server
yum install -y openssh-server
# Start service at Boot
systemctl enable sshd
# Start ssh server
systemctl start sshd